From 37a7257affa5e1ad449d911797dfc4b9e46677b3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 15 Jun 2018 10:50:08 +1000 Subject: [PATCH] stm32/timer: Support TIM1 on F0 MCUs. --- ports/stm32/stm32_it.c | 6 ++++++ ports/stm32/timer.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ports/stm32/stm32_it.c b/ports/stm32/stm32_it.c index c09ffce767..a2a8d0f2e5 100644 --- a/ports/stm32/stm32_it.c +++ b/ports/stm32/stm32_it.c @@ -610,6 +610,12 @@ void EXTI4_15_IRQHandler(void) { IRQ_EXIT(EXTI4_15_IRQn); } +void TIM1_BRK_UP_TRG_COM_IRQHandler(void) { + IRQ_ENTER(TIM1_BRK_UP_TRG_COM_IRQn); + timer_irq_handler(1); + IRQ_EXIT(TIM1_BRK_UP_TRG_COM_IRQn); +} + #endif void TIM1_BRK_TIM9_IRQHandler(void) { diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index cc00f7a887..cf198e8651 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -655,11 +655,13 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, size_t n_args, cons return mp_const_none; } -// This table encodes the timer instance and irq number. +// This table encodes the timer instance and irq number (for the update irq). // It assumes that timer instance pointer has the lower 8 bits cleared. #define TIM_ENTRY(id, irq) [id - 1] = (uint32_t)TIM##id | irq STATIC const uint32_t tim_instance_table[MICROPY_HW_MAX_TIMER] = { - #if defined(STM32F4) || defined(STM32F7) + #if defined(STM32F0) + TIM_ENTRY(1, TIM1_BRK_UP_TRG_COM_IRQn), + #elif defined(STM32F4) || defined(STM32F7) TIM_ENTRY(1, TIM1_UP_TIM10_IRQn), #elif defined(STM32L4) TIM_ENTRY(1, TIM1_UP_TIM16_IRQn),