Skip to content

Commit ba3d7ab

Browse files
authored
Merge pull request #9076 from kylefmohr/kylefmohr_waveshare_esp32_s3_geek
Add support for new board: Waveshare ESP32-S3 GEEK
2 parents ac66da2 + 838a5b4 commit ba3d7ab

File tree

5 files changed

+265
-0
lines changed

5 files changed

+265
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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/fourwire/FourWire.h"
31+
#include "shared-bindings/microcontroller/Pin.h"
32+
#include "shared-bindings/microcontroller/Pin.h"
33+
#include "shared-module/displayio/__init__.h"
34+
#include "shared-module/displayio/mipi_constants.h"
35+
#include "shared-bindings/board/__init__.h"
36+
37+
fourwire_fourwire_obj_t board_display_obj;
38+
39+
40+
41+
// display init sequence according to https://github.com/adafruit/Adafruit_CircuitPython_ST7789
42+
uint8_t display_init_sequence[] = {
43+
0x01, 0x80, 0x96, // _SWRESET and Delay 150ms
44+
0x11, 0x80, 0xFF, // _SLPOUT and Delay 500ms
45+
0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms
46+
0x36, 0x01, 0x08, // _MADCTL
47+
0x21, 0x80, 0x0A, // _INVON Hack and Delay 10ms
48+
0x13, 0x80, 0x0A, // _NORON and Delay 10ms
49+
0x36, 0x01, 0xC0, // _MADCTL
50+
0x29, 0x80, 0xFF, // _DISPON and Delay 500ms
51+
};
52+
53+
static void display_init(void) {
54+
55+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
56+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
57+
58+
common_hal_busio_spi_construct(
59+
spi,
60+
&pin_GPIO12, // CLK
61+
&pin_GPIO11, // MOSI
62+
NULL, // MISO not connected
63+
false); // Not half-duplex
64+
65+
66+
bus->base.type = &fourwire_fourwire_type;
67+
68+
common_hal_fourwire_fourwire_construct(
69+
bus,
70+
spi,
71+
&pin_GPIO8, // TFT_DC
72+
&pin_GPIO10, // TFT_CS
73+
&pin_GPIO9, // TFT_RST
74+
50000000, // Baudrate
75+
0, // Polarity
76+
0 // Phase
77+
78+
);
79+
80+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
81+
display->base.type = &busdisplay_busdisplay_type;
82+
83+
common_hal_busdisplay_busdisplay_construct(
84+
display,
85+
bus,
86+
240, // Width
87+
135, // Height
88+
53, // column start
89+
40, // row start
90+
270, // rotation
91+
16, // Color depth
92+
false, // Grayscale
93+
false, // Pixels in a byte share a row
94+
1, // bytes per cell
95+
false, // reverse_pixels_in_byte
96+
true, // reverse_pixels_in_word
97+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
98+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
99+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
100+
display_init_sequence,
101+
sizeof(display_init_sequence),
102+
&pin_GPIO7, // backlight pin
103+
NO_BRIGHTNESS_COMMAND,
104+
1.0f, // brightness
105+
false, // single_byte_bounds
106+
false, // data_as_commands
107+
true, // auto_refresh
108+
60, // native_frames_per_second
109+
true, // backlight_on_high
110+
false, // SH1107_addressing
111+
1000 // backlight pwm frequency
112+
);
113+
}
114+
115+
void board_init(void) {
116+
display_init();
117+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 "Waveshare ESP32-S3-GEEK"
30+
#define MICROPY_HW_MCU_NAME "ESP32S3"
31+
32+
#define DEFAULT_UART_BUS_RX (&pin_GPIO44)
33+
#define DEFAULT_UART_BUS_TX (&pin_GPIO43)
34+
35+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO17)
36+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO16)
37+
38+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36)
39+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35)
40+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
USB_VID = 0x303a
2+
USB_PID = 0x81ea
3+
USB_PRODUCT = "ESP32-S3-GEEK"
4+
USB_MANUFACTURER = "Waveshare Electronics"
5+
6+
IDF_TARGET = esp32s3
7+
8+
CIRCUITPY_ESP_FLASH_MODE = qio
9+
CIRCUITPY_ESP_FLASH_FREQ = 80m
10+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
11+
12+
CIRCUITPY_ESP_PSRAM_SIZE = 2MB
13+
CIRCUITPY_ESP_PSRAM_MODE = qio
14+
CIRCUITPY_ESP_PSRAM_FREQ = 80m
15+
CIRCUITPY_BUILD_EXTENSIONS = bin,uf2
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+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
5+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
6+
7+
// Boot button (can also be used as regular button)
8+
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
9+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
10+
// GPIO
11+
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
12+
// 7-12 LCD
13+
// LCD Backlight
14+
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
15+
// LCD DC
16+
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
17+
// LCD RST
18+
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
19+
// LCD CS
20+
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO10) },
21+
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
22+
// LCD MOSI
23+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
24+
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
25+
// LCD SCK
26+
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO12) },
27+
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
28+
29+
// GPIO
30+
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
31+
// GPIO
32+
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
33+
// 16-17 I2C
34+
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
35+
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
36+
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
37+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
38+
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
39+
// 34-38 SD
40+
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
41+
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
42+
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
43+
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
44+
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
45+
46+
// 43-44 UART
47+
{ MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) },
48+
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
49+
50+
// UART
51+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
52+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
53+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
54+
55+
// I2C
56+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO17) },
57+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO16) },
58+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
59+
60+
// SD Card
61+
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36)},
62+
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35)},
63+
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37)},
64+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34)},
65+
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_spi_obj) },
66+
// Pin 38 is for the SDIO interface, and therefore not included in the SPI object
67+
68+
// LCD
69+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO11) },
70+
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO12) },
71+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO10) },
72+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO9) },
73+
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO7) },
74+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO8) },
75+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
76+
77+
};
78+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Component config
6+
#
7+
#
8+
# LWIP
9+
#
10+
CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3"
11+
# end of LWIP
12+
13+
# end of Component config
14+
15+
# end of Espressif IoT Development Framework Configuration

0 commit comments

Comments
 (0)