https://www.fi.muni.cz/~kas/git
/
bike-lights.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
918f7a8
)
main.c: on-demand sleep modes
author
Jan "Yenya" Kasprzak
<kas@fi.muni.cz>
Mon, 3 Jun 2013 15:56:06 +0000 (17:56 +0200)
committer
Jan "Yenya" Kasprzak
<kas@fi.muni.cz>
Mon, 3 Jun 2013 15:56:06 +0000 (17:56 +0200)
firmware/main.c
patch
|
blob
|
history
diff --git
a/firmware/main.c
b/firmware/main.c
index
0e33957
..
a83884b
100644
(file)
--- a/
firmware/main.c
+++ b/
firmware/main.c
@@
-71,7
+71,20
@@
int main(void)
sei();
#if 1
while (1) {
- sleep_mode();
+ cli();
+ if (TIMER1_IS_ON()) {
+ set_sleep_mode(SLEEP_MODE_IDLE);
+ } else if (adc_is_on) {
+ set_sleep_mode(SLEEP_MODE_ADC);
+ } else {
+ set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+ }
+
+ sleep_enable();
+ // keep BOD active, no sleep_bod_disable();
+ sei();
+ sleep_cpu();
+ sleep_disable();
}
#endif