summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-07-09 16:45:39 -0400
committerLucian Copeland <hierophect@gmail.com>2020-07-10 11:06:12 -0400
commiteb860101766741fd75326577bb779d91cb3afd01 (patch)
tree5c082b3b851a0fc1c9573ddfb9e4839c47cd4acf
parentedc48a505fd92ed246696be38cc2d3c1e2c36fcf (diff)
Enable RGB Matrix
-rw-r--r--ports/stm/common-hal/rgbmatrix/RGBMatrix.c5
-rw-r--r--ports/stm/mpconfigport.mk4
-rw-r--r--ports/stm/peripherals/timers.c6
-rw-r--r--ports/stm/peripherals/timers.h1
4 files changed, 11 insertions, 5 deletions
diff --git a/ports/stm/common-hal/rgbmatrix/RGBMatrix.c b/ports/stm/common-hal/rgbmatrix/RGBMatrix.c
index 9e60cc3e6..312f15358 100644
--- a/ports/stm/common-hal/rgbmatrix/RGBMatrix.c
+++ b/ports/stm/common-hal/rgbmatrix/RGBMatrix.c
@@ -27,17 +27,16 @@
#include <stddef.h>
#include "common-hal/rgbmatrix/RGBMatrix.h"
+#include "timers.h"
#include STM32_HAL_H
extern void _PM_IRQ_HANDLER(void);
void *common_hal_rgbmatrix_timer_allocate() {
- // TODO(jepler) properly handle resource allocation including never-reset
- return TIM6;
+ return stm_peripherals_find_timer();
}
-
void common_hal_rgbmatrix_timer_enable(void* ptr) {
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
}
diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk
index 74ecf656e..896d78bba 100644
--- a/ports/stm/mpconfigport.mk
+++ b/ports/stm/mpconfigport.mk
@@ -4,8 +4,8 @@ INTERNAL_LIBM ?= 1
USB_SERIAL_NUMBER_LENGTH ?= 24
ifeq ($(MCU_VARIANT),STM32F405xx)
- CIRCUITPY_FRAMEBUFFERIO ?= 0
- CIRCUITPY_RGBMATRIX ?= 0
+ CIRCUITPY_FRAMEBUFFERIO ?= 1
+ CIRCUITPY_RGBMATRIX ?= 1
endif
ifeq ($(MCU_SERIES),F4)
diff --git a/ports/stm/peripherals/timers.c b/ports/stm/peripherals/timers.c
index 589c28310..924d3a16f 100644
--- a/ports/stm/peripherals/timers.c
+++ b/ports/stm/peripherals/timers.c
@@ -85,6 +85,11 @@ uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef * timer) {
return source;
}
+size_t stm_peripherals_timer_get_irqnum(TIM_TypeDef * instance) {
+ size_t tim_id = stm_peripherals_timer_get_index(instance);
+ return irq_map[tim_id];
+}
+
void timers_reset(void) {
uint16_t never_reset_mask = 0x00;
for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
@@ -120,6 +125,7 @@ TIM_TypeDef * stm_peripherals_find_timer(void) {
return mcu_tim_banks[i];
}
}
+ //TODO: secondary search for timers outside the pins in the board profile
// Work backwards - higher index timers have fewer pin allocations
for (size_t i = (MP_ARRAY_SIZE(mcu_tim_banks) - 1); i >= 0; i--) {
diff --git a/ports/stm/peripherals/timers.h b/ports/stm/peripherals/timers.h
index 8c8a80d53..02e4e304e 100644
--- a/ports/stm/peripherals/timers.h
+++ b/ports/stm/peripherals/timers.h
@@ -41,6 +41,7 @@
void tim_clock_enable(uint16_t mask);
void tim_clock_disable(uint16_t mask);
uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef * timer);
+size_t stm_peripherals_timer_get_irqnum(TIM_TypeDef * instance);
void timers_reset(void);
TIM_TypeDef * stm_peripherals_find_timer(void);
void stm_peripherals_timer_preinit(TIM_TypeDef * instance, uint8_t prio, void (*callback)(void));