diff options
Diffstat (limited to 'common/uart_buffering.c')
-rw-r--r-- | common/uart_buffering.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/common/uart_buffering.c b/common/uart_buffering.c index e3b7e73fbd..1c0db3b151 100644 --- a/common/uart_buffering.c +++ b/common/uart_buffering.c @@ -80,14 +80,10 @@ void uart_init_buffer(void) * @param c Character to write. * @return 0 if the character was transmitted, 1 if it was dropped. */ -static int __tx_char(void *context, int c) +static int __tx_char_raw(void *context, int c) { int tx_buf_next, tx_buf_new_tail; - /* Do newline to CRLF translation */ - if (c == '\n' && __tx_char(NULL, '\r')) - return 1; - #if defined CONFIG_POLLING_UART (void) tx_buf_next; (void) tx_buf_new_tail; @@ -122,6 +118,14 @@ static int __tx_char(void *context, int c) return 0; } +static int __tx_char(void *context, int c) +{ + /* Translate '\n' to '\r\n' */ + if (c == '\n' && __tx_char_raw(NULL, '\r')) + return 1; + return __tx_char_raw(context, c); +} + #ifdef CONFIG_UART_TX_DMA /** @@ -298,6 +302,20 @@ int uart_put(const char *out, int len) return len ? EC_ERROR_OVERFLOW : EC_SUCCESS; } +int uart_put_raw(const char *out, int len) +{ + /* Put all characters in the output buffer */ + while (len--) { + if (__tx_char_raw(NULL, *out++) != 0) + break; + } + + uart_tx_start(); + + /* Successful if we consumed all output */ + return len ? EC_ERROR_OVERFLOW : EC_SUCCESS; +} + int uart_vprintf(const char *format, va_list args) { int rv = vfnprintf(__tx_char, NULL, format, args); |