forked from adafruit/circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request adafruit#9918 from PasswordVault/main
Added new board sunton_esp32_2432S024C
- Loading branch information
Showing
5 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// This file is part of the CircuitPython project: https://circuitpython.org | ||
// | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include "supervisor/board.h" | ||
#include "mpconfigboard.h" | ||
#include "shared-bindings/board/__init__.h" | ||
#include "shared-bindings/microcontroller/Pin.h" | ||
#include "shared-module/displayio/__init__.h" | ||
#include "shared-module/displayio/mipi_constants.h" | ||
#include "driver/gpio.h" | ||
#include "common-hal/microcontroller/Pin.h" | ||
#include "shared-module/os/__init__.h" | ||
|
||
uint8_t display_init_sequence[] = { | ||
0x01, 0x80, 0x80, // # Software reset then delay 0x80 (128ms) | ||
0xEF, 0x03, 0x03, 0x80, 0x02, | ||
0xCF, 0x03, 0x00, 0xC1, 0x30, | ||
0xED, 0x04, 0x64, 0x03, 0x12, 0x81, | ||
0xE8, 0x03, 0x85, 0x00, 0x78, | ||
0xCB, 0x05, 0x39, 0x2C, 0x00, 0x34, 0x02, | ||
0xF7, 0x01, 0x20, | ||
0xEA, 0x02, 0x00, 0x00, | ||
0xc0, 0x01, 0x23, // # Power control VRH[5:0] | ||
0xc1, 0x01, 0x10, // # Power control SAP[2:0];BT[3:0] | ||
0xc5, 0x02, 0x3e, 0x28, // # VCM control | ||
0xc7, 0x01, 0x86, // # VCM control2 | ||
0x36, 0x01, 0x38, // # Memory Access Control | ||
0x37, 0x01, 0x00, // # Vertical scroll zero | ||
0x3a, 0x01, 0x55, // # COLMOD: Pixel Format Set | ||
0xb1, 0x02, 0x00, 0x18, // # Frame Rate Control (In Normal Mode/Full Colors) | ||
0xb6, 0x03, 0x08, 0x82, 0x27, // # Display Function Control | ||
0xF2, 0x01, 0x00, // # 3Gamma Function Disable | ||
0x26, 0x01, 0x01, // # Gamma curve selected | ||
0xe0, 0x0f, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, // # Set Gamma | ||
0xe1, 0x0f, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, // # Set Gamma | ||
0x11, 0x80, 0x48, // # Exit Sleep then delay | ||
0x29, 0x80, 0x78, // # Display on then delay 0x78 (120ms) | ||
}; | ||
|
||
static void display_init(void) { | ||
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; | ||
busio_spi_obj_t *spi = &bus->inline_bus; | ||
mp_int_t rotation; | ||
common_hal_busio_spi_construct(spi, &pin_GPIO14, &pin_GPIO13, &pin_GPIO12, false); | ||
common_hal_busio_spi_never_reset(spi); | ||
|
||
bus->base.type = &fourwire_fourwire_type; | ||
common_hal_fourwire_fourwire_construct(bus, | ||
spi, | ||
&pin_GPIO2, // TFT_DC Command or data | ||
&pin_GPIO15, // TFT_CS Chip select | ||
NULL, // TFT_RST Reset | ||
6000000, // Baudrate | ||
0, // Polarity | ||
0); // Phase | ||
|
||
busdisplay_busdisplay_obj_t *display = &allocate_display()->display; | ||
display->base.type = &busdisplay_busdisplay_type; | ||
os_getenv_err_t result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_ROTATION", &rotation); | ||
if (result != GETENV_OK) { | ||
rotation = 0; | ||
} | ||
|
||
common_hal_busdisplay_busdisplay_construct(display, | ||
bus, | ||
320, // Width | ||
240, // Height | ||
0, // column start | ||
0, // row start | ||
rotation, // rotation | ||
16, // Color depth | ||
false, // Grayscale | ||
false, // pixels in a byte share a row. Only valid for depths < 8 | ||
1, // bytes per cell. Only valid for depths < 8 | ||
false, // reverse_pixels_in_byte. Only valid for depths < 8 | ||
true, // reverse_pixels_in_word | ||
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command | ||
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command | ||
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command | ||
display_init_sequence, | ||
sizeof(display_init_sequence), | ||
&pin_GPIO27, // backlight pin | ||
NO_BRIGHTNESS_COMMAND, | ||
1.0f, // brightness | ||
false, // single_byte_bounds | ||
false, // data_as_commands | ||
true, // auto_refresh | ||
60, // native_frames_per_second | ||
true, // backlight_on_high | ||
false, // SH1107_addressing | ||
50000); // backlight pwm frequency | ||
} | ||
|
||
void board_init(void) { | ||
display_init(); | ||
} | ||
|
||
bool espressif_board_reset_pin_number(gpio_num_t pin_number) { | ||
// Pull the speaker pin low to reduce noise on reset | ||
if (pin_number == 26) { | ||
// Turn on TFT | ||
config_pin_as_output_with_level(pin_number, false); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. |
27 changes: 27 additions & 0 deletions
27
ports/espressif/boards/sunton_esp32_2432S024C/mpconfigboard.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// This file is part of the CircuitPython project: https://circuitpython.org | ||
// | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
|
||
// Micropython setup | ||
|
||
#define MICROPY_HW_BOARD_NAME "sunton_esp32_2432S024C" | ||
#define MICROPY_HW_MCU_NAME "ESP32-D0WD-V3" | ||
#define MICROPY_HW_LED_STATUS (&pin_GPIO17) // LED_BLUE | ||
|
||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) | ||
|
||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) | ||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO32) | ||
|
||
#define CIRCUITPY_BOARD_SPI (2) | ||
#define CIRCUITPY_BOARD_SPI_PIN { \ | ||
{.clock = &pin_GPIO18, .mosi = &pin_GPIO23, .miso = &pin_GPIO19}, /*SD*/ \ | ||
{.clock = &pin_GPIO14, .mosi = &pin_GPIO13, .miso = &pin_GPIO12}, /*LCD*/ \ | ||
} | ||
|
||
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) | ||
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3) |
14 changes: 14 additions & 0 deletions
14
ports/espressif/boards/sunton_esp32_2432S024C/mpconfigboard.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CIRCUITPY_CREATOR_ID = 0x19991000 | ||
CIRCUITPY_CREATION_ID = 0x00AA024C | ||
|
||
IDF_TARGET = esp32 | ||
|
||
CIRCUITPY_ESP_FLASH_MODE = qio | ||
CIRCUITPY_ESP_FLASH_FREQ = 80m | ||
CIRCUITPY_ESP_FLASH_SIZE = 4MB | ||
|
||
CIRCUITPY_ESPCAMERA = 0 | ||
|
||
CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1 | ||
|
||
CIRCUITPY_BUILD_EXTENSIONS = bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// This file is part of the CircuitPython project: https://circuitpython.org | ||
// | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include "shared-bindings/board/__init__.h" | ||
#include "shared-module/displayio/__init__.h" | ||
|
||
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 0) | ||
CIRCUITPY_BOARD_BUS_SINGLETON(lcd_spi, spi, 2) | ||
|
||
static const mp_rom_map_elem_t board_module_globals_table[] = { | ||
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS | ||
|
||
// Boot button | ||
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, | ||
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, | ||
|
||
// Blue LED | ||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO17) }, | ||
|
||
// RGB LED | ||
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO16) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_GPIO4) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_GPIO17) }, | ||
|
||
// CDS Light sensor (Not present on all boards) | ||
{ MP_ROM_QSTR(MP_QSTR_LDR), MP_ROM_PTR(&pin_GPIO34) }, | ||
|
||
// Speaker pin | ||
{ MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO26) }, | ||
|
||
// User available GPIO | ||
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, // P3 Pin 1 | ||
{ MP_ROM_QSTR(MP_QSTR_IO22), MP_ROM_PTR(&pin_GPIO22) }, // P3 Pin 2 | ||
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, // P3 Pin 3 | ||
|
||
// i2c | ||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO33) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO32) }, | ||
|
||
// TF card slot | ||
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO23) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO19) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO18) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO5) }, | ||
|
||
// ILI9341 dsplay (spi) | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO13) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_MISO), MP_ROM_PTR(&pin_GPIO12) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_SCK), MP_ROM_PTR(&pin_GPIO14) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO15) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO2) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO27) }, | ||
|
||
// Touch (CST820) | ||
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO21) }, | ||
{ MP_ROM_QSTR(MP_QSTR_TOUCH_RST), MP_ROM_PTR(&pin_GPIO25) }, | ||
|
||
// objects | ||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_lcd_spi_obj) }, | ||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, | ||
|
||
}; | ||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); |
Empty file.