aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--synology-autopoweron/main.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/synology-autopoweron/main.c b/synology-autopoweron/main.c
index 698a887..6b0acf0 100644
--- a/synology-autopoweron/main.c
+++ b/synology-autopoweron/main.c
@@ -1,6 +1,7 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/power.h>
+#include <avr/sleep.h>
/* Pinout used:
* -----
@@ -68,25 +69,10 @@ static void reset_sleep_time(void)
sleep_time = 0;
}
-static void button_pushed()
-{
- PORTB &= ~(1 << PB3); /* make sure reset line is disabled */
- PORTB |= (1 << PB4); /* activate plug modules set */
-}
-
-static void button_normal()
-{
- /* be sure set line is not active before doing a reset else both coil will
- * be energized at the same time and thus the behaviour may be
- * unpredictable. */
- plug_unset();
- /* activate module reset */
- PORTB |= (1 << PB3);
-}
-
int main()
{
cli();
+ PORTB = 0; // outputs set to low and input not set to internal pull-up
init_timer();
sei();
@@ -95,16 +81,14 @@ int main()
for (;;) {
reset_sleep_time();
- PORTB = 0; // outputs set to low and input not set to internal pull-up
-
// digital output, pull-down for a time then go to default PB0 = Hi-Z
DDRB |= (1 << PB0);
while (get_sleep_time() <= SLEPT_TIMEOUT);
DDRB &= ~(1 << PB0);
/* set low power mode */
- power_all_disable(); // disable all peripherals
- set_sleep_mode(<mode>); // sleep mode
+ power_all_disable(); // disable all peripherals
+ set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode
sleep_enable(); // set register to enable sleep
sleep_bod_disable(); // disable bod to consume even less
//sei(); // normally set sei to ensure wakeup but I do