Merge pull request #2487 from wangyq2018/es32f0654

[bsp/es32f0654] add hwtimer driver
This commit is contained in:
Bernard Xiong authored and GitHub committed 2019-03-25 19:19:09 +08:00
commit c949383704
8 files changed
+322 -12

No files matched your search

+8
View File
@@ -346,6 +346,14 @@ CONFIG_BSP_USING_UART2=y
# CONFIG_BSP_USING_PWM2 is not set
# CONFIG_BSP_USING_PWM3 is not set
#
# HWtimer Drivers
#
# CONFIG_BSP_USING_HWTIMER0 is not set
# CONFIG_BSP_USING_HWTIMER1 is not set
# CONFIG_BSP_USING_HWTIMER2 is not set
# CONFIG_BSP_USING_HWTIMER3 is not set
#
# Onboard Peripheral Drivers
#
+5 -2
View File
@@ -35,14 +35,17 @@ ES-PDS-ES32F0654-V1.1
| **板载外设** | **支持情况** | **备注** |
| :---------------- | :----------: | :------------------------------------|
| SPI FLASH | 支持 | SPI0 |
| **片上外设** | **支持情况** | **备注** |
| :---------------- | :----------: | :------------------------------------|
| GPIO | 支持 | 54 GPIOs |
| UART | 支持 | UART0/1/2/3 |
| SPI | 支持 | SPI0/1 |
| I2C | 支持 | I2C0/1 |
| PWM | 支持 | PWM0/1/2/3 |
| TIMER | 支持 | TIMER0/1/2/3 |
### 1.2 注意事项
- 本BSP中,UART2和TIMER1不能同时使用,UART3和TIMER2不能同时使用
更多详细信息请咨询[上海东软载波微电子技术支持](http://www.essemi.com/)
+32 -4
View File
@@ -16,16 +16,18 @@ menu "Hardware Drivers Config"
bool "Enable UART1 PC10/PC11(T/R)"
select RT_USING_SERIAL
default n
config BSP_USING_UART2
bool "Enable UART2 PC12/PD02(T/R)"
select RT_USING_SERIAL
default y
depends on !BSP_USING_HWTIMER1
config BSP_USING_UART3
bool "Enable UART3 PC04/PC05(T/R)"
select RT_USING_SERIAL
default n
depends on !BSP_USING_HWTIMER2
endmenu
menu "SPI Drivers"
@@ -47,6 +49,7 @@ menu "Hardware Drivers Config"
bool "Enable I2C0 BUS PB08/PB09(SCL/SDA)"
select RT_USING_I2C
default n
config BSP_USING_I2C1
bool "Enable I2C1 BUS PB10/PB11(SCL/SDA)"
select RT_USING_I2C
@@ -62,18 +65,43 @@ menu "Hardware Drivers Config"
config BSP_USING_PWM1
bool "Using PWM1 PB06/PB07/PB08/PB09"
select RT_USING_PWM
default n
default n
config BSP_USING_PWM2
bool "Using PWM2 PA00/PA01"
select RT_USING_PWM
default n
default n
config BSP_USING_PWM3
bool "Using PWM3 PC06/PC07"
select RT_USING_PWM
default n
default n
endmenu
menu "HWtimer Drivers"
config BSP_USING_HWTIMER0
bool "Using timer0"
select RT_USING_HWTIMER
default n
config BSP_USING_HWTIMER1
bool "Using timer1"
select RT_USING_HWTIMER
default n
depends on !BSP_USING_UART2
config BSP_USING_HWTIMER2
bool "Using timer2"
select RT_USING_HWTIMER
default n
depends on !BSP_USING_UART3
config BSP_USING_HWTIMER3
bool "Using timer3"
select RT_USING_HWTIMER
default n
endmenu
endmenu
menu "Onboard Peripheral Drivers"
+4
View File
@@ -31,6 +31,10 @@ if GetDepend('BSP_USING_SPI_FLASH'):
if GetDepend('BSP_USING_PWM0') or GetDepend('BSP_USING_PWM1') or GetDepend('BSP_USING_PWM2') or GetDepend('BSP_USING_PWM3'):
src += ['drv_pwm.c']
# add hwtimer driver code
if GetDepend('BSP_USING_HWTIMER0') or GetDepend('BSP_USING_HWTIMER1') or GetDepend('BSP_USING_HWTIMER2') or GetDepend('BSP_USING_HWTIMER3'):
src += ['drv_hwtimer.c']
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
File diff suppressed because it is too large. Load diff
+16
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-3-19 wangyq the first version
*/
#ifndef DRV_HWTIMER_H__
#define DRV_HWTIMER_H__
int rt_hw_hwtimer_init(void);
#endif
+2 -6
View File
@@ -19,7 +19,7 @@
static void pwm_set_freq(timer_handle_t *timer_initstruct, uint32_t ns)
{
uint64_t _arr = (uint64_t)cmu_get_pclk1_clock() * ns / 1000000000 /
(timer_initstruct->init.prescaler + 1) - 1;
(timer_initstruct->init.prescaler + 1);
WRITE_REG(timer_initstruct->perh->AR, (uint32_t)_arr);
timer_initstruct->init.period = (uint32_t)_arr;
@@ -28,7 +28,7 @@ static void pwm_set_freq(timer_handle_t *timer_initstruct, uint32_t ns)
static void pwm_set_duty(timer_handle_t *timer_initstruct, timer_channel_t ch, uint32_t ns)
{
uint64_t tmp = (uint64_t)cmu_get_pclk1_clock() * ns / 1000000000 /
(timer_initstruct->init.prescaler + 1) - 1;
(timer_initstruct->init.prescaler + 1);
if (ch == TIMER_CHANNEL_1)
WRITE_REG(timer_initstruct->perh->CCVAL1, (uint32_t)tmp);
@@ -38,10 +38,6 @@ static void pwm_set_duty(timer_handle_t *timer_initstruct, timer_channel_t ch, u
WRITE_REG(timer_initstruct->perh->CCVAL3, (uint32_t)tmp);
else if (ch == TIMER_CHANNEL_4)
WRITE_REG(timer_initstruct->perh->CCVAL4, (uint32_t)tmp);
else
{
;/* do nothing */
}
}
static rt_err_t es32f0_pwm_control(struct rt_device_pwm *device, int cmd, void *arg)
+3
View File
@@ -172,6 +172,9 @@
/* PWM Drivers */
/* HWtimer Drivers */
/* Onboard Peripheral Drivers */