Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
160
Ver.1.0.0
keyscan in mainloop. Data buffer is designed considering valid button data detected in
adv state and pushed into BLE TX FIFO will be cleared after entering connection state.
The macro “DEEPBACK_FAST_KEYSCAN_ENABLE” in app_config.h is used to control
fast keyscan and data buffer.
#define
DEEPBACK_FAST_KEYSCAN_ENABLE 1
void
deep_wakeup_proc
(
void
)
{
#if
(DEEPBACK_FAST_KEYSCAN_ENABLE)
if
(analog_read(DEEP_ANA_REG0) == CONN_DEEP_FLG){
if
(kb_scan_key (KB_NUMLOCK_STATUS_POWERON,1) && kb_event.
cnt
){
deepback_key_state = DEEPBACK_KEY_CACHE;
key_not_released = 1;
memcpy(&kb_event_cache,&kb_event,
sizeof
(kb_event));
}
}
#endif
}
In initialization key scan is processed before user_init. After it
’s detected by reading
retention analog register that MCU enters deep wakeup from connection state, the
“kb_scan_key” is invoked to directly obtain the whole matrix button state without enabling
the debounce filtering. If key scan process shows a button is pressed (button state
update is returned, and kb_event.cnt in non-
zero value), the “kb_event” variable will be
copied to the cache variable “kb_event_cache”.
The “deepback_pre_proc” and “deepback_post_proc” processing are added in keyscan
during mainloop.
void
proc_keyboard
(
u8
e,
u8
*p)
{
kb_event.
keycode
[0] = 0;
int
det_key = kb_scan_key (0, 1);
#if
(DEEPBACK_FAST_KEYSCAN_ENABLE)
if
(deepback_key_state != DEEPBACK_KEY_IDLE){
deepback_pre_proc(&det_key);
}
#endif
if
(det_key){
key_change_proc();