Skip to content

Commit 8c10cd3

Browse files
authored
Merge branch 'adafruit:main' into espressif_esp32s3_lcd_ev_v1.5
2 parents 51e0250 + 13d659a commit 8c10cd3

File tree

4 files changed

+93
-6
lines changed

4 files changed

+93
-6
lines changed

ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8_hacktablet/board.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ static void display_init(void) {
7777
}
7878

7979
void board_init(void) {
80-
// Debug UART
81-
#ifdef DEBUG
82-
common_hal_never_reset_pin(&pin_GPIO43);
83-
common_hal_never_reset_pin(&pin_GPIO44);
84-
#endif
8580
display_init();
8681
}
8782

ports/espressif/boards/makerfabs_tft7/board.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,94 @@
66

77
#include "supervisor/board.h"
88
#include "mpconfigboard.h"
9+
#include "shared-bindings/board/__init__.h"
10+
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
11+
#include "shared-bindings/dotclockframebuffer/__init__.h"
12+
#include "shared-bindings/framebufferio/FramebufferDisplay.h"
913
#include "shared-bindings/microcontroller/Pin.h"
14+
#include "shared-module/displayio/__init__.h"
15+
#include "shared-module/os/__init__.h"
16+
17+
static const mcu_pin_obj_t *blue_pins[] = {
18+
&pin_GPIO8,
19+
&pin_GPIO3,
20+
&pin_GPIO46,
21+
&pin_GPIO9,
22+
&pin_GPIO1
23+
};
24+
static const mcu_pin_obj_t *green_pins[] = {
25+
&pin_GPIO5,
26+
&pin_GPIO6,
27+
&pin_GPIO7,
28+
&pin_GPIO15,
29+
&pin_GPIO16,
30+
&pin_GPIO4
31+
};
32+
static const mcu_pin_obj_t *red_pins[] = {
33+
&pin_GPIO45,
34+
&pin_GPIO48,
35+
&pin_GPIO47,
36+
&pin_GPIO21,
37+
&pin_GPIO14
38+
};
39+
40+
static void display_init(void) {
41+
42+
mp_int_t height = 0, width = 0, frequency = 0;
43+
os_getenv_err_t result;
44+
45+
result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width);
46+
if (result == GETENV_OK && width == 800) {
47+
width = 800;
48+
height = 480;
49+
frequency = 6500000;
50+
} else if (result == GETENV_OK && width == 1024) {
51+
width = 1024;
52+
height = 600;
53+
frequency = 10000000;
54+
}
55+
56+
if (height == 0) {
57+
width = 800;
58+
height = 480;
59+
frequency = 6500000;
60+
}
61+
62+
dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock;
63+
framebuffer->base.type = &dotclockframebuffer_framebuffer_type;
64+
65+
common_hal_dotclockframebuffer_framebuffer_construct(
66+
framebuffer,
67+
&pin_GPIO40, // de
68+
&pin_GPIO41, // vsync
69+
&pin_GPIO39, // hsync
70+
&pin_GPIO42, // pclk
71+
red_pins, MP_ARRAY_SIZE(red_pins),
72+
green_pins, MP_ARRAY_SIZE(green_pins),
73+
blue_pins, MP_ARRAY_SIZE(blue_pins),
74+
frequency, // Frequency
75+
width, // width
76+
height, // height
77+
30, 16, 210, false, // horiz: pulse, back porch, front porch, idle low
78+
13, 10, 22, false, // vert: pulse, back porch, front porch, idle low
79+
false, // DE idle high
80+
false, // pclk active high
81+
false, // pclk idle high
82+
0 // overscan left
83+
);
84+
85+
framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display;
86+
display->base.type = &framebufferio_framebufferdisplay_type;
87+
common_hal_framebufferio_framebufferdisplay_construct(
88+
display,
89+
framebuffer,
90+
0, // rotation
91+
true // auto-refresh
92+
);
93+
}
1094

1195
void board_init(void) {
96+
display_init();
1297
}
1398

1499
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

ports/espressif/boards/makerfabs_tft7/pins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "py/objtuple.h"
88
#include "shared-bindings/board/__init__.h"
9+
#include "shared-module/displayio/__init__.h"
910

1011
static const mp_rom_obj_tuple_t tft_r_pins = {
1112
{&mp_type_tuple},
@@ -125,6 +126,8 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
125126
// { MP_ROM_QSTR(MP_QSTR_SDIO_D0), MP_ROM_PTR(&pin_GPIO13) },
126127
// { MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO12) },
127128

129+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
130+
128131
// boot mode button can be used in SW as well
129132
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO1) },
130133

shared-bindings/memorymap/AddressRange.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//| # Pad control register is updated using an MP-safe atomic XOR
4040
//| pad_ctrl ^= (d << 4)
4141
//| pad_ctrl &= 0x00000030
42-
//| pads_bank0[p*4+0x3004:p*4+0x3008] = pad_ctrl.to_bytes(4, "little")
42+
//| pads_bank0[p*4+0x1004:p*4+0x1008] = pad_ctrl.to_bytes(4, "little")
4343
//|
4444
//| def rp2040_get_pad_drive(p):
4545
//| pads_bank0 = memorymap.AddressRange(start=0x4001C000, length=0x4000)
@@ -51,6 +51,10 @@
5151
//|
5252
//| # print GPIO16 pad drive strength
5353
//| print(rp2040_get_pad_drive(16))
54+
//|
55+
//| Note that the above example does **not** work on RP2350 because base
56+
//| address and organization of the "pads0" registers changed compared
57+
//| to the RP2040.
5458
//| """
5559
//|
5660

0 commit comments

Comments
 (0)