智能小车驱动程序源码

时间:2022-04-26 09:05:04
【文件属性】:
文件名称:智能小车驱动程序源码
文件大小:7.54MB
文件格式:ZIP
更新时间:2022-04-26 09:05:04
智能小车驱动 智能小车的简单驱动,代码质量很高 #include "motor.h" //导入led头文件 #include "stm32f10x.h" //导入STM32官方库 #include "stm32f10x_rcc.h" //导入STM32的RCC时钟库 #include "PWM.h" //导入PWM //motor1 右轮 对应PA1 PA2 //motor2 左轮 对应 PA11 PA12 //该文件用于马达的驱动信号 控制相关运动状态 void Motor_12_Config(void) //定义初始化函数 { GPIO_InitTypeDef GPIO_InitStructure; //定义GPIO_InitTypeDef结构体 RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE); //开启引脚时钟 RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE); //开启引脚时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //通用推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //设置输出功率 GPIO_Init(GPIOA, &GPIO;_InitStructure); //初始化GPIOA的引脚参数,写进 GPIO_ResetBits(GPIOA,GPIO_Pin_1|GPIO_Pin_2); //所有引脚拉低 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //通用推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //设置输出功率 GPIO_Init(GPIOB, &GPIO;_InitStructure); //初始化GPIOB的引脚参数,写进 GPIO_ResetBits(GPIOA,GPIO_Pin_11|GPIO_Pin_12); //所有引脚拉低 } //1是右轮,2是左轮 //下面为运动状态函数

网友评论