diff options
Diffstat (limited to 'software/avr.lib/usbio.c')
-rw-r--r-- | software/avr.lib/usbio.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/software/avr.lib/usbio.c b/software/avr.lib/usbio.c index 371f9e7..6a7f76e 100644 --- a/software/avr.lib/usbio.c +++ b/software/avr.lib/usbio.c @@ -83,8 +83,13 @@ void usbio_init(void) void usbio_task(void) { - CDC_Device_USBTask(&VirtualSerial_CDC_Interface); - USB_USBTask(); + if(USB_DeviceState == DEVICE_STATE_Unattached && USB_VBUS_GetStatus()) { + USB_Disable(); + USB_Init(); + } + + CDC_Device_USBTask(&VirtualSerial_CDC_Interface); + USB_USBTask(); } int16_t usbio_bytes_received(void) @@ -95,7 +100,7 @@ int16_t usbio_bytes_received(void) return 0; } -void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) { if(CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR) stdin = stdout = stderr = &usb_stream; |