Skip to content

Commit accadf9

Browse files
authored
Merge pull request adafruit#5570 from ladyada/main
add esp32s2 tft feather rev A
2 parents 27d0f1d + 0ba47ed commit accadf9

File tree

7 files changed

+213
-74
lines changed

7 files changed

+213
-74
lines changed

ports/espressif/boards/adafruit_feather_esp32s2_nopsram/board.c

Lines changed: 0 additions & 52 deletions
This file was deleted.

ports/espressif/boards/adafruit_feather_esp32s2_nopsram/sdkconfig

Whitespace-only changes.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 Scott Shawcroft 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 "supervisor/board.h"
28+
#include "mpconfigboard.h"
29+
#include "shared-bindings/busio/SPI.h"
30+
#include "shared-bindings/displayio/FourWire.h"
31+
#include "shared-bindings/microcontroller/Pin.h"
32+
#include "shared-module/displayio/__init__.h"
33+
#include "shared-module/displayio/mipi_constants.h"
34+
35+
displayio_fourwire_obj_t board_display_obj;
36+
37+
#define DELAY 0x80
38+
39+
// display init sequence according to LilyGO example app
40+
uint8_t display_init_sequence[] = {
41+
// sw reset
42+
0x01, 0 | DELAY, 150,
43+
// sleep out
44+
0x11, 0 | DELAY, 255,
45+
// normal display mode on
46+
0x13, 0,
47+
// display and color format settings
48+
0x36, 1, 0x08,
49+
0xB6, 2, 0x0A, 0x82,
50+
0x3A, 1 | DELAY, 0x55, 10,
51+
// ST7789V frame rate setting
52+
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
53+
// voltages: VGH / VGL
54+
0xB7, 1, 0x35,
55+
// ST7789V power setting
56+
0xBB, 1, 0x28,
57+
0xC0, 1, 0x0C,
58+
0xC2, 2, 0x01, 0xFF,
59+
0xC3, 1, 0x10,
60+
0xC4, 1, 0x20,
61+
0xC6, 1, 0x0F,
62+
0xD0, 2, 0xA4, 0xA1,
63+
// ST7789V gamma setting
64+
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
65+
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
66+
0x21, 0,
67+
// display on
68+
0x29, 0 | DELAY, 255,
69+
};
70+
71+
72+
void board_init(void) {
73+
// USB
74+
common_hal_never_reset_pin(&pin_GPIO19);
75+
common_hal_never_reset_pin(&pin_GPIO20);
76+
77+
78+
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
79+
80+
common_hal_busio_spi_construct(
81+
spi,
82+
&pin_GPIO36, // CLK
83+
&pin_GPIO35, // MOSI
84+
NULL // MISO not connected
85+
);
86+
87+
common_hal_busio_spi_never_reset(spi);
88+
89+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
90+
bus->base.type = &displayio_fourwire_type;
91+
92+
common_hal_displayio_fourwire_construct(
93+
bus,
94+
spi,
95+
&pin_GPIO39, // DC
96+
&pin_GPIO21, // CS
97+
&pin_GPIO40, // RST
98+
40000000, // baudrate
99+
0, // polarity
100+
0 // phase
101+
);
102+
displayio_display_obj_t* display = &displays[0].display;
103+
display->base.type = &displayio_display_type;
104+
105+
// workaround as board_init() is called before reset_port() in main.c
106+
pwmout_reset();
107+
108+
109+
common_hal_displayio_display_construct(
110+
display,
111+
bus,
112+
240, // width (after rotation)
113+
135, // height (after rotation)
114+
52, // column start
115+
40, // row start
116+
90, // rotation
117+
16, // color depth
118+
false, // grayscale
119+
false, // pixels in a byte share a row. Only valid for depths < 8
120+
1, // bytes per cell. Only valid for depths < 8
121+
false, // reverse_pixels_in_byte. Only valid for depths < 8
122+
true, // reverse_pixels_in_word
123+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
124+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
125+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
126+
display_init_sequence,
127+
sizeof(display_init_sequence),
128+
&pin_GPIO45, // backlight pin
129+
NO_BRIGHTNESS_COMMAND,
130+
1.0f, // brightness (ignored)
131+
false, // auto_brightness
132+
false, // single_byte_bounds
133+
false, // data_as_commands
134+
true, // auto_refresh
135+
60, // native_frames_per_second
136+
true, // backlight_on_high
137+
false // SH1107_addressing
138+
);
139+
140+
common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
141+
}
142+
143+
bool board_requests_safe_mode(void) {
144+
return false;
145+
}
146+
147+
void reset_board(void) {
148+
149+
}
150+
151+
void board_deinit(void) {
152+
}

ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h renamed to ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,24 @@
2626

