Button
Sample API functions for using push-buttons.
See button.h for source code.
Button State Definitions#
A set of numerical definitions for use with the button APIs indicating the state of a button.
Button state is pressed.
Button state is released.
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.
Button State Definitions Documentation#
BUTTON_PRESSED
#define BUTTON_PRESSEDValue:
1
Button state is pressed.
38
of file platform/service/legacy_hal/inc/button.h
BUTTON_RELEASED
#define BUTTON_RELEASEDValue:
0
Button state is released.
42
of file platform/service/legacy_hal/inc/button.h
Function Documentation#
halInternalInitButton
void halInternalInitButton (void )
Initializes the buttons.
N/A |
This function is automatically called by halInit().
49
of file platform/service/legacy_hal/inc/button.h
halButtonState
uint8_t halButtonState (uint8_t button)
Returns the current state (pressed or released) of a button.
N/A | button | 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
BUTTON_PRESSED if the button is pressed or BUTTON_RELEASED if the button is not pressed.
62
of file platform/service/legacy_hal/inc/button.h
halButtonPinState
uint8_t halButtonPinState (uint8_t button)
Returns the current state (pressed or released) of the pin associated with a button.
N/A | button | 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
BUTTON_PRESSED if the button is pressed or BUTTON_RELEASED if the button is not pressed.
76
of file platform/service/legacy_hal/inc/button.h
halButtonIsr
void halButtonIsr (uint8_t button, uint8_t state)
A callback called in interrupt context whenever a button changes its state.
N/A | button | The button which has changed state, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER. |
N/A | 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. |
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.
92
of file platform/service/legacy_hal/inc/button.h