From aaa2be120071e2b1bba03147691da47d2af1ddae Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 12 Sep 2022 18:19:33 +0800 Subject: [PATCH 1/3] Set the default pin state for GPIOs to pull down. --- .../cytron_maker_feather_aiot_s3/board.c | 41 +++++++++++++++++++ .../mpconfigboard.h | 1 + 2 files changed, 42 insertions(+) diff --git a/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c b/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c index 7ddb33fa45..67f2c8d17a 100644 --- a/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c +++ b/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c @@ -35,6 +35,47 @@ void board_init(void) { reset_board(); } +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // For GPIOs used in Maker Feather AIoT S3, set the default state to pull down + // as most of them are connected to active high LED. + switch (pin_number) { + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 12: + case 14: + case 15: + case 16: + case 17: + case 18: + case 21: + case 38: + case 39: + case 40: + case 41: + case 42: + case 47: + case 48: + gpio_reset_pin(pin_number); + gpio_pullup_dis(pin_number); + gpio_pulldown_en(pin_number); + return true; + + // Do not pull up/down as this is the battery voltage monitoring pin. + case 13: + gpio_reset_pin(pin_number); + gpio_pullup_dis(pin_number); + gpio_pulldown_dis(pin_number); + return true; + } + + return false; +} + void reset_board(void) { // Turn on VP by default. gpio_set_direction(11, GPIO_MODE_DEF_OUTPUT); diff --git a/ports/espressif/boards/cytron_maker_feather_aiot_s3/mpconfigboard.h b/ports/espressif/boards/cytron_maker_feather_aiot_s3/mpconfigboard.h index 14512efd9d..39c1edc5bd 100644 --- a/ports/espressif/boards/cytron_maker_feather_aiot_s3/mpconfigboard.h +++ b/ports/espressif/boards/cytron_maker_feather_aiot_s3/mpconfigboard.h @@ -30,6 +30,7 @@ #define MICROPY_HW_MCU_NAME "ESP32S3" #define MICROPY_HW_NEOPIXEL (&pin_GPIO46) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO11) #define MICROPY_HW_LED_STATUS (&pin_GPIO2) From 0ae015e4d9da9a938b5c960f02475b553431ca91 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 12 Sep 2022 18:25:27 +0800 Subject: [PATCH 2/3] Removed whitespaces. --- ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c b/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c index 67f2c8d17a..f86996eb12 100644 --- a/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c +++ b/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c @@ -64,7 +64,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) { gpio_pullup_dis(pin_number); gpio_pulldown_en(pin_number); return true; - + // Do not pull up/down as this is the battery voltage monitoring pin. case 13: gpio_reset_pin(pin_number); @@ -72,7 +72,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) { gpio_pulldown_dis(pin_number); return true; } - + return false; } From c157f1cb3973f11995b30a424f2459b1a089e7a6 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 12 Sep 2022 18:56:15 +0800 Subject: [PATCH 3/3] Cast pin_number to int8_t so that it can be used with switch-case. --- ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c b/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c index f86996eb12..1f9ef3c4e7 100644 --- a/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c +++ b/ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c @@ -38,7 +38,7 @@ void board_init(void) { bool espressif_board_reset_pin_number(gpio_num_t pin_number) { // For GPIOs used in Maker Feather AIoT S3, set the default state to pull down // as most of them are connected to active high LED. - switch (pin_number) { + switch ((int8_t)pin_number) { case 4: case 5: case 6: