mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 09:57:50 +00:00
fixed usb serial not working after reconnect (#2196)
* fixed usb serial not working after reconnect * added restart for sd over usb disconnect * improved usb serial fix * fixed formatting
This commit is contained in:
@@ -49,6 +49,7 @@ void USBSerial::on_channel_opened() {
|
||||
}
|
||||
|
||||
void USBSerial::on_channel_closed() {
|
||||
reset_transfer_queues();
|
||||
connected = false;
|
||||
}
|
||||
|
||||
|
@@ -42,6 +42,10 @@ CH_IRQ_HANDLER(USB0_IRQHandler) {
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
if (status & USB0_USBSTS_D_SLI) {
|
||||
on_channel_closed();
|
||||
}
|
||||
|
||||
CH_IRQ_EPILOGUE();
|
||||
}
|
||||
|
||||
@@ -131,11 +135,7 @@ usb_request_status_t usb_get_line_coding_request(usb_endpoint_t* const endpoint,
|
||||
}
|
||||
usb_request_status_t usb_set_control_line_state_request(usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage) {
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
// if (endpoint->setup.value == 3) {
|
||||
on_channel_opened();
|
||||
//} else {
|
||||
// on_channel_closed();
|
||||
//}
|
||||
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
|
@@ -54,6 +54,14 @@ void init_host_to_device() {
|
||||
thread_usb_event = chThdSelf();
|
||||
}
|
||||
|
||||
void reset_transfer_queues() {
|
||||
while (usb_bulk_buffer_queue.empty() == false)
|
||||
usb_bulk_buffer_queue.pop();
|
||||
|
||||
while (usb_bulk_buffer_spare.empty() == false)
|
||||
usb_bulk_buffer_spare.pop();
|
||||
}
|
||||
|
||||
void schedule_host_to_device_transfer() {
|
||||
if (usb_bulk_buffer_queue.size() >= 8)
|
||||
return;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#define USB_BULK_BUFFER_SIZE 64
|
||||
|
||||
void init_host_to_device();
|
||||
void reset_transfer_queues();
|
||||
void serial_bulk_transfer_complete(void* user_data, unsigned int bytes_transferred);
|
||||
void schedule_host_to_device_transfer();
|
||||
void complete_host_to_device_transfer();
|
||||
|
Reference in New Issue
Block a user