Sleep instead of busy-wait, approx 50% power reduction!

pull/7/head
Robert Fisk 8 years ago
parent fa98307a3b
commit 7e073a091d

@ -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!
}
}
}

@ -78,11 +78,12 @@ int main(void)
while (1)
{
__WFI(); //sleep time!
}
}
void DisableFlashWrites(void)
{
//Disable flash writes until the next reset

Loading…
Cancel
Save