do power down
This commit is contained in:
19
main.c
19
main.c
@ -65,6 +65,9 @@ ISR(PORTA_PORT_vect)
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
// MCU resumes execution here after reset
|
||||
sleep_disable(); // Disable sleep
|
||||
|
||||
// Configure LED pins as outputs
|
||||
VPORTA.DIR = (PA1_SET_MASK | PA2_SET_MASK | PA3_SET_MASK | PA6_SET_MASK | PA7_SET_MASK);
|
||||
|
||||
@ -108,19 +111,17 @@ int main(void)
|
||||
blinkLed(true); // reset blink state machine
|
||||
leds_off();
|
||||
|
||||
_delay_ms(BUTTON_IGNORE_DURATION_MS * 2);
|
||||
|
||||
// TODO: activate the interrupt for PA0
|
||||
PORTA.PIN0CTRL = PORT_PULLUPEN_bm | PORT_ISC_FALLING_gc;
|
||||
|
||||
sei(); // Enable global interrupts
|
||||
while (1)
|
||||
{
|
||||
leds_off();
|
||||
_delay_ms(BUTTON_IGNORE_DURATION_MS / 20);
|
||||
leds_on();
|
||||
_delay_ms(BUTTON_IGNORE_DURATION_MS / 20);
|
||||
}
|
||||
set_sleep_mode(SLEEP_MODE_STANDBY); // Deepest sleep mode (standby)
|
||||
sleep_enable(); // Enable sleep
|
||||
|
||||
// TODO: add a isr that disabled all leds and loops in while(1);
|
||||
cli(); // Disable global interrupts
|
||||
sei(); // Re-enable interrupts
|
||||
sleep_cpu(); // MCU sleeps here
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user