From 2d717ad97a48c9451a2a51096904f471a0af0a60 Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Thu, 26 Mar 2015 10:25:28 +0100 Subject: cc3200: Add callback support to the UART for RX interrupts. --- cc3200/mods/pybrtc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cc3200/mods/pybrtc.c') diff --git a/cc3200/mods/pybrtc.c b/cc3200/mods/pybrtc.c index 4d22c85f7..9c42222bc 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); -- cgit v1.2.3