打印
[S3C2440]

TQ2440 使用 printf()函数

[复制链接]
697|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
   哈哈TQ2440上面也能使用printf()函数了之前在使用STM32的时候,使用重定向功能使得STM32能够使用printf()函数。前几天在使用TQ2440的时候我就在想是不是也能在S3C2440上面也进行重定向使用printf()函数呢?结果很开心的发现是能够使用的!
   关键的地方就要加几条语句就能搞定了!
   
struct __FILE 
{
int handle;
/* Whatever you require here. If the only file you are using is */
/* standard output using printf() for debugging, no file handling */
/* is required. */
};
/* FILE is typedef’ d in stdio.h. */
FILE __stdout;
FILE __stdin;
_sys_exit(int x)
{
x = x;
}

void send_char(char num)
{
rUTXH0 =num;
while((rUTRSTAT0 & 4 )==0);
}
int fputc(int ch,FILE *f)
{
send_char((char)ch);
return ch;
}
int fgetc(FILE *f)
{
while((rUTRSTAT0 &1)==0);
return rURXH0 ;
}
上面的那个send_char函数是2440的串口非中断发送函数!不要忘了加#include<stdio.h>哟
现在来看一看!







看到没有!呵呵 成功了
最后附上工程!


有任何疑问QQ905377346

printf.png (112.35 KB )

2440 printf

2440 printf

UART printf重定向.rar

466.38 KB

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

9

帖子

0

粉丝