にいむら にいむら
/
mainboardnrp2018
unkounko
Output/Motor/Motor.h@11:88f17bc0724f, 2019-02-25 (annotated)
- Committer:
- niimurasyou
- Date:
- Mon Feb 25 05:48:20 2019 +0000
- Revision:
- 11:88f17bc0724f
- Parent:
- 8:cb53beff4bb2
hhhhhhhhh
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 | 8:cb53beff4bb2 | 6 | //#define USE_MOTOR0_SENSOR |
t_yamamoto | 0:562021ed1ba9 | 7 | namespace MOTOR |
t_yamamoto | 0:562021ed1ba9 | 8 | { |
t_yamamoto | 0:562021ed1ba9 | 9 | #define FREE 0 |
t_yamamoto | 0:562021ed1ba9 | 10 | #define BACK 1 |
t_yamamoto | 0:562021ed1ba9 | 11 | #define FOR 2 |
t_yamamoto | 0:562021ed1ba9 | 12 | #define BRAKE 3 |
t_yamamoto | 0:562021ed1ba9 | 13 | |
t_yamamoto | 1:e73cf2469f83 | 14 | #define MOUNTING_MOTOR_NUM 5 |
t_yamamoto | 0:562021ed1ba9 | 15 | |
t_yamamoto | 0:562021ed1ba9 | 16 | #define MOTOR0_D1 directions[0] |
t_yamamoto | 0:562021ed1ba9 | 17 | #define MOTOR0_D2 directions[1] |
t_yamamoto | 0:562021ed1ba9 | 18 | #define MOTOR1_D1 directions[2] |
t_yamamoto | 0:562021ed1ba9 | 19 | #define MOTOR1_D2 directions[3] |
t_yamamoto | 0:562021ed1ba9 | 20 | #define MOTOR2_D1 directions[4] |
t_yamamoto | 0:562021ed1ba9 | 21 | #define MOTOR2_D2 directions[5] |
t_yamamoto | 0:562021ed1ba9 | 22 | #define MOTOR3_D1 directions[6] |
t_yamamoto | 0:562021ed1ba9 | 23 | #define MOTOR3_D2 directions[7] |
t_yamamoto | 0:562021ed1ba9 | 24 | #define MOTOR4_D1 directions[8] |
t_yamamoto | 0:562021ed1ba9 | 25 | #define MOTOR4_D2 directions[9] |
t_yamamoto | 0:562021ed1ba9 | 26 | |
t_yamamoto | 1:e73cf2469f83 | 27 | #define MOTOR0_D1_PIN D3 |
t_yamamoto | 3:a9ab1a251456 | 28 | #define MOTOR0_D2_PIN D4 |
t_yamamoto | 4:42ba5ccc4a2a | 29 | #define MOTOR1_D1_PIN D5 |
t_yamamoto | 4:42ba5ccc4a2a | 30 | #define MOTOR1_D2_PIN D6 |
t_yamamoto | 3:a9ab1a251456 | 31 | #define MOTOR2_D1_PIN D8 |
t_yamamoto | 3:a9ab1a251456 | 32 | #define MOTOR2_D2_PIN D9 |
t_yamamoto | 1:e73cf2469f83 | 33 | #define MOTOR3_D1_PIN D12 |
t_yamamoto | 3:a9ab1a251456 | 34 | #define MOTOR3_D2_PIN A3 |
t_yamamoto | 3:a9ab1a251456 | 35 | #define MOTOR4_D1_PIN A1 |
t_yamamoto | 3:a9ab1a251456 | 36 | #define MOTOR4_D2_PIN A0 |
t_yamamoto | 0:562021ed1ba9 | 37 | |
t_yamamoto | 3:a9ab1a251456 | 38 | #define MOTOR0_PWM_PIN D2 |
t_yamamoto | 4:42ba5ccc4a2a | 39 | #define MOTOR1_PWM_PIN D7 |
t_yamamoto | 1:e73cf2469f83 | 40 | #define MOTOR2_PWM_PIN D10 |
t_yamamoto | 3:a9ab1a251456 | 41 | #define MOTOR3_PWM_PIN D11 |
t_yamamoto | 3:a9ab1a251456 | 42 | #define MOTOR4_PWM_PIN A2 |
t_yamamoto | 8:cb53beff4bb2 | 43 | |
t_yamamoto | 8:cb53beff4bb2 | 44 | #ifdef USE_MOTOR0_SENSOR |
t_yamamoto | 8:cb53beff4bb2 | 45 | #define MOTOR_START_NUM 1 |
t_yamamoto | 8:cb53beff4bb2 | 46 | #else |
t_yamamoto | 8:cb53beff4bb2 | 47 | #define MOTOR_START_NUM 0 |
t_yamamoto | 8:cb53beff4bb2 | 48 | #endif |
t_yamamoto | 0:562021ed1ba9 | 49 | |
t_yamamoto | 0:562021ed1ba9 | 50 | typedef struct |
t_yamamoto | 0:562021ed1ba9 | 51 | { |
t_yamamoto | 0:562021ed1ba9 | 52 | union |
t_yamamoto | 0:562021ed1ba9 | 53 | { |
t_yamamoto | 0:562021ed1ba9 | 54 | struct |
t_yamamoto | 0:562021ed1ba9 | 55 | { |
t_yamamoto | 0:562021ed1ba9 | 56 | unsigned int d2 : 1; |
t_yamamoto | 0:562021ed1ba9 | 57 | unsigned int d1 : 1; |
t_yamamoto | 0:562021ed1ba9 | 58 | unsigned int : 6; |
t_yamamoto | 0:562021ed1ba9 | 59 | }; |
t_yamamoto | 0:562021ed1ba9 | 60 | uint8_t dir; |
t_yamamoto | 0:562021ed1ba9 | 61 | }; |
t_yamamoto | 0:562021ed1ba9 | 62 | float pwm; |
t_yamamoto | 0:562021ed1ba9 | 63 | }MotorStatus; |
t_yamamoto | 0:562021ed1ba9 | 64 | |
t_yamamoto | 0:562021ed1ba9 | 65 | class Motor |
t_yamamoto | 0:562021ed1ba9 | 66 | { |
t_yamamoto | 0:562021ed1ba9 | 67 | public: |
t_yamamoto | 0:562021ed1ba9 | 68 | static void Initialize(void); |
t_yamamoto | 0:562021ed1ba9 | 69 | static void Update(MotorStatus *status); |
t_yamamoto | 0:562021ed1ba9 | 70 | static void SetDefault(void); |
t_yamamoto | 0:562021ed1ba9 | 71 | static int SetStatus(float pwm); |
t_yamamoto | 0:562021ed1ba9 | 72 | }; |
t_yamamoto | 0:562021ed1ba9 | 73 | } |
t_yamamoto | 0:562021ed1ba9 | 74 | |
t_yamamoto | 0:562021ed1ba9 | 75 | #endif |