summaryrefslogtreecommitdiff
path: root/board/servo_micro/board.c
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2017-07-11 15:14:37 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-07-13 17:30:40 -0700
commit1106dea40d3b18fbab2f42a2510d0a7899650db9 (patch)
tree11900831f90cbc9f16f213618de360ad110c9cc2 /board/servo_micro/board.c
parent9fad1adc800cd950e4bd3f292f83186eb0e4f272 (diff)
downloadchrome-ec-1106dea40d3b18fbab2f42a2510d0a7899650db9.tar.gz
servo_micro: add parity setting
Add a control interface to set parity for USB-UART bridge. BRANCH=None BUG=b:37513705 TEST=parity settable on command line or by servod Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: Ib859a70981162be58edfa79c7cb267e0084e05e6 Reviewed-on: https://chromium-review.googlesource.com/564150 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'board/servo_micro/board.c')
-rw-r--r--board/servo_micro/board.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c
index dedfcfdd7a..505a6d628a 100644
--- a/board/servo_micro/board.c
+++ b/board/servo_micro/board.c
@@ -5,6 +5,7 @@
/* Servo micro board configuration */
#include "common.h"
+#include "console.h"
#include "ec_version.h"
#include "gpio.h"
#include "hooks.h"
@@ -52,14 +53,15 @@ static struct usart_config const usart2 =
usart2_to_usb,
usb_to_usart2);
-USB_STREAM_CONFIG(usart2_usb,
+USB_STREAM_CONFIG_USART_IFACE(usart2_usb,
USB_IFACE_USART2_STREAM,
USB_STR_USART2_STREAM_NAME,
USB_EP_USART2_STREAM,
USB_STREAM_RX_SIZE,
USB_STREAM_TX_SIZE,
usb_to_usart2,
- usart2_to_usb)
+ usart2_to_usb,
+ usart2)
/******************************************************************************
@@ -82,14 +84,15 @@ static struct usart_config const usart3 =
usart3_to_usb,
usb_to_usart3);
-USB_STREAM_CONFIG(usart3_usb,
+USB_STREAM_CONFIG_USART_IFACE(usart3_usb,
USB_IFACE_USART3_STREAM,
USB_STR_USART3_STREAM_NAME,
USB_EP_USART3_STREAM,
USB_STREAM_RX_SIZE,
USB_STREAM_TX_SIZE,
usb_to_usart3,
- usart3_to_usb)
+ usart3_to_usb,
+ usart3)
/******************************************************************************
@@ -112,15 +115,56 @@ static struct usart_config const usart4 =
usart4_to_usb,
usb_to_usart4);
-USB_STREAM_CONFIG(usart4_usb,
+USB_STREAM_CONFIG_USART_IFACE(usart4_usb,
USB_IFACE_USART4_STREAM,
USB_STR_USART4_STREAM_NAME,
USB_EP_USART4_STREAM,
USB_STREAM_RX_SIZE,
USB_STREAM_TX_SIZE,
usb_to_usart4,
- usart4_to_usb)
+ usart4_to_usb,
+ usart4)
+/******************************************************************************
+ * Check parity setting on usarts.
+ */
+static int command_uart_parity(int argc, char **argv)
+{
+ int parity, newparity;
+ 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;
+
+ if (argc == 3) {
+ parity = strtoi(argv[2], &e, 0);
+ if (*e || (parity < 0) || (parity > 2))
+ return EC_ERROR_PARAM2;
+
+ usart_set_parity(usart, parity);
+ }
+
+ newparity = usart_get_parity(usart);
+ ccprintf("Parity on %s is %d.\n", argv[1], newparity);
+
+ if ((argc == 3) && (newparity != parity))
+ return EC_ERROR_UNKNOWN;
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(parity, command_uart_parity,
+ "usart[2|3|4] [0|1|2]",
+ "Set parity on uart");
/******************************************************************************
* Define the strings used in our USB descriptors.