Simple Button Driver
Description
Simple Button Driver.
Introduction
The Simple Button driver is a module of the button driver that provides the functionality to initialize and read simple buttons.
Simple Button Configuration
Simple buttons use the sl_button_t struct and their sl_simple_button_context_t struct. These are automatically generated into the following files, as well as instance specific headers with macro definitions in them. The samples below are for a single instance called "inst0".
- Note
- The sl_simple_button_instances.c file is shown with only one instance, but if more were in use they would all appear in this .c file.
- Note
- The sl_simple_button_instances.h file is shown with only one instance, but if more were in use they would all appear in this .h file.
Simple Button Usage
The simple button driver has no differences in its usage from the common button driver. See Usage .
Data Structures |
|
struct | sl_simple_button_context_t |
Functions |
|
sl_status_t | sl_simple_button_init (void *context) |
Initialize the simple button driver.
|
|
sl_button_state_t | sl_simple_button_get_state (void *context) |
Get the current state of the simple button.
|
|
void | sl_simple_button_poll_step (void *context) |
Poll the simple button.
|
|
Macros |
|
#define | SL_SIMPLE_BUTTON_MODE_POLL 0U |
#define | SL_SIMPLE_BUTTON_MODE_POLL_AND_DEBOUNCE 1U |
#define | SL_SIMPLE_BUTTON_MODE_INTERRUPT 2U |
#define | SL_SIMPLE_BUTTON_PRESSED 1U |
#define | SL_SIMPLE_BUTTON_RELEASED 0U |
#define | SL_SIMPLE_BUTTON_GET_STATE (context) ( sl_simple_button_get_state ((context))) |
#define | SL_SIMPLE_BUTTON_GET_PORT (context) ((( sl_simple_button_context_t *)(context))->port) |
#define | SL_SIMPLE_BUTTON_GET_PIN (context) ((( sl_simple_button_context_t *)(context))->pin) |
#define | SL_SIMPLE_BUTTON_GET_MODE (context) ((( sl_simple_button_context_t *)(context))->mode) |
Function Documentation
◆ sl_simple_button_init()
sl_status_t sl_simple_button_init | ( | void * |
context
|
) |
Initialize the simple button driver.
- Parameters
-
[in] context
Pointer to simple-button specific data:
- Returns
-
Status Code:
- SL_STATUS_OK
◆ sl_simple_button_get_state()
sl_button_state_t sl_simple_button_get_state | ( | void * |
context
|
) |
Get the current state of the simple button.
- Parameters
-
[in] context
Pointer to simple-button specific data
- Returns
-
Button State: Current state of the button
- SL_SIMPLE_BUTTON_PRESSED
- SL_SIMPLE_BUTTON_RELEASED
◆ sl_simple_button_poll_step()
void sl_simple_button_poll_step | ( | void * |
context
|
) |
Poll the simple button.
(button mode - poll / poll and debonuce)
- Parameters
-
[in] context
Pointer to simple-button specific data