diff options
author | Nick Sanders <nsanders@chromium.org> | 2017-07-11 15:14:37 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-13 17:30:40 -0700 |
commit | 1106dea40d3b18fbab2f42a2510d0a7899650db9 (patch) | |
tree | 11900831f90cbc9f16f213618de360ad110c9cc2 /chip/stm32/usb-stream.c | |
parent | 9fad1adc800cd950e4bd3f292f83186eb0e4f272 (diff) | |
download | chrome-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 'chip/stm32/usb-stream.c')
-rw-r--r-- | chip/stm32/usb-stream.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/chip/stm32/usb-stream.c b/chip/stm32/usb-stream.c index 313e29e8df..e1ec19d7d4 100644 --- a/chip/stm32/usb-stream.c +++ b/chip/stm32/usb-stream.c @@ -12,6 +12,7 @@ #include "task.h" #include "timer.h" #include "util.h" +#include "usart.h" #include "usb_hw.h" #include "usb-stream.h" @@ -143,3 +144,38 @@ void usb_stream_reset(struct usb_stream_config const *config) (0 << 9) | /* Bulk EP */ (rx_disabled(config) ? EP_RX_NAK : EP_RX_VALID)); } + +int usb_usart_interface(struct usb_stream_config const *config, + struct usart_config const *usart, + int interface, + usb_uint *rx_buf, usb_uint *tx_buf) +{ + struct usb_setup_packet req; + + usb_read_setup_packet(rx_buf, &req); + + if (req.bmRequestType != (USB_DIR_OUT | + USB_TYPE_VENDOR | + USB_RECIP_INTERFACE)) + return -1; + + if (req.wIndex != interface || + req.wLength != 0) + return -1; + + switch (req.bRequest) { + /* Set parity. */ + case USB_USART_SET_PARITY: + usart_set_parity(usart, req.wValue); + break; + + /* TODO(nsanders): support reading parity. */ + /* TODO(nsanders): support baud. */ + default: + return -1; + } + + btable_ep[0].tx_count = 0; + STM32_TOGGLE_EP(0, EP_TX_RX_MASK, EP_TX_RX_VALID, EP_STATUS_OUT); + return 0; +} |