Skip to content

Commit c311b5c

Browse files
authored
Merge pull request #2842 from hierophect/stm32-h7-displayio
STM32: Add displayio to F7/H7
2 parents f40db45 + 61b0994 commit c311b5c

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

ports/stm/boards/STM32H743_fs.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ MEMORY
1212
{
1313
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
1414
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* sector 0, 128K */
15-
FLASH_FS (r) : ORIGIN = 0x08020000, LENGTH = 128K /* sector 1, 128K */
16-
FLASH_FIRMWARE (rx) : ORIGIN = 0x08040000, LENGTH = 1792K /* sectors 6*128 + 8*128 */
15+
FLASH_FS (r) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 1-3, 128K */
16+
FLASH_FIRMWARE (rx) : ORIGIN = 0x08080000, LENGTH = 1536K /* sectors 4*128 + 8*128 */
1717
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
1818
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* AXI SRAM */
1919
SRAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K /* AHB1 SRAM */

ports/stm/mpconfigport.mk

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,24 @@ ifeq ($(MCU_SERIES),H7)
2222
CIRCUITPY_ANALOGIO = 0
2323
CIRCUITPY_NEOPIXEL_WRITE = 0
2424
CIRCUITPY_PULSEIO = 0
25-
CIRCUITPY_OS = 1
2625
CIRCUITPY_NVM = 0
2726
CIRCUITPY_AUDIOBUSIO = 0
2827
CIRCUITPY_AUDIOIO = 0
2928
CIRCUITPY_ROTARYIO = 0
3029
CIRCUITPY_RTC = 0
3130
CIRCUITPY_FREQUENCYIO = 0
3231
CIRCUITPY_I2CSLAVE = 0
33-
# shared-module modules that still need prerequisites filled
34-
CIRCUITPY_DISPLAYIO = 0 # Requires SPI, PulseIO, and common-hal module (stub ok)
35-
CIRCUITPY_RANDOM = 0 # Requires OS
36-
CIRCUITPY_STORAGE = 0 # Requires OS, filesystem
3732
endif
3833

3934
ifeq ($(MCU_SERIES),F7)
4035
# Not yet implemented common-hal modules:
4136
CIRCUITPY_ANALOGIO = 0
4237
CIRCUITPY_NEOPIXEL_WRITE = 0
43-
CIRCUITPY_PULSEIO = 1
44-
CIRCUITPY_OS = 1
4538
CIRCUITPY_NVM = 0
4639
CIRCUITPY_AUDIOBUSIO = 0
4740
CIRCUITPY_AUDIOIO = 0
4841
CIRCUITPY_ROTARYIO = 0
4942
CIRCUITPY_RTC = 0
5043
CIRCUITPY_FREQUENCYIO = 0
5144
CIRCUITPY_I2CSLAVE = 0
52-
# shared-module modules that still need prerequisites filled
53-
CIRCUITPY_DISPLAYIO = 0 # Requires SPI, PulseIO, and common-hal module (stub ok)
54-
CIRCUITPY_RANDOM = 0 # Requires OS
55-
CIRCUITPY_STORAGE = 0 # Requires OS, filesystem
5645
endif

ports/stm/supervisor/internal_flash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
#ifdef STM32H743xx
8585
#define STM32_FLASH_SIZE 0x200000 //2MB
86-
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x20000 //128KiB
86+
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x60000 //384KiB
8787
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08020000
8888
#endif
8989

shared-module/displayio/Display.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
109109
// Always set the backlight type in case we're reusing memory.
110110
self->backlight_inout.base.type = &mp_type_NoneType;
111111
if (backlight_pin != NULL && common_hal_mcu_pin_is_free(backlight_pin)) {
112+
// Avoid PWM types and functions when the module isn't enabled
113+
#if (CIRCUITPY_PULSEIO)
112114
pwmout_result_t result = common_hal_pulseio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false);
113115
if (result != PWMOUT_OK) {
114116
self->backlight_inout.base.type = &digitalio_digitalinout_type;
@@ -118,6 +120,12 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
118120
self->backlight_pwm.base.type = &pulseio_pwmout_type;
119121
common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm);
120122
}
123+
#else
124+
// Otherwise default to digital
125+
self->backlight_inout.base.type = &digitalio_digitalinout_type;
126+
common_hal_digitalio_digitalinout_construct(&self->backlight_inout, backlight_pin);
127+
common_hal_never_reset_pin(backlight_pin);
128+
#endif
121129
}
122130
if (!self->auto_brightness && (self->backlight_inout.base.type != &mp_type_NoneType ||
123131
brightness_command != NO_BRIGHTNESS_COMMAND)) {
@@ -162,9 +170,21 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
162170
brightness = 1.0-brightness;
163171
}
164172
bool ok = false;
165-
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
173+
174+
// Avoid PWM types and functions when the module isn't enabled
175+
#if (CIRCUITPY_PULSEIO)
176+
bool ispwm = (self->backlight_pwm.base.type == &pulseio_pwmout_type) ? true : false;
177+
#else
178+
bool ispwm = false;
179+
#endif
180+
181+
if (ispwm) {
182+
#if (CIRCUITPY_PULSEIO)
166183
common_hal_pulseio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness));
167184
ok = true;
185+
#else
186+
ok = false;
187+
#endif
168188
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
169189
common_hal_digitalio_digitalinout_set_value(&self->backlight_inout, brightness > 0.99);
170190
ok = true;
@@ -390,12 +410,16 @@ void displayio_display_background(displayio_display_obj_t* self) {
390410

391411
void release_display(displayio_display_obj_t* self) {
392412
release_display_core(&self->core);
413+
#if (CIRCUITPY_PULSEIO)
393414
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
394415
common_hal_pulseio_pwmout_reset_ok(&self->backlight_pwm);
395-
common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
416+
common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
396417
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
397418
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
398419
}
420+
#else
421+
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
422+
#endif
399423
}
400424

401425
void reset_display(displayio_display_obj_t* self) {

0 commit comments

Comments
 (0)