Skip to content

Commit 4ab92d3

Browse files
authored
Merge pull request #6574 from makermelissa/esp_box_lite
Added Esp box lite
2 parents f95bd24 + 08b4a64 commit 4ab92d3

File tree

5 files changed

+261
-0
lines changed

5 files changed

+261
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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/microcontroller/Pin.h"
30+
31+
#include "shared-bindings/busio/SPI.h"
32+
#include "shared-bindings/displayio/FourWire.h"
33+
#include "shared-module/displayio/__init__.h"
34+
#include "shared-module/displayio/mipi_constants.h"
35+
36+
uint8_t display_init_sequence[] = {
37+
0x01, 0x80, 0x96, // _SWRESET and Delay 150ms
38+
0x11, 0x80, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms
40+
0x21, 0x80, 0x0A, // _INVON
41+
0x13, 0x80, 0x0A, // _NORON and Delay 10ms
42+
0x36, 0x01, 0xA0, // _MADCTL
43+
0x29, 0x80, 0xFF, // _DISPON and Delay 500ms
44+
};
45+
46+
void board_init(void) {
47+
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
48+
common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL, false);
49+
common_hal_busio_spi_never_reset(spi);
50+
51+
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
52+
bus->base.type = &displayio_fourwire_type;
53+
common_hal_displayio_fourwire_construct(bus,
54+
spi,
55+
&pin_GPIO4, // TFT_DC Command or data
56+
&pin_GPIO5, // TFT_CS Chip select
57+
&pin_GPIO48, // TFT_RST Reset
58+
60000000, // Baudrate
59+
0, // Polarity
60+
0); // Phase
61+
62+
displayio_display_obj_t *display = &displays[0].display;
63+
display->base.type = &displayio_display_type;
64+
common_hal_displayio_display_construct(display,
65+
bus,
66+
320, // Width
67+
240, // Height
68+
0, // column start
69+
0, // row start
70+
0, // rotation
71+
16, // Color depth
72+
false, // Grayscale
73+
false, // pixels in a byte share a row. Only valid for depths < 8
74+
1, // bytes per cell. Only valid for depths < 8
75+
false, // reverse_pixels_in_byte. Only valid for depths < 8
76+
true, // reverse_pixels_in_word
77+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
78+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
79+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
80+
display_init_sequence,
81+
sizeof(display_init_sequence),
82+
&pin_GPIO45, // backlight pin
83+
NO_BRIGHTNESS_COMMAND,
84+
1.0f, // brightness (ignored)
85+
true, // auto_brightness
86+
false, // single_byte_bounds
87+
false, // data_as_commands
88+
true, // auto_refresh
89+
60, // native_frames_per_second
90+
false, // backlight_on_high
91+
false, // SH1107_addressing
92+
50000); // backlight pwm frequency
93+
94+
// Debug UART
95+
#ifdef DEBUG
96+
common_hal_never_reset_pin(&pin_GPIO43);
97+
common_hal_never_reset_pin(&pin_GPIO44);
98+
#endif
99+
}
100+
101+
bool board_requests_safe_mode(void) {
102+
return false;
103+
}
104+
105+
void reset_board(void) {
106+
107+
}
108+
109+
void board_deinit(void) {
110+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 "ESP32-S3-Box-Lite"
30+
#define MICROPY_HW_MCU_NAME "ESP32S3"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
USB_VID = 0x303A
2+
USB_PID = 0x700D
3+
USB_PRODUCT = "ESP32-S3-Box-Lite"
4+
USB_MANUFACTURER = "Espressif"
5+
6+
IDF_TARGET = esp32s3
7+
8+
INTERNAL_FLASH_FILESYSTEM = 1
9+
LONGINT_IMPL = MPZ
10+
11+
# The default queue depth of 16 overflows on release builds,
12+
# so increase it to 32.
13+
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
14+
15+
CIRCUITPY_ESP_FLASH_MODE=dio
16+
CIRCUITPY_ESP_FLASH_FREQ=40m
17+
CIRCUITPY_ESP_FLASH_SIZE=16MB
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include "shared-bindings/board/__init__.h"
2+
#include "shared-module/displayio/__init__.h"
3+
4+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
5+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
6+
7+
// First PMOD connector
8+
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_GPIO9) },
9+
10+
{ MP_ROM_QSTR(MP_QSTR_U0TXD), MP_ROM_PTR(&pin_GPIO43) },
11+
{ MP_ROM_QSTR(MP_QSTR_G43), MP_ROM_PTR(&pin_GPIO43) },
12+
13+
{ MP_ROM_QSTR(MP_QSTR_U0RXD), MP_ROM_PTR(&pin_GPIO44) },
14+
{ MP_ROM_QSTR(MP_QSTR_G44), MP_ROM_PTR(&pin_GPIO44) },
15+
16+
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO10) },
17+
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_GPIO10) },
18+
19+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
20+
{ MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_GPIO11) },
21+
22+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO13) },
23+
{ MP_ROM_QSTR(MP_QSTR_G13), MP_ROM_PTR(&pin_GPIO13) },
24+
25+
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO12) },
26+
{ MP_ROM_QSTR(MP_QSTR_G12), MP_ROM_PTR(&pin_GPIO12) },
27+
28+
{ MP_ROM_QSTR(MP_QSTR_G14), MP_ROM_PTR(&pin_GPIO14) },
29+
30+
// Second PMOD connector
31+
{ MP_ROM_QSTR(MP_QSTR_G38), MP_ROM_PTR(&pin_GPIO38) },
32+
{ MP_ROM_QSTR(MP_QSTR_G39), MP_ROM_PTR(&pin_GPIO39) },
33+
{ MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_GPIO40) },
34+
{ MP_ROM_QSTR(MP_QSTR_G40), MP_ROM_PTR(&pin_GPIO40) },
35+
{ MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_GPIO41) },
36+
{ MP_ROM_QSTR(MP_QSTR_G41), MP_ROM_PTR(&pin_GPIO41) },
37+
{ MP_ROM_QSTR(MP_QSTR_G42), MP_ROM_PTR(&pin_GPIO42) },
38+
{ MP_ROM_QSTR(MP_QSTR_G21), MP_ROM_PTR(&pin_GPIO21) },
39+
40+
// LCD & touchscreen
41+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO4) },
42+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO5) },
43+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO6) },
44+
{ MP_ROM_QSTR(MP_QSTR_LCD_SCK), MP_ROM_PTR(&pin_GPIO7) },
45+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO48) },
46+
{ MP_ROM_QSTR(MP_QSTR_LCD_CTRL), MP_ROM_PTR(&pin_GPIO45) },
47+
{ MP_ROM_QSTR(MP_QSTR_CTP_INT), MP_ROM_PTR(&pin_GPIO3) },
48+
49+
// Audio
50+
{ MP_ROM_QSTR(MP_QSTR_I2S_ADC_SDOUT), MP_ROM_PTR(&pin_GPIO16) },
51+
{ MP_ROM_QSTR(MP_QSTR_I2S_MCLK), MP_ROM_PTR(&pin_GPIO2) },
52+
{ MP_ROM_QSTR(MP_QSTR_I2S_SCLK), MP_ROM_PTR(&pin_GPIO17) },
53+
{ MP_ROM_QSTR(MP_QSTR_I2S_LRCK), MP_ROM_PTR(&pin_GPIO47) },
54+
{ MP_ROM_QSTR(MP_QSTR_I2S_CODEC_DSDIN), MP_ROM_PTR(&pin_GPIO15) },
55+
{ MP_ROM_QSTR(MP_QSTR_PA_CTRL), MP_ROM_PTR(&pin_GPIO46) },
56+
{ MP_ROM_QSTR(MP_QSTR_MUTE_STATUS), MP_ROM_PTR(&pin_GPIO1) },
57+
58+
// Internal I2C bus
59+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) },
60+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO18) },
61+
62+
// boot button, also usable as a software button
63+
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) },
64+
65+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
66+
};
67+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
2+
#
3+
# SPI RAM config
4+
#
5+
# CONFIG_SPIRAM_MODE_QUAD is not set
6+
CONFIG_SPIRAM_MODE_OCT=y
7+
CONFIG_SPIRAM_TYPE_AUTO=y
8+
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
9+
CONFIG_SPIRAM_SIZE=-1
10+
# end of SPI RAM config
11+
12+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
13+
#
14+
# PSRAM Clock and CS IO for ESP32S3
15+
#
16+
CONFIG_DEFAULT_PSRAM_CS_IO=26
17+
# end of PSRAM Clock and CS IO for ESP32S3
18+
19+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
20+
# CONFIG_SPIRAM_RODATA is not set
21+
CONFIG_SPIRAM_SPEED_80M=y
22+
# CONFIG_SPIRAM_SPEED_40M is not set
23+
CONFIG_SPIRAM=y
24+
CONFIG_SPIRAM_BOOT_INIT=y
25+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
26+
# CONFIG_SPIRAM_USE_MEMMAP is not set
27+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
28+
CONFIG_SPIRAM_USE_MALLOC=y
29+
CONFIG_SPIRAM_MEMTEST=y
30+
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
31+
# CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is not set
32+
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
33+
#
34+
# LWIP
35+
#
36+
CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3"
37+
# end of LWIP

0 commit comments

Comments
 (0)