【在线等!】ARM 硬件重定向printf问题

[复制链接]
2607|3
 楼主| arm_debug_yj 发表于 2013-6-16 11:10 | 显示全部楼层 |阅读模式
【问题描述】ARM硬件重定向后,单个用底层IO函数SendChar(ch)连续输出字符都可以,用printf("abcdefgh\n"),只打印出了ab,请问高人是什么问题啊,在线等,跪求解决方法!!
【代码】
  1. #include "../../common/drivers.h"

  2. #pragma import(__use_no_semihosting_swi)


  3. /*----------------------------------------------------------------------------
  4.   external functions
  5. *----------------------------------------------------------------------------*/

  6. struct __FILE
  7. {
  8.       int32 handle;                 // Add whatever you need here
  9. };
  10. FILE __stdout;
  11. FILE __stdin;

  12. /*----------------------------------------------------------------------------
  13.   SendChar
  14.   Write character to Serial Port.
  15. *----------------------------------------------------------------------------*/
  16. int SendChar (int ch)  {

  17.   //while (UARTGetLineStatus(g_pUART0, UART_标志寄存器_THR_EMPTY) == RESET);
  18.   UARTSendData(g_pUART0, (uint8)(ch & 0xFF));

  19.   return (ch);
  20. }


  21. /*----------------------------------------------------------------------------
  22.   GetKey
  23.   Read character to Serial Port.
  24. *----------------------------------------------------------------------------*/
  25. int32 GetKey (void)  {

  26.   while (UARTGetLineStatus(g_pUART0, UART_标志寄存器_DATA_READY) == RESET);

  27.   return ((int)UARTRecvData(g_pUART0));
  28. }

  29. /*----------------------------------------------------------------------------
  30.   fputc
  31. *----------------------------------------------------------------------------*/
  32. int fputc(int ch, FILE *f) {
  33.   return (SendChar(ch));
  34. }

  35. /*----------------------------------------------------------------------------
  36.   fgetc
  37. *----------------------------------------------------------------------------*/
  38. int fgetc(FILE *f) {
  39.   return (SendChar(GetKey()));
  40. }

  41. /*----------------------------------------------------------------------------
  42.   _ttywrch
  43. *----------------------------------------------------------------------------*/
  44. void _ttywrch(int ch) {
  45. SendChar (ch);
  46. }

  47. /*----------------------------------------------------------------------------
  48.   ferror
  49. *----------------------------------------------------------------------------*/
  50. int32 ferror(FILE *f) {
  51.                               // Your implementation of ferror
  52.   return EOF;
  53. }

  54. /*----------------------------------------------------------------------------
  55.   _sys_exit
  56. *----------------------------------------------------------------------------*/
  57. void _sys_exit(int return_code) {
  58. label:  goto label;           // endless loop
  59. }


阿南 发表于 2013-6-16 20:08 | 显示全部楼层
这个你要具体跟进printf函数。ARM里面的一些标准函数不一定都是实现的,需要测试。
jamsan 发表于 2013-6-17 09:00 | 显示全部楼层
为何把  //while (UARTGetLineStatus(g_pUART0, UART_标志寄存器_THR_EMPTY) == RESET);这一句注掉?在发送完一个字符前,不能再送新字节。或者FIFO已满的情况下,都不能再写,否则肯定丢失。
 楼主| arm_debug_yj 发表于 2013-6-18 12:31 | 显示全部楼层
jamsan 发表于 2013-6-17 09:00
为何把  //while (UARTGetLineStatus(g_pUART0, UART_标志寄存器_THR_EMPTY) == RESET);这一句注掉?在发送 ...

是这个问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

14

主题

33

帖子

0

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