diff options
author | Anton Staaf <robotboy@chromium.org> | 2015-03-02 14:48:27 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-03 21:39:35 +0000 |
commit | e6f670440832f519464b19f497b4cac9476de548 (patch) | |
tree | fed7fd5cfea19d11e21dac8f07995ddece5c4907 /chip/stm32/usb-stream.c | |
parent | 07b4158649fb65d0474febb05879c80e413ad826 (diff) | |
download | chrome-ec-e6f670440832f519464b19f497b4cac9476de548.tar.gz |
USB Stream: Make RX and TX buffer sizes configurable
Previously the USB Stream buffer sizes were fixed at
USB_MAX_PACKET_SIZE (currently 64 bytes). But that
ended up using up too much packet RAM, a very limited
resource. This change makes them configurable and
adds asserts to insure that the sizes are valid for
the underlying hardware.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Verify that USART forwarding on discovery works
Change-Id: Ib19c0dcfa9b16f23c1d72a5a7fc18026ab103f05
Reviewed-on: https://chromium-review.googlesource.com/255232
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usb-stream.c')
-rw-r--r-- | chip/stm32/usb-stream.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/chip/stm32/usb-stream.c b/chip/stm32/usb-stream.c index 42d9d3774c..05351a8ca3 100644 --- a/chip/stm32/usb-stream.c +++ b/chip/stm32/usb-stream.c @@ -36,7 +36,7 @@ static size_t tx_write(struct usb_stream_config const *config) { size_t count = consumer_read_memcpy(&config->consumer, config->tx_ram, - USB_MAX_PACKET_SIZE, + config->tx_size, memcpy_to_usbram); btable_ep[config->endpoint].tx_count = count; @@ -120,6 +120,14 @@ void usb_stream_rx(struct usb_stream_config const *config) } } +static usb_uint usb_ep_rx_size(size_t bytes) +{ + if (bytes < 64) + return bytes << 9; + else + return 0x8000 | ((bytes - 32) << 5); +} + void usb_stream_reset(struct usb_stream_config const *config) { int i = config->endpoint; @@ -128,7 +136,7 @@ void usb_stream_reset(struct usb_stream_config const *config) btable_ep[i].tx_count = 0; btable_ep[i].rx_addr = usb_sram_addr(config->rx_ram); - btable_ep[i].rx_count = 0x8000 | ((USB_MAX_PACKET_SIZE / 32 - 1) << 10); + btable_ep[i].rx_count = usb_ep_rx_size(config->rx_size); config->state->rx_waiting = 0; |