
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
163
Ver.1.0.0
int
det_key = kb_scan_key (0, 1);
if
(det_key){
#if
(STUCK_KEY_PROCESS_ENABLE)
if
(kb_event.
cnt
){
//key press
stuckKey_keyPressTime = clock_time();
}
#endif
.......
}
For each button state update, when button press is detected (i.e. kb_event.cnt is non-
zero value), the “stuckKey_keyPressTime” is used to record the time for the latest button
press state.
Processing in blt_pm_proc is shown as below:
#if
(STUCK_KEY_PROCESS_ENABLE)
if
(key_not_released &&
clock_time_exceed(stuckKey_keyPressTime,
STUCK_KEY_ENTERDEEP_TIME*1000000)){
u32
pin[] = KB_DRIVE_PINS;
for
(
int
i=0; i<(
sizeof
(pin)/
sizeof
(*pin)); i++)
{
extern
u8
stuckKeyPress[];
if
(stuckKeyPress[i]){
cpu_set_gpio_wakeup (pin[i],0,1);
//reverse stuck
key pad wakeup level
}
}
cpu_sleep_wakeup(1,
PM_WAKEUP_PAD,
0);
//deepsleep
}
#endif
Check whether the latest
pressed button is held for more than 60s: if yes, it’s considered
as stuck key, all row numbers with stuck key will be obtained via the bottom-layer
“stuckKeyPress[]”; then modify corresponding PAD wakeup polarity as low level from
high level, so that MCU can enter deepsleep and wake up by button release normally
(when button is pressed, corresponding drive pin reads high level of 10/11 VCC; after
release, the drive pin turns to low level).