Merge pull request #6898 from dhalbert/espressif-pwmout-reset

Espressif pwmout reset fixes
This commit is contained in:
Dan Halbert 2022-09-14 18:47:05 -04:00 committed by GitHub
commit 14fc4a0797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 6 additions and 56 deletions

6
main.c
View File

@ -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);

View File

@ -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(

View File

@ -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;
@ -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,
@ -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) {

View File

@ -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(

View File

@ -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,
@ -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.

View File

@ -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,
@ -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) {

View File

@ -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,
@ -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) {

View File

@ -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,
@ -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) {

View File

@ -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(

View File

@ -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,
@ -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
}

View File

@ -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;
}

@ -1 +1 @@
Subproject commit 28804391c002f6a3ea5ce6a55aee3b191be3ecde
Subproject commit 54c3f61c864c3d3ffd779042454554045b9dd9d2