summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Lawrence <[email protected]>2020-01-11 15:31:42 -0600
committerPeter Lawrence <[email protected]>2020-01-11 15:31:42 -0600
commit53732805b76882b3e0eba561ce854e0a95dd6dfe (patch)
treeca879806b7ed653fef3d0f6b0ecb22b5cd133a19 /src
parent33c715bdd060c4c2bbc89da3ccc62f10b3faba09 (diff)
CDC device: help ensure code is consistent with the size of the buffers it operates on
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_device.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index a4c42863a..015c1c6fd 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -82,9 +82,9 @@ static void _prep_out_transaction (uint8_t itf)
// Prepare for incoming data but only allow what we can store in the ring buffer.
uint16_t max_read = tu_fifo_remaining(&p_cdc->rx_ff);
- if ( max_read >= CFG_TUD_CDC_EPSIZE )
+ if ( max_read >= TU_ARRAY_SIZE(p_cdc->epout_buf) )
{
- usbd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_out, p_cdc->epout_buf, CFG_TUD_CDC_EPSIZE);
+ usbd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_out, p_cdc->epout_buf, TU_ARRAY_SIZE(p_cdc->epout_buf));
}
}
@@ -162,7 +162,7 @@ bool tud_cdc_n_write_flush (uint8_t itf)
cdcd_interface_t* p_cdc = &_cdcd_itf[itf];
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_in) ); // skip if previous transfer not complete
- uint16_t count = tu_fifo_read_n(&_cdcd_itf[itf].tx_ff, p_cdc->epin_buf, CFG_TUD_CDC_EPSIZE);
+ uint16_t count = tu_fifo_read_n(&_cdcd_itf[itf].tx_ff, p_cdc->epin_buf, TU_ARRAY_SIZE(p_cdc->epin_buf));
if ( count )
{
TU_VERIFY( tud_cdc_n_connected(itf) ); // fifo is empty if not connected
@@ -198,8 +198,8 @@ void cdcd_init(void)
p_cdc->line_coding.data_bits = 8;
// config fifo
- tu_fifo_config(&p_cdc->rx_ff, p_cdc->rx_ff_buf, CFG_TUD_CDC_RX_BUFSIZE, 1, false);
- tu_fifo_config(&p_cdc->tx_ff, p_cdc->tx_ff_buf, CFG_TUD_CDC_TX_BUFSIZE, 1, false);
+ tu_fifo_config(&p_cdc->rx_ff, p_cdc->rx_ff_buf, TU_ARRAY_SIZE(p_cdc->rx_ff_buf), 1, false);
+ tu_fifo_config(&p_cdc->tx_ff, p_cdc->tx_ff_buf, TU_ARRAY_SIZE(p_cdc->tx_ff_buf), 1, false);
#if CFG_FIFO_MUTEX
tu_fifo_config_mutex(&p_cdc->rx_ff, osal_mutex_create(&p_cdc->rx_ff_mutex));