Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
cascoda_btn.c File Reference
Include dependency graph for cascoda_btn.c:

Functions

ca_error Btn_RegisterLEDOutput (uint8_t ledBtn)
 Register LED output (open drain) More...
 
ca_error Btn_RegisterButtonInput (uint8_t ledBtn)
 Register button input. More...
 
ca_error Btn_RegisterButtonIRQInput (uint8_t ledBtn)
 Register button input with interrupt (for sleepy devices) More...
 
ca_error Btn_RegisterSharedButtonLED (uint8_t ledBtn)
 Register button as shared input/output. More...
 
ca_error Btn_RegisterSharedIRQButtonLED (uint8_t ledBtn)
 Register button as shared input/output with interrupt (for sleepy devices) More...
 
ca_error Btn_DeRegister (uint8_t ledBtn)
 De-Register an LED or Button Pin. More...
 
ca_error Btn_SetButtonShortPressCallback (uint8_t ledBtn, btn_callback callback, void *context, uint8_t shortPressMode)
 Set a callback function to a button when it is short pressed. More...
 
ca_error Btn_SetButtonLongPressCallback (uint8_t ledBtn, btn_callback callback, void *context, uint32_t timeThreshold)
 Set a callback function to a button when it is long pressed. More...
 
ca_error Btn_SetButtonHoldCallback (uint8_t ledBtn, btn_callback callback, void *context, uint32_t TimeInterval)
 Set a callback function to a button when it is held. More...
 
ca_error Btn_SetLED (uint8_t ledBtn, uint8_t val)
 Set the state of the LED. More...
 
ca_error Btn_Sense (uint8_t ledBtn, uint8_t *val)
 Get the state of the LED/Button. More...
 
ca_error Btn_SenseOutput (uint8_t ledBtn, uint8_t *val)
 Get the output state of the LED. More...
 
ca_error Btn_PollButtons (void)
 Main polling function to activate callbacks for any buttons that are currently being pressed. More...
 
ca_error Btn_HandleButtonCallbacks (btn_callback_info *callback, uint8_t pressed)
 Process the button callbacks and timing. More...
 
void Btn_IncrementGPIOWakeup (void)
 One additional GPIO is now being used for wakeup. More...
 
ca_error Btn_DecrementGPIOWakeup (void)
 One fewer GPIO is now being used for wakeup. More...
 
void Btn_SetSleepPermanently (void)
 Register that the device will be put to sleep permanently. More...
 
bool Btn_CanSleep (void)
 Check if all buttons have been handled. More...
 
ca_error Btn_DevboardSleep (uint32_t aSleepTime, struct ca821x_dev *pDeviceRef)
 Put board to sleep / powerdown. More...
 

Variables

uint8_t registeredPinMappings [NUM_LEDBTN]
 

Function Documentation

◆ Btn_CanSleep()

bool Btn_CanSleep ( void  )

Check if all buttons have been handled.

Returns
true/false

◆ Btn_DecrementGPIOWakeup()

ca_error Btn_DecrementGPIOWakeup ( void  )

One fewer GPIO is now being used for wakeup.

Returns
status

◆ Btn_DeRegister()

ca_error Btn_DeRegister ( uint8_t  ledBtn)

De-Register an LED or Button Pin.

Parameters
ledBtn- reference to LED/Button
Returns
status

◆ Btn_DevboardSleep()

ca_error Btn_DevboardSleep ( uint32_t  aSleepTime,
struct ca821x_dev pDeviceRef 
)

Put board to sleep / powerdown.

Returns
status

◆ Btn_HandleButtonCallbacks()

ca_error Btn_HandleButtonCallbacks ( btn_callback_info callback,
uint8_t  pressed 
)

Process the button callbacks and timing.

Parameters
callback- callback info struct for button
pressed- the state of the Button

◆ Btn_IncrementGPIOWakeup()

void Btn_IncrementGPIOWakeup ( void  )

One additional GPIO is now being used for wakeup.

◆ Btn_PollButtons()

ca_error Btn_PollButtons ( void  )

Main polling function to activate callbacks for any buttons that are currently being pressed.

Returns
status

◆ Btn_RegisterButtonInput()

ca_error Btn_RegisterButtonInput ( uint8_t  ledBtn)

Register button input.

Parameters
ledBtn- reference to button
Returns
status

◆ Btn_RegisterButtonIRQInput()

ca_error Btn_RegisterButtonIRQInput ( uint8_t  ledBtn)

Register button input with interrupt (for sleepy devices)

Parameters
ledBtn- reference to button
Returns
status

◆ Btn_RegisterLEDOutput()

ca_error Btn_RegisterLEDOutput ( uint8_t  ledBtn)

Register LED output (open drain)

Parameters
ledBtn- reference to LED
Returns
status

◆ Btn_RegisterSharedButtonLED()

ca_error Btn_RegisterSharedButtonLED ( uint8_t  ledBtn)

Register button as shared input/output.

Parameters
ledBtn- reference to button
Returns
status

◆ Btn_RegisterSharedIRQButtonLED()

ca_error Btn_RegisterSharedIRQButtonLED ( uint8_t  ledBtn)

Register button as shared input/output with interrupt (for sleepy devices)

Parameters
ledBtn- reference to button
Returns
status

◆ Btn_Sense()

ca_error Btn_Sense ( uint8_t  ledBtn,
uint8_t *  val 
)

Get the state of the LED/Button.

Parameters
ledBtn- reference to LED/Button
val- the state of the LED/Button
Returns
status

◆ Btn_SenseOutput()

ca_error Btn_SenseOutput ( uint8_t  ledBtn,
uint8_t *  val 
)

Get the output state of the LED.

Parameters
ledBtn- reference to LED
val- the state of the LED
Returns
status

◆ Btn_SetButtonHoldCallback()

ca_error Btn_SetButtonHoldCallback ( uint8_t  ledBtn,
btn_callback  callback,
void *  context,
uint32_t  TimeInterval 
)

Set a callback function to a button when it is held.

Parameters
ledBtn- reference to LED/Button
callback- function to call
context- context for the callback, should be set to NULL if not context is needed.
TimeInterval- time interval in [ms] in which callback function is called
Returns
status

◆ Btn_SetButtonLongPressCallback()

ca_error Btn_SetButtonLongPressCallback ( uint8_t  ledBtn,
btn_callback  callback,
void *  context,
uint32_t  timeThreshold 
)

Set a callback function to a button when it is long pressed.

Parameters
ledBtn- reference to LED/Button
callback- function to call
context- context for the callback, should be set to NULL if not context is needed.
timeThreshold- time above which a button press is considered a long press
Returns
status

◆ Btn_SetButtonShortPressCallback()

ca_error Btn_SetButtonShortPressCallback ( uint8_t  ledBtn,
btn_callback  callback,
void *  context,
uint8_t  shortPressMode 
)

Set a callback function to a button when it is short pressed.

Parameters
ledBtn- reference to LED/Button
callback- function to call
context- context for the callback, should be set to NULL if no context is needed.
shortPressMode- short press mode (when pressed or when released).
Returns
status

◆ Btn_SetLED()

ca_error Btn_SetLED ( uint8_t  ledBtn,
uint8_t  val 
)

Set the state of the LED.

Parameters
ledBtn- reference to LED
val- the state of the LED
Returns
status

◆ Btn_SetSleepPermanently()

void Btn_SetSleepPermanently ( void  )

Register that the device will be put to sleep permanently.

Variable Documentation

◆ registeredPinMappings

uint8_t registeredPinMappings[NUM_LEDBTN]