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;
165 const bool negative_logic;
167#if GPIO_HAL_PORT_PIN_NUMBERING
179 uint8_t press_duration_seconds;
189 const uint8_t unique_id;
192#if BUTTON_HAL_WITH_DESCRIPTION
193#if GPIO_HAL_PORT_PIN_NUMBERING
204#define BUTTON_HAL_BUTTON(name, descr, po, pi, u, id, nl) \
205 static button_hal_button_t name = { \
206 .description = descr, \
211 .negative_logic = nl, \
214#define BUTTON_HAL_BUTTON(name, descr, pi, u, id, nl) \
215 static button_hal_button_t name = { \
216 .description = descr, \
220 .negative_logic = nl, \
231#define BUTTON_HAL_GET_DESCRIPTION(b) (b)->description
235#if GPIO_HAL_PORT_PIN_NUMBERING
236#define BUTTON_HAL_BUTTON(name, descr, po, pi, u, id, nl) \
237 static button_hal_button_t name = { \
242 .negative_logic = nl, \
245#define BUTTON_HAL_BUTTON(name, descr, pi, u, id, nl) \
246 static button_hal_button_t name = { \
250 .negative_logic = nl, \
254#define BUTTON_HAL_GET_DESCRIPTION(b) ""
257#define BUTTON_HAL_BUTTONS(...) \
258 button_hal_button_t *button_hal_buttons[] = {__VA_ARGS__, NULL}; \
259 const uint8_t button_hal_button_count = \
260 (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.