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

Macros

#define IS_INP(pin)   ((extpin_is_inp >> pin) & 0x01)
 
#define IS_BTN(pin)   ((extpin_is_btn >> pin) & 0x01)
 
#define IS_OUT(pin)   ((extpin_is_out >> pin) & 0x01)
 
#define SET_INP(pin)   (extpin_is_inp |= (0x01 << pin))
 
#define SET_BTN(pin)   (extpin_is_btn |= (0x01 << pin))
 
#define SET_OUT(pin)   (extpin_is_out |= (0x01 << pin))
 
#define CLR_INP(pin)   (extpin_is_inp &= ~(0x01 << pin))
 
#define CLR_BTN(pin)   (extpin_is_btn &= ~(0x01 << pin))
 
#define CLR_OUT(pin)   (extpin_is_out &= ~(0x01 << pin))
 

Functions

ca_error Btn_RegisterOutputExt (uint8_t ledBtn)
 Set the functionality as output/LED. More...
 
ca_error Btn_RegisterButtonInputExt (uint8_t ledBtn)
 Set the functionality of a button to be an input. More...
 
ca_error Btn_RegisterGeneralInputExt (uint8_t ledBtn)
 Set the functionality to be a general input (no interrupt, polling only) More...
 
ca_error Btn_DeRegisterExt (uint8_t ledBtn)
 De-Register an LED or Button Pin. More...
 
ca_error Btn_CheckOutputExt (uint8_t ledBtn)
 check if valid output/LED More...
 
ca_error Btn_CheckInputOrButtonExt (uint8_t ledBtn)
 check if valid input/Button More...
 
bool Btn_HasButtonExt (void)
 Check if any button declared. More...
 
ca_error Btn_SetButtonShortPressCallbackExt (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_SetButtonLongPressCallbackExt (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_SetButtonHoldCallbackExt (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_PollButtonsExt (uint8_t port)
 Main polling function to activate callbacks for any buttons that are currently being pressed. More...
 
bool Btn_CanSleepExt (void)
 Check if all buttons have been handled. More...
 

Macro Definition Documentation

◆ CLR_BTN

#define CLR_BTN (   pin)    (extpin_is_btn &= ~(0x01 << pin))

◆ CLR_INP

#define CLR_INP (   pin)    (extpin_is_inp &= ~(0x01 << pin))

◆ CLR_OUT

#define CLR_OUT (   pin)    (extpin_is_out &= ~(0x01 << pin))

◆ IS_BTN

#define IS_BTN (   pin)    ((extpin_is_btn >> pin) & 0x01)

◆ IS_INP

#define IS_INP (   pin)    ((extpin_is_inp >> pin) & 0x01)

◆ IS_OUT

#define IS_OUT (   pin)    ((extpin_is_out >> pin) & 0x01)

◆ SET_BTN

#define SET_BTN (   pin)    (extpin_is_btn |= (0x01 << pin))

◆ SET_INP

#define SET_INP (   pin)    (extpin_is_inp |= (0x01 << pin))

◆ SET_OUT

#define SET_OUT (   pin)    (extpin_is_out |= (0x01 << pin))

Function Documentation

◆ Btn_CanSleepExt()

bool Btn_CanSleepExt ( void  )

Check if all buttons have been handled.

Returns
true/false

◆ Btn_CheckInputOrButtonExt()

ca_error Btn_CheckInputOrButtonExt ( uint8_t  ledBtn)

check if valid input/Button

Parameters
ionr- I/O number
val- the state of the input/Button
Returns
status

◆ Btn_CheckOutputExt()

ca_error Btn_CheckOutputExt ( uint8_t  ledBtn)

check if valid output/LED

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

◆ Btn_DeRegisterExt()

ca_error Btn_DeRegisterExt ( uint8_t  ledBtn)

De-Register an LED or Button Pin.

Parameters
ledBtn- reference to LED/Button
Returns
status

◆ Btn_HasButtonExt()

bool Btn_HasButtonExt ( void  )

Check if any button declared.

Parameters
values- the state of all buttons
Returns
true if any button is registered, false if not

◆ Btn_PollButtonsExt()

ca_error Btn_PollButtonsExt ( uint8_t  port)

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

Parameters
port- gpio values read from extender chip
Returns
status

◆ Btn_RegisterButtonInputExt()

ca_error Btn_RegisterButtonInputExt ( uint8_t  ledBtn)

Set the functionality of a button to be an input.

Parameters
ledBtn- reference to button
Returns
status

◆ Btn_RegisterGeneralInputExt()

ca_error Btn_RegisterGeneralInputExt ( uint8_t  ledBtn)

Set the functionality to be a general input (no interrupt, polling only)

Parameters
ledBtn- reference number to input
Returns
status

◆ Btn_RegisterOutputExt()

ca_error Btn_RegisterOutputExt ( uint8_t  ledBtn)

Set the functionality as output/LED.

Parameters
ledBtn- reference to output/LED
Returns
status

◆ Btn_SetButtonHoldCallbackExt()

ca_error Btn_SetButtonHoldCallbackExt ( 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 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_SetButtonLongPressCallbackExt()

ca_error Btn_SetButtonLongPressCallbackExt ( 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 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_SetButtonShortPressCallbackExt()

ca_error Btn_SetButtonShortPressCallbackExt ( 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 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