atmel-samd: Stop hanging on usb write when a terminal isn't connected by checking DTR status.
This commit is contained in:
parent
db918da5f0
commit
ab7da9353a
@ -175,9 +175,11 @@ static bool write_complete(const uint8_t ep,
|
||||
}
|
||||
|
||||
volatile bool reset_on_disconnect = false;
|
||||
volatile bool cdc_connected = false;
|
||||
|
||||
static bool usb_device_cb_state_c(usb_cdc_control_signal_t state)
|
||||
{
|
||||
cdc_connected = state.rs232.DTR;
|
||||
if (state.rs232.DTR) {
|
||||
} else if (!state.rs232.DTR && reset_on_disconnect) {
|
||||
reset_to_bootloader();
|
||||
@ -282,6 +284,10 @@ void usb_write(const char* buffer, uint32_t len) {
|
||||
if (!cdc_enabled()) {
|
||||
return;
|
||||
}
|
||||
if (!cdc_connected) {
|
||||
// TODO(tannewt): Should we write to a file instead?
|
||||
return;
|
||||
}
|
||||
uint8_t * output_buffer;
|
||||
uint8_t output_len;
|
||||
while (len > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user