Skip to content

Commit

Permalink
Wrap the panic handler to disable the gdo uart pins and prevent door …
Browse files Browse the repository at this point in the history
…openings.
  • Loading branch information
h2zero committed Jul 19, 2024
1 parent f8af4c7 commit 9814bcd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 17 additions & 1 deletion components/secplus_gdo/secplus_gdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,20 @@ namespace secplus_gdo {
}

} // namespace secplus_gdo
} // namespace esphome
} // namespace esphome

// Need to wrap the panic handler to disable the gdo uart pins before calling the real panic handler.
extern "C" {
#include "hal/gpio_hal.h"

void __real_esp_panic_handler(void*);

void __wrap_esp_panic_handler (void* info) {
esp_rom_printf("DISABLING GDO UART PINS!\n");
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[(gpio_num_t)GDO_UART_TX_PIN], PIN_FUNC_GPIO);
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[(gpio_num_t)GDO_UART_RX_PIN], PIN_FUNC_GPIO);

// Call the original panic handler
__real_esp_panic_handler(info);
}
} //extern "C"
3 changes: 2 additions & 1 deletion garage-door-GDOv2-Q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@ esphome:
lib_deps:
- https://github.com/konnected-io/gdolib#76ba232
build_flags:
- -DUART_SCLK_DEFAULT=UART_SCLK_APB
- -DUART_SCLK_DEFAULT=UART_SCLK_APB
- -Wl,--wrap=esp_panic_handler

0 comments on commit 9814bcd

Please sign in to comment.