![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
If you wont to knock me down, look this file...
Output/Motor/Motor.h@0:4df75b08b14a, 2019-05-03 (annotated)
- Committer:
- Ryosei
- Date:
- Fri May 03 11:47:27 2019 +0000
- Revision:
- 0:4df75b08b14a
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ryosei | 0:4df75b08b14a | 1 | #ifndef MOTOR_H_ |
Ryosei | 0:4df75b08b14a | 2 | #define MOTOR_H_ |
Ryosei | 0:4df75b08b14a | 3 | |
Ryosei | 0:4df75b08b14a | 4 | #include <stdint.h> |
Ryosei | 0:4df75b08b14a | 5 | |
Ryosei | 0:4df75b08b14a | 6 | //#define USE_MOTOR0_SENSOR |
Ryosei | 0:4df75b08b14a | 7 | namespace MOTOR |
Ryosei | 0:4df75b08b14a | 8 | { |
Ryosei | 0:4df75b08b14a | 9 | #define FREE 0 |
Ryosei | 0:4df75b08b14a | 10 | #define BACK 1 |
Ryosei | 0:4df75b08b14a | 11 | #define FOR 2 |
Ryosei | 0:4df75b08b14a | 12 | #define BRAKE 3 |
Ryosei | 0:4df75b08b14a | 13 | |
Ryosei | 0:4df75b08b14a | 14 | #define MOUNTING_MOTOR_NUM 5 |
Ryosei | 0:4df75b08b14a | 15 | |
Ryosei | 0:4df75b08b14a | 16 | #define MOTOR0_D1 directions[0] |
Ryosei | 0:4df75b08b14a | 17 | #define MOTOR0_D2 directions[1] |
Ryosei | 0:4df75b08b14a | 18 | #define MOTOR1_D1 directions[2] |
Ryosei | 0:4df75b08b14a | 19 | #define MOTOR1_D2 directions[3] |
Ryosei | 0:4df75b08b14a | 20 | #define MOTOR2_D1 directions[4] |
Ryosei | 0:4df75b08b14a | 21 | #define MOTOR2_D2 directions[5] |
Ryosei | 0:4df75b08b14a | 22 | #define MOTOR3_D1 directions[6] |
Ryosei | 0:4df75b08b14a | 23 | #define MOTOR3_D2 directions[7] |
Ryosei | 0:4df75b08b14a | 24 | #define MOTOR4_D1 directions[8] |
Ryosei | 0:4df75b08b14a | 25 | #define MOTOR4_D2 directions[9] |
Ryosei | 0:4df75b08b14a | 26 | |
Ryosei | 0:4df75b08b14a | 27 | #define MOTOR0_D1_PIN D3 |
Ryosei | 0:4df75b08b14a | 28 | #define MOTOR0_D2_PIN D4 |
Ryosei | 0:4df75b08b14a | 29 | #define MOTOR1_D1_PIN D5 |
Ryosei | 0:4df75b08b14a | 30 | #define MOTOR1_D2_PIN D6 |
Ryosei | 0:4df75b08b14a | 31 | #define MOTOR2_D1_PIN D8 |
Ryosei | 0:4df75b08b14a | 32 | #define MOTOR2_D2_PIN D9 |
Ryosei | 0:4df75b08b14a | 33 | #define MOTOR3_D1_PIN D12 |
Ryosei | 0:4df75b08b14a | 34 | #define MOTOR3_D2_PIN A3 |
Ryosei | 0:4df75b08b14a | 35 | #define MOTOR4_D1_PIN A1 |
Ryosei | 0:4df75b08b14a | 36 | #define MOTOR4_D2_PIN A0 |
Ryosei | 0:4df75b08b14a | 37 | |
Ryosei | 0:4df75b08b14a | 38 | #define MOTOR0_PWM_PIN D2 |
Ryosei | 0:4df75b08b14a | 39 | #define MOTOR1_PWM_PIN D7 |
Ryosei | 0:4df75b08b14a | 40 | #define MOTOR2_PWM_PIN D10 |
Ryosei | 0:4df75b08b14a | 41 | #define MOTOR3_PWM_PIN D11 |
Ryosei | 0:4df75b08b14a | 42 | #define MOTOR4_PWM_PIN A2 |
Ryosei | 0:4df75b08b14a | 43 | |
Ryosei | 0:4df75b08b14a | 44 | #ifdef USE_MOTOR0_SENSOR |
Ryosei | 0:4df75b08b14a | 45 | #define MOTOR_START_NUM 1 |
Ryosei | 0:4df75b08b14a | 46 | #else |
Ryosei | 0:4df75b08b14a | 47 | #define MOTOR_START_NUM 0 |
Ryosei | 0:4df75b08b14a | 48 | #endif |
Ryosei | 0:4df75b08b14a | 49 | |
Ryosei | 0:4df75b08b14a | 50 | typedef struct |
Ryosei | 0:4df75b08b14a | 51 | { |
Ryosei | 0:4df75b08b14a | 52 | union |
Ryosei | 0:4df75b08b14a | 53 | { |
Ryosei | 0:4df75b08b14a | 54 | struct |
Ryosei | 0:4df75b08b14a | 55 | { |
Ryosei | 0:4df75b08b14a | 56 | unsigned int d2 : 1; |
Ryosei | 0:4df75b08b14a | 57 | unsigned int d1 : 1; |
Ryosei | 0:4df75b08b14a | 58 | unsigned int : 6; |
Ryosei | 0:4df75b08b14a | 59 | }; |
Ryosei | 0:4df75b08b14a | 60 | uint8_t dir; |
Ryosei | 0:4df75b08b14a | 61 | }; |
Ryosei | 0:4df75b08b14a | 62 | float pwm; |
Ryosei | 0:4df75b08b14a | 63 | }MotorStatus; |
Ryosei | 0:4df75b08b14a | 64 | |
Ryosei | 0:4df75b08b14a | 65 | class Motor |
Ryosei | 0:4df75b08b14a | 66 | { |
Ryosei | 0:4df75b08b14a | 67 | public: |
Ryosei | 0:4df75b08b14a | 68 | static void Initialize(void); |
Ryosei | 0:4df75b08b14a | 69 | static void Update(MotorStatus *status); |
Ryosei | 0:4df75b08b14a | 70 | static void SetDefault(void); |
Ryosei | 0:4df75b08b14a | 71 | static int SetStatus(float pwm); |
Ryosei | 0:4df75b08b14a | 72 | }; |
Ryosei | 0:4df75b08b14a | 73 | } |
Ryosei | 0:4df75b08b14a | 74 | |
Ryosei | 0:4df75b08b14a | 75 | #endif |