mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
shutdowner fix
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "shutdowner.hpp"
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <esp_sleep.h>
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
@@ -13,10 +14,10 @@ Shutdowner& Shutdowner::get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void shutdown(void* arg) {
|
||||
static void IRAM_ATTR shutdown(void* arg) {
|
||||
// printf("Shutting down...\n");
|
||||
// ESP_ERROR_CHECK(gpio_hold_dis(PWR_KILL));
|
||||
// ESP_ERROR_CHECK(gpio_set_level(PWR_KILL, 0));
|
||||
ESP_ERROR_CHECK(gpio_hold_dis(PWR_KILL));
|
||||
ESP_ERROR_CHECK(gpio_set_level(PWR_KILL, 0));
|
||||
}
|
||||
|
||||
Shutdowner::Shutdowner() {
|
||||
@@ -27,7 +28,9 @@ Shutdowner::Shutdowner() {
|
||||
ESP_ERROR_CHECK(gpio_set_direction(PWR_KILL, GPIO_MODE_OUTPUT));
|
||||
ESP_ERROR_CHECK(gpio_set_level(PWR_KILL, 1));
|
||||
ESP_ERROR_CHECK(gpio_set_pull_mode(PWR_INT, GPIO_FLOATING));
|
||||
ESP_ERROR_CHECK(gpio_set_intr_type(PWR_INT, GPIO_INTR_NEGEDGE));
|
||||
ESP_ERROR_CHECK(gpio_set_intr_type(PWR_INT, GPIO_INTR_LOW_LEVEL));
|
||||
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());
|
||||
ESP_ERROR_CHECK(gpio_wakeup_enable(PWR_INT, GPIO_INTR_LOW_LEVEL));
|
||||
ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
||||
ESP_ERROR_CHECK(gpio_hold_en(PWR_KILL));
|
||||
gpio_isr_handler_add(PWR_INT, shutdown, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user