rt-thread-official/bsp/es32f0334/drivers/drv_pm.c

75 lines
1.4 KiB
C
Raw Normal View History

2019-04-08 10:57:22 +08:00
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-04-08 wangyq the first version
* 2019-05-06 Zero-Free adapt to the new power management interface
2019-04-08 10:57:22 +08:00
*/
#include <rthw.h>
#include <rtdevice.h>
#include "board.h"
#include "drv_pm.h"
#include <ald_pmu.h>
#ifdef RT_USING_PM
static void _drv_pm_enter(struct rt_pm *pm, uint8_t mode)
2019-04-08 10:57:22 +08:00
{
switch (mode)
{
case PM_SLEEP_MODE_NONE:
2019-04-08 10:57:22 +08:00
break;
case PM_SLEEP_MODE_IDLE:
2019-04-08 10:57:22 +08:00
__WFI();
break;
case PM_SLEEP_MODE_LIGHT:
2019-04-08 10:57:22 +08:00
break;
case PM_SLEEP_MODE_DEEP:
pmu_stop2_enter();
2019-04-08 10:57:22 +08:00
break;
case PM_SLEEP_MODE_STANDBY:
pmu_standby_enter(PMU_STANDBY_PORT_NONE);
2019-04-08 10:57:22 +08:00
break;
case PM_SLEEP_MODE_SHUTDOWN:
break;
default:
RT_ASSERT(0);
break;
}
}
static int drv_hw_pm_init(void)
{
static const struct rt_pm_ops _ops =
{
_drv_pm_enter,
RT_NULL,
2019-04-08 10:57:22 +08:00
RT_NULL,
RT_NULL,
RT_NULL
};
rt_uint8_t timer_mask = 0;
2019-04-08 10:57:22 +08:00
/* initialize timer mask(no need tickless) */
// timer_mask = 1UL << PM_SLEEP_MODE_DEEP;
2019-04-08 10:57:22 +08:00
/* initialize system pm module */
rt_system_pm_init(&_ops, timer_mask, RT_NULL);
return 0;
}
INIT_BOARD_EXPORT(drv_hw_pm_init);
#endif