Skip to content

Commit eb86010

Browse files
committed
Enable RGB Matrix
1 parent edc48a5 commit eb86010

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

ports/stm/common-hal/rgbmatrix/RGBMatrix.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@
2727
#include <stddef.h>
2828

2929
#include "common-hal/rgbmatrix/RGBMatrix.h"
30+
#include "timers.h"
3031

3132
#include STM32_HAL_H
3233

3334
extern void _PM_IRQ_HANDLER(void);
3435

3536
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();
3838
}
3939

40-
4140
void common_hal_rgbmatrix_timer_enable(void* ptr) {
4241
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
4342
}

ports/stm/mpconfigport.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ INTERNAL_LIBM ?= 1
44
USB_SERIAL_NUMBER_LENGTH ?= 24
55

66
ifeq ($(MCU_VARIANT),STM32F405xx)
7-
CIRCUITPY_FRAMEBUFFERIO ?= 0
8-
CIRCUITPY_RGBMATRIX ?= 0
7+
CIRCUITPY_FRAMEBUFFERIO ?= 1
8+
CIRCUITPY_RGBMATRIX ?= 1
99
endif
1010

1111
ifeq ($(MCU_SERIES),F4)

ports/stm/peripherals/timers.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
8893
void 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--) {

ports/stm/peripherals/timers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
void tim_clock_enable(uint16_t mask);
4242
void tim_clock_disable(uint16_t mask);
4343
uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef * timer);
44+
size_t stm_peripherals_timer_get_irqnum(TIM_TypeDef * instance);
4445
void timers_reset(void);
4546
TIM_TypeDef * stm_peripherals_find_timer(void);
4647
void stm_peripherals_timer_preinit(TIM_TypeDef * instance, uint8_t prio, void (*callback)(void));

0 commit comments

Comments
 (0)