MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_system_pm_init

Function rt_system_pm_init

components/drivers/pm/pm.c:992–1041  ·  view source on GitHub ↗

* This function will initialize power management. * * @param ops the PM operations. * @param timer_mask indicates which mode has timer feature. * @param user_data user data */

Source from the content-addressed store, hash-verified

990 * @param user_data user data
991 */
992void rt_system_pm_init(const struct rt_pm_ops *ops,
993 rt_uint8_t timer_mask,
994 void *user_data)
995{
996 struct rt_device *device;
997 struct rt_pm *pm;
998
999 pm = &_pm;
1000 device = &(_pm.parent);
1001
1002 device->type = RT_Device_Class_PM;
1003 device->rx_indicate = RT_NULL;
1004 device->tx_complete = RT_NULL;
1005
1006#ifdef RT_USING_DEVICE_OPS
1007 device->ops = &pm_ops;
1008#else
1009 device->init = RT_NULL;
1010 device->open = RT_NULL;
1011 device->close = RT_NULL;
1012 device->read = _rt_pm_device_read;
1013 device->write = _rt_pm_device_write;
1014 device->control = _rt_pm_device_control;
1015#endif
1016 device->user_data = user_data;
1017
1018 /* register PM device to the system */
1019 rt_device_register(device, "pm", RT_DEVICE_FLAG_RDWR);
1020
1021 rt_memset(pm->modes, 0, sizeof(pm->modes));
1022 pm->sleep_mode = _pm_default_sleep;
1023
1024 /* when system power on, set default sleep modes */
1025 pm->modes[pm->sleep_mode] = 1;
1026 pm->module_status[PM_POWER_ID].req_status = 1;
1027 pm->run_mode = RT_PM_DEFAULT_RUN_MODE;
1028 pm->timer_mask = timer_mask;
1029
1030 pm->ops = ops;
1031
1032 pm->device_pm = RT_NULL;
1033
1034 rt_slist_init(&pm->device_list);
1035
1036#if IDLE_THREAD_STACK_SIZE <= 256
1037 #error "[pm.c ERR] IDLE Stack Size Too Small!"
1038#endif
1039
1040 _pm_init_flag = 1;
1041}
1042
1043#ifdef RT_USING_FINSH
1044#include <finsh.h>

Callers 12

drv_pm_hw_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
rt_hw_pm_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
drv_pm_hw_initFunction · 0.85
rt_hw_pm_initFunction · 0.85
rt_hw_pm_initFunction · 0.85
rt_hw_pm_initFunction · 0.85

Calls 3

rt_device_registerFunction · 0.85
rt_memsetFunction · 0.85
rt_slist_initFunction · 0.85

Tested by

no test coverage detected