Skip to content

Commit

Permalink
sunton_esp32_2432S024C: Fixed pins, tested screen, touch, led, sdcard
Browse files Browse the repository at this point in the history
  • Loading branch information
oschettler committed Dec 27, 2024
1 parent d38119f commit cd2c6c4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand Down
4 changes: 2 additions & 2 deletions ports/espressif/boards/sunton_esp32_2432S024C/board.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -82,7 +82,7 @@ static void display_init(void) {
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
display_init_sequence,
sizeof(display_init_sequence),
&pin_GPIO21, // backlight pin
&pin_GPIO27, // backlight pin
NO_BRIGHTNESS_COMMAND,
1.0f, // brightness
false, // single_byte_bounds
Expand Down
15 changes: 7 additions & 8 deletions ports/espressif/boards/sunton_esp32_2432S024C/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2022 Dan Halbert for Adafruit Industries
// SPDX-FileCopyrightText: Copyright (c) 2024 Olav Schettler
//
// SPDX-License-Identifier: MIT

#pragma once

// Micropython setup

#define MICROPY_HW_BOARD_NAME "sunton_esp32_2432S028"
#define MICROPY_HW_MCU_NAME "ESP32"
#define MICROPY_HW_LED_STATUS (&pin_GPIO17)
#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_GPIO27)
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO22)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO33)
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO32)

#define CIRCUITPY_BOARD_SPI (3)
#define CIRCUITPY_BOARD_SPI (2)
#define CIRCUITPY_BOARD_SPI_PIN { \
{.clock = &pin_GPIO18, .mosi = &pin_GPIO23, .miso = &pin_GPIO19}, /*SD*/ \
{.clock = &pin_GPIO25, .mosi = &pin_GPIO32, .miso = &pin_GPIO39}, /*TOUCH*/ \
{.clock = &pin_GPIO14, .mosi = &pin_GPIO13, .miso = &pin_GPIO12}, /*LCD*/ \
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CIRCUITPY_CREATOR_ID = 0x19991000
CIRCUITPY_CREATION_ID = 0x00AA0001
CIRCUITPY_CREATION_ID = 0x00AA024C

IDF_TARGET = esp32

Expand All @@ -10,3 +10,5 @@ CIRCUITPY_ESP_FLASH_SIZE = 4MB
CIRCUITPY_ESPCAMERA = 0

CIRCUITPY_LEGACY_4MB_FLASH_LAYOUT = 1

CIRCUITPY_BUILD_EXTENSIONS = bin
29 changes: 13 additions & 16 deletions ports/espressif/boards/sunton_esp32_2432S024C/pins.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
// 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(touch_spi, spi, 1)
CIRCUITPY_BOARD_BUS_SINGLETON(lcd_spi, spi, 2)

static const mp_rom_map_elem_t board_module_globals_table[] = {
Expand All @@ -18,6 +17,9 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ 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) },
Expand All @@ -30,14 +32,13 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ 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 4, shared with backlight
{ MP_ROM_QSTR(MP_QSTR_IO22), MP_ROM_PTR(&pin_GPIO22) }, // P3 Pin 3, i2c_scl
{ MP_ROM_QSTR(MP_QSTR_IO27), MP_ROM_PTR(&pin_GPIO27) }, // CN1 Pin 3, i2c_sda
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, // P3 Pin 2, input only
{ 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_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO22) },
{ 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) },
Expand All @@ -51,20 +52,16 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
{ 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_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO27) },

// XPT2046 touch (spi)
{ MP_ROM_QSTR(MP_QSTR_TOUCH_MOSI), MP_ROM_PTR(&pin_GPIO32) },
{ MP_ROM_QSTR(MP_QSTR_TOUCH_MISO), MP_ROM_PTR(&pin_GPIO39) },
{ MP_ROM_QSTR(MP_QSTR_TOUCH_SCK), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_TOUCH_CS), MP_ROM_PTR(&pin_GPIO33) },
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO36) },
// 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_TOUCH_SPI), MP_ROM_PTR(&board_touch_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },

};
Expand Down

0 comments on commit cd2c6c4

Please sign in to comment.