8000 Merge pull request #9149 from SeanTheITGuy/sunton_esp32_8048S07 · brushmate/circuitpython@f2d42e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit f2d42e9

Browse files
authored
Merge pull request adafruit#9149 from SeanTheITGuy/sunton_esp32_8048S07
sunton esp32-8048s070 support
2 parents 0f66ecb + b938c84 commit f2d42e9

File tree

5 files changed

+307
-0
lines changed

5 files changed

+307
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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/board/__init__.h"
30+
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
31+
#include "shared-bindings/dotclockframebuffer/__init__.h"
32+
#include "shared-bindings/framebufferio/FramebufferDisplay.h"
33+
#include "shared-bindings/microcontroller/Pin.h"
34+
#include "shared-module/displayio/__init__.h"
35+
36+
static const mcu_pin_obj_t *blue_pins[] = {
37+
&pin_GPIO15,
38+
&pin_GPIO7,
39+
&pin_GPIO6,
40+
&pin_GPIO5,
41+
&pin_GPIO4
42+
};
43+
static const mcu_pin_obj_t *green_pins[] = {
44+
&pin_GPIO9,
45+
&pin_GPIO46,
46+
&pin_GPIO3,
47+
&pin_GPIO8,
48+
&pin_GPIO16,
49+
&pin_GPIO1
50+
};
51+
static const mcu_pin_obj_t *red_pins[] = {
52+
&pin_GPIO14,
53+
&pin_GPIO21,
54+
&pin_GPIO47,
55+
&pin_GPIO48,
56+
&pin_GPIO45
57+
};
58+
59+
static void display_init(void) {
60+
61+
// Turn on backlight
62+
gpio_set_direction(2, GPIO_MODE_DEF_OUTPUT);
63+
gpio_set_level(2, true);
64+
common_hal_never_reset_pin(&pin_GPIO2);
65+
66+
dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock;
67+
framebuffer->base.type = &dotclockframebuffer_framebuffer_type;
68+
69+
common_hal_dotclockframebuffer_framebuffer_construct(
70+
framebuffer,
71+
&pin_GPIO41, // de
72+
&pin_GPIO40, // vsync
73+
&pin_GPIO39, // hsync
74+
&pin_GPIO42, // pclk
75+
red_pins, MP_ARRAY_SIZE(red_pins),
76+
green_pins, MP_ARRAY_SIZE(green_pins),
77+
blue_pins, MP_ARRAY_SIZE(blue_pins),
78+
12500000, // Frequency
79+
800, // width
80+
480, // height
81+
30, 16, 210, true, // horiz: pulse, back porch, front porch, idle low
82+
13, 10, 22, true, // vert: pulse, back porch, front porch, idle low
83+
false, // DE idle high
84+
false, // pclk active high
85+
false, // pclk idle high
86+
0 // overscan left
87+
);
88+
89+
framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display;
90+
display->base.type = &framebufferio_framebufferdisplay_type;
91+
common_hal_framebufferio_framebufferdisplay_construct(
92+
display,
93+
framebuffer,
94+
0, // rotation
95+
true // auto-refresh
96+
);
97+
}
98+
99+
void board_init(void) {
100+
display_init();
101+
}
102+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 "Sunton-ESP32-8048S070"
30+
#define MICROPY_HW_MCU_NAME "ESP32S3"
31+
32+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO19)
33+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO20)
34+
35+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO11)
36+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO12)
37+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO13)
38+
39+
// UART pins attached to the USB-serial converter chip
40+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO43)
41+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO44)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CIRCUITPY_CREATOR_ID = 0x19991000
2+
CIRCUITPY_CREATION_ID = 0x00AA0004
3+
4+
# This board doesn't have USB by default, it
5+
# instead uses a CH340C USB-to-Serial chip
6+
CIRCUITPY_USB = 0
7+
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0
8+
9+
IDF_TARGET = esp32s3
10+
11+
CIRCUITPY_ESP_FLASH_MODE = qio
12+
CIRCUITPY_ESP_FLASH_FREQ = 80m
13+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
14+
15+
CIRCUITPY_ESP_PSRAM_SIZE = 8MB
16+
CIRCUITPY_ESP_PSRAM_MODE = opi
17+
CIRCUITPY_ESP_PSRAM_FREQ = 80m
18+
19+
CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#include "py/objtuple.h"
2+
#include "shared-bindings/board/__init__.h"
3+
#include "shared-module/displayio/__init__.h"
4+
5+
STATIC const mp_rom_obj_tuple_t tft_r_pins = {
6+
{&mp_type_tuple},
7+
5,
8+
{
9+
MP_ROM_PTR(&pin_GPIO14),
10+
MP_ROM_PTR(&pin_GPIO21),
11+
MP_ROM_PTR(&pin_GPIO47),
12+
MP_ROM_PTR(&pin_GPIO48),
13+
MP_ROM_PTR(&pin_GPIO45),
14+
}
15+
};
16+
17+
STATIC const mp_rom_obj_tuple_t tft_g_pins = {
18+
{&mp_type_tuple},
19+
6,
20+
{
21+
MP_ROM_PTR(&pin_GPIO9),
22+
MP_ROM_PTR(&pin_GPIO46),
23+
MP_ROM_PTR(&pin_GPIO3),
24+
MP_ROM_PTR(&pin_GPIO8),
25+
MP_ROM_PTR(&pin_GPIO16),
26+
MP_ROM_PTR(&pin_GPIO1),
27+
}
28+
};
29+
30+
STATIC const mp_rom_obj_tuple_t tft_b_pins = {
31+
{&mp_type_tuple},
32+
5,
33+
{
34+
MP_ROM_PTR(&pin_GPIO15),
35+
MP_ROM_PTR(&pin_GPIO7),
36+
MP_ROM_PTR(&pin_GPIO6),
37+
MP_ROM_PTR(&pin_GPIO5),
38+
MP_ROM_PTR(&pin_GPIO4),
39+
}
40+
};
41+
42+
STATIC const mp_rom_map_elem_t tft_pins_table[] = {
43+
{ MP_ROM_QSTR(MP_QSTR_de), MP_ROM_PTR(&pin_GPIO41) },
44+
{ MP_ROM_QSTR(MP_QSTR_vsync), MP_ROM_PTR(&pin_GPIO40) },
45+
{ MP_ROM_QSTR(MP_QSTR_hsync), MP_ROM_PTR(&pin_GPIO39) },
46+
{ MP_ROM_QSTR(MP_QSTR_dclk), MP_ROM_PTR(&pin_GPIO42) },
47+
{ MP_ROM_QSTR(MP_QSTR_red), MP_ROM_PTR(&tft_r_pins) },
48+
{ MP_ROM_QSTR(MP_QSTR_green), MP_ROM_PTR(&tft_g_pins) },
49+
{ MP_ROM_QSTR(MP_QSTR_blue), MP_ROM_PTR(&tft_b_pins) },
50+
};
51+
MP_DEFINE_CONST_DICT(tft_pins_dict, tft_pins_table);
52+
53+
STATIC const mp_rom_map_elem_t timings_table[] = {
54+
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_INT(12500000) },
55+
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_INT(800) },
56+
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_INT(480) },
57+
{ MP_ROM_QSTR(MP_QSTR_hsync_pulse_width), MP_ROM_INT(30) },
58+
{ MP_ROM_QSTR(MP_QSTR_hsync_back_porch), MP_ROM_INT(16) },
59+
{ MP_ROM_QSTR(MP_QSTR_hsync_front_porch), MP_ROM_INT(210) },
60+
{ MP_ROM_QSTR(MP_QSTR_hsync_idle_low), MP_ROM_TRUE },
61+
{ MP_ROM_QSTR(MP_QSTR_vsync_pulse_width), MP_ROM_INT(13) },
62+
{ MP_ROM_QSTR(MP_QSTR_vsync_back_porch), MP_ROM_INT(10) },
63+
{ MP_ROM_QSTR(MP_QSTR_vsync_front_porch), MP_ROM_INT(22) },
64+
{ MP_ROM_QSTR(MP_QSTR_vsync_idle_low), MP_ROM_TRUE },
65+
{ MP_ROM_QSTR(MP_QSTR_de_idle_high), MP_ROM_FALSE },
66+
{ MP_ROM_QSTR(MP_QSTR_pclk_active_high), MP_ROM_FALSE },
67+
{ MP_ROM_QSTR(MP_QSTR_pclk_idle_high), MP_ROM_FALSE },
68+
69+
};
70+
MP_DEFINE_CONST_DICT(timings_dict, timings_table);
71+
72+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
73+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
74+
75+
// Display constructs
76+
{ MP_ROM_QSTR(MP_QSTR_TFT_PINS), MP_ROM_PTR(&tft_pins_dict) },
77+
{ MP_ROM_QSTR(MP_QSTR_TFT_TIMINGS), MP_ROM_PTR(&timings_dict) },
78+
{ MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO2) },
79+
80+
// User buttons
81+
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
82+
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) },
83+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
84+
85+
// User accessible GPIO
86+
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, // P2, External SPI plug
87+
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
88+
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
89+
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
90+
91+
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, // P3 has 19&20 for I2C bus, plus 17&18
92+
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, // P4 & P5 are both 17,18,3.3v,G
93+
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
94+
95+
// UART pins
96+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
97+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
98+
99+
// I2C
100+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO19) },
101+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO20) },
102+
103+
// SPI
104+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
105+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO12) },
106+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO13) },
107+
108+
// i2s amplifier
109+
{ MP_ROM_QSTR(MP_QSTR_I2S_BIT_CLOCK), MP_ROM_PTR(&pin_GPIO0) },
110+
{ MP_ROM_QSTR(MP_QSTR_I2S_WORD_SELECT), MP_ROM_PTR(&pin_GPIO18) },
111+
{ MP_ROM_QSTR(MP_QSTR_I2S_DATA), MP_ROM_PTR(&pin_GPIO17) },
112+
113+
// Touch (GT911 I2C, XPT2046 SPI)
114+
// There are two versions of this tablet, one with capacitive touch
115+
// one with resistive. They use their respective bus as defined,
116+
// with GPIO38 being reset on capacitive and cs on resistive.
117+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_RESET), MP_ROM_PTR(&pin_GPIO38) },
118+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_CS), MP_ROM_PTR(&pin_GPIO38) },
119+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO18) },
120+
121+
// SD Slot (SPI)
122+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO10) },
123+
124+
// Objects
125+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
126+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
127+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
128+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
129+
};
130+
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="sunton-esp32-8048S070"
11+
# end of LWIP
12+
13+
# end of Component config
14+
15+
# end of Espressif IoT Development Framework Configuration

0 commit comments

Comments
 (0)
0