Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
118
Ver.1.0.0
The absolute wakeup_tick value must be within the range 32 bits can represent, the
maximum sleep time configured by this API is limited. In current design, maximum
sleep time is set as 3/4 of the maximum scope 32 bits can represent. For 16MHz
clock, 32 bits can represent about 268s, the maximum suspend/deepsleep should be
268s*3/4=201s.
The int return value is one or “logic or” result of the five values below.
enum
{
WAKEUP_STATUS_COMP
= BIT(0),
WAKEUP_STATUS_TIMER
= BIT(1),
WAKEUP_STATUS_CORE
= BIT(2),
WAKEUP_STATUS_PAD
= BIT(3),
STATUS_GPIO_ERR_NO_ENTER_PM
= BIT(7),
STATUS_ENTER_SUSPEND = BIT(30),
};
1) WAKEUP_STATUS_COMP is never used in BLE SDK, users do not need to know it.
2) WAKEUP_STATUS_TIMER/ WAKEUP_STATUS_CORE/ WAKEUP_STATUS_PAD
correspond to PM_WAKEUP_TIMER/ PM_WAKEUP_CORE/ PM_WAKEUP_PAD,
which represents the current low power mode is woken up by the wakeup sources.
3)
STATUS_GPIO_ERR_NO_ENTER_PM
is a special state, and indicates a GPIO wakeup
error occurs currently. E.g. When a GPIO CORE high level wakeup is configured,
when this GPIO is high level, it tries to invoke “cpu_sleep_wakeup” to enter suspend
and wakeup sourc
e is set as “PM_WAKEUP_CORE”. In this case, MCU cannot
enter suspend, but will exit “cpu_sleep_wakeup” immediately and return the value
STATUS_GPIO_ERR_NO_ENTER_PM
.
4)
STATUS_ENTER_SUSPEND
represents the status enters suspend successfully.
5) The return value may be (
WAKEUP_STATUS_TIMER | WAKEUP_STATUS_CORE
)
and
it means two wakeup sources take effect simultaneously.
Generally the following method is used to control sleep time:
cpu_sleep_wakeup (0, PM_WAKEUP_TIMER, clock_time() + delta_Tick);
“delta_Tick” is a relative time (e.g. 100*CLOCK_SYS_CLOCK_1MS). The result of
“clock_time()” plus “delta_Tick” is absolute time.
Examples for cpu_sleep_wakeup usage:
1) cpu_sleep_wakeup (0, PM_WAKEUP_CORE, 0);
MCU enters suspend mode when this function is executed, and it can be woken up
by GPIO CORE only.
2) cpu_sleep_wakeup (0, PM_WAKEUP_TIMER, clock_time() +
10*
CLOCK_SYS_CLOCK_1MS
);
MCU enters suspend mode when this function is executed, and it can be woken up
by TIMER only; suspend time is 10ms, i.e. wakeup time is function execution
moment plus 10ms.