mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 11:10:14 +01:00
stm32/rtc: Fix passing invalid argument to RTC callback.
NameError occurred when trying to access the argument of RTC.wakeup() callback because the callback argument is not initialized. To fix this issue, this commit passes EXTI_RTC_WAKEUP to callback argument. This is equivalent behavior with ExtInt callback. Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This commit is contained in:
committed by
Damien George
parent
39e4413f46
commit
58ff28b505
@@ -127,7 +127,7 @@ static uint8_t pyb_extint_mode[EXTI_NUM_VECTORS];
|
||||
static bool pyb_extint_hard_irq[EXTI_NUM_VECTORS];
|
||||
|
||||
// The callback arg is a small-int or a ROM Pin object, so no need to scan by GC
|
||||
static mp_obj_t pyb_extint_callback_arg[EXTI_NUM_VECTORS];
|
||||
mp_obj_t pyb_extint_callback_arg[EXTI_NUM_VECTORS];
|
||||
|
||||
#if !defined(ETH)
|
||||
#define ETH_WKUP_IRQn 62 // Some MCUs don't have ETH, but we want a value to put in our table
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#endif
|
||||
|
||||
#define EXTI_NUM_VECTORS (PYB_EXTI_NUM_VECTORS)
|
||||
extern mp_obj_t pyb_extint_callback_arg[];
|
||||
|
||||
void extint_init0(void);
|
||||
|
||||
|
||||
@@ -771,6 +771,7 @@ mp_obj_t pyb_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
|
||||
|
||||
// set the callback
|
||||
MP_STATE_PORT(pyb_extint_callback)[EXTI_RTC_WAKEUP] = callback;
|
||||
pyb_extint_callback_arg[EXTI_RTC_WAKEUP] = MP_OBJ_NEW_SMALL_INT(EXTI_RTC_WAKEUP);
|
||||
|
||||
// disable register write protection
|
||||
RTC->WPR = 0xca;
|
||||
|
||||
Reference in New Issue
Block a user