这个代码还没有测试通过,哈哈原理是不会错的你看吧
我觉得我真的写的太好了
extern "C" {
#include "cal.h"
#endif
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
void adjustSpeed(TIM_HandleTypeDef htimx,/*引脚号*/unsigned int TIM_CHANNEL_X,/*速度*/int speed,int rotation)
{
//获取分母值
int motherPWM=htimx.Init.Period;
float rate=motherPWM/100.0;
GPIO_TypeDef *GPIOX=GPIOA;
int i=0,j=0;
uint16_t GPIO_PIN_1_P=GPIO_PIN_4;
uint16_t GPIO_PIN_1_N=GPIO_PIN_4;
uint16_t GPIO_PIN_2_P=GPIO_PIN_4;
uint16_t GPIO_PIN_2_N=GPIO_PIN_4;
uint16_t GPIO_PIN_3_P=GPIO_PIN_4;
uint16_t GPIO_PIN_3_N=GPIO_PIN_4;
uint16_t GPIO_PIN_4_P=GPIO_PIN_4;
uint16_t GPIO_PIN_4_N=GPIO_PIN_4;
if(rotation<0)
{
HAL_GPIO_TogglePin(GPIOX,GPIO_PIN_1_P);
HAL_GPIO_Toggle