43 #define BTN_MIN_PRESS_TIME 5
45 #ifndef BTN_SHARED_SENSE_DELAY
46 #define BTN_SHARED_SENSE_DELAY 2
The main ca821x-api include file.
Global error declarations for use across the Cascoda SDK.
ca_error Btn_RegisterButtonInput(uint8_t ledBtn)
Register button input.
Definition: cascoda_btn.c:89
ca_error Btn_HandleButtonCallbacks(btn_callback_info *callback, uint8_t pressed)
Process the button callbacks and timing.
Definition: cascoda_btn.c:324
ca_error Btn_DeRegister(uint8_t ledBtn)
De-Register an LED or Button Pin.
Definition: cascoda_btn.c:181
ca_error Btn_SenseOutput(uint8_t ledBtn, uint8_t *val)
Get the output state of the LED.
Definition: cascoda_btn.c:273
ca_error Btn_DecrementGPIOWakeup(void)
One fewer GPIO is now being used for wakeup.
Definition: cascoda_btn.c:389
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.
Definition: cascoda_btn.c:201
bool Btn_CanSleep(void)
Check if all buttons have been handled.
Definition: cascoda_btn.c:412
ca_error Btn_RegisterSharedButtonLED(uint8_t ledBtn)
Register button as shared input/output.
Definition: cascoda_btn.c:135
ca_error Btn_PollButtons(void)
Main polling function to activate callbacks for any buttons that are currently being pressed.
Definition: cascoda_btn.c:280
btn_shortpress_mode
Definition: cascoda_btn.h:55
@ BTN_SHORTPRESS_RELEASED
Definition: cascoda_btn.h:57
@ BTN_SHORTPRESS_PRESSED
Definition: cascoda_btn.h:56
void Btn_SetSleepPermanently(void)
Register that the device will be put to sleep permanently.
Definition: cascoda_btn.c:405
void Btn_IncrementGPIOWakeup(void)
One additional GPIO is now being used for wakeup.
Definition: cascoda_btn.c:382
ca_error Btn_SetLED(uint8_t ledBtn, uint8_t val)
Set the state of the LED.
Definition: cascoda_btn.c:228
struct btn_callback_info btn_callback_info
Callbacks and associated timers for the buttons.
void(* btn_callback)(void *context)
Definition: cascoda_btn.h:84
btn_pin_int
Definition: cascoda_btn.h:78
@ PIN_INTERRUPT
Definition: cascoda_btn.h:80
@ PIN_NO_INTERRUPT
Definition: cascoda_btn.h:79
ca_error Btn_RegisterLEDOutput(uint8_t ledBtn)
Register LED output (open drain)
Definition: cascoda_btn.c:74
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.
Definition: cascoda_btn.c:219
ca_error Btn_DevboardSleep(uint32_t aSleepTime, struct ca821x_dev *pDeviceRef)
Put board to sleep / powerdown.
Definition: cascoda_btn.c:427
uint8_t registeredPinMappings[]
Definition: cascoda_btn.c:41
ca_error Btn_Sense(uint8_t ledBtn, uint8_t *val)
Get the state of the LED/Button.
Definition: cascoda_btn.c:235
ca_error Btn_RegisterSharedIRQButtonLED(uint8_t ledBtn)
Register button as shared input/output with interrupt (for sleepy devices)
Definition: cascoda_btn.c:157
btn_button_state
Definition: cascoda_btn.h:62
@ BTN_PRESSED
Definition: cascoda_btn.h:63
@ BTN_RELEASED
Definition: cascoda_btn.h:64
ca_error Btn_RegisterButtonIRQInput(uint8_t ledBtn)
Register button input with interrupt (for sleepy devices)
Definition: cascoda_btn.c:111
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.
Definition: cascoda_btn.c:210
btn_pin_type
Definition: cascoda_btn.h:69
@ PINTYPE_BTN
Definition: cascoda_btn.h:72
@ PINTYPE_SHARED
Definition: cascoda_btn.h:73
@ PINTYPE_LED
Definition: cascoda_btn.h:71
@ PINTYPE_NONE
Definition: cascoda_btn.h:70
Type definitions used by Cascoda baremetal drivers.
ca_error
Cascoda error type.
Definition: ca821x_error.h:51
Callbacks and associated timers for the buttons.
Definition: cascoda_btn.h:88
void * shortPressContext
Context for shortPressCallback.
Definition: cascoda_btn.h:90
void * holdContext
Context for holdCallback.
Definition: cascoda_btn.h:96
btn_callback shortPressCallback
Callback function for a short button press.
Definition: cascoda_btn.h:89
uint32_t longPressTimeThreshold
Time limit [ms] above which a button press is considered a long press.
Definition: cascoda_btn.h:99
uint32_t holdTimeLast
Time [ms] when hold callback was last called.
Definition: cascoda_btn.h:101
uint8_t lastState
Last button state.
Definition: cascoda_btn.h:102
uint32_t currentPressTime
Time [ms] when the button has been pressed.
Definition: cascoda_btn.h:98
void * longPressContext
Context for longPressCallback.
Definition: cascoda_btn.h:93
btn_callback holdCallback
Callback function for when the button is held.
Definition: cascoda_btn.h:95
btn_callback longPressCallback
Callback function for a long button press.
Definition: cascoda_btn.h:92
uint8_t shortPressMode
Short Press callback when pressed or on release.
Definition: cascoda_btn.h:103
uint32_t holdTimeInterval
Time interval [ms] for triggering the hold function.
Definition: cascoda_btn.h:100
CA-821x Device reference struct.
Definition: ca821x_api.h:123