84 #include "sys/clock.h" 97 #ifdef BUTTON_HAL_CONF_DEBOUNCE_DURATION 98 #define BUTTON_HAL_DEBOUNCE_DURATION BUTTON_HAL_CONF_DEBOUNCE_DURATION 100 #define BUTTON_HAL_DEBOUNCE_DURATION (CLOCK_SECOND >> 6) 108 #if BUTTON_HAL_CONF_WITH_DESCRIPTION 109 #define BUTTON_HAL_WITH_DESCRIPTION BUTTON_HAL_CONF_WITH_DESCRIPTION 111 #define BUTTON_HAL_WITH_DESCRIPTION 1 114 #define BUTTON_HAL_STATE_RELEASED 0 115 #define BUTTON_HAL_STATE_PRESSED 1 120 #define BUTTON_HAL_ID_BUTTON_ZERO 0x00 121 #define BUTTON_HAL_ID_BUTTON_ONE 0x01 122 #define BUTTON_HAL_ID_BUTTON_TWO 0x02 123 #define BUTTON_HAL_ID_BUTTON_THREE 0x03 124 #define BUTTON_HAL_ID_BUTTON_FOUR 0x04 125 #define BUTTON_HAL_ID_BUTTON_FIVE 0x05 127 #define BUTTON_HAL_ID_USER_BUTTON BUTTON_HAL_ID_BUTTON_ZERO 134 struct button_hal_button_s {
136 struct ctimer debounce_ctimer;
139 struct ctimer duration_ctimer;
141 #if BUTTON_HAL_WITH_DESCRIPTION 148 const char *description;
152 const bool negative_logic;
161 uint8_t press_duration_seconds;
171 const uint8_t unique_id;
174 #if BUTTON_HAL_WITH_DESCRIPTION 184 #define BUTTON_HAL_BUTTON(name, descr, p, u, id, nl) \ 185 static button_hal_button_t name = { \ 186 .description = descr, \ 190 .negative_logic = nl, \ 200 #define BUTTON_HAL_GET_DESCRIPTION(b) (b)->description 202 #define BUTTON_HAL_BUTTON(name, descr, p, u, id, nl) \ 203 static button_hal_button_t name = { \ 207 .negative_logic = nl, \ 210 #define BUTTON_HAL_GET_DESCRIPTION(b) "" 213 #define BUTTON_HAL_BUTTONS(...) \ 214 button_hal_button_t *button_hal_buttons[] = {__VA_ARGS__, NULL}; \ 215 const uint8_t button_hal_button_count = \ 216 (sizeof(button_hal_buttons) / sizeof(button_hal_buttons[0])) - 1;
Header file for the callback timer
uint8_t gpio_hal_pin_t
GPIO pin number representation.
Header file for the GPIO HAL.
uint32_t gpio_hal_pin_cfg_t
GPIO pin configuration.