From 74a2f8409f3bfb462de36bca04ad44ac65473f7b Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 30 Sep 2014 16:08:30 +0200 Subject: LED error code for assert() --- common.c | 15 +++++++++++++++ common.h | 7 +++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/common.c b/common.c index e3f3195..31af23e 100644 --- a/common.c +++ b/common.c @@ -1,4 +1,19 @@ #include "common.h" +#include "pwm.h" volatile uint8_t wakeup = 0; +/* shutdown device signaling internal error + */ +void shutdownError () { + pwmSet (0, PWM_ON); + for (uint8_t i = 1; i < PWM_LED_COUNT-1; i++) { + pwmSet (i, PWM_OFF); + } + pwmSet (PWM_LED_COUNT-1, PWM_ON); + sleep_enable (); + while (1) { + sleep_cpu (); + } +} + diff --git a/common.h b/common.h index fb53d4d..eced70e 100644 --- a/common.h +++ b/common.h @@ -17,10 +17,7 @@ #include #define assert(x) if (!(x)) { \ puts("assert in " __FILE__ ":" #x); \ - sleep_enable (); \ - while (1) { \ - sleep_cpu (); \ - } \ + shutdownError (); \ } #include @@ -45,5 +42,7 @@ enum { wakeup &= ~(1 << x); \ } +void shutdownError (); + #endif /* COMMON_H */ -- cgit v1.2.3