aboutsummaryrefslogtreecommitdiff
path: root/cc3200/misc/mperror.c
diff options
context:
space:
mode:
authordanicampora2015-02-26 15:03:52 +0100
committerdanicampora2015-02-28 19:03:21 +0100
commitd01060241a2102878a2b6ff270323e7d278f0af8 (patch)
tree08ab66e810ac650cc990f3413f3d1f9f035bacd9 /cc3200/misc/mperror.c
parent6a41bf99bdd2e19d6922864bf6845a91b3ab6b99 (diff)
cc3200: Add heartbeat signal on system led.
Diffstat (limited to 'cc3200/misc/mperror.c')
-rw-r--r--cc3200/misc/mperror.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/cc3200/misc/mperror.c b/cc3200/misc/mperror.c
index bfb17a2b4..bff581279 100644
--- a/cc3200/misc/mperror.c
+++ b/cc3200/misc/mperror.c
@@ -45,14 +45,27 @@
#include "prcm.h"
#include "pybuart.h"
#include "utils.h"
+#include "mperror.h"
+/******************************************************************************
+ DEFINE CONSTANTS
+ ******************************************************************************/
#define MPERROR_TOOGLE_MS (200)
#define MPERROR_SIGNAL_ERROR_MS (2000)
+#define MPERROR_HEARTBEAT_ON_MS (80)
+#define MPERROR_HEARTBEAT_OFF_MS (2920)
#define MPERROR_SAFE_BOOT_REG_IDX (0)
+/******************************************************************************
+ DECLARE PRIVATE DATA
+ ******************************************************************************/
+static bool mperror_heartbeat_enabled;
+/******************************************************************************
+ DEFINE PUBLIC FUNCTIONS
+ ******************************************************************************/
void mperror_init0 (void) {
// Enable SYS GPIOs peripheral clocks
MAP_PRCMPeripheralClkEnable(MICROPY_SYS_LED_PRCM, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
@@ -102,6 +115,40 @@ bool mperror_safe_boot_requested (void) {
return ret;
}
+void mperror_enable_heartbeat (void) {
+ mperror_heartbeat_enabled = true;
+}
+
+void mperror_disable_heartbeat (void) {
+ mperror_heartbeat_enabled = false;
+ mperror_heartbeat_off();
+}
+
+void mperror_heartbeat_signal (void) {
+ static uint off_start = 0;
+ static uint on_start = 0;
+ static bool beat = false;
+
+ if (mperror_heartbeat_enabled) {
+ if (!beat) {
+ if ((on_start = HAL_GetTick()) - off_start > MPERROR_HEARTBEAT_OFF_MS) {
+ MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN);
+ beat = true;
+ }
+ }
+ else {
+ if ((off_start = HAL_GetTick()) - on_start > MPERROR_HEARTBEAT_ON_MS) {
+ mperror_heartbeat_off();
+ beat = false;
+ }
+ }
+ }
+}
+
+void mperror_heartbeat_off (void) {
+ MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
+}
+
void NORETURN __fatal_error(const char *msg) {
#ifdef DEBUG
if (msg != NULL) {