File tree 3 files changed +3
-7
lines changed
3 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -47,5 +47,4 @@ char serial_read(void);
47
47
bool serial_bytes_available (void );
48
48
bool serial_connected (void );
49
49
50
- extern volatile bool _serial_connected ;
51
50
#endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H
Original file line number Diff line number Diff line change @@ -47,8 +47,6 @@ busio_uart_obj_t debug_uart;
47
47
byte buf_array [64 ];
48
48
#endif
49
49
50
- volatile bool _serial_connected ;
51
-
52
50
void serial_early_init (void ) {
53
51
#if defined(DEBUG_UART_TX ) && defined(DEBUG_UART_RX )
54
52
debug_uart .base .type = & busio_uart_type ;
@@ -71,7 +69,9 @@ bool serial_connected(void) {
71
69
#if defined(DEBUG_UART_TX ) && defined(DEBUG_UART_RX )
72
70
return true;
73
71
#else
74
- return _serial_connected ;
72
+ // True if DTR is asserted, and the USB connection is up.
73
+ // tud_cdc_get_line_state(): bit 0 is DTR, bit 1 is RTS
74
+ return (tud_cdc_get_line_state () & 1 ) && tud_ready ();
75
75
#endif
76
76
}
77
77
Original file line number Diff line number Diff line change @@ -116,7 +116,6 @@ void tud_umount_cb(void) {
116
116
// remote_wakeup_en : if host allows us to perform remote wakeup
117
117
// USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus
118
118
void tud_suspend_cb (bool remote_wakeup_en ) {
119
- _serial_connected = false;
120
119
}
121
120
122
121
// Invoked when usb bus is resumed
@@ -128,8 +127,6 @@ void tud_resume_cb(void) {
128
127
void tud_cdc_line_state_cb (uint8_t itf , bool dtr , bool rts ) {
129
128
(void ) itf ; // interface ID, not used
130
129
131
- _serial_connected = dtr ;
132
-
133
130
// DTR = false is counted as disconnected
134
131
if ( !dtr )
135
132
{
You can’t perform that action at this time.
0 commit comments