[S3C2440] TQ2440 使用 printf()函数

[复制链接]
 楼主| 李伟1991 发表于 2015-4-13 15:33 | 显示全部楼层 |阅读模式
   哈哈TQ2440上面也能使用printf()函数了之前在使用STM32的时候,使用重定向功能使得STM32能够使用printf()函数。前几天在使用TQ2440的时候我就在想是不是也能在S3C2440上面也进行重定向使用printf()函数呢?结果很开心的发现是能够使用的!
   关键的地方就要加几条语句就能搞定了!
   
  1. struct __FILE
  2. {
  3. int handle;
  4. /* Whatever you require here. If the only file you are using is */
  5. /* standard output using printf() for debugging, no file handling */
  6. /* is required. */
  7. };
  8. /* FILE is typedef’ d in stdio.h. */
  9. FILE __stdout;
  10. FILE __stdin;
  11. _sys_exit(int x)
  12. {
  13. x = x;
  14. }

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







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


有任何疑问QQ905377346

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

9

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部

2

主题

9

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部