sdk ver 2.2.5
example:w_uart
Create a task and implement the following code :
static void set_event(void *param)
{
OSA_EventSet(event, 1);
}
static tmrTimerID_t p_timer = gTmrInvalidTimerID_c;
void test_service()
{
uint32_t count = 0;
osaStatus_t status;
osaEventFlags_t flags = 0;
p_timer = TMR_AllocateTimer();
TMR_StartLowPowerTimer(p_timer, gTmrLowPowerIntervalMillisTimer_c, 200, set_event, NULL);
event = OSA_EventCreate(true);
for (;;) {
status = OSA_EventWait(event, ~0, false, 1000, &flags);
if (status == osaStatus_Success && (flags & 1)) {
if (++count >= 300) {
count = 0;
PWR_DisallowDeviceToSleep();
printf("test.........\n");//1分钟打印一次
PWR_AllowDeviceToSleep();
}
}
}
}
The execution result is shown in the figure. After entering low power consumption, the timing is inaccurate