Sample API functions for using push-buttons. More...

Functions

void halInternalInitButton (void)
 Initializes the buttons. This function is automatically called by halInit(). More...
 
uint8_t halButtonState (uint8_t button)
 Returns the current state (pressed or released) of a button. More...
 
uint8_t halButtonPinState (uint8_t button)
 Returns the current state (pressed or released) of the pin associated with a button. More...
 
void halButtonIsr (uint8_t button, uint8_t state)
 A callback called in interrupt context whenever a button changes its state. More...
 

Button State Definitions

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

#define BUTTON_PRESSED
 Button state is pressed. More...
 
#define BUTTON_RELEASED
 Button state is released. More...
 

Detailed Description

Sample API functions for using push-buttons.

See button.h for source code.

Macro Definition Documentation

#define BUTTON_PRESSED

Button state is pressed.

Definition at line 32 of file button.h.

#define BUTTON_RELEASED

Button state is released.

Definition at line 36 of file button.h.

Function Documentation

void halButtonIsr ( uint8_t  button,
uint8_t  state 
)

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

Application Usage:
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.
Parameters
buttonThe button which has changed state, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER.
stateThe 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.
uint8_t halButtonPinState ( uint8_t  button)

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

This reads the actual state of the pin and can be used on startup to determine the initial position of the buttons.

Parameters
buttonThe button being queried, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER.
Returns
BUTTON_PRESSED if the button is pressed or BUTTON_RELEASED if the button is not pressed.
uint8_t halButtonState ( uint8_t  button)

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

Note
This function is correlated with halButtonIsr() and so returns the shadow state rather than reading the actual state of the pin.
Parameters
buttonThe button being queried, either BUTTON0 or BUTTON1 as defined in the appropriate BOARD_HEADER.
Returns
BUTTON_PRESSED if the button is pressed or BUTTON_RELEASED if the button is not pressed.
void halInternalInitButton ( void  )

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