summaryrefslogtreecommitdiff
path: root/cc3200/misc/mperror.c
diff options
context:
space:
mode:
Diffstat (limited to 'cc3200/misc/mperror.c')
-rw-r--r--cc3200/misc/mperror.c61
1 files changed, 13 insertions, 48 deletions
diff --git a/cc3200/misc/mperror.c b/cc3200/misc/mperror.c
index 845a2a814..624a9d91d 100644
--- a/cc3200/misc/mperror.c
+++ b/cc3200/misc/mperror.c
@@ -149,17 +149,13 @@ void mperror_heartbeat_switch_off (void) {
void mperror_heartbeat_signal (void) {
if (mperror_heart_beat.do_disable) {
mperror_heart_beat.do_disable = false;
- mperror_heartbeat_switch_off();
- mperror_heart_beat.enabled = false;
- }
- else if (mperror_heart_beat.enabled) {
+ } else if (mperror_heart_beat.enabled) {
if (!mperror_heart_beat.beating) {
if ((mperror_heart_beat.on_time = HAL_GetTick()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN);
mperror_heart_beat.beating = true;
}
- }
- else {
+ } else {
if ((mperror_heart_beat.off_time = HAL_GetTick()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
mperror_heart_beat.beating = false;
@@ -199,48 +195,17 @@ void nlr_jump_fail(void *val) {
#endif
}
-#ifndef BOOTLOADER
-/******************************************************************************/
-// Micro Python bindings
-
-/// \classmethod \constructor()
-///
-/// Return the heart beat object
-STATIC mp_obj_t pyb_heartbeat_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
- // check arguments
- mp_arg_check_num(n_args, n_kw, 0, 0, false);
-
- // return constant object
- return (mp_obj_t)&pyb_heartbeat_obj;
-}
-
-/// \function enable()
-/// Enables the heartbeat signal
-STATIC mp_obj_t pyb_enable_heartbeat(mp_obj_t self) {
- mperror_heart_beat.enabled = true;
- return mp_const_none;
+void mperror_enable_heartbeat (bool enable) {
+ if (enable) {
+ mperror_heart_beat.enabled = true;
+ mperror_heart_beat.do_disable = false;
+ mperror_heartbeat_switch_off();
+ } else {
+ mperror_heart_beat.do_disable = true;
+ mperror_heart_beat.enabled = false;
+ }
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_enable_heartbeat_obj, pyb_enable_heartbeat);
-/// \function disable()
-/// Disables the heartbeat signal
-STATIC mp_obj_t pyb_disable_heartbeat(mp_obj_t self) {
- mperror_heart_beat.do_disable = true;
- return mp_const_none;
+bool mperror_is_heartbeat_enabled (void) {
+ return mperror_heart_beat.enabled;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_disable_heartbeat_obj, pyb_disable_heartbeat);
-
-STATIC const mp_map_elem_t pyb_heartbeat_locals_dict_table[] = {
- { MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&pyb_enable_heartbeat_obj },
- { MP_OBJ_NEW_QSTR(MP_QSTR_disable), (mp_obj_t)&pyb_disable_heartbeat_obj },
-};
-STATIC MP_DEFINE_CONST_DICT(pyb_heartbeat_locals_dict, pyb_heartbeat_locals_dict_table);
-
-const mp_obj_type_t pyb_heartbeat_type = {
- { &mp_type_type },
- .name = MP_QSTR_HeartBeat,
- .make_new = pyb_heartbeat_make_new,
- .locals_dict = (mp_obj_t)&pyb_heartbeat_locals_dict,
-};
-
-#endif