2727
// Micropython setup
2828

29-
#define MICROPY_HW_BOARD_NAME "Feather ESP32S2 without PSRAM"
29+
#define MICROPY_HW_BOARD_NAME "Adafruit Feather ESP32-S2 TFT"
3030
#define MICROPY_HW_MCU_NAME "ESP32S2"
3131

3232
#define MICROPY_HW_NEOPIXEL (&pin_GPIO33)
33-
#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21)
33+
#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO34)
3434

3535
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
3636

3737
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
3838

3939
#define AUTORESET_DELAY_MS 500
4040

41-
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4)
42-
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3)
41+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO41)
42+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO42)
4343

4444
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
4545
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
4646
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
47+
48+
#define DEFAULT_UART_BUS_RX (&pin_GPIO2)
49+
#define DEFAULT_UART_BUS_TX (&pin_GPIO1)

ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk renamed to ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.mk

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
USB_VID = 0x239A
2-
USB_PID = 0x8FFF
3-
USB_PRODUCT = "Feather ESP32S2 no PSRAM"
2+
USB_PID = 0x8110
3+
4+
USB_PRODUCT = "Feather ESP32-S2 TFT"
45
USB_MANUFACTURER = "Adafruit"
56

67
IDF_TARGET = esp32s2
@@ -17,8 +18,3 @@ CIRCUITPY_ESP_FLASH_FREQ=40m
1718
CIRCUITPY_ESP_FLASH_SIZE=4MB
1819

1920
CIRCUITPY_MODULE=wroom
20-
21-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
22-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
23-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
24-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register

ports/espressif/boards/adafruit_feather_esp32s2_nopsram/pins.c renamed to ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "shared-bindings/board/__init__.h"
22

3+
#include "shared-module/displayio/__init__.h"
4+
35
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
46
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
57

6-
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) },
7-
8-
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) },
9-
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) },
8+
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) },
9+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO1) },
1010

11-
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) },
12-
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) },
11+
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) },
12+
{ MP_ROM_QSTR(MP_QSTR_R2), MP_ROM_PTR(&pin_GPIO2) },
1313

1414
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
1515
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
@@ -41,8 +41,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4141
{ MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) },
4242
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) },
4343

44-
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) },
4544
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) },
45+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO34) },
4646

4747
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) },
4848
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
@@ -53,14 +53,21 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
5353
{ MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) },
5454
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
5555

56+
{ MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) },
57+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO41) },
5658

57-
{ MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) },
58-
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) },
59+
{ MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) },
60+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO42) },
5961

60-
{ MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) },
61-
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) },
62+
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO21) },
63+
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) },
64+
{ MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO40) },
65+
{ MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO45) },
6266

6367
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
6468
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
69+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
70+
71+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
6572
};
6673
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
2+
3+
#
4+
# SPI RAM config
5+
#
6+
# CONFIG_SPIRAM_TYPE_AUTO is not set
7+
CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
8+
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
9+
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
10+
CONFIG_SPIRAM_SIZE=2097152
11+
12+
#
13+
# PSRAM clock and cs IO for ESP32S2
14+
#
15+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
16+
CONFIG_DEFAULT_PSRAM_CS_IO=26
17+
# end of PSRAM clock and cs IO for ESP32S2
18+
19+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
20+
# CONFIG_SPIRAM_RODATA is not set
21+
# CONFIG_SPIRAM_SPEED_80M is not set
22+
CONFIG_SPIRAM_SPEED_40M=y
23+
# CONFIG_SPIRAM_SPEED_26M is not set
24+
# CONFIG_SPIRAM_SPEED_20M is not set
25+
CONFIG_SPIRAM=y
26+
CONFIG_SPIRAM_BOOT_INIT=y
27+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
28+
CONFIG_SPIRAM_USE_MEMMAP=y
29+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
30+
# CONFIG_SPIRAM_USE_MALLOC is not set
31+
CONFIG_SPIRAM_MEMTEST=y
32+
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
33+
# end of SPI RAM config

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy