1
0
forked from me/IronOS

Fix interrupt race

This commit is contained in:
Ben V. Brown
2020-09-05 20:19:03 +10:00
parent d48b27928a
commit 11e583be63

View File

@@ -143,21 +143,13 @@ void fusb_send_hardrst() {
} }
void fusb_setup() { void fusb_setup() {
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
if (!I2CBB::lock2()) { if (!I2CBB::lock2()) {
return; return;
} }
/* Fully reset the FUSB302B */ /* Fully reset the FUSB302B */
fusb_write_byte( FUSB_RESET, FUSB_RESET_SW_RES); // fusb_write_byte( FUSB_RESET, FUSB_RESET_SW_RES);
osDelay(2); // osDelay(2);
if (!fusb_read_id()) { if (!fusb_read_id()) {
return; return;
} }
@@ -200,6 +192,14 @@ void fusb_setup() {
} }
I2CBB::unlock2(); I2CBB::unlock2();
fusb_reset(); fusb_reset();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
} }
void fusb_get_status(union fusb_status *status) { void fusb_get_status(union fusb_status *status) {