mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
change printf retarget to make \n to \r\n automatically
This commit is contained in:
parent
a522263a9d
commit
23f4d7356f
@ -51,7 +51,26 @@ int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
|
||||
(void) iFileHandle;
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
return board_uart_send((uint8_t*)pcBuffer, iLength);
|
||||
// following code to make \n --> \r\n
|
||||
int length = iLength;
|
||||
char* p_newline_pos = memchr(pcBuffer, '\n', length);
|
||||
|
||||
while(p_newline_pos != NULL)
|
||||
{
|
||||
uint32_t chunk_len = p_newline_pos - pcBuffer;
|
||||
|
||||
board_uart_send((uint8_t*)pcBuffer, chunk_len);
|
||||
board_uart_send(&"\r\n", 2);
|
||||
|
||||
pcBuffer += (chunk_len + 1);
|
||||
length -= (chunk_len + 1);
|
||||
p_newline_pos = memchr(pcBuffer, '\n', length);
|
||||
}
|
||||
|
||||
board_uart_send((uint8_t*)pcBuffer, length);
|
||||
|
||||
return iLength;
|
||||
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
uint32_t i;
|
||||
for (i = 0; i<iLength; i++)
|
||||
|
@ -174,12 +174,12 @@ OSAL_TASK_FUNCTION( led_blinking_task ) (void* p_task_para)
|
||||
//--------------------------------------------------------------------+
|
||||
void print_greeting(void)
|
||||
{
|
||||
printf("\r\n\
|
||||
--------------------------------------------------------------------\r\n\
|
||||
- Host Demo (a tinyusb example)\r\n\
|
||||
- if you find any bugs or get any questions, feel free to file an\r\n\
|
||||
- issue at https://github.com/hathach/tinyusb\r\n\
|
||||
--------------------------------------------------------------------\r\n\r\n"
|
||||
printf("\n\
|
||||
--------------------------------------------------------------------\n\
|
||||
- Host Demo (a tinyusb example)\n\
|
||||
- if you find any bugs or get any questions, feel free to file an\n\
|
||||
- issue at https://github.com/hathach/tinyusb\n\
|
||||
--------------------------------------------------------------------\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user