@@ -139,12 +139,14 @@ static void hw_cdc_isr_handler(void *arg) {
139
139
}
140
140
141
141
static void ARDUINO_ISR_ATTR cdc0_write_char (char c) {
142
- if (xPortInIsrContext ()){
143
- xRingbufferSendFromISR (tx_ring_buf, (void *) (&c), 1 , NULL );
144
- } else {
145
- xRingbufferSend (tx_ring_buf, (void *) (&c), 1 , tx_timeout_ms / portTICK_PERIOD_MS);
142
+ if (initial_empty){
143
+ if (xPortInIsrContext ()){
144
+ xRingbufferSendFromISR (tx_ring_buf, (void *) (&c), 1 , NULL );
145
+ } else {
146
+ xRingbufferSend (tx_ring_buf, (void *) (&c), 1 , tx_timeout_ms / portTICK_PERIOD_MS);
147
+ }
148
+ usb_serial_jtag_ll_ena_intr_mask (USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
146
149
}
147
- usb_serial_jtag_ll_ena_intr_mask (USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
148
150
}
149
151
150
152
HWCDC::HWCDC () {
@@ -245,7 +247,7 @@ int HWCDC::availableForWrite(void)
245
247
246
248
size_t HWCDC::write (const uint8_t *buffer, size_t size)
247
249
{
248
- if (buffer == NULL || size == 0 || tx_ring_buf == NULL || tx_lock == NULL ){
250
+ if (buffer == NULL || size == 0 || tx_ring_buf == NULL || tx_lock == NULL || initial_empty == false ){
249
251
return 0 ;
250
252
}
251
253
if (xSemaphoreTake (tx_lock, tx_timeout_ms / portTICK_PERIOD_MS) != pdPASS){
@@ -293,7 +295,7 @@ size_t HWCDC::write(uint8_t c)
293
295
294
296
void HWCDC::flush (void )
295
297
{
296
- if (tx_ring_buf == NULL || tx_lock == NULL ){
298
+ if (tx_ring_buf == NULL || tx_lock == NULL || initial_empty == false ){
297
299
return ;
298
300
}
299
301
if (xSemaphoreTake (tx_lock, tx_timeout_ms / portTICK_PERIOD_MS) != pdPASS){
0 commit comments