diff --git a/drivers/drivers-x2600/include/x2600_hal_pwm.h b/drivers/drivers-x2600/include/x2600_hal_pwm.h index 1377da02263e02ac284d9337e44cdabafed3f5c6..81f4e58733b790387af3094ee26b5cef7e2dd4c6 100644 --- a/drivers/drivers-x2600/include/x2600_hal_pwm.h +++ b/drivers/drivers-x2600/include/x2600_hal_pwm.h @@ -108,7 +108,7 @@ typedef struct __PWM_HandleTypeDef { // TODO: ADD more here or remove!! PWM_TypeDef *Instance; /*!< PWM 寄存器基地址 */ PWM_InitTypeDef Init[__HAL_PWM_MAX_CHANNEL]; /*!< PWM 初始化参数. */ - uint32_t PWMColck; /*!< PWM时钟频率 */ + uint32_t PWMClock; /*!< PWM时钟频率 */ __IO uint32_t Channels; /*!< 所有通道 */ HAL_LockTypeDef Lock; /*!< PWM Lock */ DMA_HandleTypeDef *DMA_Handle; diff --git a/drivers/drivers-x2600/src/x2600_hal_pwm.c b/drivers/drivers-x2600/src/x2600_hal_pwm.c index 48725873d82b02a33355dd2f31ecb78e0102f3d7..00a159955bbbf8479237f66964a7599970ec31ed 100644 --- a/drivers/drivers-x2600/src/x2600_hal_pwm.c +++ b/drivers/drivers-x2600/src/x2600_hal_pwm.c @@ -119,7 +119,7 @@ HAL_StatusTypeDef HAL_PWM_setOneChannel(PWM_HandleTypeDef *hpwm, uint8_t ch) __HAL_SET_PWM_UPDATE_MODE(hpwm, ch, hpwm->Init[ch].Mode); if (hpwm->Init[ch].Mode == commonMode) { - uint32_t PWMClock = hpwm->PWMColck; + uint32_t PWMClock = hpwm->PWMClock; uint64_t period_us = (uint64_t)hpwm->Init[ch].periodus * PWMClock / 1000000LL; uint64_t duty_us = (uint64_t)hpwm->Init[ch].dutyus * PWMClock / 1000000LL; uint32_t p_cycles, d_cycles; diff --git a/projects/x2660-halley/Demos/pwm-oneshort/bare/CMakeLists.txt b/projects/x2660-halley/Demos/pwm-oneshort/bare/CMakeLists.txt index 06c102c8f13e1048ffa7244adc05a72779b6abcd..dd42b35df5c5a146641f2484afb74553dc007343 100755 --- a/projects/x2660-halley/Demos/pwm-oneshort/bare/CMakeLists.txt +++ b/projects/x2660-halley/Demos/pwm-oneshort/bare/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8) # # Core project settings # -Project(pwm_oneshort) # Modified +Project(pwm_oneshot) # Modified enable_language(C CXX ASM) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Setup compiler settings @@ -58,7 +58,7 @@ set(sources_SRCS # Modified ${SDK_PATH}/lib/libc/minimal/string.c ${SDK_PATH}/lib/libc/minimal/vsprintf.c main.c - pwm_oneshort.c + pwm_oneshot.c ) diff --git a/projects/x2660-halley/Demos/pwm-oneshort/bare/Makefile b/projects/x2660-halley/Demos/pwm-oneshort/bare/Makefile index 47345dd30d383f9609f8b3a5b188e94f86d22615..3336dea6f3e6046f49ec1b40021251b8de92832c 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/bare/Makefile +++ b/projects/x2660-halley/Demos/pwm-oneshort/bare/Makefile @@ -1,7 +1,7 @@ ###################################### # target ###################################### -TARGET = pwm_oneshort +TARGET = pwm_oneshot SDK_PATH = $(CURDIR)/../../../../.. @@ -43,7 +43,7 @@ $(SDK_PATH)/lib/libc/minimal/string.c \ $(SDK_PATH)/lib/libc/minimal/ctype.c \ $(SDK_PATH)/lib/libc/minimal/div64.c \ main.c \ -pwm_oneshort.c +pwm_oneshot.c # ASM sources ASM_SOURCES = \ diff --git a/projects/x2660-halley/Demos/pwm-oneshort/bare/README.md b/projects/x2660-halley/Demos/pwm-oneshort/bare/README.md index b3cce920d45b8c8c3008efd82fc98ae99e92db08..e358bf02f0b546b7bd1ee887b17154d07370841c 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/bare/README.md +++ b/projects/x2660-halley/Demos/pwm-oneshort/bare/README.md @@ -1,4 +1,4 @@ -# pwm oneshort控制输出 +# pwm oneshot控制输出 用于gpio控制pwm波形单步输出 @@ -6,15 +6,15 @@ 1. 使用PWM产生波形,确保gpio 200us触发一次 2. GPIO上升沿作为中断输入 -3. 中断后启动oneshort传输 -4. 由oneshort输出的pwm产生波形 +3. 中断后启动oneshot传输 +4. 由oneshot输出的pwm产生波形 5. 产生的波形由启动时传输的HighCount,LowCount决定 -6. 测量PWM输出,和pwm_oneshort输出的时间 +6. 测量PWM输出,和pwm_oneshot输出的时间 ## 硬件连接 ![hardware-connect](image/README/hardware-connect.png) -pwm12(pc11)为5kHz,一个周期为200us,pb4为上升沿中断触发,200us触发后执行oneshort操作 +pwm12(pc11)为5kHz,一个周期为200us,pb4为上升沿中断触发,200us触发后执行oneshot操作 ## 时钟时序图 ![pwm_clk](image/README/pwm_clk.png) @@ -38,19 +38,19 @@ pwm12(pc11)为5kHz,一个周期为200us,pb4为上升沿中断触发,200us触 ## 数据输出时序图 ![timing-diagram-1](image/README/timing-diagram-1.png) -oneshort的时间大于200us +oneshot的时间大于200us ![timing-diagram-2](image/README/timing-diagram-2.png) -oneshort的时间小于于200us +oneshot的时间小于于200us ![timing-diagram-3](image/README/timing-diagram-3.png) -oneshort200us触发一次 +oneshot200us触发一次 ## Linux 命令行编译 ### 基于Makefile编译 1 $ make - 会在build目录生成pwm_oneshort.elf, pwm_oneshort.bin文件. + 会在build目录生成pwm_oneshot.elf, pwm_oneshot.bin文件. ### 基于cmake构建 @@ -60,7 +60,7 @@ oneshort200us触发一次 3 $ cmake -DCMAKE_TOOLCHAIN_FILE=../riscv32-gcc.cmake .. 4 $ make -会在build目录下生成pwm_oneshort.elf,pwm_oneshort.bin文件. +会在build目录下生成pwm_oneshot.elf,pwm_oneshot.bin文件. ### 基于vscode 集成开发环境 @@ -104,25 +104,25 @@ typedef struct { DMA_InitChannelConfTypeDef PWM_DMA_Config; /*!< dma配置通道结构体 */ DMA_InitDescConfTypeDef PWM_Tx_descConfig; /*!< dma配置描述符结构体 */ int txdata; /*!< dma传输的数据 */ -} PWM_Oneshort; +} PWM_Oneshot; /** - * @brief 初始化oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 初始化oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int pwm_channel); +int PWM_Oneshot_Init(PWM_Oneshot *oneshot, int pwm_channel); ### 控制类函数 ```c /** - * @brief 启动一次oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 启动一次oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param HighCount pwm高电平周期数 * @param LowCount pwm低电平周期数 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Start(PWM_Oneshort *oneshort, int16_t HighCount, int16_t LowCount); +int PWM_Oneshot_Start(PWM_Oneshot *oneshot, int16_t HighCount, int16_t LowCount); ``` diff --git a/projects/x2660-halley/Demos/pwm-oneshort/bare/main.c b/projects/x2660-halley/Demos/pwm-oneshort/bare/main.c index 9d7e4bf9929f593feef73c1e7cda759d22937c92..09097d046ba303295c465d255f6ed9fa5a6d8c1e 100755 --- a/projects/x2660-halley/Demos/pwm-oneshort/bare/main.c +++ b/projects/x2660-halley/Demos/pwm-oneshort/bare/main.c @@ -1,17 +1,17 @@ #include -#include "pwm_oneshort.h" +#include "pwm_oneshot.h" -#define PWM0_ONESHORT_GPIO_IRQ 0 +#define PWM0_ONESHOT_GPIO_IRQ 0 #define PWM12_COMMON 12 static PWM_HandleTypeDef PWM_Handle; static DMA_HandleTypeDef DMA_Handle; -PWM_Oneshort pwm_oneshort = { +PWM_Oneshot pwm_oneshot = { .P_PWM_Handle = &PWM_Handle, - .PWM_Config.Channels = PWM_CHANNEL(PWM0_ONESHORT_GPIO_IRQ), + .PWM_Config.Channels = PWM_CHANNEL(PWM0_ONESHOT_GPIO_IRQ), .PWM_Config.idleLevel = PWMIdleLow, .PWM_Config.initLevel = PWMInitHigh, .PWM_Config.prescale_dma = 0, @@ -29,18 +29,18 @@ PWM_InitTypeDef PWM_Config = { void gpio_handler(int irq, void *data) { - PWM_Oneshort *oneshort = (PWM_Oneshort *)data; + PWM_Oneshot *oneshot = (PWM_Oneshot *)data; static int cnt = 0; int ret = 0; if (cnt == 0) { - ret = PWM_Oneshort_Start(oneshort, 0x0FA0, 0x0FA0); + ret = PWM_Oneshot_Start(oneshot, 0x0FA0, 0x0FA0); cnt = 1; } else { - ret = PWM_Oneshort_Start(oneshort, 0x1F40, 0x1F40); + ret = PWM_Oneshot_Start(oneshot, 0x1F40, 0x1F40); cnt = 0; } if (ret < 0) { - prom_printk("Oneshort_Enable fail\n"); + prom_printk("Oneshot_Enable fail\n"); } } @@ -99,13 +99,13 @@ int main(void) HAL_PWM_Enable(&PWM_Handle); - ret = PWM_Oneshort_Init(&pwm_oneshort, PWM0_ONESHORT_GPIO_IRQ); + ret = PWM_Oneshot_Init(&pwm_oneshot, PWM0_ONESHOT_GPIO_IRQ); if (ret < 0) { - prom_printk("Oneshort_Init fail\n"); + prom_printk("Oneshot_Init fail\n"); return -1; } - gpio_request_irq(GPIO_IRQ_PB(4), GPIO_MODE_IRQ_EDGE_RISING, gpio_handler, (void *)&pwm_oneshort); + gpio_request_irq(GPIO_IRQ_PB(4), GPIO_MODE_IRQ_EDGE_RISING, gpio_handler, (void *)&pwm_oneshot); while (1); return 0; diff --git a/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.c b/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.c index d0d4a3a0e3bd18571a356de22eb129749a6656b3..d95bc581540654b68eff43b9c3cee5140e29b959 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.c +++ b/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.c @@ -20,47 +20,47 @@ @endverbatim */ #include -#include "pwm_oneshort.h" +#include "pwm_oneshot.h" /** * @brief 配置pwm和dma描述符 - * @param oneshort 指向PWM_Oneshort结构的指针 + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval None **/ -static void PWM_Oneshort_Desc_Config(PWM_Oneshort *oneshort, int channel) +static void PWM_Oneshot_Desc_Config(PWM_Oneshot *oneshot, int channel) { - oneshort->PWM_DMA_Config.DescMode = NO_DESCRIPTOR; - oneshort->PWM_DMA_Config.descConfig = &oneshort->PWM_Tx_descConfig; - - oneshort->PWM_Tx_descConfig.Desc_Interrupt = NO_DMA_INTERRUPT; - oneshort->PWM_Tx_descConfig.Desc_Link = NO_LINK; - oneshort->PWM_Tx_descConfig.DescDMATransferType = DMA_RQ_PWM0_TX + channel; - oneshort->PWM_Tx_descConfig.DescSrcAddress = &oneshort->txdata; - oneshort->PWM_Tx_descConfig.DescSrcAddrIncrement = DISABLE; - oneshort->PWM_Tx_descConfig.DescSrcPortWidth = DMA_PORT_32BIT; - - oneshort->PWM_Tx_descConfig.DescDstAddress = (void *)PWM_FIFO(oneshort->P_PWM_Handle, channel); - oneshort->PWM_Tx_descConfig.DescDstAddrIncrement = DISABLE; - oneshort->PWM_Tx_descConfig.DescDstPortWidth = DMA_PORT_32BIT; - - oneshort->PWM_Tx_descConfig.DescTransferNumByte = 4; - oneshort->PWM_Tx_descConfig.DataLength = 4; + oneshot->PWM_DMA_Config.DescMode = NO_DESCRIPTOR; + oneshot->PWM_DMA_Config.descConfig = &oneshot->PWM_Tx_descConfig; + + oneshot->PWM_Tx_descConfig.Desc_Interrupt = NO_DMA_INTERRUPT; + oneshot->PWM_Tx_descConfig.Desc_Link = NO_LINK; + oneshot->PWM_Tx_descConfig.DescDMATransferType = DMA_RQ_PWM0_TX + channel; + oneshot->PWM_Tx_descConfig.DescSrcAddress = &oneshot->txdata; + oneshot->PWM_Tx_descConfig.DescSrcAddrIncrement = DISABLE; + oneshot->PWM_Tx_descConfig.DescSrcPortWidth = DMA_PORT_32BIT; + + oneshot->PWM_Tx_descConfig.DescDstAddress = (void *)PWM_FIFO(oneshot->P_PWM_Handle, channel); + oneshot->PWM_Tx_descConfig.DescDstAddrIncrement = DISABLE; + oneshot->PWM_Tx_descConfig.DescDstPortWidth = DMA_PORT_32BIT; + + oneshot->PWM_Tx_descConfig.DescTransferNumByte = 4; + oneshot->PWM_Tx_descConfig.DataLength = 4; } /** - * @brief 初始化oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 初始化oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int channel) +int PWM_Oneshot_Init(PWM_Oneshot *oneshot, int channel) { int ret = 0; - PWM_Oneshort_Desc_Config(oneshort, channel); + PWM_Oneshot_Desc_Config(oneshot, channel); - if (&oneshort->PWM_DMA_Config != NULL) { - ret = HAL_DMA_requestChannel(oneshort->P_PWM_Handle->DMA_Handle, &oneshort->PWM_DMA_Config); + if (&oneshot->PWM_DMA_Config != NULL) { + ret = HAL_DMA_requestChannel(oneshot->P_PWM_Handle->DMA_Handle, &oneshot->PWM_DMA_Config); if(ret < 0) { prom_printk("DMA Channel has been used up\n"); return -1; @@ -68,43 +68,43 @@ int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int channel) } /* 设置PWM配置 */ - ret = HAL_PWM_setConfig(oneshort->P_PWM_Handle, &oneshort->PWM_Config); + ret = HAL_PWM_setConfig(oneshot->P_PWM_Handle, &oneshot->PWM_Config); if (ret != 0) { prom_printk("HAL_PWM_setConfig fail\n"); return -1; } /* 初始化PWM配置 */ - ret = HAL_PWM_Init(oneshort->P_PWM_Handle); + ret = HAL_PWM_Init(oneshot->P_PWM_Handle); if (ret != 0) { prom_printk("HAL_PWM_Init fail\n"); return -1; } - ret = HAL_PWM_Enable(oneshort->P_PWM_Handle); + ret = HAL_PWM_Enable(oneshot->P_PWM_Handle); if (ret != 0) { prom_printk("HAL_PWM_Enable fail\n"); return -1; } - HAL_DMA_Init_Common(oneshort->P_PWM_Handle->DMA_Handle, &oneshort->PWM_Tx_descConfig, oneshort->PWM_DMA_Config.Channel); + HAL_DMA_Init_Common(oneshot->P_PWM_Handle->DMA_Handle, &oneshot->PWM_Tx_descConfig, oneshot->PWM_DMA_Config.Channel); return 0; } /** - * @brief 启动一次oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 启动一次oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_high pwm高电平周期 * @param pwm_low pwm低电平周期 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowCount) +int PWM_Oneshot_Start(PWM_Oneshot *oneshot, uint16_t HighCount, uint16_t LowCount) { int ret = 0; assert_param(HighCount > 0 && HighCount <= 0xFFFF); assert_param(LowCount > 0 && LowCount <= 0xFFFF); - oneshort->txdata = HighCount << 16 | LowCount; - ret = HAL_DMA_Start_Common(oneshort->P_PWM_Handle->DMA_Handle, &oneshort->PWM_Tx_descConfig, oneshort->PWM_DMA_Config.Channel); + oneshot->txdata = HighCount << 16 | LowCount; + ret = HAL_DMA_Start_Common(oneshot->P_PWM_Handle->DMA_Handle, &oneshot->PWM_Tx_descConfig, oneshot->PWM_DMA_Config.Channel); if (ret != 0) { prom_printk("HAL_DMA_ReStart fail\n"); return -1; @@ -114,27 +114,27 @@ int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowC } /** - * @brief 取消oneshort初始化 - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 取消oneshot初始化 + * @param oneshot 指向PWM_Oneshot结构的指针 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_DeInit(PWM_Oneshort *oneshort) +int PWM_Oneshot_DeInit(PWM_Oneshot *oneshot) { int ret = 0; - ret = HAL_DMA_Stop(oneshort->P_PWM_Handle->DMA_Handle, oneshort->PWM_DMA_Config.Channel); + ret = HAL_DMA_Stop(oneshot->P_PWM_Handle->DMA_Handle, oneshot->PWM_DMA_Config.Channel); if (ret != 0) { prom_printk("HAL_DMA_Stop fail\n"); return -1; } - ret = HAL_DMA_releseChannel(oneshort->P_PWM_Handle->DMA_Handle,oneshort->PWM_DMA_Config.Channel); + ret = HAL_DMA_releseChannel(oneshot->P_PWM_Handle->DMA_Handle,oneshot->PWM_DMA_Config.Channel); if (ret != 0) { prom_printk("HAL_DMA_DeInit fail\n"); return -1; } - ret = HAL_PWM_Disable(oneshort->P_PWM_Handle); + ret = HAL_PWM_Disable(oneshot->P_PWM_Handle); if (ret != 0) { prom_printk("HAL_PWM_Disable fail\n"); return -1; diff --git a/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.h b/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.h index 410b5b5d3a21174dd7c3ed851125f555b214a107..5ceaffe9f38c372853629cd08fc1239e2e8957bf 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.h +++ b/projects/x2660-halley/Demos/pwm-oneshort/bare/pwm_oneshort.h @@ -1,8 +1,8 @@ -#ifndef __PWM_ONESHORT_H__ -#define __PWM_ONESHORT_H__ +#ifndef __PWM_ONESHOT_H__ +#define __PWM_ONESHOT_H__ -/** @defgroup PWM_Oneshort - * @brief PWM_Oneshort配置结构体定义 +/** @defgroup PWM_Oneshot + * @brief PWM_Oneshot配置结构体定义 * @{ */ typedef struct { @@ -11,30 +11,30 @@ typedef struct { DMA_InitChannelConfTypeDef PWM_DMA_Config; /*!< dma配置通道结构体 */ DMA_InitDescConfTypeDef PWM_Tx_descConfig; /*!< dma配置描述符结构体 */ int txdata; /*!< dma传输的数据 */ -} PWM_Oneshort; +} PWM_Oneshot; /** - * @brief 初始化oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 初始化oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int channel); +int PWM_Oneshot_Init(PWM_Oneshot *oneshot, int channel); /** - * @brief 启动一次oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 启动一次oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param Highcount pwm高电平周期 * @param Lowcount pwm低电平周期 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowCount); +int PWM_Oneshot_Start(PWM_Oneshot *oneshot, uint16_t HighCount, uint16_t LowCount); /** - * @brief 取消oneshort初始化 - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 取消oneshot初始化 + * @param oneshot 指向PWM_Oneshot结构的指针 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_DeInit(PWM_Oneshort *oneshort); +int PWM_Oneshot_DeInit(PWM_Oneshot *oneshot); #endif diff --git a/projects/x2660-halley/Demos/pwm-oneshort/freertos/CMakeLists.txt b/projects/x2660-halley/Demos/pwm-oneshort/freertos/CMakeLists.txt index f3b313e4cb4c8b131e1c027981807359df8bff6a..61c9821aeb22b4e6e13c8824aca3eb16a95b9195 100755 --- a/projects/x2660-halley/Demos/pwm-oneshort/freertos/CMakeLists.txt +++ b/projects/x2660-halley/Demos/pwm-oneshort/freertos/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8) # # Core project settings # -Project(pwm_oneshort) # Modified +Project(pwm_oneshot) # Modified enable_language(C CXX ASM) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Setup compiler settings @@ -68,7 +68,7 @@ set(sources_SRCS # Modified ${SDK_PATH}/drivers/drivers-x2600/src/x2600_hal_tick.c ${SDK_PATH}/drivers/drivers-x2600/src/x2600_ll_risc_ccu.c main.c - pwm_oneshort.c + pwm_oneshot.c ) diff --git a/projects/x2660-halley/Demos/pwm-oneshort/freertos/Makefile b/projects/x2660-halley/Demos/pwm-oneshort/freertos/Makefile index 54f3ddc400f071987574cf97eb3aed1da431b860..45fc4e16f82cf7e75d190663d4cd1e7624c2b0d7 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/freertos/Makefile +++ b/projects/x2660-halley/Demos/pwm-oneshort/freertos/Makefile @@ -1,7 +1,7 @@ ###################################### # target ###################################### -TARGET = pwm_oneshort +TARGET = pwm_oneshot SDK_PATH = $(CURDIR)/../../../../.. @@ -49,7 +49,7 @@ C_SOURCES = \ ${SDK_PATH}/drivers/drivers-x2600/src/x2600_hal_tick.c \ ${SDK_PATH}/drivers/drivers-x2600/src/x2600_ll_risc_ccu.c \ main.c \ - pwm_oneshort.c + pwm_oneshot.c # ASM sources ASM_SOURCES = \ diff --git a/projects/x2660-halley/Demos/pwm-oneshort/freertos/README.md b/projects/x2660-halley/Demos/pwm-oneshort/freertos/README.md index 0d6114d1e6e54afdf041cdad7974728bf930de2a..08f48fdcadc613764fb296c523b0dfb920152c37 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/freertos/README.md +++ b/projects/x2660-halley/Demos/pwm-oneshort/freertos/README.md @@ -1,4 +1,4 @@ -# pwm oneshort控制输出 +# pwm oneshot控制输出 用于gpio控制pwm波形单步输出 @@ -6,15 +6,15 @@ 1. 使用PWM产生波形,确保gpio 200us触发一次 2. GPIO上升沿作为中断输入 -3. 中断后启动oneshort传输 -4. 由oneshort输出的pwm产生波形 +3. 中断后启动oneshot传输 +4. 由oneshot输出的pwm产生波形 5. 产生的波形由启动时传输的HighCount,LowCount决定 -6. 测量PWM输出,和pwm_oneshort输出的时间 +6. 测量PWM输出,和pwm_oneshot输出的时间 ## 硬件连接 ![hardware-connect](image/README/hardware-connect.png) -pwm12(pc11)为5kHz,一个周期为200us,pb4为上升沿中断触发,200us触发后执行oneshort操作 +pwm12(pc11)为5kHz,一个周期为200us,pb4为上升沿中断触发,200us触发后执行oneshot操作 ## 时钟时序图 ![pwm_clk](image/README/pwm_clk.png) @@ -38,19 +38,19 @@ pwm12(pc11)为5kHz,一个周期为200us,pb4为上升沿中断触发,200us触 ## 数据输出时序图 ![timing-diagram-1](image/README/timing-diagram-1.png) -oneshort的时间大于200us +oneshot的时间大于200us ![timing-diagram-2](image/README/timing-diagram-2.png) -oneshort的时间小于于200us +oneshot的时间小于于200us ![timing-diagram-3](image/README/timing-diagram-3.png) -oneshort200us触发一次 +oneshot200us触发一次 ## Linux 命令行编译 ### 基于Makefile编译 1 $ make - 会在build目录生成pwm_oneshort.elf, pwm_oneshort.bin文件. + 会在build目录生成pwm_oneshot.elf, pwm_oneshot.bin文件. ### 基于cmake构建 @@ -62,7 +62,7 @@ $ cd build $ cmake -DCMAKE_TOOLCHAIN_FILE=../riscv32-gcc.cmake .. $ make ``` -会在build目录下生成pwm_oneshort.elf,pwm_oneshort.bin文件. +会在build目录下生成pwm_oneshot.elf,pwm_oneshot.bin文件. ### 基于vscode 集成开发环境 @@ -111,25 +111,25 @@ typedef struct { uint32_t prevOutputNum; int errorCount; int channel; -} PWM_Oneshort; +} PWM_Oneshot; /** - * @brief 初始化oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 初始化oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int pwm_channel); +int PWM_Oneshot_Init(PWM_Oneshot *oneshot, int pwm_channel); ### 控制类函数 ```c /** - * @brief 启动一次oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 启动一次oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param HighCount pwm高电平周期数 * @param LowCount pwm低电平周期数 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Start(PWM_Oneshort *oneshort, int16_t HighCount, int16_t LowCount); +int PWM_Oneshot_Start(PWM_Oneshot *oneshot, int16_t HighCount, int16_t LowCount); ``` diff --git a/projects/x2660-halley/Demos/pwm-oneshort/freertos/main.c b/projects/x2660-halley/Demos/pwm-oneshort/freertos/main.c index 660df4545971294cd933a3f19a7cd331057880c3..d836ae41b56a369c159a12faf3b05ecfbe4e5877 100755 --- a/projects/x2660-halley/Demos/pwm-oneshort/freertos/main.c +++ b/projects/x2660-halley/Demos/pwm-oneshort/freertos/main.c @@ -1,19 +1,19 @@ #include #include #include -#include "pwm_oneshort.h" +#include "pwm_oneshot.h" -#define PWM_ONESHORT_CHANNEL 8 +#define PWM_ONESHOT_CHANNEL 8 #define PWM12_COMMON 12 static PWM_HandleTypeDef PWM_Handle; static DMA_HandleTypeDef DMA_Handle; -PWM_Oneshort pwm_oneshort = { +PWM_Oneshot pwm_oneshot = { .P_PWM_Handle = &PWM_Handle, - .PWM_Config.Channels = PWM_CHANNEL(PWM_ONESHORT_CHANNEL), + .PWM_Config.Channels = PWM_CHANNEL(PWM_ONESHOT_CHANNEL), .PWM_Config.idleLevel = PWMIdleLow, .PWM_Config.initLevel = PWMInitHigh, .PWM_Config.prescale_dma = 0, @@ -32,19 +32,19 @@ PWM_InitTypeDef PWM_Config = { void gpio_handler(int irq, void *data) { - PWM_Oneshort *oneshort = (PWM_Oneshort *)data; + PWM_Oneshot *oneshot = (PWM_Oneshot *)data; static int cnt = 0; int ret = 0; if (cnt == 0) { - ret = PWM_Oneshort_Start(oneshort, 10000, 20000); + ret = PWM_Oneshot_Start(oneshot, 10000, 20000); cnt = 1; } else { - ret = PWM_Oneshort_Start(oneshort, 20000, 10000); + ret = PWM_Oneshot_Start(oneshot, 20000, 10000); cnt = 0; } if (ret < 0) { - prom_printk("Oneshort_Enable fail\n"); + prom_printk("Oneshot_Enable fail\n"); } } @@ -99,13 +99,13 @@ static int board_init() HAL_PWM_Enable(&PWM_Handle); - ret = PWM_Oneshort_Init(&pwm_oneshort, PWM_ONESHORT_CHANNEL); + ret = PWM_Oneshot_Init(&pwm_oneshot, PWM_ONESHOT_CHANNEL); if (ret < 0) { - prom_printk("Oneshort_Init fail\n"); + prom_printk("Oneshot_Init fail\n"); return -1; } - gpio_request_irq(GPIO_IRQ_PC(8), GPIO_MODE_IRQ_EDGE_BOTH, gpio_handler, (void *)&pwm_oneshort); + gpio_request_irq(GPIO_IRQ_PC(8), GPIO_MODE_IRQ_EDGE_BOTH, gpio_handler, (void *)&pwm_oneshot); return 0; } diff --git a/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.c b/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.c index 477e95cad646cf10dd8413c89daea2df53036bd1..4a6757bc0009cd5a15bbdd95013b2cf5e247a520 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.c +++ b/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.c @@ -22,75 +22,75 @@ #include #include #include -#include "pwm_oneshort.h" +#include "pwm_oneshot.h" /** * @brief 配置pwm和dma描述符 - * @param oneshort 指向PWM_Oneshort结构的指针 + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval None **/ -static void PWM_Oneshort_Desc_Config(PWM_Oneshort *oneshort, int channel) +static void PWM_Oneshot_Desc_Config(PWM_Oneshot *oneshot, int channel) { - oneshort->PWM_DMA_Config.DescMode = NO_DESCRIPTOR; - oneshort->PWM_DMA_Config.descConfig = &oneshort->PWM_Tx_descConfig; - - oneshort->PWM_Tx_descConfig.Desc_Interrupt = NO_DMA_INTERRUPT; - oneshort->PWM_Tx_descConfig.Desc_Link = NO_LINK; - oneshort->PWM_Tx_descConfig.DescDMATransferType = DMA_RQ_PWM0_TX + channel; - oneshort->PWM_Tx_descConfig.DescSrcAddress = &oneshort->txdata; - oneshort->PWM_Tx_descConfig.DescSrcAddrIncrement = DISABLE; - oneshort->PWM_Tx_descConfig.DescSrcPortWidth = DMA_PORT_32BIT; - - oneshort->PWM_Tx_descConfig.DescDstAddress = (void *)PWM_FIFO(oneshort->P_PWM_Handle, channel); - oneshort->PWM_Tx_descConfig.DescDstAddrIncrement = DISABLE; - oneshort->PWM_Tx_descConfig.DescDstPortWidth = DMA_PORT_32BIT; - - oneshort->PWM_Tx_descConfig.DescTransferNumByte = 4; - oneshort->PWM_Tx_descConfig.DataLength = 4; + oneshot->PWM_DMA_Config.DescMode = NO_DESCRIPTOR; + oneshot->PWM_DMA_Config.descConfig = &oneshot->PWM_Tx_descConfig; + + oneshot->PWM_Tx_descConfig.Desc_Interrupt = NO_DMA_INTERRUPT; + oneshot->PWM_Tx_descConfig.Desc_Link = NO_LINK; + oneshot->PWM_Tx_descConfig.DescDMATransferType = DMA_RQ_PWM0_TX + channel; + oneshot->PWM_Tx_descConfig.DescSrcAddress = &oneshot->txdata; + oneshot->PWM_Tx_descConfig.DescSrcAddrIncrement = DISABLE; + oneshot->PWM_Tx_descConfig.DescSrcPortWidth = DMA_PORT_32BIT; + + oneshot->PWM_Tx_descConfig.DescDstAddress = (void *)PWM_FIFO(oneshot->P_PWM_Handle, channel); + oneshot->PWM_Tx_descConfig.DescDstAddrIncrement = DISABLE; + oneshot->PWM_Tx_descConfig.DescDstPortWidth = DMA_PORT_32BIT; + + oneshot->PWM_Tx_descConfig.DescTransferNumByte = 4; + oneshot->PWM_Tx_descConfig.DataLength = 4; } /** - * @brief 初始化oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 初始化oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int channel) +int PWM_Oneshot_Init(PWM_Oneshot *oneshot, int channel) { int ret = 0; - PWM_Oneshort_Desc_Config(oneshort, channel); + PWM_Oneshot_Desc_Config(oneshot, channel); - if (&oneshort->PWM_DMA_Config != NULL) { - HAL_DMA_requestChannel(oneshort->P_PWM_Handle->DMA_Handle, &oneshort->PWM_DMA_Config); + if (&oneshot->PWM_DMA_Config != NULL) { + HAL_DMA_requestChannel(oneshot->P_PWM_Handle->DMA_Handle, &oneshot->PWM_DMA_Config); } /* 设置PWM配置 */ - ret = HAL_PWM_setConfig(oneshort->P_PWM_Handle, &oneshort->PWM_Config); + ret = HAL_PWM_setConfig(oneshot->P_PWM_Handle, &oneshot->PWM_Config); if (ret != 0) { prom_printk("HAL_PWM_setConfig fail\n"); return -1; } /* 初始化PWM配置 */ - ret = HAL_PWM_Init(oneshort->P_PWM_Handle); + ret = HAL_PWM_Init(oneshot->P_PWM_Handle); if (ret != 0) { prom_printk("HAL_PWM_Init fail\n"); return -1; } - ret = HAL_PWM_Enable(oneshort->P_PWM_Handle); + ret = HAL_PWM_Enable(oneshot->P_PWM_Handle); if (ret != 0) { prom_printk("HAL_PWM_Enable fail\n"); return -1; } - HAL_DMA_Init_Common(oneshort->P_PWM_Handle->DMA_Handle, &oneshort->PWM_Tx_descConfig, oneshort->PWM_DMA_Config.Channel); + HAL_DMA_Init_Common(oneshot->P_PWM_Handle->DMA_Handle, &oneshot->PWM_Tx_descConfig, oneshot->PWM_DMA_Config.Channel); - oneshort->timestamp_ns = -1ULL; - oneshort->prevOutputNum = -1UL; - oneshort->errorCount = 0; - oneshort->channel = channel; + oneshot->timestamp_ns = -1ULL; + oneshot->prevOutputNum = -1UL; + oneshot->errorCount = 0; + oneshot->channel = channel; return 0; } @@ -98,14 +98,14 @@ int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int channel) #define PWM_GetOutputNum(__HANDLE__,ch) __HAL_PWM_GET_OUTPUT_NUM(__HANDLE__,ch) /** - * @brief 启动一次oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 启动一次oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_high pwm高电平周期 * @param pwm_low pwm低电平周期 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowCount) +int PWM_Oneshot_Start(PWM_Oneshot *oneshot, uint16_t HighCount, uint16_t LowCount) { int ret = 0; uint64_t timestamp; @@ -113,23 +113,23 @@ int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowC assert_param(LowCount > 0 && LowCount <= 0xFFFF); timestamp = vPortGetSchedulerNSClock_Raw(); - if (oneshort->timestamp_ns != -1ULL && timestamp - oneshort->timestamp_ns < oneshort->minIntervalTime_ns) { - oneshort->errorCount++; + if (oneshot->timestamp_ns != -1ULL && timestamp - oneshot->timestamp_ns < oneshot->minIntervalTime_ns) { + oneshot->errorCount++; return -1; } - oneshort->timestamp_ns = timestamp; + oneshot->timestamp_ns = timestamp; - if (oneshort->prevOutputNum != -1UL) { - if (PWM_GetOutputNum(oneshort->P_PWM_Handle, oneshort->channel) == oneshort->prevOutputNum) { - prom_printk("PWM ONESHORT: output Busy\n"); + if (oneshot->prevOutputNum != -1UL) { + if (PWM_GetOutputNum(oneshot->P_PWM_Handle, oneshot->channel) == oneshot->prevOutputNum) { + prom_printk("PWM ONESHOT: output Busy\n"); } - while (PWM_GetOutputNum(oneshort->P_PWM_Handle, oneshort->channel) == oneshort->prevOutputNum); + while (PWM_GetOutputNum(oneshot->P_PWM_Handle, oneshot->channel) == oneshot->prevOutputNum); } - oneshort->prevOutputNum = PWM_GetOutputNum(oneshort->P_PWM_Handle, oneshort->channel); - oneshort->txdata = HighCount << 16 | LowCount; + oneshot->prevOutputNum = PWM_GetOutputNum(oneshot->P_PWM_Handle, oneshot->channel); + oneshot->txdata = HighCount << 16 | LowCount; - ret = HAL_DMA_Start_Common(oneshort->P_PWM_Handle->DMA_Handle, &oneshort->PWM_Tx_descConfig, oneshort->PWM_DMA_Config.Channel); + ret = HAL_DMA_Start_Common(oneshot->P_PWM_Handle->DMA_Handle, &oneshot->PWM_Tx_descConfig, oneshot->PWM_DMA_Config.Channel); if (ret != 0) { prom_printk("HAL_DMA_ReStart fail\n"); return -1; @@ -139,35 +139,35 @@ int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowC } -void PWM_Oneshort_Clear(PWM_Oneshort *oneshort) +void PWM_Oneshot_Clear(PWM_Oneshot *oneshot) { - oneshort->timestamp_ns = -1ULL; - oneshort->prevOutputNum = -1UL; - oneshort->errorCount = 0; + oneshot->timestamp_ns = -1ULL; + oneshot->prevOutputNum = -1UL; + oneshot->errorCount = 0; } /** - * @brief 取消oneshort初始化 - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 取消oneshot初始化 + * @param oneshot 指向PWM_Oneshot结构的指针 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_DeInit(PWM_Oneshort *oneshort) +int PWM_Oneshot_DeInit(PWM_Oneshot *oneshot) { int ret = 0; - ret = HAL_DMA_Stop(oneshort->P_PWM_Handle->DMA_Handle, oneshort->PWM_DMA_Config.Channel); + ret = HAL_DMA_Stop(oneshot->P_PWM_Handle->DMA_Handle, oneshot->PWM_DMA_Config.Channel); if (ret != 0) { prom_printk("HAL_DMA_Stop fail\n"); return -1; } - ret = HAL_DMA_DeInit(oneshort->P_PWM_Handle->DMA_Handle); + ret = HAL_DMA_DeInit(oneshot->P_PWM_Handle->DMA_Handle); if (ret != 0) { prom_printk("HAL_DMA_DeInit fail\n"); return -1; } - ret = HAL_PWM_Disable(oneshort->P_PWM_Handle); + ret = HAL_PWM_Disable(oneshot->P_PWM_Handle); if (ret != 0) { prom_printk("HAL_PWM_Disable fail\n"); return -1; diff --git a/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.h b/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.h index ab9803e2520c4cad0aa246818b8abaf22b2d52c3..6b4bbeb057c05f92ea762442384e91789111ffb4 100644 --- a/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.h +++ b/projects/x2660-halley/Demos/pwm-oneshort/freertos/pwm_oneshort.h @@ -1,8 +1,8 @@ -#ifndef __PWM_ONESHORT_H__ -#define __PWM_ONESHORT_H__ +#ifndef __PWM_ONESHOT_H__ +#define __PWM_ONESHOT_H__ -/** @defgroup PWM_Oneshort - * @brief PWM_Oneshort配置结构体定义 +/** @defgroup PWM_Oneshot + * @brief PWM_Oneshot配置结构体定义 * @{ */ typedef struct { @@ -16,30 +16,30 @@ typedef struct { uint32_t prevOutputNum; int errorCount; int channel; -} PWM_Oneshort; +} PWM_Oneshot; /** - * @brief 初始化oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 初始化oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param pwm_channel 使用的pwm通道 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Init(PWM_Oneshort *oneshort, int channel); +int PWM_Oneshot_Init(PWM_Oneshot *oneshot, int channel); /** - * @brief 启动一次oneshort - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 启动一次oneshot + * @param oneshot 指向PWM_Oneshot结构的指针 * @param Highcount pwm高电平周期 * @param Lowcount pwm低电平周期 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_Start(PWM_Oneshort *oneshort, uint16_t HighCount, uint16_t LowCount); +int PWM_Oneshot_Start(PWM_Oneshot *oneshot, uint16_t HighCount, uint16_t LowCount); /** - * @brief 取消oneshort初始化 - * @param oneshort 指向PWM_Oneshort结构的指针 + * @brief 取消oneshot初始化 + * @param oneshot 指向PWM_Oneshot结构的指针 * @retval 成功返回 0 失败返回 -1 **/ -int PWM_Oneshort_DeInit(PWM_Oneshort *oneshort); +int PWM_Oneshot_DeInit(PWM_Oneshot *oneshot); #endif diff --git a/projects/x2660-halley/Examples/pwm-dma/README.md b/projects/x2660-halley/Examples/pwm-dma/README.md index 7a6866a9f2bb926dfdef40c252a06824dfa47d63..3dff364c18999b450bc3232d4be3317e3cef7e58 100644 --- a/projects/x2660-halley/Examples/pwm-dma/README.md +++ b/projects/x2660-halley/Examples/pwm-dma/README.md @@ -101,7 +101,7 @@ typedef struct __PWM_HandleTypeDef { // TODO: ADD more here or remove!! PWM_TypeDef *Instance; /*!< PWM 寄存器基地址 */ PWM_InitTypeDef Init[__HAL_PWM_MAX_CHANNEL]; /*!< PWM 初始化参数. */ - uint32_t PWMColck; /*!< PWM时钟频率 */ + uint32_t PWMClock; /*!< PWM时钟频率 */ __IO uint32_t Channels; /*!< 所有通道 */ HAL_LockTypeDef Lock; /*!< PWM Lock */ DMA_HandleTypeDef *DMA_Handle; /*!< DMA句柄 */ diff --git a/projects/x2660-halley/Examples/pwm-dma/main.c b/projects/x2660-halley/Examples/pwm-dma/main.c index 51064ab617bfa984f73105fc690440571e88944a..c14c811a27b62a0215342aa328e7e7dc53fe503e 100644 --- a/projects/x2660-halley/Examples/pwm-dma/main.c +++ b/projects/x2660-halley/Examples/pwm-dma/main.c @@ -26,11 +26,11 @@ LL_CPM_CGU_ConfigTypeDef CGU_Config_PWM_120000000 = { void Pwm_Dma_Mode_Config(void) { PWM_Handle.Instance = PWMx; - PWM_Handle.PWMColck = SYSCLK_APLL / 12; // 100M频率 + PWM_Handle.PWMClock = SYSCLK_APLL / 12; // 100M频率 PWM_Handle.DMA_Handle = &DMA_Handle; PWM_Handle.PWM_DMA_Config = &PWM_DMA_Config; - prom_printk("pwmClock = %d\n", PWM_Handle.PWMColck); + prom_printk("pwmClock = %d\n", PWM_Handle.PWMClock); PWM_Config.Channels = CHANNEL_12; PWM_Config.idleLevel = PWMIdleLow; PWM_Config.Mode = dmaMode; diff --git a/projects/x2660-halley/Examples/pwm/README.md b/projects/x2660-halley/Examples/pwm/README.md index 783ed93eaaf523a18d82bb66c89d1b7161f1be63..1c0600d8415b718af02fe968b799ed6053d20536 100644 --- a/projects/x2660-halley/Examples/pwm/README.md +++ b/projects/x2660-halley/Examples/pwm/README.md @@ -100,7 +100,7 @@ typedef struct __PWM_HandleTypeDef { // TODO: ADD more here or remove!! PWM_TypeDef *Instance; /*!< PWM 寄存器基地址 */ PWM_InitTypeDef Init[__HAL_PWM_MAX_CHANNEL]; /*!< PWM 初始化参数. */ - uint32_t PWMColck; /*!< PWM时钟频率 */ + uint32_t PWMClock; /*!< PWM时钟频率 */ __IO uint32_t Channels; /*!< 所有通道 */ HAL_LockTypeDef Lock; /*!< PWM Lock */ DMA_HandleTypeDef *DMA_Handle; /*!< DMA句柄 */ diff --git a/projects/x2660-halley/Examples/pwm/main.c b/projects/x2660-halley/Examples/pwm/main.c index a1744db646ec10287599464eb892506445502271..867a698627c678ef9ccaf0b5f67f1021f7bc84ac 100644 --- a/projects/x2660-halley/Examples/pwm/main.c +++ b/projects/x2660-halley/Examples/pwm/main.c @@ -27,9 +27,9 @@ int main(void) LL_GPIO_getPinLevel(PC_Instance, 11); LL_GPIO_setPinMode(PC_Instance, 11, GPIO_MODE_FUNCTION0); PWM_Handle.Instance = PWMx; - PWM_Handle.PWMColck = SYSCLK_APLL / 12; // 100M频率 + PWM_Handle.PWMClock = SYSCLK_APLL / 12; // 100M频率 - prom_printk("pwmClock = %d\n", PWM_Handle.PWMColck); + prom_printk("pwmClock = %d\n", PWM_Handle.PWMClock); PWM_Config.Channels = CHANNEL_12; PWM_Config.periodus = 1000; PWM_Config.dutyus = 500;