File tree Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 27
27
#include <stddef.h>
28
28
29
29
#include "common-hal/rgbmatrix/RGBMatrix.h"
30
+ #include "timers.h"
30
31
31
32
#include STM32_HAL_H
32
33
33
34
extern void _PM_IRQ_HANDLER (void );
34
35
35
36
void * common_hal_rgbmatrix_timer_allocate () {
36
- // TODO(jepler) properly handle resource allocation including never-reset
37
- return TIM6 ;
37
+ return stm_peripherals_find_timer ();
38
38
}
39
39
40
-
41
40
void common_hal_rgbmatrix_timer_enable (void * ptr ) {
42
41
HAL_NVIC_EnableIRQ (TIM6_DAC_IRQn );
43
42
}
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ INTERNAL_LIBM ?= 1
4
4
USB_SERIAL_NUMBER_LENGTH ?= 24
5
5
6
6
ifeq ($(MCU_VARIANT ) ,STM32F405xx)
7
- CIRCUITPY_FRAMEBUFFERIO ?= 0
8
- CIRCUITPY_RGBMATRIX ?= 0
7
+ CIRCUITPY_FRAMEBUFFERIO ?= 1
8
+ CIRCUITPY_RGBMATRIX ?= 1
9
9
endif
10
10
11
11
ifeq ($(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) {
85
85
return source ;
86
86
}
87
87
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
+
88
93
void timers_reset (void ) {
89
94
uint16_t never_reset_mask = 0x00 ;
90
95
for (size_t i = 0 ; i < MP_ARRAY_SIZE (mcu_tim_banks ); i ++ ) {
@@ -120,6 +125,7 @@ TIM_TypeDef * stm_peripherals_find_timer(void) {
120
125
return mcu_tim_banks [i ];
121
126
}
122
127
}
128
+ //TODO: secondary search for timers outside the pins in the board profile
123
129
124
130
// Work backwards - higher index timers have fewer pin allocations
125
131
for (size_t i = (MP_ARRAY_SIZE (mcu_tim_banks ) - 1 ); i >= 0 ; i -- ) {
Original file line number Diff line number Diff line change 41
41
void tim_clock_enable (uint16_t mask );
42
42
void tim_clock_disable (uint16_t mask );
43
43
uint32_t stm_peripherals_timer_get_source_freq (TIM_TypeDef * timer );
44
+ size_t stm_peripherals_timer_get_irqnum (TIM_TypeDef * instance );
44
45
void timers_reset (void );
45
46
TIM_TypeDef * stm_peripherals_find_timer (void );
46
47
void 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