Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
127
Ver.1.0.0
“BLT_EV_FLAG_SUSPEND_ENTER” callback, if current state is Conn state, and
wakeup time for the following suspend is more than 80ms from current time, GPIO CORE
wakeup will be added. If timer wakeup is not triggered yet, and GPIO level changes due
to key press, MCU wakeup is triggered in advan
ce, so that key press won’t be lost and
key scan task can be processed.
4.5.2 bls_pm_enableAdvMcuStall
The API below is used to decrease peak current during advertising.
void
bls_pm_enableAdvMcuStall
(
u8
en);
en: 1 - Enable MCU stall; 0 - Disable MCU stall.
Please note that Timer1 is used in stack bottom layer to implement MCU stall during
advertising. If this power optimization is added, APP layer should not use Timer1.
4.6 Notes about GPIO Wakeup
4.6.1 Fail to Enter Suspend/Deepsleep When Wakeup Level is
Valid
Since TLSR8232 CORE/PAD wakeup is triggered by high/low level rather than
positive/negative edge, after GPIO CORE or PAD source is configured, e.g. MCU is
configured to wake up from suspend by high level of certain GPIO CORE, the GPIO input
must be low lev
el when MCU invokes “cpu_wakeup_sleep” to enter suspend. If the GPIO
is already high level input currently, the configuration won’t take effect, and Slave doesn’t
enter suspend. This also applies to GPIO PAD wakeup.
The situation above may lead to unexpected problems. For example, MCU is expected to
enter deepsleep and execute firmware after wakeup; however, MCU can’t enter
deepsleep and continues to execute the code unexpectedly, thus firmware running flow
may be messed.
In code of 5316 ble remote, a solution is given to solve the problem.
Via configuration in “BLT_EV_FLAG_SUSPEND_ENTER”, GPIO CORE wakeup won’t
be enabled unless suspend time exceeds the specified time.
void
ble_remote_set_sleep_wakeup
(
u8
e,
u8
*p,
int
n)
{
if
( bls_ll_getCurrentState() == BLS_LINK_STATE_CONN &&
((
u32
)(bls_pm_getSystemWakeupTick() - clock_time())) >
80 *
CLOCK_SYS_CLOCK_1MS
)
{
bls_pm_setWakeupSource(
PM_WAKEUP_CORE
);
}
}
When there is key not released, users
can ensure suspend time won’t exceed 80ms by
manually setting latency as 0 or a small value, thus GPIO CORE high-
level wakeup won’t
be enabled with key held (high level in drive pin). The sample code is shown as below: