File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,8 +54,10 @@ extern void mp_cdc_disable(uint8_t port);
5454#define UDI_CDC_RX_NOTIFY (port ) usb_rx_notify()
5555void usb_rx_notify (void );
5656#define UDI_CDC_SET_CODING_EXT (port ,cfg )
57- #define UDI_CDC_SET_DTR_EXT (port ,set )
58- #define UDI_CDC_SET_RTS_EXT (port ,set )
57+ #define UDI_CDC_SET_DTR_EXT (port ,set ) usb_dtr_notify(port, set)
58+ void usb_dtr_notify (uint8_t port , bool set );
59+ #define UDI_CDC_SET_RTS_EXT (port ,set ) usb_rts_notify(port, set)
60+ void usb_rts_notify (uint8_t port , bool set );
5961
6062/**
6163 * USB CDC low level configuration
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ void mp_msc_disable()
5050
5151bool mp_cdc_enable (uint8_t port )
5252{
53- mp_cdc_enabled = true ;
53+ mp_cdc_enabled = false ;
5454 return true;
5555}
5656
@@ -59,6 +59,14 @@ void mp_cdc_disable(uint8_t port)
5959 mp_cdc_enabled = false;
6060}
6161
62+ void usb_dtr_notify (uint8_t port , bool set ) {
63+ mp_cdc_enabled = set ;
64+ }
65+
66+ void usb_rts_notify (uint8_t port , bool set ) {
67+ return ;
68+ }
69+
6270void usb_rx_notify (void )
6371{
6472 irqflags_t flags ;
@@ -177,7 +185,10 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
177185 #endif
178186
179187 #ifdef USB_REPL
180- if (mp_cdc_enabled && udi_cdc_is_tx_ready ()) {
188+ // Always make sure there is enough room in the usb buffer for the outgoing
189+ // string. If there isn't we risk getting caught in a loop within the usb
190+ // code as it tries to send all the characters it can't buffer.
191+ if (mp_cdc_enabled && udi_cdc_get_free_tx_buffer () >= len ) {
181192 udi_cdc_write_buf (str , len );
182193 }
183194 #endif
You can’t perform that action at this time.
0 commit comments