diff --git a/Downstream/Src/main.c b/Downstream/Src/main.c index f64aa9a..a13a160 100644 --- a/Downstream/Src/main.c +++ b/Downstream/Src/main.c @@ -52,6 +52,8 @@ void CheckFirmwareMatchesHardware(void); int main(void) { + uint32_t iterationCount = 0; + //First things first! DisableFlashWrites(); CheckFirmwareMatchesHardware(); @@ -74,6 +76,15 @@ int main(void) USB_Host_Process(); Downstream_SPIProcess(); Downstream_PacketProcessor_CheckNotifyDisconnectReply(); + + //Some USB host state transitions take 3 iterations to fully apply. + //We'll be generous and give it 5 before sleeping. + iterationCount++; + if (iterationCount > 4) + { + iterationCount = 0; + __WFI(); //sleep time! + } } } diff --git a/Upstream/Src/main.c b/Upstream/Src/main.c index d6886c2..b640d54 100755 --- a/Upstream/Src/main.c +++ b/Upstream/Src/main.c @@ -78,11 +78,12 @@ int main(void) while (1) { - + __WFI(); //sleep time! } } + void DisableFlashWrites(void) { //Disable flash writes until the next reset