Skip to content

Commit c3b3eb4

Browse files
authored
Merge pull request #2831 from jepler/rgbmatrix-stm
stm: enable RGBMatrix
2 parents 4519dde + e5be728 commit c3b3eb4

File tree

7 files changed

+104
-1
lines changed

7 files changed

+104
-1
lines changed

ports/stm/common-hal/microcontroller/Pin.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,15 @@ GPIO_TypeDef * pin_port(uint8_t pin_port) {
134134
uint16_t pin_mask(uint8_t pin_number) {
135135
return 1<<pin_number;
136136
}
137+
138+
uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t* pin) {
139+
return pin->port * 16 + pin->number;
140+
}
141+
142+
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
143+
claim_pin(pin);
144+
}
145+
146+
void common_hal_mcu_pin_reset_number(uint8_t pin_no) {
147+
reset_pin_number(pin_no / 16, pin_no % 16);
148+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stddef.h>
28+
29+
#include "common-hal/rgbmatrix/RGBMatrix.h"
30+
31+
#include STM32_HAL_H
32+
33+
extern void _PM_IRQ_HANDLER(void);
34+
35+
void *common_hal_rgbmatrix_timer_allocate() {
36+
// TODO(jepler) properly handle resource allocation including never-reset
37+
return TIM6;
38+
}
39+
40+
41+
void common_hal_rgbmatrix_timer_enable(void* ptr) {
42+
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
43+
}
44+
45+
void common_hal_rgbmatrix_timer_disable(void* ptr) {
46+
TIM_TypeDef *tim = (TIM_TypeDef*)ptr;
47+
tim->DIER &= ~TIM_DIER_UIE;
48+
HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);
49+
}
50+
51+
void common_hal_rgbmatrix_timer_free(void* ptr) {
52+
common_hal_rgbmatrix_timer_disable(ptr);
53+
// TODO(jepler) properly handle resource allocation including never-reset
54+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H
28+
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H
29+
30+
void *common_hal_rgbmatrix_timer_allocate(void);
31+
void common_hal_rgbmatrix_timer_enable(void*);
32+
void common_hal_rgbmatrix_timer_disable(void*);
33+
void common_hal_rgbmatrix_timer_free(void*);
34+
35+
#endif

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

Whitespace-only changes.

ports/stm/common-hal/rgbmatrix/__init__.h

Whitespace-only changes.

ports/stm/mpconfigport.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ifeq ($(MCU_SERIES),F4)
77
# Not yet implemented common-hal modules:
88
CIRCUITPY_AUDIOBUSIO = 0
99
CIRCUITPY_AUDIOIO = 0
10+
CIRCUITPY_FRAMEBUFFERIO = 1
11+
CIRCUITPY_RGBMATRIX = 1
1012
CIRCUITPY_ROTARYIO = 0
1113
CIRCUITPY_RTC = 0
1214
CIRCUITPY_FREQUENCYIO = 0

0 commit comments

Comments
 (0)