Skip to content

Commit f319924

Browse files
committed
feat: add sleep functionality to AVR test for power management
1 parent 4915eb7 commit f319924

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

tests/avr_test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define ESTACK_NO_MALLOC
33
#include "easy_stack.h"
44
#include <stdlib.h>
5+
#include <avr/interrupt.h>
6+
#include <avr/sleep.h>
57

68
/*
79
* Standalone assertion helper for bare-metal AVR environment.
@@ -52,5 +54,10 @@ int main(void) {
5254
estack_free(stack, t1);
5355
avr_assert(estack_get_meta_index(stack) == 0);
5456

57+
cli(); // Disable all interrupts
58+
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Set deepest sleep mode (Power-Down)
59+
sleep_enable();
60+
sleep_cpu(); // Put CPU to sleep. simavr will exit cleanly.
61+
5562
return 0; // Success
5663
}

0 commit comments

Comments
 (0)