Skip to content

Commit e2f56e9

Browse files
authored
Merge pull request #6065 from prplz/ai-thinker-esp32c3s-changes
ai_thinker_esp32-c3s: Pull LEDs down on reset
2 parents 85b53ea + dbedb15 commit e2f56e9

File tree

2 files changed

+46
-0
lines changed
  • ports/espressif/boards

2 files changed

+46
-0
lines changed

ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,41 @@
2828
#include "shared-bindings/microcontroller/Pin.h"
2929
#include "supervisor/board.h"
3030

31+
#include "components/driver/include/driver/gpio.h"
32+
#include "soc/usb_serial_jtag_struct.h"
33+
3134
void board_init(void) {
3235
// Debug UART
3336
#ifdef DEBUG
3437
common_hal_never_reset_pin(&pin_GPIO20);
3538
common_hal_never_reset_pin(&pin_GPIO21);
3639
#endif
40+
41+
// This board has LEDs connected to the USB pins
42+
USB_SERIAL_JTAG.conf0.usb_pad_enable = 0;
43+
USB_SERIAL_JTAG.conf0.dp_pullup = 0;
3744
}
3845

3946
bool board_requests_safe_mode(void) {
4047
return false;
4148
}
4249

50+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
51+
// Pull LEDs down on reset rather than the default up
52+
if (pin_number == 3 || pin_number == 4 || pin_number == 5 || pin_number == 18 || pin_number == 19) {
53+
gpio_config_t cfg = {
54+
.pin_bit_mask = BIT64(pin_number),
55+
.mode = GPIO_MODE_DISABLE,
56+
.pull_up_en = false,
57+
.pull_down_en = true,
58+
.intr_type = GPIO_INTR_DISABLE,
59+
};
60+
gpio_config(&cfg);
61+
return true;
62+
}
63+
return false;
64+
}
65+
4366
void reset_board(void) {
4467
}
4568

ports/espressif/boards/ai_thinker_esp32-c3s/board.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,41 @@
2828
#include "shared-bindings/microcontroller/Pin.h"
2929
#include "supervisor/board.h"
3030

31+
#include "components/driver/include/driver/gpio.h"
32+
#include "soc/usb_serial_jtag_struct.h"
33+
3134
void board_init(void) {
3235
// Debug UART
3336
#ifdef DEBUG
3437
common_hal_never_reset_pin(&pin_GPIO20);
3538
common_hal_never_reset_pin(&pin_GPIO21);
3639
#endif
40+
41+
// This board has LEDs connected to the USB pins
42+
USB_SERIAL_JTAG.conf0.usb_pad_enable = 0;
43+
USB_SERIAL_JTAG.conf0.dp_pullup = 0;
3744
}
3845

3946
bool board_requests_safe_mode(void) {
4047
return false;
4148
}
4249

50+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
51+
// Pull LEDs down on reset rather than the default up
52+
if (pin_number == 3 || pin_number == 4 || pin_number == 5 || pin_number == 18 || pin_number == 19) {
53+
gpio_config_t cfg = {
54+
.pin_bit_mask = BIT64(pin_number),
55+
.mode = GPIO_MODE_DISABLE,
56+
.pull_up_en = false,
57+
.pull_down_en = true,
58+
.intr_type = GPIO_INTR_DISABLE,
59+
};
60+
gpio_config(&cfg);
61+
return true;
62+
}
63+
return false;
64+
}
65+
4366
void reset_board(void) {
4467
}
4568

0 commit comments

Comments
 (0)