DUE USB CDC: Do not send any character if no program on the PC is listening to them. This avoids Marlin waiting until the user actually opens a program that is able to consume the output of Marlin
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
|
||||
static volatile bool main_b_msc_enable = false;
|
||||
static volatile bool main_b_cdc_enable = false;
|
||||
static volatile bool main_b_dtr_active = false;
|
||||
|
||||
void HAL_idletask(void) {
|
||||
// Attend SD card access from the USB MSD -- Prioritize access to improve speed
|
||||
@@ -69,7 +70,7 @@ void usb_task_msc_disable(void) { main_b_msc_enable = false; }
|
||||
bool usb_task_msc_isenabled(void) { return main_b_msc_enable; }
|
||||
|
||||
bool usb_task_cdc_enable(const uint8_t port) { return ((main_b_cdc_enable = true)); }
|
||||
void usb_task_cdc_disable(const uint8_t port) { main_b_cdc_enable = false; }
|
||||
void usb_task_cdc_disable(const uint8_t port) { main_b_cdc_enable = false; main_b_dtr_active = false; }
|
||||
bool usb_task_cdc_isenabled(void) { return main_b_cdc_enable; }
|
||||
|
||||
/*! \brief Called by CDC interface
|
||||
@@ -87,12 +88,17 @@ void usb_task_cdc_config(const uint8_t port, usb_cdc_line_coding_t *cfg) {
|
||||
dwDTERate = cfg->dwDTERate;
|
||||
}
|
||||
|
||||
|
||||
void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable) {
|
||||
|
||||
// Keep DTR status
|
||||
main_b_dtr_active = b_enable;
|
||||
|
||||
// Implement Arduino-Compatible kludge to enter programming mode from
|
||||
// the native port:
|
||||
// "Auto-reset into the bootloader is triggered when the port, already
|
||||
// open at 1200 bps, is closed."
|
||||
|
||||
|
||||
if (1200 == dwDTERate) {
|
||||
// We check DTR state to determine if host port is open (bit 0 of lineState).
|
||||
if (!b_enable)
|
||||
@@ -102,6 +108,8 @@ void usb_task_cdc_set_dtr(const uint8_t port, const bool b_enable) {
|
||||
}
|
||||
}
|
||||
|
||||
bool usb_task_cdc_dtr_active(void) { return main_b_dtr_active; }
|
||||
|
||||
/// Microsoft WCID descriptor
|
||||
typedef struct USB_MicrosoftCompatibleDescriptor_Interface {
|
||||
uint8_t bFirstInterfaceNumber;
|
||||
|
||||
Reference in New Issue
Block a user