File tree Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Original file line number Diff line number Diff line change 46
46
47
47
extern void tusb_hal_nrf_power_event (uint32_t event );
48
48
49
- static void cdc_task (void );
49
+ static void cdc_task (bool tx );
50
50
51
51
static uint8_t rx_ringbuf_array [1024 ];
52
52
static uint8_t tx_ringbuf_array [1024 ];
@@ -121,7 +121,7 @@ static int cdc_tx_char(void) {
121
121
return ringbuf_get ((ringbuf_t * )& tx_ringbuf );
122
122
}
123
123
124
- static void cdc_task (void )
124
+ static void cdc_task (bool tx )
125
125
{
126
126
if ( tud_cdc_connected () ) {
127
127
// connected and there are data available
@@ -138,24 +138,30 @@ static void cdc_task(void)
138
138
}
139
139
}
140
140
141
- int chars = 0 ;
142
- while (cdc_tx_any ()) {
143
- if (chars < 64 ) {
144
- tud_cdc_write_char (cdc_tx_char ());
145
- chars ++ ;
146
- } else {
147
- chars = 0 ;
148
- tud_cdc_write_flush ();
141
+ if (tx ) {
142
+ int chars = 0 ;
143
+ while (cdc_tx_any ()) {
144
+ if (chars < 64 ) {
145
+ tud_cdc_write_char (cdc_tx_char ());
146
+ chars ++ ;
147
+ } else {
148
+ chars = 0 ;
149
+ tud_cdc_write_flush ();
150
+ }
149
151
}
150
- }
151
152
152
- tud_cdc_write_flush ();
153
+ tud_cdc_write_flush ();
154
+ }
153
155
}
154
156
}
155
157
156
158
static void usb_cdc_loop (void ) {
157
159
tud_task ();
158
- cdc_task ();
160
+ cdc_task (true);
161
+ }
162
+
163
+ void tud_cdc_rx_cb (uint8_t itf ) {
164
+ cdc_task (false);
159
165
}
160
166
161
167
int usb_cdc_init (void )
You can’t perform that action at this time.
0 commit comments