Skip to content

Commit 4576ae5

Browse files
committed
add board files
1 parent 50ad62d commit 4576ae5

File tree

5 files changed

+264
-0
lines changed

5 files changed

+264
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
56+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
57+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
58+
59+
common_hal_busio_spi_construct(
60+
spi,
61+
&pin_GPIO12, // CLK
62+
&pin_GPIO11, // MOSI
63+
NULL, // MISO not connected
64+
false); // Not half-duplex
65+
66+
67+
bus->base.type = &fourwire_fourwire_type;
68+
69+
common_hal_fourwire_fourwire_construct(
70+
bus,
71+
spi,
72+
&pin_GPIO8, // TFT_DC
73+
&pin_GPIO10, // TFT_CS
74+
&pin_GPIO9, // TFT_RST
75+
50000000, // Baudrate
76+
0, // Polarity
77+
0 // Phase
78+
79+
);
80+
81+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
82+
display->base.type = &busdisplay_busdisplay_type;
83+
84+
common_hal_busdisplay_busdisplay_construct(
85+
display,
86+
bus,
87+
240, // Width
88+
135, // Height
89+
53, // column start
90+
40, // row start
91+
270, // rotation
92+
16, // Color depth
93+
false, // Grayscale
94+
false, // Pixels in a byte share a row
95+
1, // bytes per cell
96+
false, // reverse_pixels_in_byte
97+
true, // reverse_pixels_in_word
98+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
99+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
100+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
101+
display_init_sequence,
102+
sizeof(display_init_sequence),
103+
&pin_GPIO7, // backlight pin
104+
NO_BRIGHTNESS_COMMAND,
105+
1.0f, // brightness
106+
false, // single_byte_bounds
107+
false, // data_as_commands
108+
true, // auto_refresh
109+
60, // native_frames_per_second
110+
true, // backlight_on_high
111+
false, // SH1107_addressing
112+
1000 //backlight pwm frequency
113+
);
114+
}
115+
116+
void board_init(void) {
117+
display_init();
118+
}
119+
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 = 0x7003
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: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
//GPIO
10+
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
11+
//7-12 LCD
12+
//LCD Backlight
13+
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
14+
//LCD DC
15+
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
16+
//LCD RST
17+
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
18+
//LCD CS
19+
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO10) },
20+
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
21+
//LCD MOSI
22+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
23+
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
24+
//LCD SCK
25+
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO12) },
26+
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
27+
28+
//GPIO
29+
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
30+
//GPIO
31+
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
32+
//16-17 I2C
33+
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
34+
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
35+
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
36+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
37+
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
38+
//34-37 SD
39+
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
40+
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
41+
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
42+
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
43+
44+
//43-44 UART
45+
{ MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) },
46+
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
47+
48+
// UART
49+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
50+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
51+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
52+
53+
// I2C
54+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO17) },
55+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO16) },
56+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
57+
58+
// SD Card
59+
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36)},
60+
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35)},
61+
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37)},
62+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34)},
63+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
64+
65+
// LCD
66+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO11) },
67+
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO12) },
68+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO10) },
69+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO9) },
70+
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO7) },
71+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO18) },
72+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
73+
74+
};
75+
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)