Miya Miyagawa
/
OREWOTAOSITAI
aaaaa
Diff: Output/Motor/Motor.h
- Revision:
- 0:562021ed1ba9
- Child:
- 1:e73cf2469f83
diff -r 000000000000 -r 562021ed1ba9 Output/Motor/Motor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Output/Motor/Motor.h Sat Jan 13 13:33:09 2018 +0000 @@ -0,0 +1,74 @@ +#ifndef MOTOR_H_ +#define MOTOR_H_ + +#include <stdint.h> + +namespace MOTOR +{ + #define FREE 0 + #define BACK 1 + #define FOR 2 + #define BRAKE 3 + + #define MOUNTING_MOTOR_NUM (5 + 1) //MOTOR0の関係で+1 + + #define MOTOR0_D1 directions[0] + #define MOTOR0_D2 directions[1] + #define MOTOR1_D1 directions[2] + #define MOTOR1_D2 directions[3] + #define MOTOR2_D1 directions[4] + #define MOTOR2_D2 directions[5] + #define MOTOR3_D1 directions[6] + #define MOTOR3_D2 directions[7] + #define MOTOR4_D1 directions[8] + #define MOTOR4_D2 directions[9] + #define MOTOR5_D1 directions[10] + #define MOTOR6_D2 directions[11] + + #define MOTOR0_D1_PIN NC + #define MOTOR0_D2_PIN NC + #define MOTOR1_D1_PIN D3 + #define MOTOR1_D2_PIN D2 + #define MOTOR2_D1_PIN D6 + #define MOTOR2_D2_PIN D5 + #define MOTOR3_D1_PIN D9 + #define MOTOR3_D2_PIN D8 + #define MOTOR4_D1_PIN D12 + #define MOTOR4_D2_PIN D11 + #define MOTOR5_D1_PIN A0 + #define MOTOR5_D2_PIN A1 + + #define MOTOR0_PWM_PIN NC + #define MOTOR1_PWM_PIN D4 + #define MOTOR2_PWM_PIN D7 + #define MOTOR3_PWM_PIN D10 + #define MOTOR4_PWM_PIN A2 + #define MOTOR5_PWM_PIN A3 + + typedef struct + { + union + { + struct + { + unsigned int d2 : 1; + unsigned int d1 : 1; + unsigned int : 6; + }; + uint8_t dir; + }; + float pwm; + }MotorStatus; + + class Motor + { + public: + static void Initialize(void); + static void Update(MotorStatus *status); + static void SetDefault(void); + static int SetStatus(float pwm); + }; +} + +#endif +