See Button Control for documentation.

License#

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.

/***************************************************************************/
#define BUTTON_PRESSED  1

#define BUTTON_RELEASED 0

void halInternalInitButton(void);

uint8_t halButtonState(uint8_t button);

uint8_t halButtonPinState(uint8_t button);

void halButtonIsr(uint8_t button, uint8_t state);

Button State Definitions#

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

#define

Button state is pressed.

#define

Button state is released.

Functions#

void

Initializes the buttons. This function is automatically called by halInit().

uint8_t
halButtonState(uint8_t button)

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

uint8_t
halButtonPinState(uint8_t button)

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

void
halButtonIsr(uint8_t button, uint8_t state)

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

Button State Definitions Documentation#

BUTTON_PRESSED#

#define BUTTON_PRESSED
Value:
1

Button state is pressed.


Definition at line 32 of file /mnt/raid/workspaces/ws.GB1qsZ2Je/overlay/gsdk/platform/base/hal/micro/button.h

BUTTON_RELEASED#

#define BUTTON_RELEASED
Value:
0

Button state is released.


Definition at line 36 of file /mnt/raid/workspaces/ws.GB1qsZ2Je/overlay/gsdk/platform/base/hal/micro/button.h

Function Documentation#

halInternalInitButton#

void halInternalInitButton (void )

Initializes the buttons. This function is automatically called by halInit().

Parameters
N/A

Definition at line 43 of file /mnt/raid/workspaces/ws.GB1qsZ2Je/overlay/gsdk/platform/base/hal/micro/button.h

halButtonState#

uint8_t halButtonState (uint8_t button)

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

Parameters
N/Abutton

The button being queried, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER.

Note

  • This function is correlated with halButtonIsr() and so returns the shadow state rather than reading the actual state of the pin.

Returns


Definition at line 56 of file /mnt/raid/workspaces/ws.GB1qsZ2Je/overlay/gsdk/platform/base/hal/micro/button.h

halButtonPinState#

uint8_t halButtonPinState (uint8_t button)

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

Parameters
N/Abutton

The button being queried, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER.

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 70 of file /mnt/raid/workspaces/ws.GB1qsZ2Je/overlay/gsdk/platform/base/hal/micro/button.h

halButtonIsr#

void halButtonIsr (uint8_t button, uint8_t state)

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

Parameters
N/Abutton

The button which has changed state, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER.

N/Astate

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.

  • Application Usage:\n 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 86 of file /mnt/raid/workspaces/ws.GB1qsZ2Je/overlay/gsdk/platform/base/hal/micro/button.h