1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-01-11 23:43:04 +00:00

USB: fix race condition between SOF IRQ check and reset

This commit is contained in:
Gyorgy Szombathelyi 2024-02-04 19:38:02 +01:00
parent 5af9aab6cc
commit 38fca2e6e5
2 changed files with 12 additions and 6 deletions

View File

@ -196,10 +196,10 @@ uint8_t max3421e_poll() {
max3421e_write_u08( MAX3421E_HIRQ, MAX3421E_SNDBAVIRQ);
}
if( hirq & MAX3421E_FRAMEIRQ) {
//if( hirq & MAX3421E_FRAMEIRQ) {
// iprintf("=> MAX3421E_FRAMEIRQ\n");
max3421e_write_u08( MAX3421E_HIRQ, MAX3421E_FRAMEIRQ);
}
//max3421e_write_u08( MAX3421E_HIRQ, MAX3421E_FRAMEIRQ);
//}
#if 0
int i;

View File

@ -365,6 +365,10 @@ void usb_poll() {
// max poll 1ms
static msec_t poll=0;
if(timer_check(poll, 1)) {
if (usb_task_state != USB_ATTACHED_SUBSTATE_WAIT_SOF && (max3421e_read_u08( MAX3421E_HIRQ ) & MAX3421E_FRAMEIRQ )) {
max3421e_write_u08( MAX3421E_HIRQ, MAX3421E_FRAMEIRQ); // clear SOF irq
}
poll = timer_get_msec();
// poll all configured devices
@ -412,10 +416,12 @@ void usb_poll() {
}
break;
case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
if( max3421e_read_u08( MAX3421E_HIRQ ) & MAX3421E_FRAMEIRQ ) { //when first SOF received we can continue
if( timer_check(delay, 20) ) //20ms passed
case USB_ATTACHED_SUBSTATE_WAIT_SOF:
if( timer_check(delay, 20) ) {//20ms passed
if( max3421e_read_u08( MAX3421E_HIRQ ) & MAX3421E_FRAMEIRQ ) { //when first SOF received we can continue
max3421e_write_u08( MAX3421E_HIRQ, MAX3421E_FRAMEIRQ);
usb_task_state = USB_STATE_CONFIGURING;
}
}
break;