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
121#ifdef BUTTON_HAL_CONF_PORT_COUNT
122#define BUTTON_HAL_PORT_COUNT BUTTON_HAL_CONF_PORT_COUNT
124#define BUTTON_HAL_PORT_COUNT 1
127#define BUTTON_HAL_STATE_RELEASED 0
128#define BUTTON_HAL_STATE_PRESSED 1
133#define BUTTON_HAL_ID_BUTTON_ZERO 0x00
134#define BUTTON_HAL_ID_BUTTON_ONE 0x01
135#define BUTTON_HAL_ID_BUTTON_TWO 0x02
136#define BUTTON_HAL_ID_BUTTON_THREE 0x03
137#define BUTTON_HAL_ID_BUTTON_FOUR 0x04
138#define BUTTON_HAL_ID_BUTTON_FIVE 0x05
140#define BUTTON_HAL_ID_USER_BUTTON BUTTON_HAL_ID_BUTTON_ZERO
147struct button_hal_button_s {
149 struct ctimer debounce_ctimer;
152 struct ctimer duration_ctimer;
154#if BUTTON_HAL_WITH_DESCRIPTION
161 const char *description;
167 const bool negative_logic;
169#if GPIO_HAL_PORT_PIN_NUMBERING
178 uint8_t press_duration_seconds;
188 const uint8_t unique_id;
191#if BUTTON_HAL_WITH_DESCRIPTION
192#if GPIO_HAL_PORT_PIN_NUMBERING
203#define BUTTON_HAL_BUTTON(name, descr, po, pi, u, id, nl) \
204 static button_hal_button_t name = { \
205 .description = descr, \
210 .negative_logic = nl, \
213#define BUTTON_HAL_BUTTON(name, descr, pi, u, id, nl) \
214 static button_hal_button_t name = { \
215 .description = descr, \
219 .negative_logic = nl, \
230#define BUTTON_HAL_GET_DESCRIPTION(b) (b)->description
234#if GPIO_HAL_PORT_PIN_NUMBERING
235#define BUTTON_HAL_BUTTON(name, descr, po, pi, u, id, nl) \
236 static button_hal_button_t name = { \
241 .negative_logic = nl, \
244#define BUTTON_HAL_BUTTON(name, descr, pi, u, id, nl) \
245 static button_hal_button_t name = { \
249 .negative_logic = nl, \
253#define BUTTON_HAL_GET_DESCRIPTION(b) ""
256#define BUTTON_HAL_BUTTONS(...) \
257 button_hal_button_t *button_hal_buttons[] = {__VA_ARGS__, NULL}; \
258 const uint8_t button_hal_button_count = \
259 (sizeof(button_hal_buttons) / sizeof(button_hal_buttons[0])) - 1;
Header file for the callback timer.
Header file for the GPIO HAL.
uint32_t gpio_hal_pin_cfg_t
GPIO pin configuration.
uint8_t gpio_hal_port_t
A data structure that represents ports.
uint8_t gpio_hal_pin_t
GPIO pin number representation.