-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (31 loc) · 744 Bytes
/
main.cpp
File metadata and controls
37 lines (31 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* ECU_Code.cpp
*
* Created: 4/29/2019 7:39:53 AM
* Author : Jordan
*/
//It won't sleep unless you comment this out
//#define DEBUG_MODE
#include "sam.h"
#include "ECU.h"
int main(void){
ECUConfig();
ECUStart();
//Only allow sleep and sleep on exit if debug is disabled, it inhibits debugger
//when sleep is enabled
#ifndef DEBUG_MODE
//Setup sleep mode
PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_STANDBY;
SCB->SCR |= (1 << 1); //Causes sleep on exit
//Wait for this to happen
while(PM->SLEEPCFG.reg != PM_SLEEPCFG_SLEEPMODE_STANDBY);
//Ensure sleeping is allowed
while(0 == PM->INTFLAG.bit.SLEEPRDY);
//Put it to sleep
__WFI();
#else
while(1){
for(unsigned int i = 0; i<10000000; i++);
}
#endif
}