]> www.fi.muni.cz Git - tinyboard.git/commitdiff
Watchdog handling moved to its own source file
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 10 May 2013 11:44:11 +0000 (13:44 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 10 May 2013 11:44:11 +0000 (13:44 +0200)
projects/step-up/Makefile
projects/step-up/lights.h
projects/step-up/main.c
projects/step-up/wdt.c [new file with mode: 0644]

index 0e9b7284342ecac985eacf5c476a4d396b7a5603..07bb15180295615c1e861df1f1c0a25d2d2113a6 100644 (file)
@@ -1,7 +1,7 @@
 
 PROGRAM=lights
 SRC=main.c logging.c pwm.c adc.c pwmled.c pattern.c buttons.c control.c \
-       battery.c
+       battery.c wdt.c
 OBJ=$(SRC:.c=.o)
 
 
index 7a268ef161d6c9ae122810379f58b3a6448b2644..6318c56fb92387ec5fcd9e98925585ff9f996346 100644 (file)
@@ -75,6 +75,10 @@ pattern_t *status_led_pattern_select();
 #define ERR_PWMLED  2
 void set_error(unsigned char err);
 
+/* wdt.c */
+void init_wdt();
+void susp_wdt();
+
 /* main.c */
 void power_down();
 
index 69657a8a70052d37b5b4cdd1545febfeba8ad456..1ac54039a5398aa5c085bef1517b35a81ec5e00d 100644 (file)
@@ -11,11 +11,10 @@ static void hw_setup()
 {
        power_all_disable();
 
-       wdt_enable(WDTO_1S);
-
        init_battery();
        init_pwm();
        init_adc();
+       init_wdt();
 
        init_buttons();
 
@@ -30,9 +29,10 @@ static void hw_suspend()
 {
        susp_pwm();
        susp_adc();
+       susp_wdt();
+
        susp_buttons();
 
-       wdt_disable();
        power_all_disable();
 }
 
diff --git a/projects/step-up/wdt.c b/projects/step-up/wdt.c
new file mode 100644 (file)
index 0000000..050c0c5
--- /dev/null
@@ -0,0 +1,16 @@
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <avr/wdt.h>
+
+#include "lights.h"
+
+void init_wdt()
+{
+       wdt_enable(WDTO_1S);
+}
+
+void susp_wdt()
+{
+       wdt_disable();
+}
+