Skip to content

Espressif pwmout reset fixes #6898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,15 +967,15 @@ int __attribute__((used)) main(void) {
safe_mode = NO_CIRCUITPY;
}

// displays init after filesystem, since they could share the flash SPI
board_init();

// Reset everything and prep MicroPython to run boot.py.
reset_port();
// Port-independent devices, like CIRCUITPY_BLEIO_HCI.
reset_devices();
reset_board();

// displays init after filesystem, since they could share the flash SPI
board_init();

// This is first time we are running CircuitPython after a reset or power-up.
supervisor_set_run_reason(RUN_REASON_STARTUP);

Expand Down
3 changes: 0 additions & 3 deletions ports/espressif/boards/adafruit_esp32s2_camera/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ void board_init(void) {
0, // Polarity
0); // Phase

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;
common_hal_displayio_display_construct(
Expand Down
11 changes: 0 additions & 11 deletions ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ uint8_t display_init_sequence[] = {


void board_init(void) {
// THIS SHOULD BE HANDLED BY espressif_board_reset_pin_number(), but it is not working.
// TEMPORARY FIX UNTIL IT'S DIAGNOSED.
common_hal_never_reset_pin(&pin_GPIO21);
gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(21, true);

busio_spi_obj_t *spi = common_hal_board_create_spi(0);
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
bus->base.type = &displayio_fourwire_type;
Expand All @@ -94,9 +88,6 @@ void board_init(void) {
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

common_hal_displayio_display_construct(
display,
bus,
Expand Down Expand Up @@ -127,8 +118,6 @@ void board_init(void) {
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
}

bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
Expand Down
3 changes: 0 additions & 3 deletions ports/espressif/boards/adafruit_funhouse/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ void board_init(void) {
0, // Polarity
0); // Phase

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;
common_hal_displayio_display_construct(
Expand Down
6 changes: 0 additions & 6 deletions ports/espressif/boards/espressif_esp32s3_eye/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ void board_init(void) {
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

common_hal_displayio_display_construct(
display,
bus,
Expand Down Expand Up @@ -120,9 +117,6 @@ void board_init(void) {
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO48); // backlight pin
// Debug UART
}

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
5 changes: 0 additions & 5 deletions ports/espressif/boards/hexky_s2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ void board_init(void) {
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

common_hal_displayio_display_construct(
display,
bus,
Expand Down Expand Up @@ -121,8 +118,6 @@ void board_init(void) {
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
}

bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
Expand Down
5 changes: 0 additions & 5 deletions ports/espressif/boards/hiibot_iots2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ static void display_init(void) {
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

common_hal_displayio_display_construct(
display,
bus,
Expand Down Expand Up @@ -126,8 +123,6 @@ static void display_init(void) {
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO38); // backlight pin
}

void board_init(void) {
Expand Down
5 changes: 0 additions & 5 deletions ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ static void display_init(void) {
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

common_hal_displayio_display_construct(
display,
bus,
Expand Down Expand Up @@ -126,8 +123,6 @@ static void display_init(void) {
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO33); // backlight pin
}

void board_init(void) {
Expand Down
3 changes: 0 additions & 3 deletions ports/espressif/boards/morpheans_morphesp-240/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ void board_init(void) {
0 // phase
);

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;
common_hal_displayio_display_construct(
Expand Down
5 changes: 0 additions & 5 deletions ports/espressif/boards/waveshare_esp32_s2_pico_lcd/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ static void display_init(void) {
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;

// workaround as board_init() is called before reset_port() in main.c
pwmout_reset();

common_hal_displayio_display_construct(
display,
bus,
Expand Down Expand Up @@ -125,8 +122,6 @@ static void display_init(void) {
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
}


Expand Down
8 changes: 2 additions & 6 deletions ports/espressif/common-hal/pwmio/PWMOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@ STATIC uint32_t calculate_duty_cycle(uint32_t frequency) {

void pwmout_reset(void) {
for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++) {
if (reserved_channels[i] != INDEX_EMPTY) {
if (reserved_channels[i] != INDEX_EMPTY && !never_reset_chan[i]) {
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
}
if (!never_reset_chan[i]) {
reserved_channels[i] = INDEX_EMPTY;
}
}
for (size_t i = 0; i < LEDC_TIMER_MAX; i++) {
if (reserved_timer_freq[i]) {
if (reserved_timer_freq[i] && !never_reset_tim[i]) {
ledc_timer_rst(LEDC_LOW_SPEED_MODE, i);
}
if (!never_reset_tim[i]) {
reserved_timer_freq[i] = 0;
varfreq_timers[i] = false;
}
Expand Down
2 changes: 1 addition & 1 deletion ports/espressif/esp32-camera
Submodule esp32-camera updated 1 files
+6 −2 target/xclk.c