-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmds_power_management.c
63 lines (56 loc) · 1.65 KB
/
cmds_power_management.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @file
* Offers Power Management commands for Silabs targets only.
* @attention Must be linked for Silabs build targets only.
* @copyright 2022 Silicon Laboratories Inc.
*/
#include <stdint.h>
#include "cmd_handlers.h"
#include "SerialAPI.h"
#include "app.h"
#include "zpal_power_manager.h"
#include "SwTimer.h"
#include "AppTimer.h"
extern zpal_pm_handle_t radio_power_lock;
extern zpal_pm_handle_t io_power_lock;
extern SSwTimer mWakeupTimer;
ZW_ADD_CMD(FUNC_ID_PM_STAY_AWAKE)
{
/* HOST->ZW: PowerLock Type, timeout of stay awake, timeout of wakeup */
/* Power locks type 0 for radio and 1 for peripheral*/
uint32_t timeout = (uint32_t)(frame->payload[1]<<24);
timeout |= (uint32_t)(frame->payload[2]<<16);
timeout |= (uint32_t)(frame->payload[3]<<8);
timeout |= (uint32_t)(frame->payload[4]);
uint32_t timeoutwakeup = (uint32_t)(frame->payload[5]<<24);
timeoutwakeup |= (uint32_t)(frame->payload[6]<<16);
timeoutwakeup |= (uint32_t)(frame->payload[7]<<8);
timeoutwakeup |= (uint32_t)(frame->payload[8]);
if (0 == frame->payload[0])
{
zpal_pm_stay_awake(radio_power_lock, timeout);
}
else if (1 == frame->payload[0])
{
zpal_pm_stay_awake(io_power_lock, timeout);
}
if (timeout && timeoutwakeup)
{
AppTimerDeepSleepPersistentStart(&mWakeupTimer, timeoutwakeup);
}
set_state_and_notify(stateIdle);
}
ZW_ADD_CMD(FUNC_ID_PM_CANCEL)
{
/* HOST->ZW: PowerLock Type*/
/*Power locks type 0 for radio and 1 for peripheral*/
if (0 == frame->payload[0])
{
zpal_pm_cancel(radio_power_lock);
}
else if (1 == frame->payload[0])
{
zpal_pm_cancel(io_power_lock);
}
set_state_and_notify(stateIdle);
}