-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMotor.h
40 lines (33 loc) · 935 Bytes
/
Motor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef HEIMAROBOTV4_MOTOR_H
#define HEIMAROBOTV4_MOTOR_H
#include "stm32f1xx_hal.h"
class Motor {
public:
/**
* 电机
* @param portA 控制正反转
* @param pinA 控制正反转
* @param portB 控制正反转
* @param pinB 控制正反转
* @param tim 控制PWM的
* @param channel 定时器通道
* @param direction 后续方便调整电机的转动方向
*/
Motor(GPIO_TypeDef *portA, uint16_t pinA,GPIO_TypeDef *portB, uint16_t pinB, TIM_HandleTypeDef *tim,uint16_t channel,int direction);
// A_PORT A_PIN
GPIO_TypeDef *portA;
uint16_t pinA;
// B_PORT B_PIN
GPIO_TypeDef *portB;
uint16_t pinB;
// TIM
TIM_HandleTypeDef *tim;
// CHANNEL
uint16_t channel;
int direction;
void spin(int pwm);
void init();
int lastPwm;
// void tick();
};
#endif //HEIMAROBOTV4_MOTOR_H