diff options
author | Daniel Campora <daniel@wipy.io> | 2015-03-26 10:25:28 +0100 |
---|---|---|
committer | Daniel Campora <daniel@wipy.io> | 2015-03-26 10:28:43 +0100 |
commit | 2d717ad97a48c9451a2a51096904f471a0af0a60 (patch) | |
tree | 644a8b90210c72d34c6d62035252615a4ef873ab /cc3200/mods/pybrtc.c | |
parent | e909e3887140cb96ce340f2afb8f4afd79bb68e9 (diff) | |
download | micropython-2d717ad97a48c9451a2a51096904f471a0af0a60.tar.gz micropython-2d717ad97a48c9451a2a51096904f471a0af0a60.zip |
cc3200: Add callback support to the UART for RX interrupts.
Diffstat (limited to 'cc3200/mods/pybrtc.c')
-rw-r--r-- | cc3200/mods/pybrtc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cc3200/mods/pybrtc.c b/cc3200/mods/pybrtc.c index 4d22c85f76..9c42222bc4 100644 --- a/cc3200/mods/pybrtc.c +++ b/cc3200/mods/pybrtc.c @@ -179,7 +179,7 @@ mp_obj_t pyb_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_rtc_datetime_obj, 1, 2, pyb_rtc_datetime); -/// \method callback(handler, intmode, value, priority, pwrmode) +/// \method callback(handler, value, pwrmode) /// Creates a callback object associated with the real time clock /// min num of arguments is 1 (value). The value is the alarm time /// in the future, in msec @@ -189,7 +189,7 @@ STATIC mp_obj_t pyb_rtc_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp // check if any parameters were passed mp_obj_t _callback = mpcallback_find((mp_obj_t)&pyb_rtc_obj); - if (kw_args->used > 0 || _callback == mp_const_none) { + if (kw_args->used > 0 || !_callback) { uint32_t f_mseconds = args[3].u_int; uint32_t seconds; uint16_t mseconds; @@ -201,6 +201,10 @@ STATIC mp_obj_t pyb_rtc_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp seconds += f_mseconds / 1000; mseconds += f_mseconds - ((f_mseconds / 1000) * 1000); + // disable the interrupt before updating anything + // (the object is not relevant here, the function already knows it) + pyb_rtc_callback_disable(NULL); + // set the match value MAP_PRCMRTCMatchSet(seconds, mseconds); |