Button Utility. More...

Modules

Types
Button data types.

Functions

gos_result_t gos_button_init ( gos_gpio_t gpio, const gos_button_config_t *config, void *arg)
Initialize GPIO as a button. More...
void gos_button_deinit ( gos_gpio_t gpio)
De-initialize button feature for given GPIO. More...
bool gos_button_is_active ( gos_gpio_t gpio)
Returns if a button is considered active based on its configuration. More...
gos_result_t gos_button_update_config ( gos_gpio_t gpio, const gos_button_config_t *config)
Update a button's configuration. More...

Detailed Description

Button Utility.

Function Documentation

gos_button_deinit()

void gos_button_deinit ( gos_gpio_t gpio )

De-initialize button feature for given GPIO.

Parameters
gpio GPIO to deinitialized as button

gos_button_init()

gos_result_t gos_button_init ( gos_gpio_t gpio,
const gos_button_config_t * config,
void * arg
)

Initialize GPIO as a button.

This configures a GPIO as button. This includes the necessary functionality to debounce the button and execute handlers based on the specified configuration.

Parameters
gpio GPIO to configure as a button
config Button configuration
arg Optional argument to pass to event handlers
Returns
gos_result_t result of api call
Examples:
peripheral/button/main.c .

gos_button_is_active()

bool gos_button_is_active ( gos_gpio_t gpio )

Returns if a button is considered active based on its configuration.

Note
The specified GPIO must first be registered as a button using gos_button_init()
Parameters
gpio GPIO to test
Returns
true if button is active, FALSE else

gos_button_update_config()

gos_result_t gos_button_update_config ( gos_gpio_t gpio,
const gos_button_config_t * config
)

Update a button's configuration.

This updates a button configuration including the:

  • debounce time
  • click_time
  • press_time

All other settings are ignored.

Parameters
gpio GPIO of corresponding button
config Updated configuration
Returns
gos_result_t result of api call