diff options
| author | Daniel Campora | 2015-06-09 10:46:50 +0200 |
|---|---|---|
| committer | Daniel Campora | 2015-06-10 23:35:28 +0200 |
| commit | 6148f8b7d266a61768a15f0b27d841c12346d9c0 (patch) | |
| tree | 92292a436f3b1a7ebc5cd426afdb47409cc49481 /cc3200 | |
| parent | 76285469d3e64ffe0312f58fa1f6270f715c842c (diff) | |
cc3200: Add contructor to the HeartBeat class.
Diffstat (limited to 'cc3200')
| -rw-r--r-- | cc3200/misc/mperror.c | 18 | ||||
| -rw-r--r-- | cc3200/misc/mperror.h | 2 | ||||
| -rw-r--r-- | cc3200/mods/modpyb.c | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/cc3200/misc/mperror.c b/cc3200/misc/mperror.c index ca729b2a2..46520361f 100644 --- a/cc3200/misc/mperror.c +++ b/cc3200/misc/mperror.c @@ -32,6 +32,7 @@ #include "py/mpconfig.h" #include MICROPY_HAL_H #include "py/obj.h" +#include "py/runtime.h" #include "hw_ints.h" #include "hw_types.h" #include "hw_gpio.h" @@ -63,6 +64,8 @@ /****************************************************************************** DECLARE PRIVATE DATA ******************************************************************************/ +STATIC const mp_obj_base_t pyb_heartbeat_obj = {&pyb_heartbeat_type}; + struct mperror_heart_beat { uint32_t off_time; uint32_t on_time; @@ -198,6 +201,17 @@ void nlr_jump_fail(void *val) { /******************************************************************************/ // 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) { @@ -220,11 +234,11 @@ STATIC const mp_map_elem_t pyb_heartbeat_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(pyb_heartbeat_locals_dict, pyb_heartbeat_locals_dict_table); -static const mp_obj_type_t pyb_heartbeat_type = { +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, }; -const mp_obj_base_t pyb_heartbeat_obj = {&pyb_heartbeat_type}; #endif diff --git a/cc3200/misc/mperror.h b/cc3200/misc/mperror.h index 7f0a634d8..70a69c528 100644 --- a/cc3200/misc/mperror.h +++ b/cc3200/misc/mperror.h @@ -29,7 +29,7 @@ #define MPERROR_H_ #ifndef BOOTLOADER -extern const mp_obj_base_t pyb_heartbeat_obj; +extern const mp_obj_type_t pyb_heartbeat_type; #endif extern void NORETURN __fatal_error(const char *msg); diff --git a/cc3200/mods/modpyb.c b/cc3200/mods/modpyb.c index 5f38bc69c..1e8dc1f0e 100644 --- a/cc3200/mods/modpyb.c +++ b/cc3200/mods/modpyb.c @@ -287,7 +287,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_Timer), (mp_obj_t)&pyb_timer_type }, { MP_OBJ_NEW_QSTR(MP_QSTR_WDT), (mp_obj_t)&pyb_wdt_type }, { MP_OBJ_NEW_QSTR(MP_QSTR_Sleep), (mp_obj_t)&pyb_sleep_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_HeartBeat), (mp_obj_t)&pyb_heartbeat_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_HeartBeat), (mp_obj_t)&pyb_heartbeat_type }, #if MICROPY_HW_HAS_SDCARD { MP_OBJ_NEW_QSTR(MP_QSTR_SD), (mp_obj_t)&pyb_sd_type }, |
