にいむら にいむら
/
mainboardnrp2018
unkounko
Output/Motor/Motor.h@0:562021ed1ba9, 2018-01-13 (annotated)
- Committer:
- t_yamamoto
- Date:
- Sat Jan 13 13:33:09 2018 +0000
- Revision:
- 0:562021ed1ba9
- Child:
- 1:e73cf2469f83
NaganoNCT-MainBoardNRP2018
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:562021ed1ba9 | 13 | #define MOUNTING_MOTOR_NUM (5 + 1) //MOTOR0の関係で+1 |
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 | #define MOTOR5_D1 directions[10] |
t_yamamoto | 0:562021ed1ba9 | 26 | #define MOTOR6_D2 directions[11] |
t_yamamoto | 0:562021ed1ba9 | 27 | |
t_yamamoto | 0:562021ed1ba9 | 28 | #define MOTOR0_D1_PIN NC |
t_yamamoto | 0:562021ed1ba9 | 29 | #define MOTOR0_D2_PIN NC |
t_yamamoto | 0:562021ed1ba9 | 30 | #define MOTOR1_D1_PIN D3 |
t_yamamoto | 0:562021ed1ba9 | 31 | #define MOTOR1_D2_PIN D2 |
t_yamamoto | 0:562021ed1ba9 | 32 | #define MOTOR2_D1_PIN D6 |
t_yamamoto | 0:562021ed1ba9 | 33 | #define MOTOR2_D2_PIN D5 |
t_yamamoto | 0:562021ed1ba9 | 34 | #define MOTOR3_D1_PIN D9 |
t_yamamoto | 0:562021ed1ba9 | 35 | #define MOTOR3_D2_PIN D8 |
t_yamamoto | 0:562021ed1ba9 | 36 | #define MOTOR4_D1_PIN D12 |
t_yamamoto | 0:562021ed1ba9 | 37 | #define MOTOR4_D2_PIN D11 |
t_yamamoto | 0:562021ed1ba9 | 38 | #define MOTOR5_D1_PIN A0 |
t_yamamoto | 0:562021ed1ba9 | 39 | #define MOTOR5_D2_PIN A1 |
t_yamamoto | 0:562021ed1ba9 | 40 | |
t_yamamoto | 0:562021ed1ba9 | 41 | #define MOTOR0_PWM_PIN NC |
t_yamamoto | 0:562021ed1ba9 | 42 | #define MOTOR1_PWM_PIN D4 |
t_yamamoto | 0:562021ed1ba9 | 43 | #define MOTOR2_PWM_PIN D7 |
t_yamamoto | 0:562021ed1ba9 | 44 | #define MOTOR3_PWM_PIN D10 |
t_yamamoto | 0:562021ed1ba9 | 45 | #define MOTOR4_PWM_PIN A2 |
t_yamamoto | 0:562021ed1ba9 | 46 | #define MOTOR5_PWM_PIN A3 |
t_yamamoto | 0:562021ed1ba9 | 47 | |
t_yamamoto | 0:562021ed1ba9 | 48 | typedef struct |
t_yamamoto | 0:562021ed1ba9 | 49 | { |
t_yamamoto | 0:562021ed1ba9 | 50 | union |
t_yamamoto | 0:562021ed1ba9 | 51 | { |
t_yamamoto | 0:562021ed1ba9 | 52 | struct |
t_yamamoto | 0:562021ed1ba9 | 53 | { |
t_yamamoto | 0:562021ed1ba9 | 54 | unsigned int d2 : 1; |
t_yamamoto | 0:562021ed1ba9 | 55 | unsigned int d1 : 1; |
t_yamamoto | 0:562021ed1ba9 | 56 | unsigned int : 6; |
t_yamamoto | 0:562021ed1ba9 | 57 | }; |
t_yamamoto | 0:562021ed1ba9 | 58 | uint8_t dir; |
t_yamamoto | 0:562021ed1ba9 | 59 | }; |
t_yamamoto | 0:562021ed1ba9 | 60 | float pwm; |
t_yamamoto | 0:562021ed1ba9 | 61 | }MotorStatus; |
t_yamamoto | 0:562021ed1ba9 | 62 | |
t_yamamoto | 0:562021ed1ba9 | 63 | class Motor |
t_yamamoto | 0:562021ed1ba9 | 64 | { |
t_yamamoto | 0:562021ed1ba9 | 65 | public: |
t_yamamoto | 0:562021ed1ba9 | 66 | static void Initialize(void); |
t_yamamoto | 0:562021ed1ba9 | 67 | static void Update(MotorStatus *status); |
t_yamamoto | 0:562021ed1ba9 | 68 | static void SetDefault(void); |
t_yamamoto | 0:562021ed1ba9 | 69 | static int SetStatus(float pwm); |
t_yamamoto | 0:562021ed1ba9 | 70 | }; |
t_yamamoto | 0:562021ed1ba9 | 71 | } |
t_yamamoto | 0:562021ed1ba9 | 72 | |
t_yamamoto | 0:562021ed1ba9 | 73 | #endif |
t_yamamoto | 0:562021ed1ba9 | 74 |