aa

Dependencies:   mbed

Committer:
niimurasyou
Date:
Sat Jan 25 02:55:50 2020 +0000
Revision:
1:e1e9671724e7
Parent:
0:2e7a61458dc3
aa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
M_souta 0:2e7a61458dc3 1 #ifndef MOTOR_H_
M_souta 0:2e7a61458dc3 2 #define MOTOR_H_
M_souta 0:2e7a61458dc3 3
M_souta 0:2e7a61458dc3 4 #include <stdint.h>
M_souta 0:2e7a61458dc3 5
M_souta 0:2e7a61458dc3 6 namespace MOTOR
M_souta 0:2e7a61458dc3 7 {
M_souta 0:2e7a61458dc3 8 #define FREE 0
M_souta 0:2e7a61458dc3 9 #define BACK 1
M_souta 0:2e7a61458dc3 10 #define FOR 2
M_souta 0:2e7a61458dc3 11 #define BRAKE 3
M_souta 0:2e7a61458dc3 12
M_souta 0:2e7a61458dc3 13 #define MOUNTING_MOTOR_NUM 5
M_souta 0:2e7a61458dc3 14
M_souta 0:2e7a61458dc3 15 #define MOTOR0_D1 directions[0]
M_souta 0:2e7a61458dc3 16 #define MOTOR0_D2 directions[1]
M_souta 0:2e7a61458dc3 17 #define MOTOR1_D1 directions[2]
M_souta 0:2e7a61458dc3 18 #define MOTOR1_D2 directions[3]
M_souta 0:2e7a61458dc3 19 #define MOTOR2_D1 directions[4]
M_souta 0:2e7a61458dc3 20 #define MOTOR2_D2 directions[5]
M_souta 0:2e7a61458dc3 21 #define MOTOR3_D1 directions[6]
M_souta 0:2e7a61458dc3 22 #define MOTOR3_D2 directions[7]
M_souta 0:2e7a61458dc3 23 #define MOTOR4_D1 directions[8]
M_souta 0:2e7a61458dc3 24 #define MOTOR4_D2 directions[9]
M_souta 0:2e7a61458dc3 25
M_souta 0:2e7a61458dc3 26 #define MOTOR0_D1_PIN D3
M_souta 0:2e7a61458dc3 27 #define MOTOR0_D2_PIN D4
M_souta 0:2e7a61458dc3 28 #define MOTOR1_D1_PIN D5
M_souta 0:2e7a61458dc3 29 #define MOTOR1_D2_PIN D6
M_souta 0:2e7a61458dc3 30 #define MOTOR2_D1_PIN D8
M_souta 0:2e7a61458dc3 31 #define MOTOR2_D2_PIN D9
M_souta 0:2e7a61458dc3 32 #define MOTOR3_D1_PIN D12
M_souta 0:2e7a61458dc3 33 #define MOTOR3_D2_PIN A3
M_souta 0:2e7a61458dc3 34 #define MOTOR4_D1_PIN A1
M_souta 0:2e7a61458dc3 35 #define MOTOR4_D2_PIN A0
M_souta 0:2e7a61458dc3 36
M_souta 0:2e7a61458dc3 37 #define MOTOR0_PWM_PIN D2
M_souta 0:2e7a61458dc3 38 #define MOTOR1_PWM_PIN D7
M_souta 0:2e7a61458dc3 39 #define MOTOR2_PWM_PIN D10
M_souta 0:2e7a61458dc3 40 #define MOTOR3_PWM_PIN D11
M_souta 0:2e7a61458dc3 41 #define MOTOR4_PWM_PIN A2
M_souta 0:2e7a61458dc3 42
M_souta 0:2e7a61458dc3 43 typedef struct{
M_souta 0:2e7a61458dc3 44 union{
M_souta 0:2e7a61458dc3 45 struct{
M_souta 0:2e7a61458dc3 46 unsigned int d2:1;
M_souta 0:2e7a61458dc3 47 unsigned int d1:1;
M_souta 0:2e7a61458dc3 48 unsigned int :6;
M_souta 0:2e7a61458dc3 49 };
M_souta 0:2e7a61458dc3 50 uint8_t dir;
M_souta 0:2e7a61458dc3 51 };
M_souta 0:2e7a61458dc3 52 float pwm;
M_souta 0:2e7a61458dc3 53 }MotorStatus;
M_souta 0:2e7a61458dc3 54
M_souta 0:2e7a61458dc3 55 class Motor
M_souta 0:2e7a61458dc3 56 {
M_souta 0:2e7a61458dc3 57 public:
M_souta 0:2e7a61458dc3 58 static void Initialize(void);
M_souta 0:2e7a61458dc3 59 static void Update(MotorStatus *status);
M_souta 0:2e7a61458dc3 60 static void SetDefault(void);
M_souta 0:2e7a61458dc3 61 static int SetStatus(float pwm);
M_souta 0:2e7a61458dc3 62 };
M_souta 0:2e7a61458dc3 63 }
M_souta 0:2e7a61458dc3 64
M_souta 0:2e7a61458dc3 65 #endif
M_souta 0:2e7a61458dc3 66