diff --git a/bsp/n32/libraries/n32_drivers/SConscript b/bsp/n32/libraries/n32_drivers/SConscript index 107e4d1b333..53caa86963f 100644 --- a/bsp/n32/libraries/n32_drivers/SConscript +++ b/bsp/n32/libraries/n32_drivers/SConscript @@ -45,6 +45,12 @@ if GetDepend(['RT_USING_RTC']): if GetDepend(['RT_USING_WDT']): src += ['drv_wdt.c'] +if GetDepend('BSP_USING_PWM'): + src += ['drv_base.c'] + +if GetDepend(['BSP_USING_PWM']): + src += ['drv_pwm.c'] + path = [cwd] path += [cwd + '/config'] diff --git a/bsp/n32/libraries/n32_drivers/drv_base.c b/bsp/n32/libraries/n32_drivers/drv_base.c new file mode 100644 index 00000000000..558587d154f --- /dev/null +++ b/bsp/n32/libraries/n32_drivers/drv_base.c @@ -0,0 +1,127 @@ +/** + * @file drv_base.c + * @brief + * @author car (1085582540@qq.com) + * @version 1.0 + * @date 2026-01-07 + * + * @copyright Copyright (c) 2026 58 + * + */ +#include + + +#define DBG_TAG "PWM" +#define DBG_LEVEL DBG_LOG +#include +#include "board.h" +/** + * @brief 使能对应GPIO的时钟 + */ +void n32_gpio_rcc_enable(GPIO_Module *gpio_grp) +{ + assert_param(IS_GPIO_ALL_PERIPH(gpio_grp)); + if (GPIOA == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE); + LOG_D("enable gpio rcc GPIOA"); + } + else if (GPIOB == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE); + LOG_D("enable gpio rcc GPIOB"); + } + else if (GPIOC == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOC, ENABLE); + LOG_D("enable gpio rcc GPIOC"); + } + else if (GPIOD == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOD, ENABLE); + LOG_D("enable gpio rcc GPIOD"); + } +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) + else if (GPIOE == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOE, ENABLE); + } +#if defined(SOC_N32G45X) + else if (GPIOF == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOF, ENABLE); + } + else if (GPIOG == gpio_grp) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOG, ENABLE); + } +#endif +#endif +} +/**定时器2的引脚涉及了SWD-JTAG的调试引脚,在复用时需要先设置jSWD-JTAG的复用 + * 复用功能 GPIO端口 + JTMS/SWDIO PA13-----------swd + JTCK/SWCLK A14------------swd + JTDI PA15 + JTDO PB3 + NJTRST PB4 + + * GPIO_ConfigPinRemap(GPIO_RMP_SW_JTAG_SW_ENABLE,ENABLE); +*/ +void gpio_remap_JTAGOFF_SWDON(GPIO_Module *gpio_grp, uint16_t pin) +{ +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) + + if ((GPIOA == gpio_grp && GPIO_PIN_15) || + (GPIOB == gpio_grp && GPIO_PIN_3) || + (GPIOB == gpio_grp && GPIO_PIN_4)) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_AFIO, ENABLE); + GPIO_ConfigPinRemap(GPIO_RMP_SW_JTAG_SW_ENABLE, ENABLE); + } +#endif +} + +/** + * @brief 定时器的时钟使能配置 + */ +void n32_time_rcc_config(TIM_Module *htim) +{ + RT_ASSERT(TIM1 == htim || TIM2 == htim || TIM3 == htim || TIM4 == htim || TIM5 == htim || TIM8 == htim +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) + ); +#else + || TIM9 == htim); +#endif + + if (TIM1 == htim) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_TIM1, ENABLE); + } + else if (TIM2 == htim) + { + RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM2, ENABLE); + } + else if (TIM3 == htim) + { + RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM3, ENABLE); + } + else if (TIM4 == htim) + { + RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM4, ENABLE); + } + else if (TIM5 == htim) + { + RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM5, ENABLE); + } + else if (TIM8 == htim) + { + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_TIM8, ENABLE); + } +#if defined(SOC_N32L43X) || defined(SOC_N32L40X) || defined(SOC_N32G43X) + else if (TIM9 == htim) + { + RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM9, ENABLE); + } +#endif +} diff --git a/bsp/n32/libraries/n32_drivers/drv_base.h b/bsp/n32/libraries/n32_drivers/drv_base.h new file mode 100644 index 00000000000..de911b7e610 --- /dev/null +++ b/bsp/n32/libraries/n32_drivers/drv_base.h @@ -0,0 +1,25 @@ +#ifndef __DRV_BASE__ +#define __DRV_BASE__ +#include "board.h" +/** + * @brief 使能对应GPIO的时钟 + */ + void n32_gpio_rcc_enable(GPIO_Module *gpio_grp); + + /** + * @brief 定时器的时钟使能配置 + */ + void n32_time_rcc_config(TIM_Module *htim); + + /**定时器2的引脚涉及了SWD-JTAG的调试引脚,在复用时需要先设置jSWD-JTAG的复用 + * 复用功能 GPIO端口 + JTMS/SWDIO PA13-----------swd + JTCK/SWCLK A14------------swd + JTDI PA15 + JTDO PB3 + NJTRST PB4 + + * GPIO_ConfigPinRemap(GPIO_RMP_SW_JTAG_SW_ENABLE,ENABLE); +*/ +void gpio_remap_JTAGOFF_SWDON(GPIO_Module *gpio_grp, uint16_t pin); +#endif diff --git a/bsp/n32/libraries/n32_drivers/drv_pwm.c b/bsp/n32/libraries/n32_drivers/drv_pwm.c new file mode 100644 index 00000000000..0d48eead6e9 --- /dev/null +++ b/bsp/n32/libraries/n32_drivers/drv_pwm.c @@ -0,0 +1,981 @@ +/** + * @file drv_pwm.c + * @brief + * @author car (1085582540@qq.com) + * @version 1.0 + * @date 2025-12-02 + * + * @copyright Copyright (c) 2025 58 + * + * 2025-12-2 + * 1.PWM驱动的日志加入标签 + * 2.pwm驱动设置都是设置的周期时间单位ns,脉宽也是时间ns + * 3.pwm驱动使用Kconfig方式配置,将头文件的配置移动到c文件中;定时器1的4个复用通道测试OK + * 4.定时器2的remap=0,测试PA0-PA3输出pwm OK ;remap=3PA15 PB3 PB10 PB11测试OK + * 5.定时器3的remap=0,测试PA6,PA7,PB0,PB1输出pwm OK ;定时器3remap=3 PC6-PC9输出测试OK + * + *2025-12-06 + 1.N32L406的定时器2pwm PA15,PB3,PB10,PB11可用,添加了Kconfig配置 + 2.测试发现tim2 的PA0,PA1,输出pwm异常,PA2,PB11输出正常 + 3.测试发现tim2 的PA8,PA9,PA10,PA11,输出pwm出正常 + 4.测试发现tim3 的PA6,PA7,PB0,PB1,输出pwm出正常 + 5.测试发现tim3 的Pb4,pb5,pc8,pc9,输出pwm出正常 + 6.测试发现tim3 的pc6,pc7,输出pwm出正常 + +2025-12-18 + n32g52x的定时器tim1的pa-pa11的pwm配置加上了,未测试 + */ +#include +#ifdef BSP_USING_PWM + +#define DBG_TAG "PWM" +#include +#define PWM_LOG_E(...) LOG_E(__VA_ARGS__) +#define PWM_LOG_D(...) LOG_I(__VA_ARGS__) + +#include +#include +#include +#include +#include + +#define MAX_PERIOD 0xffff +#define MIN_PERIOD 1 +#define MIN_PULSE 1 + +struct n32_pwm_channel +{ + GPIO_Module *gpio_grp; // pwmgpio + uint16_t pin; // pwm gpio pin + uint16_t pwm_mode; // pwm mode +#if defined(SOC_N32L43X) || defined(SOC_N32L40X) || defined(SOC_N32G43X) + uint32_t gpio_af; // gpio afio +#endif + char *info; +}; + +struct n32_pwm +{ + struct rt_device_pwm pwm_device; // pwm obj + TIM_Module *tim; // timers + struct n32_pwm_channel ch[4]; // chanel + uint32_t prescaler; // pre +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) + uint32_t gpio_af; // afio +#endif + char *name; // +}; + +/** + * @brief new timer object + * + */ +static struct n32_pwm n32_pwm_obj[] = + { +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) +/* ================================================TIM1 CONFIG================================================*/ +#ifdef BSP_USING_TIM1_PWM + { + .tim = TIM1, + .name = "pwm1", + +/****************************CHANEL CFG*********************************** */ + +#ifdef TIM1_REMAP_0 + .gpio_af = 0, + +#ifdef BSP_USING_TIM1_PWM_CH1 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_8, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM1 PWMCH1 PA8", +#endif /* BSP_USING_TIM1_PWM_CH1 */ +#ifdef BSP_USING_TIM1_PWM_CH2 + .ch[1].gpio_grp = GPIOA, + .ch[1].pin = GPIO_PIN_9, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM1 PWMCH2 PA9", +#endif /* BSP_USING_TIM1_PWM_CH2 */ +#ifdef BSP_USING_TIM1_PWM_CH3 + .ch[2].gpio_grp = GPIOA, + .ch[2].pin = GPIO_PIN_10, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM1 PWMCH3 PA10", +#endif /* BSP_USING_TIM1_PWM_CH3 */ +#ifdef BSP_USING_TIM1_PWM_CH4 + .ch[3].gpio_grp = GPIOA, + .ch[3].pin = GPIO_PIN_11, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM1 PWMCH4 PA11", +#endif /* BSP_USING_TIM1_PWM_CH4 */ +#endif /*TIM1_REMAP_0*/ + +#ifdef TIM1_REMAP_3 + .gpio_af = GPIO_ALL_RMP_TIM1, + +#ifdef BSP_USING_TIM1_PWM_CH1 + .ch[0].gpio_grp = GPIOE, + .ch[0].pin = GPIO_PIN_9, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM1 PWMCH1 PE9", +#endif /* TIM1_PWM_CFG_CH1 */ +#ifdef BSP_USING_TIM1_PWM_CH2 + .ch[1].gpio_grp = GPIOE, + .ch[1].pin = GPIO_PIN_11, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM1 PWMCH2 PE11", +#endif /* TIM1_PWM_CFG_CH2 */ +#ifdef BSP_USING_TIM1_PWM_CH3 + .ch[2].gpio_grp = GPIOE, + .ch[2].pin = GPIO_PIN_13, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM1 PWMCH3 PE13", +#endif /* TIM1_PWM_CFG_CH3 */ +#ifdef BSP_USING_TIM1_PWM_CH4 + .ch[3].gpio_grp = GPIOE, + .ch[3].pin = GPIO_PIN_14, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM1 PWMCH4 PE14", +#endif /* TIM1_PWM_CFG_CH4 */ +#endif /*TIM1_REMAP_3*/ + + /*****************************CHANEL CFG************************************ */ + }, +#endif /*BSP_USING_TIM1_PWM*/ + +/* ================================================================================================*/ + +/* ================================================TIM2 CFG================================================*/ +#ifdef BSP_USING_TIM2_PWM + { + .tim = TIM2, + .name = "pwm2", + +/****************************CHANEL CFG*********************************** */ + +#ifdef TIM2_REMAP_0 + .gpio_af = 0, +#endif +#ifdef TIM2_REMAP_1 + .gpio_af = GPIO_PartialRemap1_TIM2, +#endif +#ifdef TIM2_REMAP_2 + .gpio_af = GPIO_PART2_RMP_TIM2, +#endif +#ifdef TIM2_REMAP_3 + .gpio_af = GPIO_ALL_RMP_TIM2, +#endif + +#if defined(TIM2_REMAP_0) || defined(TIM2_REMAP_2) +#ifdef BSP_USING_TIM2_PWM_CH0 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_0, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM2 PWMCH0 PA0", +#endif /*TIM2_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM2_PWM_CH1 + .ch[1].gpio_grp = GPIOA, + .ch[1].pin = GPIO_PIN_1, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM2 PWMCH1 PA1", +#endif /*TIM2_PWM_CFG_CH2 */ +#endif /*TIM2_REMAP_1 TIM2_REMAP_3 */ + +#if defined(TIM2_REMAP_1) || defined(TIM2_REMAP_3) +#ifdef BSP_USING_TIM2_PWM_CH0 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_15, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM2 PWMCH0 PA15", +#endif /*TIM2_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM2_PWM_CH1 + .ch[1].gpio_grp = GPIOB, + .ch[1].pin = GPIO_PIN_3, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM2 PWMCH1 PB3", +#endif /*TIM2_PWM_CFG_CH2 */ +#endif /*defined(TIM2_REMAP_2) ||defined(TIM2_REMAP_4) */ + +#if defined(TIM2_REMAP_0) || defined(TIM2_REMAP_1) +#ifdef BSP_USING_TIM2_PWM_CH2 + .ch[2].gpio_grp = GPIOA, + .ch[2].pin = GPIO_PIN_2, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM2 PWMCH2 PA2", +#endif /*TIM2_PWM_CFG_CH2 */ +#ifdef BSP_USING_TIM2_PWM_CH3 + .ch[3].gpio_grp = GPIOA, + .ch[3].pin = GPIO_PIN_3, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM2 PWMCH3 PA3", +#endif /*TIM2_PWM_CFG_CH2 */ +#endif /*defined(TIM2_REMAP_0) ||defined(TIM2_REMAP_1)*/ + +#if defined(TIM2_REMAP_2) || defined(TIM2_REMAP_3) +#ifdef BSP_USING_TIM2_PWM_CH2 + .ch[2].gpio_grp = GPIOB, + .ch[2].pin = GPIO_PIN_10, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM2 PWMCH2 PB10", +#endif /*TIM2_PWM_CFG_CH2 */ +#ifdef BSP_USING_TIM2_PWM_CH3 + .ch[3].gpio_grp = GPIOB, + .ch[3].pin = GPIO_PIN_11, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM2 PWMCH3 PB11", +#endif /*TIM2_PWM_CFG_CH2 */ +#endif /*defined(TIM2_REMAP_2) ||defined(TIM2_REMAP_3)*/ + +#endif /*BSP_USING_TIM2_PWM*/ + }, + +/* ================================================TIM3 CFG================================================*/ +#ifdef BSP_USING_TIM3_PWM + { + .tim = TIM3, + .name = "pwm3", +#ifdef TIM3_REMAP_0 + .gpio_af = 0, +#endif +#ifdef TIM3_REMAP_2 + .gpio_af = GPIO_PART1_RMP_TIM3, +#endif +#ifdef TIM3_REMAP_3 + .gpio_af = GPIO_ALL_RMP_TIM3, +#endif +#if defined(TIM3_REMAP_0) +#ifdef BSP_USING_TIM3_PWM_CH0 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_6, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM3 PWMCH0 PA6", +#endif /*TIM2_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM3_PWM_CH1 + .ch[1].gpio_grp = GPIOA, + .ch[1].pin = GPIO_PIN_7, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM3 PWMCH1 PA7", +#endif /*TIM2_PWM_CFG_CH2 */ +#endif /*TIM2_REMAP_0 */ + +#if defined(TIM3_REMAP_2) +#ifdef BSP_USING_TIM3_PWM_CH0 + .ch[0].gpio_grp = GPIOB, + .ch[0].pin = GPIO_PIN_4, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM3 PWMCH0 PB4", +#endif /*TIM2_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM3_PWM_CH1 + .ch[1].gpio_grp = GPIOB, + .ch[1].pin = GPIO_PIN_5, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM3 PWMCH1 PB5", +#endif /*TIM2_PWM_CFG_CH2 */ +#endif /*TIM2_REMAP_2 */ + +#if defined(TIM3_REMAP_0) || defined(TIM3_REMAP_2) +#ifdef BSP_USING_TIM3_PWM_CH2 + .ch[2].gpio_grp = GPIOB, + .ch[2].pin = GPIO_PIN_0, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM3 PWMCH2 PB0", +#endif /*BSP_USING_TIM3_PWM_CH2 */ +#ifdef BSP_USING_TIM3_PWM_CH3 + .ch[3].gpio_grp = GPIOB, + .ch[3].pin = GPIO_PIN_1, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM3 PWMCH3 PB1", +#endif /*BSP_USING_TIM3_PWM_CH3 */ +#endif /*defined(TIM3_REMAP_0) || defined(TIM3_REMAP_2)*/ + +#if defined(TIM3_REMAP_3) +#ifdef BSP_USING_TIM3_PWM_CH0 + .ch[0].gpio_grp = GPIOC, + .ch[0].pin = GPIO_PIN_6, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM3 PWMCH0 PC6", +#endif /*BSP_USING_TIM3_PWM_CH0 */ +#ifdef BSP_USING_TIM3_PWM_CH1 + .ch[1].gpio_grp = GPIOC, + .ch[1].pin = GPIO_PIN_7, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM3 PWMCH1 PC7", +#endif /*BSP_USING_TIM3_PWM_CH1 */ +#ifdef BSP_USING_TIM3_PWM_CH2 + .ch[2].gpio_grp = GPIOC, + .ch[2].pin = GPIO_PIN_8, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM3 PWMCH2 PC8", +#endif /*BSP_USING_TIM3_PWM_CH2 */ +#ifdef BSP_USING_TIM3_PWM_CH3 + .ch[3].gpio_grp = GPIOC, + .ch[3].pin = GPIO_PIN_9, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM3 PWMCH3 PC9", +#endif /*BSP_USING_TIM3_PWM_CH3 */ +#endif /*defined(TIM3_REMAP_3)*/ + }, +#endif /*BSP_USING_TIM3_PWM */ + +#else //=========================== defined(SOC_N32L43X) || defined(SOC_N32L40X) || defined(SOC_N32G43X)===================== + +#ifdef BSP_USING_TIM1_PWM //-------------------BSP_USING_TIM1_PWM-------------------------- +#define N32L406_CFG + { + .tim = TIM1, + .name = "pwm1", +#ifdef BSP_USING_TIM1_PWM_CH1 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_8, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, + .ch[0].info = "TIM1 PWMCH1 PA8", + .ch[0].gpio_af = GPIO_AF2_TIM1, +#endif /* TIM1_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM1_PWM_CH2 + .ch[1].gpio_grp = GPIOA, + .ch[1].pin = GPIO_PIN_9, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, + .ch[1].info = "TIM1 PWMCH2 PA9", + .ch[1].gpio_af = GPIO_AF2_TIM1, +#endif /* TIM1_PWM_CFG_CH2 */ +#ifdef BSP_USING_TIM1_PWM_CH3 + .ch[2].gpio_grp = GPIOA, + .ch[2].pin = GPIO_PIN_10, + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].info = "TIM1 PWMCH3 PA10", + .ch[2].gpio_af = GPIO_AF2_TIM1, +#endif /* TIM1_PWM_CFG_CH3 */ +#ifdef BSP_USING_TIM1_PWM_CH4 + .ch[3].gpio_grp = GPIOA, + .ch[3].pin = GPIO_PIN_11, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, + .ch[3].info = "TIM1 PWMCH4 PA11", + .ch[3].gpio_af = GPIO_AF2_TIM1, +#endif /* TIM1_PWM_CFG_CH4 */ + }, +#endif /*-------------------------------------BSP_USING_TIM1_PWM--------------11111------------*/ + +#ifdef BSP_USING_TIM2_PWM //-------------------BSP_USING_TIM2_PWM--------------222222------------ +#define N32L406_CFG_TIM2 + { + .tim = TIM2, + .name = "pwm2", +#ifdef BSP_USING_TIM2_PWM_CH1 +#ifdef TIM2_PWM_CH1_PA0 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_0, + .ch[0].info = "TIM2 PWMCH1 PA0", + .ch[0].gpio_af = GPIO_AF2_TIM2, +#endif /* TIM2_PWM_CH1_PA0 */ +#ifdef TIM2_PWM_CH1_PA15 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_15, + .ch[0].info = "TIM2 PWMCH1 PA15", + .ch[0].gpio_af = GPIO_AF5_TIM2, +#endif /* TIM2_PWM_CH1_PA15 */ + .ch[0].pwm_mode = TIM_OCMODE_PWM1, +#endif /* TIM2_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM2_PWM_CH2 +#ifdef TIM2_PWM_CH2_PA1 + .ch[1].gpio_grp = GPIOA, + .ch[1].pin = GPIO_PIN_1, + .ch[1].info = "TIM2 PWMCH2 PA1", +#endif /* TIM2_PWM_CH2_PA1 */ +#ifdef TIM2_PWM_CH2_PB3 + .ch[1].gpio_grp = GPIOB, + .ch[1].pin = GPIO_PIN_3, + .ch[1].info = "TIM2 PWMCH2 PB3", +#endif /* TIM2_PWM_CH2_PB3 */ + .ch[1].gpio_af = GPIO_AF2_TIM2, + .ch[1].pwm_mode = TIM_OCMODE_PWM1, +#endif /* TIM2_PWM_CFG_CH2 */ +#ifdef BSP_USING_TIM2_PWM_CH3 +#ifdef TIM2_PWM_CH3_PA2 + .ch[2].gpio_grp = GPIOA, + .ch[2].pin = GPIO_PIN_2, + .ch[2].info = "TIM2 PWMCH3 PA2", +#endif /* TIM2_PWM_CH3_PA2 */ +#ifdef TIM2_PWM_CH3_PB10 + .ch[2].gpio_grp = GPIOB, + .ch[2].pin = GPIO_PIN_10, + .ch[2].info = "TIM2 PWMCH3 PB10", +#endif /* TIM2_PWM_CH3_PB10 */ + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].gpio_af = GPIO_AF2_TIM2, +#endif /* TIM2_PWM_CFG_CH3 */ +#ifdef BSP_USING_TIM2_PWM_CH4 + .ch[3].gpio_grp = GPIOB, + .ch[3].pin = GPIO_PIN_11, + .ch[3].info = "TIM2 PWMCH4 PB11", + .ch[3].gpio_af = GPIO_AF2_TIM2, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, +#endif /* TIM2_PWM_CFG_CH4 */ + }, +#endif /*-------------------------------------BSP_USING_TIM2_PWM-------------------222222-------*/ + +#ifdef BSP_USING_TIM3_PWM //-------------------BSP_USING_TIM3_PWM--------------33333333------------ +#define N32L406_CFG_TIM3 + { + .tim = TIM3, + .name = "pwm3", +#ifdef BSP_USING_TIM3_PWM_CH1 +#ifdef TIM3_PWM_CH1_PA6 + .ch[0].gpio_grp = GPIOA, + .ch[0].pin = GPIO_PIN_6, + .ch[0].info = "TIM3 PWMCH1 PA6", + +#endif /* TIM3_PWM_CH1_PA6 */ +#ifdef TIM3_PWM_CH1_PB4 + .ch[0].gpio_grp = GPIOB, + .ch[0].pin = GPIO_PIN_4, + .ch[0].info = "TIM3 PWMCH1 PB4", +#endif /* TIM3_PWM_CH1_PB4 */ +#ifdef TIM3_PWM_CH1_PC6 + .ch[0].gpio_grp = GPIOC, + .ch[0].pin = GPIO_PIN_6, + .ch[0].info = "TIM3 PWMCH1 PC6", +#endif /* TIM3_PWM_CH1_PC6 */ + .ch[0].gpio_af = GPIO_AF2_TIM3, + .ch[0].pwm_mode = TIM_OCMODE_PWM1, +#endif /* TIM3_PWM_CFG_CH1 */ + +#ifdef BSP_USING_TIM3_PWM_CH2 +#ifdef TIM3_PWM_CH2_PA7 + .ch[1].gpio_grp = GPIOA, + .ch[1].pin = GPIO_PIN_7, + .ch[1].info = "TIM3 PWMCH2 PA7", + .ch[1].gpio_af = GPIO_AF2_TIM3, +#endif /* TIM3_PWM_CH2_PA7 */ +#ifdef TIM3_PWM_CH2_PB5 + .ch[1].gpio_grp = GPIOB, + .ch[1].pin = GPIO_PIN_5, + .ch[1].info = "TIM3 PWMCH2 PB5", + .ch[1].gpio_af = GPIO_AF4_TIM3, +#endif /* TIM3_PWM_CH2_PB5 */ +#ifdef TIM3_PWM_CH2_PC7 + .ch[1].gpio_grp = GPIOC, + .ch[1].pin = GPIO_PIN_7, + .ch[1].info = "TIM3 PWMCH2 PC7", + .ch[1].gpio_af = GPIO_AF2_TIM3, +#endif /* TIM3_PWM_CH2_PC7 */ + .ch[1].pwm_mode = TIM_OCMODE_PWM1, +#endif /* TIM3_PWM_CFG_CH2 */ +#ifdef BSP_USING_TIM3_PWM_CH3 +#ifdef TIM3_PWM_CH3_PB0 + .ch[2].gpio_grp = GPIOB, + .ch[2].pin = GPIO_PIN_0, + .ch[2].info = "TIM3 PWMCH3 PB0", +#endif /* TIM3_PWM_CH3_PB0 */ +#ifdef TIM3_PWM_CH3_PC8 + .ch[2].gpio_grp = GPIOC, + .ch[2].pin = GPIO_PIN_8, + .ch[2].info = "TIM3 PWMCH3 PC8", +#endif /* TIM3_PWM_CH3_PC8 */ + .ch[2].pwm_mode = TIM_OCMODE_PWM1, + .ch[2].gpio_af = GPIO_AF2_TIM3, +#endif /* TIM3_PWM_CFG_CH3 */ +#ifdef BSP_USING_TIM3_PWM_CH4 +#ifdef TIM3_PWM_CH4_PB1 + .ch[3].gpio_grp = GPIOB, + .ch[3].pin = GPIO_PIN_1, + .ch[3].info = "TIM3 PWMCH4 PB1", +#endif /* TIM3_PWM_CH4_PB1 */ +#ifdef TIM3_PWM_CH4_PC9 + .ch[3].gpio_grp = GPIOC, + .ch[3].pin = GPIO_PIN_9, + .ch[3].info = "TIM3 PWMCH4 PC9", +#endif /* TIM3_PWM_CH4_PC9 */ + .ch[3].gpio_af = GPIO_AF2_TIM3, + .ch[3].pwm_mode = TIM_OCMODE_PWM1, +#endif /* TIM3_PWM_CFG_CH4 */ + }, +#endif /*-------------------------------------BSP_USING_TIM3_PWM-------------------3333333-------*/ + +#endif +}; + + +/** + * get time fre + */ +static rt_uint32_t tim_clock_get(TIM_Module *htim) +{ + RCC_ClocksType RCC_Clocks; + RCC_GetClocksFreqValue(&RCC_Clocks); + if (htim == TIM1 || htim == TIM8) + { + return RCC_Clocks.Pclk2Freq * 2; + } + else + { + return RCC_Clocks.Pclk1Freq * 2; + } +} + +/** + * + * pwm enable output + * + */ +static rt_err_t drv_pwm_enable(struct n32_pwm *pwm, const rt_uint32_t channel, rt_bool_t enable) +{ + TIM_Module *time = pwm->tim; + + uint16_t tim_ch; + switch (channel) + { + case 0: + tim_ch = TIM_CH_1; + break; + case 1: + tim_ch = TIM_CH_2; + break; + case 2: + tim_ch = TIM_CH_3; + break; + case 3: + tim_ch = TIM_CH_4; + + default: + break; + } + + TIM_EnableCapCmpCh(time, tim_ch, enable ? TIM_CAP_CMP_ENABLE : TIM_CAP_CMP_DISABLE); + + PWM_LOG_D("%s %d ch enable ch = %x ", __FUNCTION__, __LINE__, channel); + return RT_EOK; +} +/* + +*/ +static rt_err_t drv_pwmn_enable(struct n32_pwm *pwm, const rt_uint16_t channel, rt_bool_t enable) +{ + /* Converts the channel number to the channel number of Hal library */ + uint16_t tim_ch; + switch (channel) + { + case 0: + tim_ch = TIM_CH_1; + break; + case 1: + tim_ch = TIM_CH_2; + break; + case 2: + tim_ch = TIM_CH_3; + break; + case 3: + tim_ch = TIM_CH_4; + + default: + break; + } + // enable out + TIM_EnableCapCmpChN(pwm->tim, tim_ch, enable ? TIM_CAP_CMP_N_ENABLE : TIM_CAP_CMP_N_DISABLE); + + return RT_EOK; +} +/** + * @brief set period and duty + */ +static rt_err_t drv_pwm_get(struct n32_pwm *pwm, struct rt_pwm_configuration *configuration) +{ + TIM_Module *htim = pwm->tim; + + TIM_Module *tim = pwm->tim; + // TIM CLK + rt_uint32_t tim_clock = tim_clock_get(tim); + /* convet ns Convert nanosecond to frequency and duty cycle. 1s = 1 * 1000 * 1000 * 1000 ns */ + // UNIT MHz + tim_clock /= 1000000UL; + // period time + uint32_t period = TIM_GetAutoReload(tim) + 1; + uint32_t psc = tim->PSC + 1; + configuration->period = period * psc * 1000UL / tim_clock; + + //nS + uint32_t cmp = 0; + switch (configuration->channel) + { + case 0: + cmp = TIM_GetCap1(htim); + break; + case 1: + cmp = TIM_GetCap2(htim); + break; + case 2: + cmp = TIM_GetCap3(htim); + break; + case 3: + cmp = TIM_GetCap4(htim); + break; + default: + cmp = 0; + break; + } + + configuration->pulse = (cmp + 1) * (psc) * 1000UL / tim_clock; + PWM_LOG_D("period = %d pulse= %d ", __FUNCTION__, __LINE__, configuration->period, configuration->pulse); + + return RT_EOK; +} + +/** + * @brief set peroid + * + * @param pwm + * @param configuration + * @return rt_err_t + */ +static rt_err_t drv_pwm_set_period(struct n32_pwm *pwm, struct rt_pwm_configuration *configuration) +{ + + rt_uint32_t period; + rt_uint64_t tim_clock, psc; + + tim_clock = tim_clock_get(pwm->tim); + /* Convert nanosecond to frequency and duty cycle. 1s = 1 * 1000 * 1000 * 1000 ns */ + tim_clock /= 1000000UL; + period = (rt_uint64_t)configuration->period * tim_clock / 1000ULL; + psc = period / MAX_PERIOD + 1; + period = period / psc; + // 1.set psc + TIM_ConfigPrescaler(pwm->tim, psc - 1, TIM_PSC_RELOAD_MODE_UPDATE); + + if (period < MIN_PERIOD) + { + period = MIN_PERIOD; + } + // 2.set period + TIM_SetAutoReload(pwm->tim, period - 1); + + PWM_LOG_D("%s %d psc=%d period %d ", __FUNCTION__, __LINE__, psc, period); + return RT_EOK; +} +/** + * @brief set duty + * + * @param pwm + * @param configuration + * @return rt_err_t + */ +static rt_err_t drv_pwm_set_pulse(struct n32_pwm *pwm, struct rt_pwm_configuration *configuration) +{ + + rt_uint32_t period, pulse; + rt_uint32_t tim_clock; + /* Converts the channel number to the channel number of Hal library */ + TIM_Module *tim = pwm->tim; + tim_clock = tim_clock_get(tim); + + tim_clock /= 1000000UL; + // caculate period + period = (TIM_GetAutoReload(tim) + 1) * (TIM_GetPrescaler(tim) + 1) * 1000UL / tim_clock; + pulse = (rt_uint64_t)configuration->pulse * (TIM_GetAutoReload(tim) + 1) / period; + + if (pulse < MIN_PULSE) + { + pulse = MIN_PULSE; + } + /*To determine user input, output high level is required*/ + else if (pulse >= period) + { + pulse = period + 1; + } + PWM_LOG_D("pulse = %d", pulse); + // set cmp value + switch (configuration->channel) + { + case 0: + TIM_SetCmp1(tim, pulse); + break; + case 1: + TIM_SetCmp2(tim, pulse); + break; + case 2: + TIM_SetCmp3(tim, pulse); + break; + case 3: + TIM_SetCmp4(tim, pulse); + break; + default: + configuration->pulse = 0; + break; + } + + TIM_SetCnt(tim, 0); + TIM_GenerateEvent(tim, TIM_EVT_SRC_UPDATE); + + return RT_EOK; +} + +static rt_err_t drv_pwm_set(struct n32_pwm *pwm, struct rt_pwm_configuration *configuration) +{ + + rt_uint32_t period, pulse; + rt_uint32_t tim_clock, psc; + /* Converts the channel number to the channel number of Hal library */ + TIM_Module *tim = pwm->tim; + tim_clock = tim_clock_get(tim); + + tim_clock /= 1000000UL; + PWM_LOG_D("TIME CLK = %dMHz,PWM fre = %dHz", tim_clock, 1000 * 1000 * 1000 / configuration->period); + period = (rt_uint64_t)configuration->period * tim_clock / 1000ULL; + // get psc + psc = period / MAX_PERIOD + 1; + // get period + period = period / psc; + + // 1.set psc + TIM_ConfigPrescaler(tim, psc - 1, TIM_PSC_RELOAD_MODE_UPDATE); + + if (period < MIN_PERIOD) + { + period = MIN_PERIOD; + } + // + TIM_SetAutoReload(tim, period - 1); + // PWM_LOG_D("TIME period %d", period); + + pulse = (rt_uint64_t)configuration->pulse * tim_clock / psc / 1000ULL; + if (pulse < MIN_PULSE) + { + pulse = MIN_PULSE; + } + /*To determine user input, output high level is required*/ + else if (pulse >= period) + { + pulse = period + 1; + } + PWM_LOG_D("TIME ch %d = pulse %d psc=%d period=%d", configuration->channel, pulse, psc, period); + + // + switch (configuration->channel) + { + case 0: + TIM_SetCmp1(tim, pulse); + break; + case 1: + TIM_SetCmp2(tim, pulse); + break; + case 2: + TIM_SetCmp3(tim, pulse); + break; + case 3: + TIM_SetCmp4(tim, pulse); + break; + default: + configuration->pulse = 0; + break; + } + + TIM_SetCnt(tim, 0); + TIM_GenerateEvent(tim, TIM_EVT_SRC_UPDATE); + + return RT_EOK; +} + +static rt_err_t drv_pwm_control(struct rt_device_pwm *device, int cmd, void *arg) +{ + struct rt_pwm_configuration *configuration = (struct rt_pwm_configuration *)arg; + struct n32_pwm *pwm = (struct n32_pwm *)device->parent.user_data; + switch (cmd) + { + case PWM_CMD_ENABLE: + // + if (configuration->complementary) + { + drv_pwmn_enable(pwm, configuration->channel, RT_TRUE); + } + return drv_pwm_enable(pwm, configuration->channel, RT_TRUE); + + case PWM_CMD_DISABLE: + if (configuration->complementary) + { + drv_pwmn_enable(pwm, configuration->channel, RT_FALSE); + } + return drv_pwm_enable(pwm, configuration->channel, RT_FALSE); + case PWM_CMD_SET: + + return drv_pwm_set(pwm, configuration); + case PWM_CMD_SET_PERIOD: + return drv_pwm_set_period(pwm, configuration); + case PWM_CMD_SET_PULSE: + return drv_pwm_set_pulse(pwm, configuration); + case PWM_CMD_GET: + return drv_pwm_get(pwm, configuration); + default: + return -RT_EINVAL; + } +} + +/** + * @brief config gpio + */ +static void pwm_time_gpio_config(struct n32_pwm_channel *chanel) + +{ + PWM_LOG_D("%s %d config %s is ok", __FUNCTION__, __LINE__, chanel->info); + GPIO_InitType GPIO_InitStructure; + +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) + + gpio_remap_JTAGOFF_SWDON(chanel->gpio_grp, chanel->pin); + + GPIO_InitStruct(&GPIO_InitStructure); + /* pwm mode gpio cofig*/ + GPIO_InitStructure.Pin = chanel->pin; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitPeripheral(chanel->gpio_grp, &GPIO_InitStructure); + +#elif defined(SOC_N32L43X) || defined(SOC_N32L40X) || defined(SOC_N32G43X) + RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_AFIO, ENABLE); + GPIO_InitStruct(&GPIO_InitStructure); + GPIO_InitStructure.Pin = chanel->pin; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Current = GPIO_DC_4mA; + GPIO_InitStructure.GPIO_Alternate = chanel->gpio_af; + GPIO_InitPeripheral(chanel->gpio_grp, &GPIO_InitStructure); + + // GPIO_ConfigPinRemap(GPIOA_PORT_SOURCE, GPIO_PIN_SOURCE0, GPIO_AF2_TIM2); + // GPIO_ConfigPinRemap(GPIOA_PORT_SOURCE, GPIO_PIN_SOURCE1, GPIO_AF2_TIM2); + +#endif +} + +static void pwm_oc_init(const rt_uint16_t chanel, const rt_uint16_t mode, TIM_Module *tim) +{ + OCInitType TIM_OCInitStructure; + /*pwn chanel cofnig*/ + TIM_OCInitStructure.OcMode = mode; // pwm mode + TIM_OCInitStructure.OutputState = TIM_OUTPUT_STATE_ENABLE; + TIM_OCInitStructure.Pulse = 500; + TIM_OCInitStructure.OcPolarity = TIM_OC_POLARITY_HIGH; + + switch (chanel) + { + + case 0: + TIM_InitOc1(tim, &TIM_OCInitStructure); + TIM_ConfigOc1Preload(tim, TIM_OC_PRE_LOAD_ENABLE); + break; + case 1: + TIM_InitOc2(tim, &TIM_OCInitStructure); + TIM_ConfigOc2Preload(tim, TIM_OC_PRE_LOAD_ENABLE); + break; + case 2: + TIM_InitOc3(tim, &TIM_OCInitStructure); + TIM_ConfigOc3Preload(tim, TIM_OC_PRE_LOAD_ENABLE); + break; + case 3: + TIM_InitOc4(tim, &TIM_OCInitStructure); + TIM_ConfigOc4Preload(tim, TIM_OC_PRE_LOAD_ENABLE); + break; + default: + + break; + } +} + +static rt_err_t n32_hw_pwm_init(struct n32_pwm *device) +{ + rt_err_t result = RT_EOK; + TIM_TimeBaseInitType TIM_TimeBaseStructure; + + RT_ASSERT(device != RT_NULL); + // enable rcc + n32_time_rcc_config(device->tim); + + // cfg time + TIM_TimeBaseStructure.Period = 1000; // + TIM_TimeBaseStructure.Prescaler = device->prescaler; + TIM_TimeBaseStructure.ClkDiv = 0; + TIM_TimeBaseStructure.CntMode = TIM_CNT_MODE_UP; + TIM_InitTimeBase(device->tim, &TIM_TimeBaseStructure); +#if defined(SOC_N32G45X) || defined(SOC_N32WB452) || defined(SOC_N32G4FR) + + // gpio afio + if (device->gpio_af) + { + // afio cfg + GPIO_ConfigPinRemap(device->gpio_af, ENABLE); + } +#endif + + /*chanel cofig*/ + for (int i = 0; i < 4; i++) + { + if (device->ch[i].gpio_grp) + { + /**gpio rcc */ + n32_gpio_rcc_enable(device->ch[i].gpio_grp); + // + pwm_time_gpio_config(device->ch + i); + // + pwm_oc_init(i, device->ch[i].pwm_mode, device->tim); + // + drv_pwm_enable(device, i, RT_FALSE); + } + } + + // enable timer + TIM_ConfigArPreload(device->tim, ENABLE); + TIM_Enable(device->tim, ENABLE); + // enable tim1 and tim8 pwm output + if (device->tim == TIM1 || device->tim == TIM8) + { + TIM_EnableCtrlPwmOutputs(device->tim, ENABLE); + } + + return result; +} + +static struct rt_pwm_ops drv_ops = + { + .control = drv_pwm_control, +}; + +static int n32_pwm_init(void) +{ + int i = 0; + int result = RT_EOK; + + + for (i = 0; i < sizeof(n32_pwm_obj) / sizeof(n32_pwm_obj[0]); i++) + { + /* pwm init */ + if (n32_hw_pwm_init(&n32_pwm_obj[i]) != RT_EOK) + { + PWM_LOG_E("%s init failed", n32_pwm_obj[i].name); + result = -RT_ERROR; + goto __exit; + } + else + { + + /* register pwm device */ + if (rt_device_pwm_register(&n32_pwm_obj[i].pwm_device, n32_pwm_obj[i].name, &drv_ops, n32_pwm_obj + i) == RT_EOK) + { + // PWM_LOG_D("%s register success", n32_pwm_obj[i].name); + } + else + { + PWM_LOG_E("%s register failed", n32_pwm_obj[i].name); + result = -RT_ERROR; + } + } + } + +__exit: + return result; +} +INIT_DEVICE_EXPORT(n32_pwm_init); + + +#endif /* BSP_USING_PWM */ diff --git a/bsp/n32/libraries/n32_drivers/drv_pwm.h b/bsp/n32/libraries/n32_drivers/drv_pwm.h new file mode 100644 index 00000000000..41b9fecc6b3 --- /dev/null +++ b/bsp/n32/libraries/n32_drivers/drv_pwm.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2022-10-19 Nations first version + */ + +#ifndef __DRV_PWM_H__ +#define __DRV_PWM_H__ + +#include +#include +#include "board.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* __DRV_PWM_H__ */ diff --git a/bsp/n32/n32g43xcl-stb/.config b/bsp/n32/n32g43xcl-stb/.config index 7f129ba8d93..d4331b1e367 100644 --- a/bsp/n32/n32g43xcl-stb/.config +++ b/bsp/n32/n32g43xcl-stb/.config @@ -179,7 +179,7 @@ CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="usart1" -CONFIG_RT_VER_NUM=0x50201 +CONFIG_RT_VER_NUM=0x50300 # CONFIG_RT_USING_STDC_ATOMIC is not set CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32 # end of RT-Thread Kernel @@ -267,6 +267,7 @@ CONFIG_RT_USING_RTC=y # CONFIG_RT_USING_SOFT_RTC is not set # CONFIG_RT_USING_SDIO is not set CONFIG_RT_USING_SPI=y +CONFIG_RT_USING_SPI_ISR=y # CONFIG_RT_USING_SOFT_SPI is not set # CONFIG_RT_USING_QSPI is not set # CONFIG_RT_USING_SPI_MSD is not set @@ -361,8 +362,6 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # CONFIG_RT_USING_RT_LINK is not set # end of Utilities -# CONFIG_RT_USING_VBUS is not set - # # Using USB legacy version # @@ -371,6 +370,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # end of Using USB legacy version # CONFIG_RT_USING_FDT is not set +# CONFIG_RT_USING_RUST is not set # end of RT-Thread Components # @@ -738,6 +738,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # CONFIG_PKG_USING_R_RHEALSTONE is not set # CONFIG_PKG_USING_HEARTBEAT is not set # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set +# CONFIG_PKG_USING_CHERRYECAT is not set # end of system packages # @@ -894,6 +895,12 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set # CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set # end of GD32 Drivers + +# +# HPMicro SDK +# +# CONFIG_PKG_USING_HPM_SDK is not set +# end of HPMicro SDK # end of HAL & SDK Drivers # @@ -1432,6 +1439,7 @@ CONFIG_BSP_USING_USART1=y # CONFIG_BSP_USING_ADC is not set # CONFIG_BSP_USING_DAC is not set # CONFIG_BSP_USING_CAN is not set +# CONFIG_BSP_USING_PWM is not set # end of On-chip Peripheral Drivers # diff --git a/bsp/n32/n32g43xcl-stb/board/Kconfig b/bsp/n32/n32g43xcl-stb/board/Kconfig index a5bfedd61c1..ac169ebc3ae 100644 --- a/bsp/n32/n32g43xcl-stb/board/Kconfig +++ b/bsp/n32/n32g43xcl-stb/board/Kconfig @@ -164,6 +164,104 @@ menu "On-chip Peripheral Drivers" select RT_USING_CAN default n + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32g43xcl-stb/project.uvprojx b/bsp/n32/n32g43xcl-stb/project.uvprojx index 8d75374a6f6..8029e924e58 100644 --- a/bsp/n32/n32g43xcl-stb/project.uvprojx +++ b/bsp/n32/n32g43xcl-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - __CLK_TCK=RT_TICK_PER_SECOND, USE_STDPERIPH_DRIVER, RT_USING_ARMLIBC, RT_USING_LIBC, N32G43X, __RTTHREAD__, __STDC_LIMIT_MACROS + USE_STDPERIPH_DRIVER, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, RT_USING_ARMLIBC, RT_USING_LIBC, N32G43X, __RTTHREAD__ - ..\..\..\components\drivers\phy;..\..\..\libcpu\arm\common;..\libraries\N32G43x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;.;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\spi;..\..\..\components\libc\compilers\common\include;..\..\..\include;..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\inc;..\libraries\n32_drivers\config;..\..\..\components\libc\posix\io\epoll;..\..\..\components\libc\posix\io\poll;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;board;..\libraries\n32_drivers;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\libc\compilers\common\extension;applications;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\components\drivers\include;..\libraries\N32G43x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include + ..\..\..\components\drivers\include;..\libraries\N32G43x_Firmware_Library\CMSIS\core;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\n32_drivers;..\..\..\components\net\utest;..\..\..\components\drivers\spi;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\inc;..\..\..\libcpu\arm\cortex-m4;applications;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;.;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\..\..\components\finsh;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\libraries\N32G43x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;board;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\smp_call @@ -388,61 +388,33 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c - 1 - ..\..\..\components\libc\compilers\common\cstdlib.c - - - - - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -970,30 +942,30 @@ Finsh - cmd.c + shell.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\shell.c - shell.c + cmd.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\cmd.c - msh_parse.c + msh.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\msh.c - msh.c + msh_parse.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\msh_parse.c @@ -1305,123 +1277,127 @@ - klibc + Libc - kerrno.c + syscall_mem.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsscanf.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - rt_vsnprintf_tiny.c + cctype.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\common\cctype.c - kstring.c + cstdlib.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kstdio.c + cstring.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - div0.c + ctime.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\ctime.c - showmem.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cunistd.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + cwchar.c + 1 + ..\..\..\components\libc\compilers\common\cwchar.c - cpuport.c + kerrno.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kerrno.c - - - Libraries - n32g43x_adc.c + kstdio.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_adc.c + ..\..\..\src\klibc\kstdio.c - n32g43x_tim.c + kstring.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_tim.c + ..\..\..\src\klibc\kstring.c - n32g43x_flash.c + rt_vsnprintf_tiny.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_flash.c + ..\..\..\src\klibc\rt_vsnprintf_tiny.c - n32g43x_dac.c + rt_vsscanf.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_dac.c + ..\..\..\src\klibc\rt_vsscanf.c + + + Libraries - n32g43x_can.c + n32g43x_pwr.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_can.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_pwr.c - n32g43x_rcc.c + system_n32g43x.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_rcc.c + ..\libraries\N32G43x_Firmware_Library\CMSIS\device\system_n32g43x.c - system_n32g43x.c + n32g43x_can.c 1 - ..\libraries\N32G43x_Firmware_Library\CMSIS\device\system_n32g43x.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_can.c + + + + + n32g43x_wwdg.c + 1 + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_wwdg.c @@ -1433,37 +1409,37 @@ - n32g43x_spi.c + n32g43x_usart.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_spi.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_usart.c - n32g43x_pwr.c + n32g43x_dac.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_pwr.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_dac.c - n32g43x_exti.c + n32g43x_rtc.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_exti.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_rtc.c - n32g43x_gpio.c + n32g43x_rcc.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_gpio.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_rcc.c - n32g43x_wwdg.c + n32g43x_exti.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_wwdg.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_exti.c @@ -1475,9 +1451,23 @@ - n32g43x_rtc.c + n32g43x_spi.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_rtc.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_spi.c + + + + + n32g43x_tim.c + 1 + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_tim.c + + + + + n32g43x_adc.c + 1 + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_adc.c @@ -1489,9 +1479,16 @@ - n32g43x_usart.c + n32g43x_gpio.c 1 - ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_usart.c + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_gpio.c + + + + + n32g43x_flash.c + 1 + ..\libraries\N32G43x_Firmware_Library\n32g43x_std_periph_driver\src\n32g43x_flash.c diff --git a/bsp/n32/n32g43xcl-stb/rtconfig.h b/bsp/n32/n32g43xcl-stb/rtconfig.h index 9c8805bc9fd..6c093603abd 100644 --- a/bsp/n32/n32g43xcl-stb/rtconfig.h +++ b/bsp/n32/n32g43xcl-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ @@ -155,6 +155,7 @@ #define RT_USING_DAC #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -327,6 +328,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ diff --git a/bsp/n32/n32g457qel-stb/board/Kconfig b/bsp/n32/n32g457qel-stb/board/Kconfig index 2e186f1a749..a02e02282b9 100644 --- a/bsp/n32/n32g457qel-stb/board/Kconfig +++ b/bsp/n32/n32g457qel-stb/board/Kconfig @@ -189,6 +189,103 @@ menu "On-chip Peripheral Drivers" bool "using can2" default n endif + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM rsource "../../libraries/n32_drivers/Kconfig" diff --git a/bsp/n32/n32g457qel-stb/project.uvprojx b/bsp/n32/n32g457qel-stb/project.uvprojx index b994bc1107a..11296604cb0 100644 --- a/bsp/n32/n32g457qel-stb/project.uvprojx +++ b/bsp/n32/n32g457qel-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - USE_STDPERIPH_DRIVER, RT_USING_LIBC, __RTTHREAD__, __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_ARMLIBC, N32G45X + USE_STDPERIPH_DRIVER, RT_USING_LIBC, RT_USING_ARMLIBC, N32G45X, __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__ - ..\..\..\components\drivers\include;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\libc\compilers\common\extension;..\..\..\components\libc\posix\io\poll;..\libraries\n32_drivers;..\..\..\components\libc\posix\ipc;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;..\..\..\components\drivers\phy;.;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\components\libc\posix\io\epoll;..\..\..\libcpu\arm\cortex-m4;..\..\..\libcpu\arm\common;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;applications;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\components\finsh + ..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\components\libc\posix\io\epoll;.;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\spi;..\..\..\components\finsh;..\..\..\include;board;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;applications;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\libraries\n32_drivers;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\net\utest;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\libc\posix\io\poll;..\..\..\components\libc\posix\ipc;..\..\..\libcpu\arm\common;..\libraries\n32_drivers\config;..\..\..\components\drivers\include @@ -388,61 +388,40 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c + atomic_arm.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\..\..\libcpu\arm\common\atomic_arm.c - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +750,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +907,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +942,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,30 +982,30 @@ Finsh - cmd.c + msh_parse.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\msh_parse.c - msh.c + cmd.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\cmd.c - msh_parse.c + shell.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\shell.c - shell.c + msh.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\msh.c @@ -1305,78 +1317,96 @@ - klibc + Libc - kerrno.c + syscall_mem.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsnprintf_tiny.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - kstdio.c + cctype.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cctype.c - kstring.c + cstdlib.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\common\cstdlib.c - rt_vsscanf.c + cstring.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - atomic_arm.c + ctime.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\..\..\components\libc\compilers\common\ctime.c - div0.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\cunistd.c - showmem.c + cwchar.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cwchar.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + kerrno.c + 1 + ..\..\..\src\klibc\kerrno.c - cpuport.c + kstdio.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kstdio.c + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + + + rt_vsnprintf_tiny.c + 1 + ..\..\..\src\klibc\rt_vsnprintf_tiny.c + + + + + rt_vsscanf.c + 1 + ..\..\..\src\klibc\rt_vsscanf.c @@ -1384,44 +1414,44 @@ Libraries - n32g45x_wwdg.c + n32g45x_pwr.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_wwdg.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c - misc.c + n32g45x_i2c.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_i2c.c - n32g45x_rcc.c + n32g45x_wwdg.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_wwdg.c - n32g45x_can.c + system_n32g45x.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c + ..\libraries\N32G45x_Firmware_Library\CMSIS\device\system_n32g45x.c - system_n32g45x.c + n32g45x_iwdg.c 1 - ..\libraries\N32G45x_Firmware_Library\CMSIS\device\system_n32g45x.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_iwdg.c - n32g45x_spi.c + n32g45x_can.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_spi.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c @@ -1433,30 +1463,30 @@ - n32g45x_pwr.c + n32g45x_spi.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_spi.c - n32g45x_rtc.c + n32g45x_exti.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c - n32g45x_i2c.c + n32g45x_dma.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_i2c.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c - n32g45x_iwdg.c + misc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_iwdg.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c @@ -1468,37 +1498,37 @@ - n32g45x_gpio.c + n32g45x_rtc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_gpio.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c - n32g45x_exti.c + n32g45x_rcc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c - n32g45x_tim.c + n32g45x_dac.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_tim.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c - n32g45x_dac.c + n32g45x_tim.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_tim.c - n32g45x_dma.c + n32g45x_gpio.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_gpio.c diff --git a/bsp/n32/n32g457qel-stb/rtconfig.h b/bsp/n32/n32g457qel-stb/rtconfig.h index e2e0b578710..342596d5406 100644 --- a/bsp/n32/n32g457qel-stb/rtconfig.h +++ b/bsp/n32/n32g457qel-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ #define RT_USING_HW_ATOMIC @@ -158,8 +158,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -332,6 +334,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -425,6 +431,10 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM +#define BSP_USING_TIM2_PWM +#define TIM2_REMAP_0 +#define BSP_USING_TIM2_PWM_CH0 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32g45xcl-stb/board/Kconfig b/bsp/n32/n32g45xcl-stb/board/Kconfig index ac08b2c594d..f63096980f8 100644 --- a/bsp/n32/n32g45xcl-stb/board/Kconfig +++ b/bsp/n32/n32g45xcl-stb/board/Kconfig @@ -189,7 +189,103 @@ menu "On-chip Peripheral Drivers" bool "using can2" default n endif - + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32g45xml-stb/board/Kconfig b/bsp/n32/n32g45xml-stb/board/Kconfig index 2e186f1a749..82f09e4b7b7 100644 --- a/bsp/n32/n32g45xml-stb/board/Kconfig +++ b/bsp/n32/n32g45xml-stb/board/Kconfig @@ -190,6 +190,104 @@ menu "On-chip Peripheral Drivers" default n endif + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32g45xml-stb/project.uvprojx b/bsp/n32/n32g45xml-stb/project.uvprojx index 7db04a3fcef..aed3c137774 100644 --- a/bsp/n32/n32g45xml-stb/project.uvprojx +++ b/bsp/n32/n32g45xml-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - RT_USING_ARMLIBC, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__, N32G45X, USE_STDPERIPH_DRIVER, __STDC_LIMIT_MACROS + __STDC_LIMIT_MACROS, USE_STDPERIPH_DRIVER, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, N32G45X, __RTTHREAD__, RT_USING_LIBC - ..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;board;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;applications;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\phy;..\libraries\n32_drivers;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\core;.;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\libc\posix\io\eventfd;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include + ..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\libraries\n32_drivers;applications;..\..\..\include;..\..\..\components\libc\posix\io\epoll;..\..\..\components\libc\compilers\common\include;..\libraries\n32_drivers\config;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\net\utest;..\..\..\components\finsh;..\..\..\components\drivers\include;board;.;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\include @@ -388,61 +388,40 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c + atomic_arm.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\..\..\libcpu\arm\common\atomic_arm.c - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +750,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +907,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +942,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,16 +982,16 @@ Finsh - shell.c + msh.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\msh.c - cmd.c + shell.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\shell.c @@ -991,9 +1003,9 @@ - msh.c + cmd.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\cmd.c @@ -1305,78 +1317,96 @@ - klibc + Libc - kstdio.c + syscall_mem.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsnprintf_tiny.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - kstring.c + cctype.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\common\cctype.c - rt_vsscanf.c + cstdlib.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kerrno.c + cstring.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - atomic_arm.c + ctime.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\..\..\components\libc\compilers\common\ctime.c - div0.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\cunistd.c - showmem.c + cwchar.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cwchar.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + kerrno.c + 1 + ..\..\..\src\klibc\kerrno.c - cpuport.c + kstdio.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kstdio.c + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + + + rt_vsnprintf_tiny.c + 1 + ..\..\..\src\klibc\rt_vsnprintf_tiny.c + + + + + rt_vsscanf.c + 1 + ..\..\..\src\klibc\rt_vsscanf.c @@ -1384,30 +1414,30 @@ Libraries - n32g45x_dac.c + system_n32g45x.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c + ..\libraries\N32G45x_Firmware_Library\CMSIS\device\system_n32g45x.c - n32g45x_wwdg.c + n32g45x_gpio.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_wwdg.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_gpio.c - n32g45x_dma.c + n32g45x_rtc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c - n32g45x_gpio.c + n32g45x_dac.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_gpio.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c @@ -1419,23 +1449,23 @@ - n32g45x_iwdg.c + n32g45x_wwdg.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_iwdg.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_wwdg.c - system_n32g45x.c + n32g45x_can.c 1 - ..\libraries\N32G45x_Firmware_Library\CMSIS\device\system_n32g45x.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c - misc.c + n32g45x_iwdg.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_iwdg.c @@ -1447,30 +1477,30 @@ - n32g45x_rtc.c + n32g45x_dma.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c - n32g45x_pwr.c + n32g45x_exti.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c - n32g45x_rcc.c + n32g45x_adc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_adc.c - n32g45x_can.c + n32g45x_rcc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c @@ -1482,9 +1512,9 @@ - n32g45x_exti.c + n32g45x_pwr.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c @@ -1496,9 +1526,9 @@ - n32g45x_adc.c + misc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_adc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c diff --git a/bsp/n32/n32g45xml-stb/rtconfig.h b/bsp/n32/n32g45xml-stb/rtconfig.h index e2e0b578710..01de9686f54 100644 --- a/bsp/n32/n32g45xml-stb/rtconfig.h +++ b/bsp/n32/n32g45xml-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ #define RT_USING_HW_ATOMIC @@ -158,8 +158,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -332,6 +334,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -425,6 +431,13 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM +#define BSP_USING_TIM2_PWM +#define TIM2_REMAP_0 +#define BSP_USING_TIM2_PWM_CH0 +#define BSP_USING_TIM2_PWM_CH1 +#define BSP_USING_TIM2_PWM_CH2 +#define BSP_USING_TIM2_PWM_CH3 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32g45xrl-stb/board/Kconfig b/bsp/n32/n32g45xrl-stb/board/Kconfig index 2e186f1a749..82f09e4b7b7 100644 --- a/bsp/n32/n32g45xrl-stb/board/Kconfig +++ b/bsp/n32/n32g45xrl-stb/board/Kconfig @@ -190,6 +190,104 @@ menu "On-chip Peripheral Drivers" default n endif + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32g45xrl-stb/project.uvprojx b/bsp/n32/n32g45xrl-stb/project.uvprojx index d2d6148d78b..03d9970da6b 100644 --- a/bsp/n32/n32g45xrl-stb/project.uvprojx +++ b/bsp/n32/n32g45xrl-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - RT_USING_ARMLIBC, USE_STDPERIPH_DRIVER, __RTTHREAD__, N32G45X, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, RT_USING_LIBC + RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, USE_STDPERIPH_DRIVER, __STDC_LIMIT_MACROS, RT_USING_LIBC, __RTTHREAD__, N32G45X - ..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\include;..\..\..\components\drivers\include;.;board;..\libraries\n32_drivers;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\epoll;..\libraries\n32_drivers\config;applications;..\..\..\components\libc\compilers\common\extension;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\libc\posix\io\eventfd;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\components\drivers\spi;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc + ..\..\..\components\drivers\include;board;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;.;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;applications;..\..\..\components\libc\posix\ipc;..\libraries\n32_drivers;..\..\..\components\drivers\phy;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\smp_call;..\..\..\components\libc\posix\io\epoll;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\net\utest;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\libcpu\arm\common;..\..\..\components\libc\posix\io\eventfd;..\..\..\include;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\finsh;..\..\..\components\libc\compilers\common\extension @@ -388,61 +388,40 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c + atomic_arm.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\..\..\libcpu\arm\common\atomic_arm.c - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +750,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +907,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +942,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,30 +982,30 @@ Finsh - shell.c + msh_parse.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\msh_parse.c - msh.c + cmd.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\cmd.c - cmd.c + msh.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\msh.c - msh_parse.c + shell.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\shell.c @@ -1305,102 +1317,106 @@ - klibc + Libc - kstring.c + syscall_mem.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsscanf.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - kstdio.c + cctype.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cctype.c - rt_vsnprintf_tiny.c + cstdlib.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kerrno.c + cstring.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - atomic_arm.c + ctime.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\..\..\components\libc\compilers\common\ctime.c - div0.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\cunistd.c - showmem.c + cwchar.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cwchar.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + kerrno.c + 1 + ..\..\..\src\klibc\kerrno.c - cpuport.c + kstdio.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kstdio.c - - - Libraries - n32g45x_pwr.c + kstring.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c + ..\..\..\src\klibc\kstring.c - n32g45x_usart.c + rt_vsnprintf_tiny.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_usart.c + ..\..\..\src\klibc\rt_vsnprintf_tiny.c - n32g45x_can.c + rt_vsscanf.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c + ..\..\..\src\klibc\rt_vsscanf.c + + + + + Libraries + + + n32g45x_spi.c + 1 + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_spi.c @@ -1412,37 +1428,37 @@ - n32g45x_iwdg.c + n32g45x_i2c.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_iwdg.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_i2c.c - misc.c + n32g45x_adc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_adc.c - n32g45x_dma.c + n32g45x_rcc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c - system_n32g45x.c + n32g45x_usart.c 1 - ..\libraries\N32G45x_Firmware_Library\CMSIS\device\system_n32g45x.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_usart.c - n32g45x_dac.c + system_n32g45x.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c + ..\libraries\N32G45x_Firmware_Library\CMSIS\device\system_n32g45x.c @@ -1454,51 +1470,65 @@ - n32g45x_exti.c + n32g45x_pwr.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c - n32g45x_gpio.c + n32g45x_dma.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_gpio.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c - n32g45x_rtc.c + n32g45x_dac.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c - n32g45x_adc.c + n32g45x_iwdg.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_adc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_iwdg.c - n32g45x_rcc.c + n32g45x_gpio.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_gpio.c - n32g45x_i2c.c + n32g45x_rtc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_i2c.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c - n32g45x_spi.c + n32g45x_can.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_spi.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c + + + + + misc.c + 1 + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c + + + + + n32g45x_exti.c + 1 + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c diff --git a/bsp/n32/n32g45xrl-stb/rtconfig.h b/bsp/n32/n32g45xrl-stb/rtconfig.h index e2e0b578710..01de9686f54 100644 --- a/bsp/n32/n32g45xrl-stb/rtconfig.h +++ b/bsp/n32/n32g45xrl-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ #define RT_USING_HW_ATOMIC @@ -158,8 +158,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -332,6 +334,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -425,6 +431,13 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM +#define BSP_USING_TIM2_PWM +#define TIM2_REMAP_0 +#define BSP_USING_TIM2_PWM_CH0 +#define BSP_USING_TIM2_PWM_CH1 +#define BSP_USING_TIM2_PWM_CH2 +#define BSP_USING_TIM2_PWM_CH3 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32g45xvl-stb/board/Kconfig b/bsp/n32/n32g45xvl-stb/board/Kconfig index 5df1f9fc3a8..5b3334e14d4 100644 --- a/bsp/n32/n32g45xvl-stb/board/Kconfig +++ b/bsp/n32/n32g45xvl-stb/board/Kconfig @@ -523,6 +523,104 @@ menu "On-chip Peripheral Drivers" default n endif + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32g45xvl-stb/project.uvprojx b/bsp/n32/n32g45xvl-stb/project.uvprojx index b4310ee0aed..37a1a16617a 100644 --- a/bsp/n32/n32g45xvl-stb/project.uvprojx +++ b/bsp/n32/n32g45xvl-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - N32G45X, RT_USING_LIBC, __RTTHREAD__, RT_USING_ARMLIBC, __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, USE_STDPERIPH_DRIVER + __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, N32G45X, __RTTHREAD__, RT_USING_ARMLIBC, USE_STDPERIPH_DRIVER, RT_USING_LIBC - ..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\components\libc\posix\io\epoll;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\libc\posix\io\poll;..\..\..\include;..\..\..\libcpu\arm\common;..\..\..\components\finsh;..\libraries\n32_drivers;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\spi;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;.;..\..\..\libcpu\arm\cortex-m4;board;..\libraries\n32_drivers\config;applications;..\..\..\components\drivers\phy + ..\..\..\components\libc\posix\io\poll;applications;..\..\..\libcpu\arm\cortex-m4;..\libraries\n32_drivers;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\posix\io\eventfd;board;..\..\..\components\drivers\include;..\..\..\components\finsh;.;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\libcpu\arm\common;..\..\..\components\drivers\spi;..\libraries\N32G45x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\libraries\N32G45x_Firmware_Library\CMSIS\device;..\..\..\components\net\utest;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\inc;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\posix\io\epoll;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include @@ -388,61 +388,40 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c + atomic_arm.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\..\..\libcpu\arm\common\atomic_arm.c - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +750,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +907,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +942,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,30 +982,30 @@ Finsh - msh.c + cmd.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\cmd.c - cmd.c + msh.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\msh.c - msh_parse.c + shell.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\shell.c - shell.c + msh_parse.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\msh_parse.c @@ -1305,78 +1317,96 @@ - klibc + Libc - rt_vsscanf.c + syscall_mem.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - kstring.c + syscalls.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - rt_vsnprintf_tiny.c + cctype.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\common\cctype.c - kstdio.c + cstdlib.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kerrno.c + cstring.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - atomic_arm.c + ctime.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\..\..\components\libc\compilers\common\ctime.c - div0.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\cunistd.c - showmem.c + cwchar.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cwchar.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + kerrno.c + 1 + ..\..\..\src\klibc\kerrno.c - cpuport.c + kstdio.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kstdio.c + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + + + rt_vsnprintf_tiny.c + 1 + ..\..\..\src\klibc\rt_vsnprintf_tiny.c + + + + + rt_vsscanf.c + 1 + ..\..\..\src\klibc\rt_vsscanf.c @@ -1384,23 +1414,23 @@ Libraries - n32g45x_i2c.c + n32g45x_pwr.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_i2c.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c - n32g45x_usart.c + n32g45x_dma.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_usart.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c - n32g45x_dac.c + n32g45x_i2c.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_i2c.c @@ -1412,9 +1442,16 @@ - n32g45x_adc.c + misc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_adc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c + + + + + n32g45x_wwdg.c + 1 + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_wwdg.c @@ -1426,23 +1463,23 @@ - n32g45x_rcc.c + n32g45x_adc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_adc.c - n32g45x_can.c + n32g45x_rtc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c - n32g45x_dma.c + n32g45x_dac.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dma.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_dac.c @@ -1454,23 +1491,23 @@ - n32g45x_exti.c + n32g45x_can.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_can.c - n32g45x_pwr.c + n32g45x_exti.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_pwr.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_exti.c - n32g45x_spi.c + n32g45x_usart.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_spi.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_usart.c @@ -1482,23 +1519,16 @@ - n32g45x_rtc.c - 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rtc.c - - - - - n32g45x_wwdg.c + n32g45x_rcc.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_wwdg.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_rcc.c - misc.c + n32g45x_spi.c 1 - ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\misc.c + ..\libraries\N32G45x_Firmware_Library\n32g45x_std_periph_driver\src\n32g45x_spi.c diff --git a/bsp/n32/n32g45xvl-stb/rtconfig.h b/bsp/n32/n32g45xvl-stb/rtconfig.h index d9a019d68cf..06f47030383 100644 --- a/bsp/n32/n32g45xvl-stb/rtconfig.h +++ b/bsp/n32/n32g45xvl-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ #define RT_USING_HW_ATOMIC @@ -158,8 +158,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -332,6 +334,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -426,6 +432,10 @@ #define BSP_USING_UART #define BSP_USING_USART1 #define BSP_USART1_AFIO_MODE_PA9_PA10 +#define BSP_USING_PWM +#define BSP_USING_TIM2_PWM +#define TIM2_REMAP_0 +#define BSP_USING_TIM2_PWM_CH0 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32g4frml-stb/board/Kconfig b/bsp/n32/n32g4frml-stb/board/Kconfig index 16351ea7e11..2af9c0e1e53 100644 --- a/bsp/n32/n32g4frml-stb/board/Kconfig +++ b/bsp/n32/n32g4frml-stb/board/Kconfig @@ -189,7 +189,104 @@ menu "On-chip Peripheral Drivers" bool "using can2" default n endif + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32g4frml-stb/project.uvprojx b/bsp/n32/n32g4frml-stb/project.uvprojx index 6008458b4ac..96ea0d3d3e7 100644 --- a/bsp/n32/n32g4frml-stb/project.uvprojx +++ b/bsp/n32/n32g4frml-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - __STDC_LIMIT_MACROS, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__, USE_STDPERIPH_DRIVER, N32G4FR, RT_USING_LIBC + USE_STDPERIPH_DRIVER, RT_USING_LIBC, RT_USING_ARMLIBC, N32G4FR, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, __RTTHREAD__ - ..\..\..\libcpu\arm\common;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;..\libraries\N32G4FR_Firmware_Library\CMSIS;..\libraries\n32_drivers;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;..\..\..\components\finsh;..\libraries\N32G4FR_Firmware_Library\CMSIS\device;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\libcpu\arm\cortex-m4;.;..\..\..\components\libc\posix\io\eventfd;applications;..\..\..\components\drivers\include;..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\inc;..\libraries\N32G4FR_Firmware_Library\CMSIS\core;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\phy + ..\libraries\n32_drivers;..\..\..\components\net\utest;..\libraries\n32_drivers\config;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\libraries\N32G4FR_Firmware_Library\CMSIS;..\..\..\include;..\..\..\components\drivers\spi;..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\inc;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;board;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32G4FR_Firmware_Library\CMSIS\device;.;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\libraries\N32G4FR_Firmware_Library\CMSIS\core;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;applications;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include @@ -388,61 +388,40 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c + atomic_arm.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\..\..\libcpu\arm\common\atomic_arm.c - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +750,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -937,6 +935,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,9 +975,9 @@ Finsh - shell.c + cmd.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\cmd.c @@ -984,16 +989,16 @@ - cmd.c + msh.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\msh.c - msh.c + shell.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\shell.c @@ -1305,78 +1310,96 @@ - klibc + Libc - rt_vsscanf.c + syscall_mem.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsnprintf_tiny.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - kstring.c + cctype.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\common\cctype.c - kstdio.c + cstdlib.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kerrno.c + cstring.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - atomic_arm.c + ctime.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\..\..\components\libc\compilers\common\ctime.c - div0.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\cunistd.c - showmem.c + cwchar.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cwchar.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + kerrno.c + 1 + ..\..\..\src\klibc\kerrno.c - cpuport.c + kstdio.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kstdio.c + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + + + rt_vsnprintf_tiny.c + 1 + ..\..\..\src\klibc\rt_vsnprintf_tiny.c + + + + + rt_vsscanf.c + 1 + ..\..\..\src\klibc\rt_vsscanf.c @@ -1384,107 +1407,107 @@ libraries - n32g4fr_i2c.c + n32g4fr_can.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_i2c.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_can.c - n32g4fr_gpio.c + n32g4fr_exti.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_gpio.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_exti.c - n32g4fr_usart.c + n32g4fr_tim.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_usart.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_tim.c - n32g4fr_tim.c + n32g4fr_rtc.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_tim.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_rtc.c - system_n32g4fr.c + misc.c 1 - ..\libraries\N32G4FR_Firmware_Library\CMSIS\device\system_n32g4fr.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\misc.c - n32g4fr_wwdg.c + n32g4fr_rcc.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_wwdg.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_rcc.c - n32g4fr_spi.c + n32g4fr_i2c.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_spi.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_i2c.c - n32g4fr_can.c + n32g4fr_iwdg.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_can.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_iwdg.c - n32g4fr_rtc.c + n32g4fr_spi.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_rtc.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_spi.c - n32g4fr_exti.c + n32g4fr_dac.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_exti.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_dac.c - misc.c + n32g4fr_wwdg.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\misc.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_wwdg.c - n32g4fr_adc.c + system_n32g4fr.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_adc.c + ..\libraries\N32G4FR_Firmware_Library\CMSIS\device\system_n32g4fr.c - n32g4fr_iwdg.c + n32g4fr_adc.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_iwdg.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_adc.c - n32g4fr_rcc.c + n32g4fr_usart.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_rcc.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_usart.c - n32g4fr_dac.c + n32g4fr_gpio.c 1 - ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_dac.c + ..\libraries\N32G4FR_Firmware_Library\n32g4fr_std_periph_driver\src\n32g4fr_gpio.c diff --git a/bsp/n32/n32g4frml-stb/rtconfig.h b/bsp/n32/n32g4frml-stb/rtconfig.h index dd1890c4ce0..b18b67abd25 100644 --- a/bsp/n32/n32g4frml-stb/rtconfig.h +++ b/bsp/n32/n32g4frml-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ #define RT_USING_HW_ATOMIC @@ -158,8 +158,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -332,6 +334,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ diff --git a/bsp/n32/n32l40xcl-stb/board/Kconfig b/bsp/n32/n32l40xcl-stb/board/Kconfig index 4303b8e4ad1..23c4a26d3bb 100644 --- a/bsp/n32/n32l40xcl-stb/board/Kconfig +++ b/bsp/n32/n32l40xcl-stb/board/Kconfig @@ -164,6 +164,144 @@ menu "On-chip Peripheral Drivers" select RT_USING_CAN default n + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 channel1 PA8 AF2" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 channel2 PA9 AF2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 channel3 PA10 AF2" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 channel4 PA11 AF2" + default n + endif#BSP_USING_TIM1_PWM + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 channel1" + default n + if BSP_USING_TIM2_PWM_CH1 + choice + prompt "Select Pin" + default TIM2_PWM_CH1_PA0 + config TIM2_PWM_CH1_PA0 + bool "PA0 AF2" + config TIM2_PWM_CH1_PA15 + bool "PA15 AF5" + endchoice + endif + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 channel2" + default n + if BSP_USING_TIM2_PWM_CH2 + choice + prompt "Select Pin" + default TIM2_PWM_CH2_PA1 + config TIM2_PWM_CH2_PA1 + bool "PA1 AF2" + config TIM2_PWM_CH2_PB3 + bool "PB3 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 channel3" + default n + if BSP_USING_TIM2_PWM_CH3 + choice + prompt "Select Pin" + default TIM2_PWM_CH3_PA2 + config TIM2_PWM_CH3_PA2 + bool "PA2 AF2" + config TIM2_PWM_CH3_PB10 + bool "PB10 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH4 + bool "Enable TIM2 channel3 AF2 PB11" + default n + endif#BSP_USING_TIM2_PWM + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 channel1" + default n + if BSP_USING_TIM3_PWM_CH1 + choice + prompt "Select Pin" + default TIM3_PWM_CH1_PA6 + config TIM3_PWM_CH1_PA6 + bool "PA6 AF2" + config TIM3_PWM_CH1_PB4 + bool "PB4 AF2" + config TIM3_PWM_CH1_PC6 + bool "PC6 AF5" + endchoice + endif + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 channel2" + default n + if BSP_USING_TIM3_PWM_CH2 + choice + prompt "Select Pin" + default TIM3_PWM_CH2_PA7 + config TIM3_PWM_CH2_PA7 + bool "PA7 AF2" + config TIM3_PWM_CH2_PB5 + bool "PB5 AF2" + config TIM3_PWM_CH2_PC7 + bool "PC7 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 channel3" + default n + if BSP_USING_TIM3_PWM_CH3 + choice + prompt "Select Pin" + default TIM3_PWM_CH3_PB0 + config TIM3_PWM_CH3_PB0 + bool "PB0 AF2" + config TIM3_PWM_CH3_PC8 + bool "PC8 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH4 + bool "Enable TIM3 channel3 AF2 PB11" + default n + if BSP_USING_TIM3_PWM_CH4 + choice + prompt "Select Pin" + default TIM3_PWM_CH4_PB1 + config TIM3_PWM_CH4_PB1 + bool "PB1 AF2" + config TIM3_PWM_CH4_PC9 + bool "PC89 AF2" + endchoice + endif + endif #BSP_USING_TIM3_PWM + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32l40xcl-stb/project.uvprojx b/bsp/n32/n32l40xcl-stb/project.uvprojx index 82add6e608d..fc6fb634f72 100644 --- a/bsp/n32/n32l40xcl-stb/project.uvprojx +++ b/bsp/n32/n32l40xcl-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, USE_STDPERIPH_DRIVER, RT_USING_ARMLIBC, __STDC_LIMIT_MACROS, __RTTHREAD__, N32L40X + RT_USING_ARMLIBC, RT_USING_LIBC, __STDC_LIMIT_MACROS, N32L40X, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__, USE_STDPERIPH_DRIVER - ..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;..\libraries\n32_drivers;..\libraries\n32_drivers\config;..\..\..\components\libc\posix\io\eventfd;..\libraries\N32L40x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include;..\..\..\components\drivers\include;.;applications;board;..\..\..\libcpu\arm\common;..\..\..\components\drivers\spi;..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\inc;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\include;..\..\..\libcpu\arm\cortex-m4;..\libraries\N32L40x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\phy;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include + ..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\spi;..\..\..\components\libc\posix\io\epoll;..\..\..\components\finsh;..\libraries\n32_drivers\config;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\include;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\libcpu\arm\common;board;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\include;..\libraries\n32_drivers;applications;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\posix\io\poll;..\libraries\N32L40x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\libraries\N32L40x_Firmware_Library\CMSIS\core;.;..\..\..\components\drivers\include;..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\inc;..\..\..\components\net\utest;..\..\..\components\drivers\phy;..\..\..\components\drivers\include @@ -388,61 +388,33 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c - 1 - ..\..\..\components\libc\compilers\common\cstdlib.c - - - - - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +743,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +900,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +935,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -977,9 +982,9 @@ - msh_parse.c + msh.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\msh.c @@ -991,9 +996,9 @@ - msh.c + msh_parse.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\msh_parse.c @@ -1305,102 +1310,106 @@ - klibc + Libc - kerrno.c + syscall_mem.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - kstring.c + syscalls.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - rt_vsnprintf_tiny.c + cctype.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\common\cctype.c - rt_vsscanf.c + cstdlib.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kstdio.c + cstring.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - div0.c + ctime.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\ctime.c - showmem.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cunistd.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + cwchar.c + 1 + ..\..\..\components\libc\compilers\common\cwchar.c - cpuport.c + kerrno.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kerrno.c - - - Libraries - misc.c + kstdio.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\misc.c + ..\..\..\src\klibc\kstdio.c - n32l40x_pwr.c + kstring.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_pwr.c + ..\..\..\src\klibc\kstring.c - n32l40x_gpio.c + rt_vsnprintf_tiny.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_gpio.c + ..\..\..\src\klibc\rt_vsnprintf_tiny.c - n32l40x_spi.c + rt_vsscanf.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_spi.c + ..\..\..\src\klibc\rt_vsscanf.c + + + + + Libraries + + + n32l40x_rcc.c + 1 + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rcc.c @@ -1419,9 +1428,23 @@ - n32l40x_wwdg.c + n32l40x_i2c.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_wwdg.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_i2c.c + + + + + misc.c + 1 + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\misc.c + + + + + n32l40x_pwr.c + 1 + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_pwr.c @@ -1447,51 +1470,58 @@ - n32l40x_dac.c + n32l40x_wwdg.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_dac.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_wwdg.c - n32l40x_adc.c + n32l40x_tim.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_adc.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_tim.c - n32l40x_usart.c + n32l40x_gpio.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_usart.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_gpio.c - n32l40x_i2c.c + n32l40x_adc.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_i2c.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_adc.c - n32l40x_rtc.c + n32l40x_dac.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rtc.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_dac.c - n32l40x_rcc.c + n32l40x_usart.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rcc.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_usart.c - n32l40x_tim.c + n32l40x_rtc.c 1 - ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_tim.c + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_rtc.c + + + + + n32l40x_spi.c + 1 + ..\libraries\N32L40x_Firmware_Library\n32l40x_std_periph_driver\src\n32l40x_spi.c diff --git a/bsp/n32/n32l40xcl-stb/rtconfig.h b/bsp/n32/n32l40xcl-stb/rtconfig.h index 236a2cdae79..26bc64abe41 100644 --- a/bsp/n32/n32l40xcl-stb/rtconfig.h +++ b/bsp/n32/n32l40xcl-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ @@ -153,8 +153,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -327,6 +329,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -419,6 +425,10 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM +#define BSP_USING_TIM2_PWM +#define BSP_USING_TIM2_PWM_CH1 +#define TIM2_PWM_CH1_PA0 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32l436-evb/board/Kconfig b/bsp/n32/n32l436-evb/board/Kconfig index 5e3fe2a39e6..81133ecf0ff 100644 --- a/bsp/n32/n32l436-evb/board/Kconfig +++ b/bsp/n32/n32l436-evb/board/Kconfig @@ -164,6 +164,145 @@ menu "On-chip Peripheral Drivers" select RT_USING_CAN default n + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 channel1 PA8 AF2" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 channel2 PA9 AF2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 channel3 PA10 AF2" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 channel4 PA11 AF2" + default n + endif#BSP_USING_TIM1_PWM + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 channel1" + default n + if BSP_USING_TIM2_PWM_CH1 + choice + prompt "Select Pin" + default TIM2_PWM_CH1_PA0 + config TIM2_PWM_CH1_PA0 + bool "PA0 AF2" + config TIM2_PWM_CH1_PA15 + bool "PA15 AF5" + endchoice + endif + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 channel2" + default n + if BSP_USING_TIM2_PWM_CH2 + choice + prompt "Select Pin" + default TIM2_PWM_CH2_PA1 + config TIM2_PWM_CH2_PA1 + bool "PA1 AF2" + config TIM2_PWM_CH2_PB3 + bool "PB3 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 channel3" + default n + if BSP_USING_TIM2_PWM_CH3 + choice + prompt "Select Pin" + default TIM2_PWM_CH3_PA2 + config TIM2_PWM_CH3_PA2 + bool "PA2 AF2" + config TIM2_PWM_CH3_PB10 + bool "PB10 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH4 + bool "Enable TIM2 channel3 AF2 PB11" + default n + endif#BSP_USING_TIM2_PWM + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 channel1" + default n + if BSP_USING_TIM3_PWM_CH1 + choice + prompt "Select Pin" + default TIM3_PWM_CH1_PA6 + config TIM3_PWM_CH1_PA6 + bool "PA6 AF2" + config TIM3_PWM_CH1_PB4 + bool "PB4 AF2" + config TIM3_PWM_CH1_PC6 + bool "PC6 AF5" + endchoice + endif + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 channel2" + default n + if BSP_USING_TIM3_PWM_CH2 + choice + prompt "Select Pin" + default TIM3_PWM_CH2_PA7 + config TIM3_PWM_CH2_PA7 + bool "PA7 AF2" + config TIM3_PWM_CH2_PB5 + bool "PB5 AF2" + config TIM3_PWM_CH2_PC7 + bool "PC7 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 channel3" + default n + if BSP_USING_TIM3_PWM_CH3 + choice + prompt "Select Pin" + default TIM3_PWM_CH3_PB0 + config TIM3_PWM_CH3_PB0 + bool "PB0 AF2" + config TIM3_PWM_CH3_PC8 + bool "PC8 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH4 + bool "Enable TIM3 channel3 AF2 PB11" + default n + if BSP_USING_TIM3_PWM_CH4 + choice + prompt "Select Pin" + default TIM3_PWM_CH4_PB1 + config TIM3_PWM_CH4_PB1 + bool "PB1 AF2" + config TIM3_PWM_CH4_PC9 + bool "PC89 AF2" + endchoice + endif + endif #BSP_USING_TIM3_PWM + endif#BSP_USING_PWM + + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32l43xml-stb/board/Kconfig b/bsp/n32/n32l43xml-stb/board/Kconfig index 5e3fe2a39e6..e31860cb93b 100644 --- a/bsp/n32/n32l43xml-stb/board/Kconfig +++ b/bsp/n32/n32l43xml-stb/board/Kconfig @@ -163,7 +163,144 @@ menu "On-chip Peripheral Drivers" bool "Enable CAN" select RT_USING_CAN default n - + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 channel1 PA8 AF2" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 channel2 PA9 AF2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 channel3 PA10 AF2" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 channel4 PA11 AF2" + default n + endif#BSP_USING_TIM1_PWM + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 channel1" + default n + if BSP_USING_TIM2_PWM_CH1 + choice + prompt "Select Pin" + default TIM2_PWM_CH1_PA0 + config TIM2_PWM_CH1_PA0 + bool "PA0 AF2" + config TIM2_PWM_CH1_PA15 + bool "PA15 AF5" + endchoice + endif + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 channel2" + default n + if BSP_USING_TIM2_PWM_CH2 + choice + prompt "Select Pin" + default TIM2_PWM_CH2_PA1 + config TIM2_PWM_CH2_PA1 + bool "PA1 AF2" + config TIM2_PWM_CH2_PB3 + bool "PB3 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 channel3" + default n + if BSP_USING_TIM2_PWM_CH3 + choice + prompt "Select Pin" + default TIM2_PWM_CH3_PA2 + config TIM2_PWM_CH3_PA2 + bool "PA2 AF2" + config TIM2_PWM_CH3_PB10 + bool "PB10 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH4 + bool "Enable TIM2 channel3 AF2 PB11" + default n + endif#BSP_USING_TIM2_PWM + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 channel1" + default n + if BSP_USING_TIM3_PWM_CH1 + choice + prompt "Select Pin" + default TIM3_PWM_CH1_PA6 + config TIM3_PWM_CH1_PA6 + bool "PA6 AF2" + config TIM3_PWM_CH1_PB4 + bool "PB4 AF2" + config TIM3_PWM_CH1_PC6 + bool "PC6 AF5" + endchoice + endif + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 channel2" + default n + if BSP_USING_TIM3_PWM_CH2 + choice + prompt "Select Pin" + default TIM3_PWM_CH2_PA7 + config TIM3_PWM_CH2_PA7 + bool "PA7 AF2" + config TIM3_PWM_CH2_PB5 + bool "PB5 AF2" + config TIM3_PWM_CH2_PC7 + bool "PC7 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 channel3" + default n + if BSP_USING_TIM3_PWM_CH3 + choice + prompt "Select Pin" + default TIM3_PWM_CH3_PB0 + config TIM3_PWM_CH3_PB0 + bool "PB0 AF2" + config TIM3_PWM_CH3_PC8 + bool "PC8 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH4 + bool "Enable TIM3 channel3 AF2 PB11" + default n + if BSP_USING_TIM3_PWM_CH4 + choice + prompt "Select Pin" + default TIM3_PWM_CH4_PB1 + config TIM3_PWM_CH4_PB1 + bool "PB1 AF2" + config TIM3_PWM_CH4_PC9 + bool "PC89 AF2" + endchoice + endif + endif #BSP_USING_TIM3_PWM + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32l43xml-stb/project.uvprojx b/bsp/n32/n32l43xml-stb/project.uvprojx index d378a750085..7bea9a62110 100644 --- a/bsp/n32/n32l43xml-stb/project.uvprojx +++ b/bsp/n32/n32l43xml-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - __RTTHREAD__, __CLK_TCK=RT_TICK_PER_SECOND, __STDC_LIMIT_MACROS, N32L43X, RT_USING_ARMLIBC, USE_STDPERIPH_DRIVER, RT_USING_LIBC + RT_USING_ARMLIBC, __STDC_LIMIT_MACROS, USE_STDPERIPH_DRIVER, RT_USING_LIBC, __RTTHREAD__, __CLK_TCK=RT_TICK_PER_SECOND, N32L43X - ..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\libraries\N32L43x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\inc;..\libraries\n32_drivers;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\include;..\..\..\components\drivers\include;.;..\..\..\components\drivers\spi;..\..\..\libcpu\arm\cortex-m4;..\libraries\N32L43x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\drivers\include;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;applications;board;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\phy;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\finsh;..\..\..\components\drivers\smp_call;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include + ..\libraries\n32_drivers;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\libc\posix\ipc;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;board;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\finsh;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\libraries\N32L43x_Firmware_Library\CMSIS\core;..\..\..\components\net\utest;..\libraries\N32L43x_Firmware_Library\CMSIS\device;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\phy;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;applications;.;..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\inc;..\..\..\components\libc\posix\io\epoll;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\libc\compilers\common\extension\fcntl\octal @@ -388,61 +388,33 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c - 1 - ..\..\..\components\libc\compilers\common\cstdlib.c - - - - - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +743,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +900,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +935,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,9 +975,9 @@ Finsh - msh_parse.c + cmd.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\cmd.c @@ -984,16 +989,16 @@ - msh.c + msh_parse.c 1 - ..\..\..\components\finsh\msh.c + ..\..\..\components\finsh\msh_parse.c - cmd.c + msh.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\msh.c @@ -1305,33 +1310,61 @@ - klibc + Libc - kstdio.c + syscall_mem.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsscanf.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - rt_vsnprintf_tiny.c + cctype.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\common\cctype.c - kstring.c + cstdlib.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\common\cstdlib.c + + + + + cstring.c + 1 + ..\..\..\components\libc\compilers\common\cstring.c + + + + + ctime.c + 1 + ..\..\..\components\libc\compilers\common\ctime.c + + + + + cunistd.c + 1 + ..\..\..\components\libc\compilers\common\cunistd.c + + + + + cwchar.c + 1 + ..\..\..\components\libc\compilers\common\cwchar.c @@ -1341,35 +1374,32 @@ ..\..\..\src\klibc\kerrno.c - - - libcpu - div0.c + kstdio.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\src\klibc\kstdio.c - showmem.c + kstring.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\src\klibc\kstring.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + rt_vsnprintf_tiny.c + 1 + ..\..\..\src\klibc\rt_vsnprintf_tiny.c - cpuport.c + rt_vsscanf.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\rt_vsscanf.c @@ -1377,51 +1407,51 @@ Libraries - n32l43x_flash.c + n32l43x_rtc.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_flash.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rtc.c - n32l43x_iwdg.c + n32l43x_gpio.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_iwdg.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_gpio.c - n32l43x_i2c.c + n32l43x_pwr.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_i2c.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_pwr.c - n32l43x_exti.c + n32l43x_wwdg.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_exti.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_wwdg.c - n32l43x_adc.c + n32l43x_tim.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_adc.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_tim.c - n32l43x_usart.c + n32l43x_rcc.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_usart.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rcc.c - n32l43x_rtc.c + n32l43x_usart.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rtc.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_usart.c @@ -1433,9 +1463,9 @@ - n32l43x_gpio.c + n32l43x_adc.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_gpio.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_adc.c @@ -1447,51 +1477,51 @@ - n32l43x_can.c + n32l43x_dac.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_can.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_dac.c - misc.c + n32l43x_iwdg.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\misc.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_iwdg.c - n32l43x_dac.c + n32l43x_i2c.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_dac.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_i2c.c - n32l43x_pwr.c + n32l43x_flash.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_pwr.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_flash.c - n32l43x_rcc.c + n32l43x_exti.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rcc.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_exti.c - n32l43x_wwdg.c + misc.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_wwdg.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\misc.c - n32l43x_tim.c + n32l43x_can.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_tim.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_can.c diff --git a/bsp/n32/n32l43xml-stb/rtconfig.h b/bsp/n32/n32l43xml-stb/rtconfig.h index a454f9f412f..253b5b926b3 100644 --- a/bsp/n32/n32l43xml-stb/rtconfig.h +++ b/bsp/n32/n32l43xml-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ @@ -153,8 +153,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -327,6 +329,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -419,6 +425,9 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM +#define BSP_USING_TIM1_PWM +#define BSP_USING_TIM1_PWM_CH1 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32l43xrl-stb/board/Kconfig b/bsp/n32/n32l43xrl-stb/board/Kconfig index 5e3fe2a39e6..2d0625c1a5a 100644 --- a/bsp/n32/n32l43xrl-stb/board/Kconfig +++ b/bsp/n32/n32l43xrl-stb/board/Kconfig @@ -164,6 +164,144 @@ menu "On-chip Peripheral Drivers" select RT_USING_CAN default n + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 channel1 PA8 AF2" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 channel2 PA9 AF2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 channel3 PA10 AF2" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 channel4 PA11 AF2" + default n + endif#BSP_USING_TIM1_PWM + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 channel1" + default n + if BSP_USING_TIM2_PWM_CH1 + choice + prompt "Select Pin" + default TIM2_PWM_CH1_PA0 + config TIM2_PWM_CH1_PA0 + bool "PA0 AF2" + config TIM2_PWM_CH1_PA15 + bool "PA15 AF5" + endchoice + endif + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 channel2" + default n + if BSP_USING_TIM2_PWM_CH2 + choice + prompt "Select Pin" + default TIM2_PWM_CH2_PA1 + config TIM2_PWM_CH2_PA1 + bool "PA1 AF2" + config TIM2_PWM_CH2_PB3 + bool "PB3 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 channel3" + default n + if BSP_USING_TIM2_PWM_CH3 + choice + prompt "Select Pin" + default TIM2_PWM_CH3_PA2 + config TIM2_PWM_CH3_PA2 + bool "PA2 AF2" + config TIM2_PWM_CH3_PB10 + bool "PB10 AF2" + endchoice + endif + config BSP_USING_TIM2_PWM_CH4 + bool "Enable TIM2 channel3 AF2 PB11" + default n + endif#BSP_USING_TIM2_PWM + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 channel1" + default n + if BSP_USING_TIM3_PWM_CH1 + choice + prompt "Select Pin" + default TIM3_PWM_CH1_PA6 + config TIM3_PWM_CH1_PA6 + bool "PA6 AF2" + config TIM3_PWM_CH1_PB4 + bool "PB4 AF2" + config TIM3_PWM_CH1_PC6 + bool "PC6 AF5" + endchoice + endif + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 channel2" + default n + if BSP_USING_TIM3_PWM_CH2 + choice + prompt "Select Pin" + default TIM3_PWM_CH2_PA7 + config TIM3_PWM_CH2_PA7 + bool "PA7 AF2" + config TIM3_PWM_CH2_PB5 + bool "PB5 AF2" + config TIM3_PWM_CH2_PC7 + bool "PC7 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 channel3" + default n + if BSP_USING_TIM3_PWM_CH3 + choice + prompt "Select Pin" + default TIM3_PWM_CH3_PB0 + config TIM3_PWM_CH3_PB0 + bool "PB0 AF2" + config TIM3_PWM_CH3_PC8 + bool "PC8 AF2" + endchoice + endif + config BSP_USING_TIM3_PWM_CH4 + bool "Enable TIM3 channel3 AF2 PB11" + default n + if BSP_USING_TIM3_PWM_CH4 + choice + prompt "Select Pin" + default TIM3_PWM_CH4_PB1 + config TIM3_PWM_CH4_PB1 + bool "PB1 AF2" + config TIM3_PWM_CH4_PC9 + bool "PC89 AF2" + endchoice + endif + endif #BSP_USING_TIM3_PWM + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32l43xrl-stb/project.uvprojx b/bsp/n32/n32l43xrl-stb/project.uvprojx index 2a9cd0823c3..0615d5f5916 100644 --- a/bsp/n32/n32l43xrl-stb/project.uvprojx +++ b/bsp/n32/n32l43xrl-stb/project.uvprojx @@ -334,9 +334,9 @@ 0 - USE_STDPERIPH_DRIVER, __CLK_TCK=RT_TICK_PER_SECOND, RT_USING_LIBC, __STDC_LIMIT_MACROS, __RTTHREAD__, RT_USING_ARMLIBC, N32L43X + __STDC_LIMIT_MACROS, __CLK_TCK=RT_TICK_PER_SECOND, N32L43X, __RTTHREAD__, RT_USING_LIBC, RT_USING_ARMLIBC, USE_STDPERIPH_DRIVER - ..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;..\..\..\components\drivers\smp_call;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;..\libraries\n32_drivers;..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\inc;..\..\..\components\drivers\phy;..\libraries\N32L43x_Firmware_Library\CMSIS\device;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\libraries\n32_drivers\config;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\include;applications;..\..\..\components\finsh;.;..\..\..\libcpu\arm\cortex-m4;..\libraries\N32L43x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\spi + ..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\smp_call;..\..\..\components\libc\posix\ipc;..\..\..\libcpu\arm\common;..\..\..\components\drivers\include;..\..\..\components\drivers\include;.;..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\inc;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;..\..\..\components\net\utest;..\libraries\n32_drivers\config;..\libraries\n32_drivers;..\libraries\N32L43x_Firmware_Library\CMSIS\device;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;applications;..\libraries\N32L43x_Firmware_Library\CMSIS\core;..\..\..\components\drivers\spi;board;..\..\..\components\libc\posix\io\poll;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\phy;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\libc\compilers\common\extension;..\..\..\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\finsh;..\..\..\components\drivers\include @@ -388,61 +388,33 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c - 1 - ..\..\..\components\libc\compilers\common\cstdlib.c - - - - - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +743,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +900,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +935,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,23 +975,23 @@ Finsh - cmd.c + msh_parse.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\msh_parse.c - shell.c + cmd.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\cmd.c - msh_parse.c + shell.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\shell.c @@ -1305,109 +1310,120 @@ - klibc + Libc - rt_vsnprintf_tiny.c + syscall_mem.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - rt_vsscanf.c + syscalls.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - kstring.c + cctype.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\common\cctype.c - kerrno.c + cstdlib.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\common\cstdlib.c - kstdio.c + cstring.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - div0.c + ctime.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\ctime.c - showmem.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cunistd.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + cwchar.c + 1 + ..\..\..\components\libc\compilers\common\cwchar.c - cpuport.c + kerrno.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kerrno.c - - - Libraries - n32l43x_adc.c + kstdio.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_adc.c + ..\..\..\src\klibc\kstdio.c - n32l43x_can.c + kstring.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_can.c + ..\..\..\src\klibc\kstring.c - n32l43x_spi.c + rt_vsnprintf_tiny.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_spi.c + ..\..\..\src\klibc\rt_vsnprintf_tiny.c - n32l43x_rtc.c + rt_vsscanf.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rtc.c + ..\..\..\src\klibc\rt_vsscanf.c + + + Libraries - misc.c + n32l43x_adc.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\misc.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_adc.c + + + + + system_n32l43x.c + 1 + ..\libraries\N32L43x_Firmware_Library\CMSIS\device\system_n32l43x.c + + + + + n32l43x_can.c + 1 + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_can.c @@ -1419,23 +1435,23 @@ - n32l43x_rcc.c + n32l43x_i2c.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rcc.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_i2c.c - n32l43x_exti.c + n32l43x_spi.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_exti.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_spi.c - n32l43x_dac.c + n32l43x_gpio.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_dac.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_gpio.c @@ -1454,44 +1470,58 @@ - n32l43x_gpio.c + n32l43x_wwdg.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_gpio.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_wwdg.c - n32l43x_i2c.c + n32l43x_tim.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_i2c.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_tim.c - n32l43x_tim.c + n32l43x_flash.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_tim.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_flash.c - system_n32l43x.c + n32l43x_rtc.c 1 - ..\libraries\N32L43x_Firmware_Library\CMSIS\device\system_n32l43x.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rtc.c - n32l43x_flash.c + n32l43x_rcc.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_flash.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_rcc.c - n32l43x_wwdg.c + n32l43x_exti.c 1 - ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_wwdg.c + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_exti.c + + + + + n32l43x_dac.c + 1 + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\n32l43x_dac.c + + + + + misc.c + 1 + ..\libraries\N32L43x_Firmware_Library\n32l43x_std_periph_driver\src\misc.c diff --git a/bsp/n32/n32l43xrl-stb/rtconfig.h b/bsp/n32/n32l43xrl-stb/rtconfig.h index a454f9f412f..89607c5cc55 100644 --- a/bsp/n32/n32l43xrl-stb/rtconfig.h +++ b/bsp/n32/n32l43xrl-stb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ @@ -153,8 +153,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -327,6 +329,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -419,6 +425,7 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */ diff --git a/bsp/n32/n32wb45xl-evb/board/Kconfig b/bsp/n32/n32wb45xl-evb/board/Kconfig index 0610640dc42..f27ee894d8e 100644 --- a/bsp/n32/n32wb45xl-evb/board/Kconfig +++ b/bsp/n32/n32wb45xl-evb/board/Kconfig @@ -184,6 +184,104 @@ menu "On-chip Peripheral Drivers" default n endif + #-----------------------------PWM---------------------------------- + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + select RT_USING_HWTIMER + if BSP_USING_PWM + menuconfig BSP_USING_TIM1_PWM + bool "Enable TIM1 output PWM" + default n + # --------------selcet remap----------------- + if BSP_USING_TIM1_PWM + choice + prompt "Select Pin" + default TIM1_REMAP_0 + config TIM1_REMAP_0 + bool "PA8 PA9 PA10 PA11" + config TIM1_REMAP_3 + bool "PE9 PE11 PE13 PE14" + endchoice + # -----------tim chanle enable----------------- + config BSP_USING_TIM1_PWM_CH1 + bool "Enable TIM1 CH1" + default n + config BSP_USING_TIM1_PWM_CH2 + bool "Enable TIM1 CH2" + default n + config BSP_USING_TIM1_PWM_CH3 + bool "Enable TIM1 CH3" + default n + config BSP_USING_TIM1_PWM_CH4 + bool "Enable TIM1 CH4" + default n + endif + + + menuconfig BSP_USING_TIM2_PWM + bool "Enable TIM2 output PWM" + default n + if BSP_USING_TIM2_PWM + choice + prompt "Select Pin" + default TIM2_REMAP_0 + config TIM2_REMAP_0 + bool "PA0 PA1 PA2 PA3" + config TIM2_REMAP_1 + bool "PA15 PB3 PA2 PA3" + config TIM2_REMAP_2 + bool "PA0 PA1 PB10 PB11" + config TIM2_REMAP_3 + bool "PA15 PB3 PB10 PB11" + endchoice + + config BSP_USING_TIM2_PWM_CH0 + bool "Enable TIM2 CH1" + default n + config BSP_USING_TIM2_PWM_CH1 + bool "Enable TIM2 CH2" + default n + config BSP_USING_TIM2_PWM_CH2 + bool "Enable TIM2 CH3" + default n + config BSP_USING_TIM2_PWM_CH3 + bool "Enable TIM2 CH4" + default n + endif + + menuconfig BSP_USING_TIM3_PWM + bool "Enable TIM3 output PWM" + default n + if BSP_USING_TIM3_PWM + choice + prompt "Select Pin" + default TIM3_REMAP_0 + config TIM3_REMAP_0 + bool "PA6 PA7 PB0 PB1" + config TIM3_REMAP_2 + bool "PB4 PB5 PB0 PB1" + config TIM3_REMAP_3 + bool "PC6 PC7 PC8 PC9" + endchoice + + config BSP_USING_TIM3_PWM_CH0 + bool "Enable TIM3 CH1" + default n + config BSP_USING_TIM3_PWM_CH1 + bool "Enable TIM3 CH2" + default n + config BSP_USING_TIM3_PWM_CH2 + bool "Enable TIM3 CH3" + default n + config BSP_USING_TIM3_PWM_CH3 + bool "Enable TIM3 CH3" + default n + endif#BSP_USING_TIM3_PWM + + endif#BSP_USING_PWM + rsource "../../libraries/n32_drivers/Kconfig" endmenu diff --git a/bsp/n32/n32wb45xl-evb/project.uvprojx b/bsp/n32/n32wb45xl-evb/project.uvprojx index 61d4ee2eb9b..19efa3efa0c 100644 --- a/bsp/n32/n32wb45xl-evb/project.uvprojx +++ b/bsp/n32/n32wb45xl-evb/project.uvprojx @@ -334,9 +334,9 @@ 0 - __STDC_LIMIT_MACROS, RT_USING_LIBC, USE_STDPERIPH_DRIVER, N32WB452, __RTTHREAD__, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND + USE_STDPERIPH_DRIVER, __STDC_LIMIT_MACROS, RT_USING_LIBC, N32WB452, __CLK_TCK=RT_TICK_PER_SECOND, __RTTHREAD__, RT_USING_ARMLIBC - ..\..\..\components\libc\compilers\common\extension;..\libraries\N32WB452_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include;..\libraries\n32_drivers\config;..\..\..\components\drivers\include;board;..\..\..\components\libc\posix\ipc;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\finsh;..\..\..\components\drivers\include;..\..\..\components\drivers\include;applications;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\..\..\components\drivers\spi;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\include;.;..\..\..\components\drivers\phy;..\..\..\components\drivers\include;..\libraries\N32WB452_Firmware_Library\CMSIS\device;..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\inc;..\..\..\libcpu\arm\common;..\libraries\n32_drivers;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\libc\compilers\common\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\epoll;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll + ..\..\..\components\libc\posix\io\epoll;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\drivers\include;..\..\..\components\libc\posix\io\poll;..\..\..\components\net\utest;..\..\..\components\drivers\include;..\..\..\components\drivers\smp_call;..\libraries\N32WB452_Firmware_Library\CMSIS\device;..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\inc;..\..\..\components\drivers\include;..\libraries\n32_drivers;..\..\..\components\libc\posix\ipc;board;..\..\..\components\finsh;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\include;..\libraries\N32WB452_Firmware_Library\CMSIS\core;..\..\..\components\drivers\include;..\..\..\components\drivers\include;applications;..\libraries\n32_drivers\config;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\libc\compilers\common\extension\fcntl\octal;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\include;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\spi;..\..\..\components\drivers\phy;..\..\..\components\drivers\include;..\..\..\components\drivers\include;.;..\..\..\components\libc\compilers\common\extension @@ -388,61 +388,40 @@ - Compiler + CPU - syscall_mem.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - - - - - syscalls.c - 1 - ..\..\..\components\libc\compilers\armlibc\syscalls.c - - - - - cctype.c - 1 - ..\..\..\components\libc\compilers\common\cctype.c - - - - - cstdlib.c + atomic_arm.c 1 - ..\..\..\components\libc\compilers\common\cstdlib.c + ..\..\..\libcpu\arm\common\atomic_arm.c - cstring.c + div0.c 1 - ..\..\..\components\libc\compilers\common\cstring.c + ..\..\..\libcpu\arm\common\div0.c - ctime.c + showmem.c 1 - ..\..\..\components\libc\compilers\common\ctime.c + ..\..\..\libcpu\arm\common\showmem.c - cunistd.c - 1 - ..\..\..\components\libc\compilers\common\cunistd.c + context_rvds.S + 2 + ..\..\..\libcpu\arm\cortex-m4\context_rvds.S - cwchar.c + cpuport.c 1 - ..\..\..\components\libc\compilers\common\cwchar.c + ..\..\..\libcpu\arm\cortex-m4\cpuport.c @@ -771,6 +750,25 @@ + + + rt_drv_pwm.c + 1 + ..\..\..\components\drivers\misc\rt_drv_pwm.c + + + + + + __RT_IPC_SOURCE__ + + + + + + + + dev_pin.c @@ -909,6 +907,13 @@ ..\libraries\n32_drivers\drv_adc.c + + + drv_base.c + 1 + ..\libraries\n32_drivers\drv_base.c + + drv_can.c @@ -937,6 +942,13 @@ ..\libraries\n32_drivers\drv_hwtimer.c + + + drv_pwm.c + 1 + ..\libraries\n32_drivers\drv_pwm.c + + drv_rtc.c @@ -970,16 +982,16 @@ Finsh - cmd.c + shell.c 1 - ..\..\..\components\finsh\cmd.c + ..\..\..\components\finsh\shell.c - msh_parse.c + cmd.c 1 - ..\..\..\components\finsh\msh_parse.c + ..\..\..\components\finsh\cmd.c @@ -991,9 +1003,9 @@ - shell.c + msh_parse.c 1 - ..\..\..\components\finsh\shell.c + ..\..\..\components\finsh\msh_parse.c @@ -1305,78 +1317,96 @@ - klibc + Libc - kstring.c + syscall_mem.c 1 - ..\..\..\src\klibc\kstring.c + ..\..\..\components\libc\compilers\armlibc\syscall_mem.c - kerrno.c + syscalls.c 1 - ..\..\..\src\klibc\kerrno.c + ..\..\..\components\libc\compilers\armlibc\syscalls.c - rt_vsscanf.c + cctype.c 1 - ..\..\..\src\klibc\rt_vsscanf.c + ..\..\..\components\libc\compilers\common\cctype.c - kstdio.c + cstdlib.c 1 - ..\..\..\src\klibc\kstdio.c + ..\..\..\components\libc\compilers\common\cstdlib.c - rt_vsnprintf_tiny.c + cstring.c 1 - ..\..\..\src\klibc\rt_vsnprintf_tiny.c + ..\..\..\components\libc\compilers\common\cstring.c - - - libcpu - atomic_arm.c + ctime.c 1 - ..\..\..\libcpu\arm\common\atomic_arm.c + ..\..\..\components\libc\compilers\common\ctime.c - div0.c + cunistd.c 1 - ..\..\..\libcpu\arm\common\div0.c + ..\..\..\components\libc\compilers\common\cunistd.c - showmem.c + cwchar.c 1 - ..\..\..\libcpu\arm\common\showmem.c + ..\..\..\components\libc\compilers\common\cwchar.c - context_rvds.S - 2 - ..\..\..\libcpu\arm\cortex-m4\context_rvds.S + kerrno.c + 1 + ..\..\..\src\klibc\kerrno.c - cpuport.c + kstdio.c 1 - ..\..\..\libcpu\arm\cortex-m4\cpuport.c + ..\..\..\src\klibc\kstdio.c + + + + + kstring.c + 1 + ..\..\..\src\klibc\kstring.c + + + + + rt_vsnprintf_tiny.c + 1 + ..\..\..\src\klibc\rt_vsnprintf_tiny.c + + + + + rt_vsscanf.c + 1 + ..\..\..\src\klibc\rt_vsscanf.c @@ -1384,121 +1414,121 @@ Libraries - system_n32wb452.c + n32wb452_rcc.c 1 - ..\libraries\N32WB452_Firmware_Library\CMSIS\device\system_n32wb452.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_rcc.c - n32wb452_exti.c + n32wb452_adc.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_exti.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_adc.c - n32wb452_bkp.c + n32wb452_usart.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_bkp.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_usart.c - n32wb452_wwdg.c + misc.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_wwdg.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\misc.c - n32wb452_dac.c + n32wb452_exti.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_dac.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_exti.c - n32wb452_rcc.c + n32wb452_spi.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_rcc.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_spi.c - n32wb452_can.c + n32wb452_bkp.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_can.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_bkp.c - n32wb452_i2c.c + n32wb452_iwdg.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_i2c.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_iwdg.c - n32wb452_tim.c + n32wb452_pwr.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_tim.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_pwr.c - n32wb452_pwr.c + n32wb452_wwdg.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_pwr.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_wwdg.c - n32wb452_gpio.c + n32wb452_rtc.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_gpio.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_rtc.c - n32wb452_adc.c + n32wb452_tim.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_adc.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_tim.c - misc.c + system_n32wb452.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\misc.c + ..\libraries\N32WB452_Firmware_Library\CMSIS\device\system_n32wb452.c - n32wb452_spi.c + n32wb452_dac.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_spi.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_dac.c - n32wb452_iwdg.c + n32wb452_gpio.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_iwdg.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_gpio.c - n32wb452_rtc.c + n32wb452_i2c.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_rtc.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_i2c.c - n32wb452_usart.c + n32wb452_can.c 1 - ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_usart.c + ..\libraries\N32WB452_Firmware_Library\n32wb452_std_periph_driver\src\n32wb452_can.c diff --git a/bsp/n32/n32wb45xl-evb/rtconfig.h b/bsp/n32/n32wb45xl-evb/rtconfig.h index 7d15dff71c8..c9b770ec0e4 100644 --- a/bsp/n32/n32wb45xl-evb/rtconfig.h +++ b/bsp/n32/n32wb45xl-evb/rtconfig.h @@ -104,7 +104,7 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "usart1" -#define RT_VER_NUM 0x50201 +#define RT_VER_NUM 0x50300 #define RT_BACKTRACE_LEVEL_MAX_NR 32 /* end of RT-Thread Kernel */ #define RT_USING_HW_ATOMIC @@ -158,8 +158,10 @@ #define RT_USING_I2C_BITOPS #define RT_USING_ADC #define RT_USING_DAC +#define RT_USING_PWM #define RT_USING_RTC #define RT_USING_SPI +#define RT_USING_SPI_ISR #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER @@ -332,6 +334,10 @@ /* GD32 Drivers */ /* end of GD32 Drivers */ + +/* HPMicro SDK */ + +/* end of HPMicro SDK */ /* end of HAL & SDK Drivers */ /* sensors drivers */ @@ -425,6 +431,13 @@ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_USART1 +#define BSP_USING_PWM +#define BSP_USING_TIM2_PWM +#define TIM2_REMAP_0 +#define BSP_USING_TIM2_PWM_CH0 +#define BSP_USING_TIM2_PWM_CH1 +#define BSP_USING_TIM2_PWM_CH2 +#define BSP_USING_TIM2_PWM_CH3 /* end of On-chip Peripheral Drivers */ /* Board extended module Drivers */