[bsp/es32f0654] add pm driver

This commit is contained in:
wangyq2018 2019-04-02 15:24:50 +08:00
parent 2236024de0
commit e6a4ad7bf3
7 changed files with 146 additions and 0 deletions

View File

@ -359,6 +359,11 @@ CONFIG_BSP_USING_UART2=y
# #
# CONFIG_BSP_USING_RTC is not set # CONFIG_BSP_USING_RTC is not set
#
# PM Drivers
#
# CONFIG_BSP_USING_PM is not set
# #
# Onboard Peripheral Drivers # Onboard Peripheral Drivers
# #

View File

@ -43,6 +43,7 @@ ES-PDS-ES32F0654-V1.1
| PWM | 支持 | PWM0/1/2/3 | | PWM | 支持 | PWM0/1/2/3 |
| TIMER | 支持 | TIMER0/1/2/3 | | TIMER | 支持 | TIMER0/1/2/3 |
| RTC | 支持 | RTC | | RTC | 支持 | RTC |
| PM | 支持 | Power Management |
### 1.2 注意事项 ### 1.2 注意事项

View File

@ -109,6 +109,13 @@ menu "Hardware Drivers Config"
default n default n
endmenu endmenu
menu "PM Drivers"
config BSP_USING_PM
bool "Using PM"
select RT_USING_PM
default n
endmenu
endmenu endmenu
menu "Onboard Peripheral Drivers" menu "Onboard Peripheral Drivers"

View File

@ -39,6 +39,10 @@ if GetDepend('BSP_USING_HWTIMER0') or GetDepend('BSP_USING_HWTIMER1') or GetDepe
if GetDepend(['BSP_USING_RTC']): if GetDepend(['BSP_USING_RTC']):
src += ['drv_rtc.c'] src += ['drv_rtc.c']
# add pm driver code
if GetDepend(['BSP_USING_PM']):
src += ['drv_pm.c']
CPPPATH = [cwd] CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)

View File

@ -0,0 +1,110 @@
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-04-01 wangyq the first version
*/
#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)
{
rt_uint32_t mode;
mode = pm->current_mode;
switch (mode)
{
case PM_RUN_MODE_NORMAL:
break;
case PM_SLEEP_MODE_SLEEP:
__WFI();
break;
case PM_SLEEP_MODE_TIMER:
pmu_stop2_enter();
break;
case PM_SLEEP_MODE_SHUTDOWN:
pmu_standby_enter(PMU_STANDBY_PORT_NONE);
break;
default:
RT_ASSERT(0);
break;
}
}
static void _drv_pm_exit(struct rt_pm *pm)
{
rt_uint32_t mode;
RT_ASSERT(pm != RT_NULL);
mode = pm->current_mode;
switch (mode)
{
case PM_RUN_MODE_NORMAL:
break;
case PM_SLEEP_MODE_SLEEP:
break;
case PM_SLEEP_MODE_TIMER:
break;
case PM_SLEEP_MODE_SHUTDOWN:
break;
default:
RT_ASSERT(0);
break;
}
}
#if PM_RUN_MODE_COUNT > 1
static void _drv_pm_frequency_change(struct rt_pm *pm, rt_uint32_t frequency)
{
return;
}
#endif
static int drv_hw_pm_init(void)
{
static const struct rt_pm_ops _ops =
{
_drv_pm_enter,
_drv_pm_exit,
#if PM_RUN_MODE_COUNT > 1
_drv_pm_frequency_change,
#endif
RT_NULL,
RT_NULL,
RT_NULL
};
rt_uint8_t timer_mask;
/* initialize timer mask */
timer_mask = 1UL << PM_SLEEP_MODE_TIMER;
/* initialize system pm module */
rt_system_pm_init(&_ops, timer_mask, RT_NULL);
return 0;
}
INIT_BOARD_EXPORT(drv_hw_pm_init);
#endif

View File

@ -0,0 +1,16 @@
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-04-01 wangyq the first version
*/
#ifndef DRV_PM_H__
#define DRV_PM_H__
int rt_hw_pm_init(void);
#endif

View File

@ -178,6 +178,9 @@
/* RTC Drivers */ /* RTC Drivers */
/* PM Drivers */
/* Onboard Peripheral Drivers */ /* Onboard Peripheral Drivers */