1
0
forked from me/IronOS

Dont use stale data in PD IRQ

This commit is contained in:
Ben V. Brown
2021-04-27 20:06:49 +10:00
parent a42c5ccd40
commit d4ea53cdcd

View File

@@ -57,7 +57,7 @@ void InterruptHandler::readPendingMessage() {
} }
} }
void InterruptHandler::Thread(const void *arg) { void InterruptHandler::Thread(const void *arg) {
(void)arg; (void)arg;
union fusb_status status; union fusb_status status;
for (;;) { for (;;) {
@@ -66,27 +66,28 @@ void InterruptHandler::Thread(const void *arg) {
xTaskNotifyWait(0x00, 0x0F, NULL, TICKS_SECOND * 30); xTaskNotifyWait(0x00, 0x0F, NULL, TICKS_SECOND * 30);
} }
/* Read the FUSB302B status and interrupt registers */ /* Read the FUSB302B status and interrupt registers */
fusb_get_status(&status); if (fusb_get_status(&status)) {
/* If the I_GCRCSENT flag is set, tell the Protocol RX thread */ /* If the I_GCRCSENT flag is set, tell the Protocol RX thread */
// This means a message was recieved with a good CRC // This means a message was received with a good CRC
if (status.interruptb & FUSB_INTERRUPTB_I_GCRCSENT) { if (status.interruptb & FUSB_INTERRUPTB_I_GCRCSENT) {
readPendingMessage(); readPendingMessage();
} }
/* If the I_TXSENT or I_RETRYFAIL flag is set, tell the Protocol TX /* If the I_TXSENT or I_RETRYFAIL flag is set, tell the Protocol TX
* thread */ * thread */
if (status.interrupta & FUSB_INTERRUPTA_I_TXSENT) { if (status.interrupta & FUSB_INTERRUPTA_I_TXSENT) {
ProtocolTransmit::notify(ProtocolTransmit::Notifications::PDB_EVT_PRLTX_I_TXSENT); ProtocolTransmit::notify(ProtocolTransmit::Notifications::PDB_EVT_PRLTX_I_TXSENT);
} }
if (status.interrupta & FUSB_INTERRUPTA_I_RETRYFAIL) { if (status.interrupta & FUSB_INTERRUPTA_I_RETRYFAIL) {
ProtocolTransmit::notify(ProtocolTransmit::Notifications::PDB_EVT_PRLTX_I_RETRYFAIL); ProtocolTransmit::notify(ProtocolTransmit::Notifications::PDB_EVT_PRLTX_I_RETRYFAIL);
} }
/* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy /* If the I_OCP_TEMP and OVRTEMP flags are set, tell the Policy
* Engine thread */ * Engine thread */
if ((status.interrupta & FUSB_INTERRUPTA_I_OCP_TEMP) && (status.status1 & FUSB_STATUS1_OVRTEMP)) { if ((status.interrupta & FUSB_INTERRUPTA_I_OCP_TEMP) && (status.status1 & FUSB_STATUS1_OVRTEMP)) {
PolicyEngine::notify(PolicyEngine::Notifications::PDB_EVT_PE_I_OVRTEMP); PolicyEngine::notify(PolicyEngine::Notifications::PDB_EVT_PE_I_OVRTEMP);
}
} }
} }
} }