From de168b106c988274d86ac5b6a199871bf5ddecfb Mon Sep 17 00:00:00 2001 From: Michael Himing Date: Tue, 15 Mar 2022 10:42:51 +1100 Subject: [PATCH 1/3] Add board lilygo_ttgo_t-01c3 --- .../boards/lilygo_ttgo_t-01c3/board.c | 38 +++++++++++++++++++ .../boards/lilygo_ttgo_t-01c3/mpconfigboard.h | 10 +++++ .../lilygo_ttgo_t-01c3/mpconfigboard.mk | 10 +++++ .../boards/lilygo_ttgo_t-01c3/pins.c | 20 ++++++++++ .../boards/lilygo_ttgo_t-01c3/sdkconfig | 5 +++ 5 files changed, 83 insertions(+) create mode 100644 ports/espressif/boards/lilygo_ttgo_t-01c3/board.c create mode 100644 ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h create mode 100644 ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk create mode 100644 ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c create mode 100644 ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/board.c b/ports/espressif/boards/lilygo_ttgo_t-01c3/board.c new file mode 100644 index 0000000000..deeb8041ea --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/board.c @@ -0,0 +1,38 @@ +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + +#include "components/driver/include/driver/gpio.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pull LED down on reset rather than the default up + if (pin_number == MICROPY_HW_LED_STATUS->number) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h new file mode 100644 index 0000000000..e0eebc9754 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h @@ -0,0 +1,10 @@ +#define MICROPY_HW_BOARD_NAME "LILYGO TTGO T-01C3" +#define MICROPY_HW_MCU_NAME "ESP32-C3" + +#define MICROPY_HW_LED_STATUS (&pin_GPIO3) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk new file mode 100644 index 0000000000..f033d411f2 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 123 +CIRCUITPY_CREATION_ID = 123 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c b/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c new file mode 100644 index 0000000000..887d85ef2f --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c @@ -0,0 +1,20 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig b/ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig new file mode 100644 index 0000000000..9d906d3c3b --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="LILYGO TTGO T-01C3" +# end of LWIP From 196bb4d1f4b9b94f469c3b5c87fedfb1cee3dc51 Mon Sep 17 00:00:00 2001 From: Michael Himing Date: Tue, 15 Mar 2022 13:25:30 +1100 Subject: [PATCH 2/3] lilygo_ttgo_t-01c3: only require .bin file --- tools/build_board_info.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 364bcefe7b..a969ba9a5b 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -72,6 +72,7 @@ extension_by_board = { "ai_thinker_esp32-c3s": BIN, "ai_thinker_esp32-c3s-2m": BIN, "espressif_esp32c3_devkitm_1_n4": BIN, + "lilygo_ttgo_t-01c3": BIN, "microdev_micro_c3": BIN, # broadcom "raspberrypi_zero": KERNEL_IMG, From da92d508c2ffaa4dc1b306a40f43b7258dfff301 Mon Sep 17 00:00:00 2001 From: Michael Himing Date: Thu, 17 Mar 2022 17:56:31 +1100 Subject: [PATCH 3/3] lilygo_ttgo_t-01c3: Add creation ID --- ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk index f033d411f2..d40c9b6722 100644 --- a/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk @@ -1,5 +1,5 @@ -CIRCUITPY_CREATOR_ID = 123 -CIRCUITPY_CREATION_ID = 123 +CIRCUITPY_CREATOR_ID = 0xC3C30000 +CIRCUITPY_CREATION_ID = 0x00C30001 IDF_TARGET = esp32c3