123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef _IO_H
- #define _IO_H
- #include "esp_common.h"
- #include "driver/gpio16.h"
- #define STATUS_LED 0
- #define SWITCH_A 5
- #define SWITCH_B 2
- #define LDO_SHUTDOWN 4
- #define STATUS_LED_MUX PERIPHS_IO_MUX_GPIO0_U
- #define SWITCH_A_MUX PERIPHS_IO_MUX_GPIO5_U
- #define SWITCH_B_MUX PERIPHS_IO_MUX_GPIO2_U
- #define LDO_SHUTDOWN_MUX PERIPHS_IO_MUX_GPIO4_U
- #define STATUS_LED_FUNC FUNC_GPIO0
- #define SWITCH_A_FUNC FUNC_GPIO5
- #define SWITCH_B_FUNC FUNC_GPIO2
- #define LDO_SHUTDOWN_FUNC FUNC_GPIO4
- #define DEBOUNCEDELAY 10 // ms
- typedef enum {
- IMU_NO_INTERRUPT = 0,
- IMU_FIFO_FULL,
- IMU_FIFO_OVERFLOW,
- IMU_MOTION
- } IMU_Interrupt_et;
- typedef void (* switch_function_t)(uint32_t);
- typedef void (* imu_function_t)(IMU_Interrupt_et);
- typedef struct {
- os_timer_t switch_a_timer;
- os_timer_t switch_b_timer;
- switch_function_t switch_a_cb;
- switch_function_t switch_b_cb;
- imu_function_t imu_cb;
- uint32_t debounce_delay;
- bool debounce_timer;
- } IO_config_t;
- void ICACHE_FLASH_ATTR IO_InitIO(void);
- void ICACHE_FLASH_ATTR IO_Shutdown(void);
- void ICACHE_FLASH_ATTR IO_Restart(void);
- void ICACHE_FLASH_ATTR IO_DisableIOInterrupts(void);
- void ICACHE_FLASH_ATTR IO_EnableIOInterrupts(void);
- void ICACHE_FLASH_ATTR IO_SetSwitchCallback(switch_function_t, switch_function_t);
- void ICACHE_FLASH_ATTR IO_SetIMUCallback(imu_function_t);
- #endif
|