Skip to content

Commit 27beb0e

Browse files
authored
Merge pull request #9918 from PasswordVault/main
Added new board sunton_esp32_2432S024C
2 parents 0a0a89a + 4f429bc commit 27beb0e

File tree

5 files changed

+220
-0
lines changed

5 files changed

+220
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/board/__init__.h"
10+
#include "shared-bindings/microcontroller/Pin.h"
11+
#include "shared-module/displayio/__init__.h"
12+
#include "shared-module/displayio/mipi_constants.h"
13+
#include "driver/gpio.h"
14+
#include "common-hal/microcontroller/Pin.h"
15+
#include "shared-module/os/__init__.h"
16+
17+
uint8_t display_init_sequence[] = {
18+
0x01, 0x80, 0x80, // # Software reset then delay 0x80 (128ms)
19+
0xEF, 0x03, 0x03, 0x80, 0x02,
20+
0xCF, 0x03, 0x00, 0xC1, 0x30,
21+
0xED, 0x04, 0x64, 0x03, 0x12, 0x81,
22+
0xE8, 0x03, 0x85, 0x00, 0x78,
23+
0xCB, 0x05, 0x39, 0x2C, 0x00, 0x34, 0x02,
24+
0xF7, 0x01, 0x20,
25+
0xEA, 0x02, 0x00, 0x00,
26+
0xc0, 0x01, 0x23, // # Power control VRH[5:0]
27+
0xc1, 0x01, 0x10, // # Power control SAP[2:0];BT[3:0]
28+
0xc5, 0x02, 0x3e, 0x28, // # VCM control
29+
0xc7, 0x01, 0x86, // # VCM control2
30+
0x36, 0x01, 0x38, // # Memory Access Control
31+
0x37, 0x01, 0x00, // # Vertical scroll zero
32+
0x3a, 0x01, 0x55, // # COLMOD: Pixel Format Set
33+
0xb1, 0x02, 0x00, 0x18, // # Frame Rate Control (In Normal Mode/Full Colors)
34+
0xb6, 0x03, 0x08, 0x82, 0x27, // # Display Function Control
35+
0xF2, 0x01, 0x00, // # 3Gamma Function Disable
36+
0x26, 0x01, 0x01, // # Gamma curve selected
37+
0xe0, 0x0f, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, // # Set Gamma
38+
0xe1, 0x0f, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, // # Set Gamma
39+
0x11, 0x80, 0x48, // # Exit Sleep then delay
40+
0x29, 0x80, 0x78, // # Display on then delay 0x78 (120ms)
41+
};
42+
43+
static void display_init(void) {
44+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
45+
busio_spi_obj_t *spi = &bus->inline_bus;
46+
mp_int_t rotation;
47+
common_hal_busio_spi_construct(spi, &pin_GPIO14, &pin_GPIO13, &pin_GPIO12, false);
48+
common_hal_busio_spi_never_reset(spi);
49+
50+
bus->base.type = &fourwire_fourwire_type;
51+
common_hal_fourwire_fourwire_construct(bus,
52+
spi,
53+
&pin_GPIO2, // TFT_DC Command or data
54+
&pin_GPIO15, // TFT_CS Chip select
55+
NULL, // TFT_RST Reset
56+
6000000, // Baudrate
57+
0, // Polarity
58+
0); // Phase
59+
60+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
61+
display->base.type = &busdisplay_busdisplay_type;
62+
os_getenv_err_t result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_ROTATION", &rotation);
63+
if (result != GETENV_OK) {
64+
rotation = 0;
65+
}
66+
67+
common_hal_busdisplay_busdisplay_construct(display,
68+
bus,
69+
320, // Width
70+
240, // Height
71+
0, // column start
72+
0, // row start
73+
rotation, // rotation
74+
16, // Color depth
75+
false, // Grayscale
76+
false, // pixels in a byte share a row. Only valid for depths < 8
77+
1, // bytes per cell. Only valid for depths < 8
78+
false, // reverse_pixels_in_byte. Only valid for depths < 8
79+
true, // reverse_pixels_in_word
80+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
81+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
82+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
83+
display_init_sequence,
84+
sizeof(display_init_sequence),
85+
&pin_GPIO27, // backlight pin
86+
NO_BRIGHTNESS_COMMAND,
87+
1.0f, // brightness
88+
false, // single_byte_bounds
89+
false, // data_as_commands
90+
true, // auto_refresh
91+
60, // native_frames_per_second
92+
true, // backlight_on_high
93+
false, // SH1107_addressing
94+
50000); // backlight pwm frequency
95+
}
96+
97+
void board_init(void) {
98+
display_init();
99+
}
100+
101+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
102+
// Pull the speaker pin low to reduce noise on reset
103+
if (pin_number == 26) {
104+
// Turn on TFT
105+
config_pin_as_output_with_level(pin_number, false);
106+
return true;
107+
}
108+
return false;
109+
}
110+
111+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Micropython setup
10+
11+
#define MICROPY_HW_BOARD_NAME "sunton_esp32_2432S024C"
12+
#define MICROPY_HW_MCU_NAME "ESP32-D0WD-V3"
13+
#define MICROPY_HW_LED_STATUS (&pin_GPIO17) // LED_BLUE
14+
15+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
16+
17+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO33)
18+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO32)
19+
20+
#define CIRCUITPY_BOARD_SPI (2)
21+
#define CIRCUITPY_BOARD_SPI_PIN { \
22+
{.clock = &pin_GPIO18, .mosi = &pin_GPIO23, .miso = &pin_GPIO19}, /*SD*/ \
23+
{.clock = &pin_GPIO14, .mosi = &pin_GPIO13, .miso = &pin_GPIO12}, /*LCD*/ \
24+
}
25+
26+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
27+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CIRCUITPY_CREATOR_ID = 0x19991000
2+
CIRCUITPY_CREATION_ID = 0x00AA024C
3+
4+
IDF_TARGET = esp32
5+
6+
CIRCUITPY_ESP_FLASH_MODE = qio
7+
CIRCUITPY_ESP_FLASH_FREQ = 80m
8+
CIRCUITPY_ESP_FLASH_SIZE = 4MB
9+
10+
CIRCUITPY_ESPCAMERA = 0
11+
12+
CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1
13+
14+
CIRCUITPY_BUILD_EXTENSIONS = bin
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 0)
11+
CIRCUITPY_BOARD_BUS_SINGLETON(lcd_spi, spi, 2)
12+
13+
static const mp_rom_map_elem_t board_module_globals_table[] = {
14+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
15+
16+
// Boot button
17+
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) },
18+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
19+
20+
// Blue LED
21+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO17) },
22+
23+
// RGB LED
24+
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO16) },
25+
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_GPIO4) },
26+
{ MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_GPIO17) },
27+
28+
// CDS Light sensor (Not present on all boards)
29+
{ MP_ROM_QSTR(MP_QSTR_LDR), MP_ROM_PTR(&pin_GPIO34) },
30+
31+
// Speaker pin
32+
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO26) },
33+
34+
// User available GPIO
35+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, // P3 Pin 1
36+
{ MP_ROM_QSTR(MP_QSTR_IO22), MP_ROM_PTR(&pin_GPIO22) }, // P3 Pin 2
37+
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, // P3 Pin 3
38+
39+
// i2c
40+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO33) },
41+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO32) },
42+
43+
// TF card slot
44+
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO23) },
45+
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO19) },
46+
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO18) },
47+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO5) },
48+
49+
// ILI9341 dsplay (spi)
50+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO13) },
51+
{ MP_ROM_QSTR(MP_QSTR_LCD_MISO), MP_ROM_PTR(&pin_GPIO12) },
52+
{ MP_ROM_QSTR(MP_QSTR_LCD_SCK), MP_ROM_PTR(&pin_GPIO14) },
53+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO15) },
54+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO2) },
55+
{ MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO27) },
56+
57+
// Touch (CST820)
58+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO21) },
59+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_RST), MP_ROM_PTR(&pin_GPIO25) },
60+
61+
// objects
62+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
63+
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) },
64+
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_lcd_spi_obj) },
65+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
66+
67+
};
68+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/espressif/boards/sunton_esp32_2432S024C/sdkconfig

Whitespace-only changes.

0 commit comments

Comments
 (0)