Enable RGB Matrix

This commit is contained in:
Lucian Copeland 2020-07-09 16:45:39 -04:00
parent edc48a505f
commit eb86010176
4 changed files with 11 additions and 5 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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--) {

View File

@ -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));