mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 17:49:31 +00:00
Usb serial fix queue full crash (#1763)
* fixed usb serial queue crashing * fixed usb input buffer handling * fixed black screen issue
This commit is contained in:
@@ -40,15 +40,19 @@
|
||||
|
||||
SerialUSBDriver SUSBD1;
|
||||
|
||||
uint8_t usbBulkBuffer[USBSERIAL_BUFFERS_SIZE];
|
||||
uint8_t usb_bulk_buffer[USB_BULK_BUFFER_SIZE];
|
||||
|
||||
void bulk_out_receive(void) {
|
||||
int ret;
|
||||
|
||||
while (chIQGetEmptyI(&SUSBD1.iqueue) < USB_BULK_BUFFER_SIZE)
|
||||
chThdSleepMilliseconds(1); // wait for shell thread when buffer is full
|
||||
|
||||
do {
|
||||
ret = usb_transfer_schedule(
|
||||
&usb_endpoint_bulk_out,
|
||||
&usbBulkBuffer[0],
|
||||
USBSERIAL_BUFFERS_SIZE,
|
||||
&usb_bulk_buffer[0],
|
||||
USB_BULK_BUFFER_SIZE,
|
||||
serial_bulk_transfer_complete,
|
||||
NULL);
|
||||
|
||||
@@ -58,18 +62,19 @@ void bulk_out_receive(void) {
|
||||
void serial_bulk_transfer_complete(void* user_data, unsigned int bytes_transferred) {
|
||||
(void)user_data;
|
||||
|
||||
chSysLockFromIsr();
|
||||
for (unsigned int i = 0; i < bytes_transferred; i++) {
|
||||
msg_t ret;
|
||||
do {
|
||||
chSysLockFromIsr();
|
||||
ret = chIQPutI(&SUSBD1.iqueue, usbBulkBuffer[i]);
|
||||
chSysUnlockFromIsr();
|
||||
ret = chIQPutI(&SUSBD1.iqueue, usb_bulk_buffer[i]);
|
||||
|
||||
if (ret == Q_FULL) {
|
||||
chThdYield();
|
||||
chDbgPanic("USB iqueue buffer full");
|
||||
}
|
||||
|
||||
} while (ret == Q_FULL);
|
||||
}
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
static void onotify(GenericQueue* qp) {
|
||||
@@ -93,7 +98,7 @@ static void onotify(GenericQueue* qp) {
|
||||
NULL);
|
||||
|
||||
if (ret == -1)
|
||||
chThdYield();
|
||||
chThdSleepMilliseconds(1);
|
||||
|
||||
} while (ret == -1);
|
||||
chSysLock();
|
||||
|
||||
Reference in New Issue
Block a user