summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2015-01-09 05:12:31 +0100
committerDavid Lamparter <equinox@diac24.net>2015-01-09 05:12:31 +0100
commit8b5d8e578d8244e330e93c717e4e47ad0963dbd5 (patch)
tree442bf8db621839ce09c6f418e2cbaab5efaa9fae
parenta9ef16e6e3c705edad07201cea742e8529c090eb (diff)
lightctrl: factor out startup routine
-rw-r--r--helpers.c26
-rw-r--r--lightctrl.c23
2 files changed, 28 insertions, 21 deletions
diff --git a/helpers.c b/helpers.c
new file mode 100644
index 0000000..a24e8fc
--- /dev/null
+++ b/helpers.c
@@ -0,0 +1,26 @@
+
+static void postinit_slowboot(void)
+{
+ sei();
+
+ uart_puts("\nreset from");
+ if (MCUSR & (1 << WDRF))
+ uart_puts(" WDT");
+ if (MCUSR & (1 << BORF))
+ uart_puts(" BO");
+ if (MCUSR & (1 << EXTRF))
+ uart_puts(" EXT");
+ if (MCUSR & (1 << PORF))
+ uart_puts(" POR");
+ MCUSR = 0;
+
+ uart_puts("\nwdt_generation ");
+ uart_puthex(wdt_generation);
+
+ uart_puts("\ndelay...\n");
+ wdt_reset();
+ _delay_ms(1000);
+ wdt_reset();
+ uart_puts("\ninit done\n");
+}
+
diff --git a/lightctrl.c b/lightctrl.c
index 443359c..5b5e1c0 100644
--- a/lightctrl.c
+++ b/lightctrl.c
@@ -39,6 +39,7 @@ static void target_set(uint8_t dst, uint8_t val);
#include "dim.c"
#include "can.c"
#include "wdt.c"
+#include "helpers.c"
#define CANA_DALI_BASE 0x440
@@ -233,27 +234,7 @@ int main(void)
dali_init();
dim_init();
- sei();
-
- uart_puts("\nreset from");
- if (MCUSR & (1 << WDRF))
- uart_puts(" WDT");
- if (MCUSR & (1 << BORF))
- uart_puts(" BO");
- if (MCUSR & (1 << EXTRF))
- uart_puts(" EXT");
- if (MCUSR & (1 << PORF))
- uart_puts(" POR");
- MCUSR = 0;
-
- uart_puts("\nwdt_generation ");
- uart_puthex(wdt_generation);
-
- uart_puts("\ndelay...\n");
- wdt_reset();
- _delay_ms(1000);
- wdt_reset();
- uart_puts("\ninit done\n");
+ postinit_slowboot();
dali_buscheck();