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

USG_1.0
Robert Fisk 8 years ago
parent 5d393a0100
commit f9b7416df0

@ -52,6 +52,8 @@ void CheckFirmwareMatchesHardware(void);
int main(void) int main(void)
{ {
uint32_t iterationCount = 0;
//First things first! //First things first!
DisableFlashWrites(); DisableFlashWrites();
CheckFirmwareMatchesHardware(); CheckFirmwareMatchesHardware();
@ -74,6 +76,15 @@ int main(void)
USB_Host_Process(); USB_Host_Process();
Downstream_SPIProcess(); Downstream_SPIProcess();
Downstream_PacketProcessor_CheckNotifyDisconnectReply(); 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) while (1)
{ {
__WFI(); //sleep time!
} }
} }
void DisableFlashWrites(void) void DisableFlashWrites(void)
{ {
//Disable flash writes until the next reset //Disable flash writes until the next reset

Loading…
Cancel
Save