summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2021-03-10 10:19:45 +0100
committerHiFiPhile <[email protected]>2021-03-10 10:19:45 +0100
commit7fc99a9e1104703566945ace1b2e1ed59819ba48 (patch)
tree96f12c806dbcdb4e6907f5ae166dcc292352e2da /src
parent0374e085507cd23124d9cc6d5f2b10565717b72d (diff)
Call One time tu_fifo_write_n on cdcd_xfer_cb
Signed-off-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_device.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 5a74b4876..64cb4ab2c 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -432,25 +432,25 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
// Received new data
if ( ep_addr == p_cdc->ep_out )
{
+ tu_fifo_write_n(&p_cdc->rx_ff, &p_cdc->epout_buf, xferred_bytes);
+
// TODO search for wanted char first for better performance
- for(uint32_t i=0; i<xferred_bytes; i++)
- {
- tu_fifo_write(&p_cdc->rx_ff, &p_cdc->epout_buf[i]);
-
+ if (tud_cdc_rx_wanted_cb && ( ((signed char) p_cdc->wanted_char) != -1)) {
// Check for wanted char and invoke callback if needed
- if ( tud_cdc_rx_wanted_cb && ( ((signed char) p_cdc->wanted_char) != -1 ) && ( p_cdc->wanted_char == p_cdc->epout_buf[i] ) )
- {
- tud_cdc_rx_wanted_cb(itf, p_cdc->wanted_char);
+ for (uint32_t i=0; i<xferred_bytes; i++) {
+ if ( p_cdc->wanted_char == p_cdc->epout_buf[i] ) {
+ tud_cdc_rx_wanted_cb(itf, p_cdc->wanted_char);
+ }
}
}
-
+
// invoke receive callback (if there is still data)
if (tud_cdc_rx_cb && tu_fifo_count(&p_cdc->rx_ff) ) tud_cdc_rx_cb(itf);
-
+
// prepare for OUT transaction
_prep_out_transaction(p_cdc);
}
-
+
// Data sent to host, we continue to fetch from tx fifo to send.
// Note: This will cause incorrect baudrate set in line coding.
// Though maybe the baudrate is not really important !!!