mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
Merge branch 'feature/ets_putc_support_cr_lf_select' into 'master'
ets_putc support CR/LR/CRLR selection See merge request sdk/ESP8266_RTOS_SDK!636
This commit is contained in:
@ -23,7 +23,7 @@
|
||||
#include "esp8266/uart_register.h"
|
||||
#include "esp8266/rom_functions.h"
|
||||
|
||||
int ets_putc(int c)
|
||||
static void uart_putc(int c)
|
||||
{
|
||||
while (1) {
|
||||
uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(CONFIG_CONSOLE_UART_NUM)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S);
|
||||
@ -33,6 +33,19 @@ int ets_putc(int c)
|
||||
}
|
||||
|
||||
WRITE_PERI_REG(UART_FIFO(CONFIG_CONSOLE_UART_NUM) , c);
|
||||
}
|
||||
|
||||
int ets_putc(int c)
|
||||
{
|
||||
#ifdef CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF
|
||||
if (c == '\n')
|
||||
uart_putc('\r');
|
||||
#elif defined(CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR)
|
||||
if (c == '\n')
|
||||
c = '\r';
|
||||
#endif
|
||||
|
||||
uart_putc(c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
@ -37,22 +37,8 @@ _ssize_t _write_r(struct _reent *r, int fd, const void *buf, size_t len)
|
||||
int i;
|
||||
const char *cbuf = buf;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
#ifdef CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF
|
||||
if (cbuf[i] == '\n') {
|
||||
ets_putc('\r');
|
||||
ets_putc('\n');
|
||||
} else
|
||||
ets_putc(cbuf[i]);
|
||||
#elif defined(CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR)
|
||||
if (cbuf[i] == '\n')
|
||||
ets_putc('\r');
|
||||
else
|
||||
ets_putc(cbuf[i]);
|
||||
#elif defined(CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF)
|
||||
for (i = 0; i < len; i++)
|
||||
ets_putc(cbuf[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
Reference in New Issue
Block a user