unkounko

Dependencies:   mbed Servo

Committer:
t_yamamoto
Date:
Mon Jan 22 09:29:57 2018 +0000
Revision:
3:a9ab1a251456
Parent:
1:e73cf2469f83
Child:
4:42ba5ccc4a2a
Pin Update;

Who changed what in which revision?

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