Button
Sample API functions for using push-buttons.
See sl_si91x_button.c for source code.
Modules#
Button State Definitions#
A set of numerical definitions for use with the button APIs indicating the state of a button.
Interrupt on low/pressed button state can be configured.
Interrupt on high/released button state.
Interrupt on low/pressed and high/released button state.
Interrupt on rising edge of the button press.
Interrupt on falling edge of the button press.
Interrupt on rising edge and falling edge of the button press.
Button state is pressed.
Button state is released.
Button state is invalid.
Functions#
Initializes the buttons.
Returns the current state (pressed or released) of a button.
Returns the current state (pressed or released) of the pin associated with a button.
A callback called in interrupt context whenever a button changes its state.
Toggles the state (pressed or released) of the pin associated with a button.
Sets the state (pressed or released) of the pin associated with a button.
A callback that user can modify for the application.
Button State Definitions Documentation#
Function Documentation#
sl_si91x_button_init
void sl_si91x_button_init (const sl_button_t * handle)
Initializes the buttons.
Type | Direction | Argument Name | Description |
---|---|---|---|
const sl_button_t * | [in] | handle | The pointer to button structure that has the specific button information. |
This function is automatically called by ::halInit().
sl_si91x_button_state_get
int8_t sl_si91x_button_state_get (uint8_t pin)
Returns the current state (pressed or released) of a button.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | pin | The button pin being queried, either BUTTON0 pin or BUTTON1 pin as defined. |
Note
This function is correlated with sl_si91x_button_isr() and so returns the shadow state rather than reading the actual state of the pin.
Returns
BUTTON_PRESSED if the button is pressed or BUTTON_RELEASED if the button is not pressed.
sl_si91x_button_pin_state
int8_t sl_si91x_button_pin_state (uint8_t pin)
Returns the current state (pressed or released) of the pin associated with a button.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | pin | The button pin being queried, either BUTTON0 pin or BUTTON1 pin as defined. |
This reads the actual state of the pin and can be used on startup to determine the initial position of the buttons.
Returns
BUTTON_PRESSED if the button is pressed or BUTTON_RELEASED if the button is not pressed.
sl_si91x_button_pin_isr
void sl_si91x_button_pin_isr (uint8_t pin, uint8_t state)
A callback called in interrupt context whenever a button changes its state.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | pin | The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined. |
uint8_t | [out] | state | The new state of the button referenced by the button parameter, either BUTTON_PRESSED if the button has been pressed or BUTTON_RELEASED if the button has been released. |
@appusage Must be implemented by the application. This function should contain the functionality to be executed in response to changes of state in each of the buttons, or callbacks to the appropriate functionality.
sl_si91x_button_state_toggle
void sl_si91x_button_state_toggle (uint8_t pin)
Toggles the state (pressed or released) of the pin associated with a button.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | pin | The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined. |
@appusage Must be implemented by the application. This function should contain the functionality to be executed in response to changes of state in each of the buttons, or callbacks to the appropriate functionality.
sl_si91x_button_state_set
void sl_si91x_button_state_set (uint8_t pin, int8_t state)
Sets the state (pressed or released) of the pin associated with a button.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | pin | The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined. |
int8_t | [in] | state | The new state of the button referenced by the button parameter, either BUTTON_PRESSED if the button has been pressed or BUTTON_RELEASED if the button has been released. |
@appusage Must be implemented by the application. This function should contain the functionality to be executed in response to changes of state in each of the buttons, or callbacks to the appropriate functionality.
sl_si91x_button_isr
void sl_si91x_button_isr (uint8_t pin, int8_t state)
A callback that user can modify for the application.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | pin | The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined. |
int8_t | [in] | state | The new state of the button referenced by the button parameter, either BUTTON_PRESSED if the button has been pressed or BUTTON_RELEASED if the button has been released. |
@appusage Must be implemented by the application. This function should contain the functionality to be executed in response to changes of state in each of the buttons, or callbacks to the appropriate functionality.