aboutsummaryrefslogtreecommitdiff
path: root/cc3200/misc
diff options
context:
space:
mode:
authordanicampora2015-10-14 09:46:18 +0200
committerdanicampora2015-10-19 21:17:15 +0200
commitd8137178bb3d0e755278703f66efe33cf07398eb (patch)
treedd0d86ce928f7c2010a7dad0384d30483b282d68 /cc3200/misc
parent39a380b6219159d97714507698ad0309a08b0a73 (diff)
cc3200: Create wipy module, remove HeartBeat class.
The heartbeat is now controllable via a single function within the wipy module.
Diffstat (limited to 'cc3200/misc')
-rw-r--r--cc3200/misc/mperror.c61
-rw-r--r--cc3200/misc/mperror.h2
2 files changed, 15 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
diff --git a/cc3200/misc/mperror.h b/cc3200/misc/mperror.h
index 70a69c528..44c77909c 100644
--- a/cc3200/misc/mperror.h
+++ b/cc3200/misc/mperror.h
@@ -40,5 +40,7 @@ void mperror_deinit_sfe_pin (void);
void mperror_signal_error (void);
void mperror_heartbeat_switch_off (void);
void mperror_heartbeat_signal (void);
+void mperror_enable_heartbeat (bool enable);
+bool mperror_is_heartbeat_enabled (void);
#endif // MPERROR_H_