1 Star 0 Fork 0

jackeer/test_printf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.c 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
jackeer 提交于 2015-04-12 02:35 . some chang
#include "REG51.H"
#include "stdio.h"
#include "stdarg.h"
#include "STRING.H"
void Uart_init(void)
{
SCON |= 0x50; // Set to enable serial reception. 8-bit UART Variable
TMOD |= 0x20; // Timer 1 Mode 2: 8-bit auto-reload Timer/Counter (TL1).(1)Reloaded from TH1 at overflow.
TH1 = 0xFA; // 9600 bauds at 11.0592 MHz
TL1 = TH1;
PCON |= 0x80; // SMOD0 Set to select double baud rate in mode 1, 2 or 3.
TCON |= 0x40; // Set to turn on Timer/Counter 1.
TI=1; // Set by hardware at the end of the 8th bit time in mode 0 or at the beginning of the
// stop bit in the other modes.
}
void put_char (const char *tmp) large
{
int i = 0;
while((tmp[i] != NULL) && (tmp[i] != EOF)&& (tmp[i] != '\n'))
{
SBUF = tmp[i];
TI=0;
while(!TI);
i ++;
}
}
void put_char_args(char *arg1, ...) large
{
va_list ap;
char *str, rent='\n';
// char temp[3]=0;
va_start(ap, arg1);
str = arg1;
// sprintf(temp, "%s", sizeof(arg1));
// put_char(temp), put_char(&rent);
// printf("%s\n", arg1);
do{
put_char(str), put_char(&rent);
// printf("%s\n", str);
str = va_arg(ap, char *);
// str=str-1;
} while((*str != NULL) && (*str != EOF));
va_end(ap);
put_char(&rent);
}
void main(void) large
{
code char *tmp_str ="Hello World!";
Uart_init();
ES=1; // Serial Port interrupt enable bit.
// put_char(tmp_str);
put_char_args("This test Variadic templates", tmp_str, "test", "4", "5", "6", "7", "8", "9");
while(1);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jackeer/test_printf.git
git@gitee.com:jackeer/test_printf.git
jackeer
test_printf
test_printf
master

搜索帮助