sensor_2026/HARDWARE/MOTOR/motor_driver.h

38 lines
992 B
C
Raw Normal View History

// motor_driver.h
#ifndef __MOTOR_DRIVER_H
#define __MOTOR_DRIVER_H
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_tim.h"
// <20><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
#define MOTOR_IN1_GPIO_PORT GPIOE
#define MOTOR_IN1_GPIO_PIN GPIO_Pin_9
#define MOTOR_IN1_GPIO_CLK RCC_AHB1Periph_GPIOE
#define MOTOR_IN2_GPIO_PORT GPIOE
#define MOTOR_IN2_GPIO_PIN GPIO_Pin_13
#define MOTOR_IN2_GPIO_CLK RCC_AHB1Periph_GPIOE
#define MOTOR_FAULT_GPIO_PORT GPIOE
#define MOTOR_FAULT_GPIO_PIN GPIO_Pin_4
#define MOTOR_FAULT_GPIO_CLK RCC_AHB1Periph_GPIOE
// <20><><EFBFBD><EFBFBD>״̬
typedef enum {
MOTOR_STOP = 0, // ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>
MOTOR_FORWARD, // <20><>ת
MOTOR_REVERSE, // <20><>ת
MOTOR_BRAKE // ɲ<><C9B2>
} MotorState;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void DRV8832_Init(void);
void Motor_Control(MotorState state);
uint8_t Motor_GetFaultStatus(void);
void Motor_SetSpeed(uint8_t speed, MotorState direction);
void PWM_Timer_Init(void);
#endif /* __MOTOR_DRIVER_H */