diff options
| author | Yuuki NAGAO <wf.yn386@gmail.com> | 2025-09-22 20:24:18 +0900 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-10-01 09:38:12 +1000 |
| commit | 58ff28b505cb311e4ffb024a81d81e1b094976bc (patch) | |
| tree | c915c36aeded8d9daf4e0f31a507bbb05d0438c1 | |
| parent | 39e4413f46e616b70499865d1c22e523365d6f55 (diff) | |
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>
| -rw-r--r-- | ports/stm32/extint.c | 2 | ||||
| -rw-r--r-- | ports/stm32/extint.h | 1 | ||||
| -rw-r--r-- | ports/stm32/rtc.c | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/ports/stm32/extint.c b/ports/stm32/extint.c index df0ed6e23..b1e5c8a8f 100644 --- a/ports/stm32/extint.c +++ b/ports/stm32/extint.c @@ -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 diff --git a/ports/stm32/extint.h b/ports/stm32/extint.h index 801dcf62b..cdebf6eb8 100644 --- a/ports/stm32/extint.h +++ b/ports/stm32/extint.h @@ -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); diff --git a/ports/stm32/rtc.c b/ports/stm32/rtc.c index fa28fda6a..fb106e179 100644 --- a/ports/stm32/rtc.c +++ b/ports/stm32/rtc.c @@ -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; |
