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;
154 #if GPIO_HAL_PORT_PIN_NUMBERING 166 uint8_t press_duration_seconds;
176 const uint8_t unique_id;
179 #if BUTTON_HAL_WITH_DESCRIPTION 180 #if GPIO_HAL_PORT_PIN_NUMBERING 191 #define BUTTON_HAL_BUTTON(name, descr, po, pi, u, id, nl) \ 192 static button_hal_button_t name = { \ 193 .description = descr, \ 198 .negative_logic = nl, \ 201 #define BUTTON_HAL_BUTTON(name, descr, pi, u, id, nl) \ 202 static button_hal_button_t name = { \ 203 .description = descr, \ 207 .negative_logic = nl, \ 218 #define BUTTON_HAL_GET_DESCRIPTION(b) (b)->description 222 #if GPIO_HAL_PORT_PIN_NUMBERING 223 #define BUTTON_HAL_BUTTON(name, descr, po, pi, u, id, nl) \ 224 static button_hal_button_t name = { \ 229 .negative_logic = nl, \ 232 #define BUTTON_HAL_BUTTON(name, descr, pi, u, id, nl) \ 233 static button_hal_button_t name = { \ 237 .negative_logic = nl, \ 241 #define BUTTON_HAL_GET_DESCRIPTION(b) "" 244 #define BUTTON_HAL_BUTTONS(...) \ 245 button_hal_button_t *button_hal_buttons[] = {__VA_ARGS__, NULL}; \ 246 const uint8_t button_hal_button_count = \ 247 (sizeof(button_hal_buttons) / sizeof(button_hal_buttons[0])) - 1;
uint8_t gpio_hal_port_t
A data structure that represents ports.
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.