File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727#include <stddef.h>
2828
2929#include "common-hal/rgbmatrix/RGBMatrix.h"
30+ #include "timers.h"
3031
3132#include STM32_HAL_H
3233
3334extern void _PM_IRQ_HANDLER (void );
3435
3536void * common_hal_rgbmatrix_timer_allocate () {
36- // TODO(jepler) properly handle resource allocation including never-reset
37- return TIM6 ;
37+ return stm_peripherals_find_timer ();
3838}
3939
40-
4140void common_hal_rgbmatrix_timer_enable (void * ptr ) {
4241 HAL_NVIC_EnableIRQ (TIM6_DAC_IRQn );
4342}
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ INTERNAL_LIBM ?= 1
44USB_SERIAL_NUMBER_LENGTH ?= 24
55
66ifeq ($(MCU_VARIANT ) ,STM32F405xx)
7- CIRCUITPY_FRAMEBUFFERIO ?= 0
8- CIRCUITPY_RGBMATRIX ?= 0
7+ CIRCUITPY_FRAMEBUFFERIO ?= 1
8+ CIRCUITPY_RGBMATRIX ?= 1
99endif
1010
1111ifeq ($(MCU_SERIES ) ,F4)
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef * timer) {
8585 return source ;
8686}
8787
88+ size_t stm_peripherals_timer_get_irqnum (TIM_TypeDef * instance ) {
89+ size_t tim_id = stm_peripherals_timer_get_index (instance );
90+ return irq_map [tim_id ];
91+ }
92+
8893void timers_reset (void ) {
8994 uint16_t never_reset_mask = 0x00 ;
9095 for (size_t i = 0 ; i < MP_ARRAY_SIZE (mcu_tim_banks ); i ++ ) {
@@ -120,6 +125,7 @@ TIM_TypeDef * stm_peripherals_find_timer(void) {
120125 return mcu_tim_banks [i ];
121126 }
122127 }
128+ //TODO: secondary search for timers outside the pins in the board profile
123129
124130 // Work backwards - higher index timers have fewer pin allocations
125131 for (size_t i = (MP_ARRAY_SIZE (mcu_tim_banks ) - 1 ); i >= 0 ; i -- ) {
Original file line number Diff line number Diff line change 4141void tim_clock_enable (uint16_t mask );
4242void tim_clock_disable (uint16_t mask );
4343uint32_t stm_peripherals_timer_get_source_freq (TIM_TypeDef * timer );
44+ size_t stm_peripherals_timer_get_irqnum (TIM_TypeDef * instance );
4445void timers_reset (void );
4546TIM_TypeDef * stm_peripherals_find_timer (void );
4647void stm_peripherals_timer_preinit (TIM_TypeDef * instance , uint8_t prio , void (* callback )(void ));
You can’t perform that action at this time.
0 commit comments