打印

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

[复制链接]
1892|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
arm_debug_yj|  楼主 | 2013-6-16 11:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
【问题描述】ARM硬件重定向后,单个用底层IO函数SendChar(ch)连续输出字符都可以,用printf("abcdefgh\n"),只打印出了ab,请问高人是什么问题啊,在线等,跪求解决方法!!
【代码】
#include "../../common/drivers.h"

#pragma import(__use_no_semihosting_swi)


/*----------------------------------------------------------------------------
  external functions
*----------------------------------------------------------------------------*/

struct __FILE
{
      int32 handle;                 // Add whatever you need here
};
FILE __stdout;
FILE __stdin;

/*----------------------------------------------------------------------------
  SendChar
  Write character to Serial Port.
*----------------------------------------------------------------------------*/
int SendChar (int ch)  {

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

  return (ch);
}


/*----------------------------------------------------------------------------
  GetKey
  Read character to Serial Port.
*----------------------------------------------------------------------------*/
int32 GetKey (void)  {

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

  return ((int)UARTRecvData(g_pUART0));
}

/*----------------------------------------------------------------------------
  fputc
*----------------------------------------------------------------------------*/
int fputc(int ch, FILE *f) {
  return (SendChar(ch));
}

/*----------------------------------------------------------------------------
  fgetc
*----------------------------------------------------------------------------*/
int fgetc(FILE *f) {
  return (SendChar(GetKey()));
}

/*----------------------------------------------------------------------------
  _ttywrch
*----------------------------------------------------------------------------*/
void _ttywrch(int ch) {
SendChar (ch);
}

/*----------------------------------------------------------------------------
  ferror
*----------------------------------------------------------------------------*/
int32 ferror(FILE *f) {
                              // Your implementation of ferror
  return EOF;
}

/*----------------------------------------------------------------------------
  _sys_exit
*----------------------------------------------------------------------------*/
void _sys_exit(int return_code) {
label:  goto label;           // endless loop
}


相关帖子

沙发
阿南| | 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

粉丝