123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #ifndef __DSHOT_H
- #define __DSHOT_H
- #include "stm32f4xx.h"
- #define ESC_CMD_BUFFER_LEN 18
- #define ESC_BIT_0 26
- #define ESC_BIT_1 52
- #define PWM3_PORT GPIOB
- #define PWM3_PIN GPIO_Pin_6
- #define PWM3_PinSource GPIO_PinSource6
- #define PWM3_GPIO_AF GPIO_AF_TIM4
- #define PWM4_PORT GPIOA
- #define PWM4_PIN GPIO_Pin_7
- #define PWM4_PinSource GPIO_PinSource7
- #define PWM4_GPIO_AF GPIO_AF_TIM3
- #define PWM5_PORT GPIOB
- #define PWM5_PIN GPIO_Pin_4
- #define PWM5_PinSource GPIO_PinSource4
- #define PWM5_GPIO_AF GPIO_AF_TIM3
- #define PWM6_PORT GPIOB
- #define PWM6_PIN GPIO_Pin_0
- #define PWM6_PinSource GPIO_PinSource0
- #define PWM6_GPIO_AF GPIO_AF_TIM3
- #define PWM7_PORT GPIOB
- #define PWM7_PIN GPIO_Pin_7
- #define PWM7_PinSource GPIO_PinSource7
- #define PWM7_GPIO_AF GPIO_AF_TIM4
- #define PWM8_PORT GPIOA
- #define PWM8_PIN GPIO_Pin_5
- #define PWM8_PinSource GPIO_PinSource5
- #define PWM8_GPIO_AF GPIO_AF_TIM2
- void pwmWriteDigital(u32 *esc_cmd, u16 value, DMA_Stream_TypeDef *DMA_Streamx);
- //void Dshot_GPIO_Config(u32 RCC_APBnPeriphn, GPIO_TypeDef *GPIOx,u16 PIN ,u8 GPIO_AF, u8 GPIO_PinSource);
- void Dshot_GPIO_Config(u32 RCC_APBnPeriphn, GPIO_TypeDef *GPIOx,u16 PIN, u8 GPIO_PinSource, u8 GPIO_AF);
- void DSHOT_DMA_Config(TIM_TypeDef* TIMx,uint16_t TIM_DMASource, DMA_Stream_TypeDef *DMA_Streamx,u32 chx,u32 par,u32 mar);
- void Dshot_NVIC_Config(u8 NVIC_IRQChannel, u8 pre, u8 sub);
-
- void Dshot_TIM_Config(void(*ClockCMD)(uint32_t, FunctionalState),u32 RCC_APBnPeriphn, //APB时钟使能设置
- TIM_TypeDef* TIMx, u16 psc, u16 per, //dshot频率设置
- void(*TIM_OCInit)(TIM_TypeDef*, TIM_OCInitTypeDef*), //OC通道设置
- void(*TIM_OCPreloadConfig)(TIM_TypeDef*, uint16_t)); //OC通道使能
-
-
- #endif
-
-
-
-
-
- //#define PWM1_PORT GPIOB
- //#define PWM1_PIN GPIO_Pin_6
- //#define PWM1_PinSource GPIO_PinSource6
- //#define PWM1_TIM TIM4
- //#define PWM1_GPIO_AF GPIO_AF_TIM4
- //#define PWM1_ClockCmd() RCC_AHB1PeriphClockCmd(RCC_APB1Periph_TIM4|RCC_AHB1Periph_GPIOB, ENABLE)
- //#define PWM1_OCInit(x) {TIM_OC1Init(PWM1_TIM, &TIM_OCInitStructure);TIM_OC1PreloadConfig(PWM1_TIM, TIM_OCPreload_Enable);}
- //#define PWM1_DMA_Stream DMA1_Stream0
- //#define PWM1_DMA_Stream_IRQn DMA1_Stream0_IRQn
- //#define PWM2_PORT GPIOB
- //#define PWM2_PIN GPIO_Pin_7
- //#define PWM2_PinSource GPIO_PinSource7
- //#define PWM2_TIM TIM4
- //#define PWM2_GPIO_AF GPIO_AF_TIM4
- //#define PWM2_ClockCmd() RCC_AHB1PeriphClockCmd(RCC_APB1Periph_TIM4|RCC_AHB1Periph_GPIOB, ENABLE)
- //#define PWM2_OCInit(x) {TIM_OC2Init(PWM2_TIM, &TIM_OCInitStructure);TIM_OC2PreloadConfig(PWM2_TIM, TIM_OCPreload_Enable);}
- //#define PWM2_DMA_Stream DMA1_Stream3
- //#define PWM2_DMA_Stream_IRQn DMA1_Stream3_IRQn
- //#define PWM3_PORT GPIOA
- //#define PWM3_PIN GPIO_Pin_7
- //#define PWM3_PinSource GPIO_PinSource7
- //#define PWM3_TIM TIM3
- //#define PWM3_GPIO_AF GPIO_AF_TIM3
- //#define PWM3_ClockCmd() RCC_AHB1PeriphClockCmd(RCC_APB1Periph_TIM3|RCC_AHB1Periph_GPIOA, ENABLE)
- //#define PWM3_OCInit(x) {TIM_OC2Init(PWM1_TIM, &TIM_OCInitStructure);TIM_OC2PreloadConfig(PWM3_TIM, TIM_OCPreload_Enable);}
- //#define PWM3_DMA_Stream DMA1_Stream5
- //#define PWM3_DMA_Stream_IRQn DMA1_Stream5_IRQn
- //#define PWM4_PORT GPIOA
- //#define PWM4_PIN GPIO_Pin_5
- //#define PWM4_PinSource GPIO_PinSource5
- //#define PWM4_TIM TIM2
- //#define PWM4_GPIO_AF GPIO_AF_TIM2
- //#define PWM4_ClockCmd() RCC_AHB1PeriphClockCmd(RCC_APB1Periph_TIM2|RCC_AHB1Periph_GPIOA, ENABLE)
- //#define PWM4_OCInit(x) {TIM_OC1Init(PWM4_TIM, &TIM_OCInitStructure);TIM_OC1PreloadConfig(PWM4_TIM, TIM_OCPreload_Enable);}
- //#define PWM4_DMA_Stream DMA1_Stream5
- //#define PWM4_DMA_Stream_IRQn DMA1_Stream5_IRQn
-
-
-
-
-
-
-
|