Button#

Sample API functions for using push-buttons.

See sl_si91x_button.c for source code.

Modules#

sl_button_t

Button State Definitions#

A set of numerical definitions for use with the button APIs indicating the state of a button.

#define

Interrupt on low/pressed button state can be configured.

#define

Interrupt on high/released button state.

#define

Interrupt on low/pressed and high/released button state.

#define

Interrupt on rising edge of the button press.

#define

Interrupt on falling edge of the button press.

#define

Interrupt on rising edge and falling edge of the button press.

#define

Button state is pressed.

#define

Button state is released.

#define

Button state is invalid.

Functions#

void
sl_si91x_button_init(const sl_button_t *handle)

Initializes the buttons.

int8_t

Returns the current state (pressed or released) of a button.

int8_t

Returns the current state (pressed or released) of the pin associated with a button.

void
sl_si91x_button_pin_isr(uint8_t pin, uint8_t state)

A callback called in interrupt context whenever a button changes its state.

void

Toggles the state (pressed or released) of the pin associated with a button.

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.

void
sl_si91x_button_isr(uint8_t pin, int8_t state)

A callback that user can modify for the application.

Button State Definitions Documentation#

HIGH_LEVEL_INTERRUPT#

#define HIGH_LEVEL_INTERRUPT
Value:
1U

Interrupt on low/pressed button state can be configured.


Definition at line 46 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

LOW_LEVEL_INTERRUPT#

#define LOW_LEVEL_INTERRUPT
Value:
2U

Interrupt on high/released button state.


Definition at line 50 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

HIGH_LEVEL_AND_LOW_LEVEL_INTERRUPT#

#define HIGH_LEVEL_AND_LOW_LEVEL_INTERRUPT
Value:
3U

Interrupt on low/pressed and high/released button state.


Definition at line 54 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

RISE_EDGE_INTERRUPT#

#define RISE_EDGE_INTERRUPT
Value:
4U

Interrupt on rising edge of the button press.


Definition at line 58 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

FALL_EDGE_INTERRUPT#

#define FALL_EDGE_INTERRUPT
Value:
8U

Interrupt on falling edge of the button press.


Definition at line 62 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

RISE_EDGE_AND_FALL_EDGE_INTERRUPT#

#define RISE_EDGE_AND_FALL_EDGE_INTERRUPT
Value:
12U

Interrupt on rising edge and falling edge of the button press.


Definition at line 66 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

BUTTON_PRESSED#

#define BUTTON_PRESSED
Value:
1

Button state is pressed.


Definition at line 70 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

BUTTON_RELEASED#

#define BUTTON_RELEASED
Value:
0

Button state is released.


Definition at line 74 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

BUTTON_STATE_INVALID#

#define BUTTON_STATE_INVALID
Value:
-1

Button state is invalid.


Definition at line 78 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

Function Documentation#

sl_si91x_button_init#

void sl_si91x_button_init (const sl_button_t * handle)

Initializes the buttons.

Parameters
[in]handle

The pointer to button structure that has the specific button information.

This function is automatically called by ::halInit().


Definition at line 95 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

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.

Parameters
[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


Definition at line 108 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

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.

Parameters
[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


Definition at line 122 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

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.

Parameters
[in]pin

The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined.

[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.


Definition at line 138 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

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.

Parameters
[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.


Definition at line 150 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

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.

Parameters
[in]pin

The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined.

[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.


Definition at line 166 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h

sl_si91x_button_isr#

void sl_si91x_button_isr (uint8_t pin, int8_t state)

A callback that user can modify for the application.

Parameters
[in]pin

The button pin which has changed state, either BUTTON0 pin or BUTTON1 pin as defined.

[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.


Definition at line 181 of file components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/inc/sl_si91x_button.h