set_sleep_mode(SLEEP_MODE_IDLE);
}
-static void hw_suspend()
+static void inline hw_suspend()
{
susp_pwm();
susp_adc();
hw_setup();
}
-int main(void)
+static void inline first_boot()
{
unsigned char mcusr_save;
power_down(mcusr_save & _BV(WDRF));
sei();
-#if 1
- while (1) {
- 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();
+static void inline main_loop_iteration()
+{
+ 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);
}
-#endif
+
+ sleep_enable();
+ // keep BOD active, no sleep_bod_disable();
+ sei();
+ sleep_cpu();
+ sleep_disable();
+}
+
+int main(void)
+{
+ first_boot();
+
+ while (1)
+ main_loop_iteration();
#if 0
DDRB |= _BV(PB2);