Skip to content

Commit 12545fb

Browse files
committed
Add prototype feather esp32s2/s3 reverse tft board definition
This is not final hardware and may change!
1 parent ef34378 commit 12545fb

File tree

10 files changed

+644
-0
lines changed

10 files changed

+644
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
#include "shared-bindings/board/__init__.h"
35+
36+
displayio_fourwire_obj_t board_display_obj;
37+
38+
#define DELAY 0x80
39+
40+
// display init sequence according to LilyGO example app
41+
uint8_t display_init_sequence[] = {
42+
// sw reset
43+
0x01, 0 | DELAY, 150,
44+
// sleep out
45+
0x11, 0 | DELAY, 255,
46+
// normal display mode on
47+
0x13, 0,
48+
// display and color format settings
49+
0x36, 1, 0x68,
50+
0xB6, 2, 0x0A, 0x82,
51+
0x3A, 1 | DELAY, 0x55, 10,
52+
// ST7789V frame rate setting
53+
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
54+
// voltages: VGH / VGL
55+
0xB7, 1, 0x35,
56+
// ST7789V power setting
57+
0xBB, 1, 0x28,
58+
0xC0, 1, 0x0C,
59+
0xC2, 2, 0x01, 0xFF,
60+
0xC3, 1, 0x10,
61+
0xC4, 1, 0x20,
62+
0xC6, 1, 0x0F,
63+
0xD0, 2, 0xA4, 0xA1,
64+
// ST7789V gamma setting
65+
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
66+
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
67+
0x21, 0,
68+
// display on
69+
0x29, 0 | DELAY, 255,
70+
};
71+
72+
73+
void board_init(void) {
74+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
75+
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
76+
bus->base.type = &displayio_fourwire_type;
77+
78+
common_hal_displayio_fourwire_construct(
79+
bus,
80+
spi,
81+
&pin_GPIO40, // DC
82+
&pin_GPIO42, // CS
83+
&pin_GPIO41, // RST
84+
40000000, // baudrate
85+
0, // polarity
86+
0 // phase
87+
);
88+
displayio_display_obj_t *display = &displays[0].display;
89+
display->base.type = &displayio_display_type;
90+
91+
common_hal_displayio_display_construct(
92+
display,
93+
bus,
94+
240, // width (after rotation)
95+
135, // height (after rotation)
96+
40, // column start
97+
53, // row start
98+
0, // rotation
99+
16, // color depth
100+
false, // grayscale
101+
false, // pixels in a byte share a row. Only valid for depths < 8
102+
1, // bytes per cell. Only valid for depths < 8
103+
false, // reverse_pixels_in_byte. Only valid for depths < 8
104+
true, // reverse_pixels_in_word
105+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
106+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
107+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
108+
display_init_sequence,
109+
sizeof(display_init_sequence),
110+
&pin_GPIO45, // backlight pin
111+
NO_BRIGHTNESS_COMMAND,
112+
1.0f, // brightness
113+
false, // single_byte_bounds
114+
false, // data_as_commands
115+
true, // auto_refresh
116+
60, // native_frames_per_second
117+
true, // backlight_on_high
118+
false, // SH1107_addressing
119+
50000 // backlight pwm frequency
120+
);
121+
}
122+
123+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
124+
// Override the I2C/TFT power pin reset to prevent resetting the display.
125+
if (pin_number == 21) {
126+
// Turn on TFT and I2C
127+
gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT);
128+
gpio_set_level(21, true);
129+
return true;
130+
}
131+
return false;
132+
}
133+
134+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
135+
136+
// TODO: Should we turn off the display when asleep, in board_deinit() ?
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 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+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "Adafruit Feather ESP32-S2 Reverse TFT"
30+
#define MICROPY_HW_MCU_NAME "ESP32S2"
31+
32+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO33)
33+
#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO34)
34+
35+
#define MICROPY_HW_LED_STATUS (&pin_GPIO13)
36+
37+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4)
38+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3)
39+
40+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
41+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
42+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
43+
44+
#define DEFAULT_UART_BUS_RX (&pin_GPIO34)
45+
#define DEFAULT_UART_BUS_TX (&pin_GPIO35)
46+
47+
#define DOUBLE_TAP_PIN (&pin_GPIO34)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x8128
3+
4+
USB_PRODUCT = "Feather ESP32-S2 Reverse TFT"
5+
USB_MANUFACTURER = "Adafruit"
6+
7+
IDF_TARGET = esp32s2
8+
9+
CIRCUITPY_ESP_FLASH_MODE = dio
10+
CIRCUITPY_ESP_FLASH_FREQ = 40m
11+
CIRCUITPY_ESP_FLASH_SIZE = 4MB
12+
13+
OPTIMIZATION_FLAGS = -Os
14+
CIRCUITPY_ESP32_CAMERA = 0
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "shared-module/displayio/__init__.h"
4+
5+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
6+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
7+
8+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) },
9+
{ MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) },
10+
11+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) },
12+
{ MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) },
13+
14+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) },
15+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
16+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) },
17+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
18+
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) },
19+
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) },
20+
21+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) },
22+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) },
23+
{ MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) },
24+
25+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) },
26+
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
27+
28+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) },
29+
{ MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) },
30+
31+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) },
32+
{ MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) },
33+
34+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) },
35+
{ MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) },
36+
37+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) },
38+
{ MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) },
39+
40+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) },
41+
{ MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) },
42+
43+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) },
44+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) },
45+
46+
{ MP_ROM_QSTR(MP_QSTR_TFT_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) },
47+
48+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
49+
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) },
50+
51+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
52+
{ MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) },
53+
54+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
55+
{ MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) },
56+
57+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) },
58+
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) },
59+
60+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) },
61+
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) },
62+
63+
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO42) },
64+
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO40) },
65+
{ MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO41) },
66+
{ MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO45) },
67+
68+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
69+
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) },
70+
71+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
72+
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
73+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
74+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
75+
76+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
77+
};
78+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# Component config
3+
#
4+
#
5+
# ESP32S3-Specific
6+
#
7+
CONFIG_ESP32S3_SPIRAM_SUPPORT=n
8+
#
9+
# SPI RAM config
10+
#
11+
CONFIG_SPIRAM_MODE_QUAD=y
12+
# CONFIG_SPIRAM_MODE_OCT is not set
13+
CONFIG_SPIRAM_TYPE_AUTO=y
14+
# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
15+
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
16+
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
17+
CONFIG_SPIRAM_SIZE=2097152
18+
#
19+
# PSRAM Clock and CS IO for ESP32S3
20+
#
21+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
22+
CONFIG_DEFAULT_PSRAM_CS_IO=26
23+
# end of PSRAM Clock and CS IO for ESP32S3
24+
25+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
26+
# CONFIG_SPIRAM_RODATA is not set
27+
# CONFIG_SPIRAM_SPEED_120M is not set
28+
CONFIG_SPIRAM_SPEED_80M=y
29+
# CONFIG_SPIRAM_SPEED_40M is not set
30+
CONFIG_SPIRAM=y
31+
CONFIG_SPIRAM_BOOT_INIT=y
32+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
33+
CONFIG_SPIRAM_USE_MEMMAP=y
34+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
35+
# CONFIG_SPIRAM_USE_MALLOC is not set
36+
CONFIG_SPIRAM_MEMTEST=y
37+
# end of SPI RAM config
38+
39+
# end of ESP32S3-Specific
40+
41+
#
42+
# LWIP
43+
#
44+
CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s2"
45+
# end of LWIP
46+
47+
# end of Component config

0 commit comments

Comments
 (0)