diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-08-27 16:05:09 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-29 11:15:45 -0700 |
commit | 7eb9ff3cfcf4b96356050da66bd957225bef6044 (patch) | |
tree | 62b5f35d135e99fa14e582d3487fabb6fa41aab2 /board/servo_micro | |
parent | 63fd7e18588023b2940167b686611e609354b78a (diff) | |
download | chrome-ec-7eb9ff3cfcf4b96356050da66bd957225bef6044.tar.gz |
servo_micro: Allow setting the baud rate for usart
We set the baud rate in increments of 100 baud, to avoid
overflowing the 16-bit wValue integer (921600 is the highest we
are likely to use).
Also, increment the buffer size for USART3 to 1024 bytes. That
helps a bit to avoid losing characters, but we still can't keep
up if the host is printing at maximum speed.
BRANCH=servo
BUG=chromium:876651
TEST=baud usart2/3/4 115200 in servo_micro console
TEST=dut-control cpu_uart_baudrate:921600
seq 1 1000 shows numbers 1 to 226 before buffer overflows
Change-Id: Ifca266189f93def493f207dd29d2cceca4d8d68f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1189782
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Diffstat (limited to 'board/servo_micro')
-rw-r--r-- | board/servo_micro/board.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c index a665b3dfe8..a06978b84d 100644 --- a/board/servo_micro/board.c +++ b/board/servo_micro/board.c @@ -101,7 +101,7 @@ USB_STREAM_CONFIG_USART_IFACE(usart2_usb, static struct usart_config const usart3; struct usb_stream_config const usart3_usb; -static struct queue const usart3_to_usb = QUEUE_DIRECT(128, uint8_t, +static struct queue const usart3_to_usb = QUEUE_DIRECT(1024, uint8_t, usart3.producer, usart3_usb.consumer); static struct queue const usb_to_usart3 = QUEUE_DIRECT(64, uint8_t, usart3_usb.producer, usart3.consumer); @@ -203,6 +203,39 @@ DECLARE_CONSOLE_COMMAND(parity, command_uart_parity, "Set parity on uart"); /****************************************************************************** + * Set baud rate setting on usarts. + */ +static int command_uart_baud(int argc, char **argv) +{ + int baud = 0; + struct usart_config const *usart; + char *e; + + if ((argc < 2) || (argc > 3)) + return EC_ERROR_PARAM_COUNT; + + if (!strcasecmp(argv[1], "usart2")) + usart = &usart2; + else if (!strcasecmp(argv[1], "usart3")) + usart = &usart3; + else if (!strcasecmp(argv[1], "usart4")) + usart = &usart4; + else + return EC_ERROR_PARAM1; + + baud = strtoi(argv[2], &e, 0); + if (*e || baud < 0) + return EC_ERROR_PARAM2; + + usart_set_baud(usart, baud); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(baud, command_uart_baud, + "usart[2|3|4] rate", + "Set baud rate on uart"); + +/****************************************************************************** * Commands for sending the magic non-I2C handshake over I2C bus wires to an * ITE IT8320 EC chip to enable direct firmware update (DFU) over I2C mode. */ |