-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
52 lines (40 loc) · 911 Bytes
/
main.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "sam.h"
#include "pins.h"
#include "app.h"
#include "system.h"
#include "delay.h"
#if __EMSCRIPTEN__
void resume_main_loop(void);
#endif
int main(void) {
// set up system clocks
sys_init();
// set up system tick
delay_init();
// allow application to do its own initialization
app_init();
// restore from BACKUP state
app_wake_from_backup();
// allow application to do its initial setup
app_setup();
#if __EMSCRIPTEN__
resume_main_loop();
#else
while (1) {
bool can_sleep = app_loop();
if (can_sleep) {
_enter_standby_mode();
}
}
#endif
return 0;
}
static void __empty() {
// Empty
}
void app_wake_from_backup(void) __attribute__ ((weak, alias("__empty")));
void yield(void) __attribute__ ((weak, alias("__empty")));