summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2021-03-11 20:36:46 +0100
committerHiFiPhile <[email protected]>2021-03-11 20:36:46 +0100
commit5caad485f199ab6acfa237d84bf3d84cf41dcfdd (patch)
treee4dae29a33a4ef56b28ef39bbef45f8195a5d18a
parent7fc99a9e1104703566945ace1b2e1ed59819ba48 (diff)
Add fifo empty check.
Signed-off-by: HiFiPhile <[email protected]>
-rw-r--r--src/class/cdc/cdc_device.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 64cb4ab2c..d9b098bb2 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -434,11 +434,10 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
{
tu_fifo_write_n(&p_cdc->rx_ff, &p_cdc->epout_buf, xferred_bytes);
- // TODO search for wanted char first for better performance
+ // Check for wanted char and invoke callback if needed
if (tud_cdc_rx_wanted_cb && ( ((signed char) p_cdc->wanted_char) != -1)) {
- // Check for wanted char and invoke callback if needed
for (uint32_t i=0; i<xferred_bytes; i++) {
- if ( p_cdc->wanted_char == p_cdc->epout_buf[i] ) {
+ if ( p_cdc->wanted_char == p_cdc->epout_buf[i] && tu_fifo_count(&p_cdc->rx_ff) ) {
tud_cdc_rx_wanted_cb(itf, p_cdc->wanted_char);
}
}