【问题描述】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
- }
|