lknds
Dependencies: mbed TrapezoidControl Pulse QEI
Communication/RS485/ActuatorHub/ActuatorHub.h@25:d367d1e7a153, 2019-09-27 (annotated)
- Committer:
- Ryosei
- Date:
- Fri Sep 27 05:19:58 2019 +0000
- Revision:
- 25:d367d1e7a153
- Parent:
- 11:028a150943b5
dskb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
t_yamamoto | 0:669ef71cba68 | 1 | #ifndef ACTUATORHUB_H_ |
t_yamamoto | 0:669ef71cba68 | 2 | #define ACTUATORHUB_H_ |
t_yamamoto | 0:669ef71cba68 | 3 | |
t_yamamoto | 0:669ef71cba68 | 4 | #include "../../../CommonLibraries/RingBuffer/RingBuffer.h" |
t_yamamoto | 0:669ef71cba68 | 5 | |
t_yamamoto | 0:669ef71cba68 | 6 | extern RINGBUFFER::RingBuffer RS485SendBuffer; |
t_yamamoto | 0:669ef71cba68 | 7 | extern RINGBUFFER::RingBuffer BluetoothSendBuffer; |
t_yamamoto | 0:669ef71cba68 | 8 | |
t_yamamoto | 0:669ef71cba68 | 9 | namespace ACTUATORHUB { |
t_yamamoto | 0:669ef71cba68 | 10 | #define MOTOR_ADDR 'M' |
t_yamamoto | 0:669ef71cba68 | 11 | #define MOTOR2_ADDR 'N' |
t_yamamoto | 0:669ef71cba68 | 12 | #define MOTOR3_ADDR 'O' |
t_yamamoto | 0:669ef71cba68 | 13 | #define SOLENOID_ADDR 'S' |
t_yamamoto | 0:669ef71cba68 | 14 | #define BLUETOOTH_ADDR 'B' |
kishibekairohan | 11:028a150943b5 | 15 | #define TAPELED_ADDR 'L' |
t_yamamoto | 0:669ef71cba68 | 16 | |
t_yamamoto | 0:669ef71cba68 | 17 | namespace MOTOR { |
t_yamamoto | 0:669ef71cba68 | 18 | #define FREE 0 |
t_yamamoto | 0:669ef71cba68 | 19 | #define BACK 1 |
t_yamamoto | 0:669ef71cba68 | 20 | #define FOR 2 |
t_yamamoto | 0:669ef71cba68 | 21 | #define BRAKE 3 |
t_yamamoto | 0:669ef71cba68 | 22 | |
t_yamamoto | 0:669ef71cba68 | 23 | typedef struct { |
t_yamamoto | 0:669ef71cba68 | 24 | uint8_t dir; |
t_yamamoto | 0:669ef71cba68 | 25 | uint8_t pwm; |
t_yamamoto | 0:669ef71cba68 | 26 | }MotorStatus; |
t_yamamoto | 0:669ef71cba68 | 27 | |
t_yamamoto | 0:669ef71cba68 | 28 | typedef union { |
t_yamamoto | 0:669ef71cba68 | 29 | struct { |
t_yamamoto | 0:669ef71cba68 | 30 | int data3 : 2; |
t_yamamoto | 0:669ef71cba68 | 31 | int data2 : 2; |
t_yamamoto | 0:669ef71cba68 | 32 | int data1 : 2; |
t_yamamoto | 0:669ef71cba68 | 33 | int data0 : 2; |
t_yamamoto | 0:669ef71cba68 | 34 | }; |
t_yamamoto | 0:669ef71cba68 | 35 | uint8_t all; |
t_yamamoto | 0:669ef71cba68 | 36 | }MotorDirectionData; |
t_yamamoto | 0:669ef71cba68 | 37 | |
t_yamamoto | 0:669ef71cba68 | 38 | typedef struct { |
t_yamamoto | 0:669ef71cba68 | 39 | MotorDirectionData direction0to3; |
t_yamamoto | 0:669ef71cba68 | 40 | MotorDirectionData direction4to7; |
t_yamamoto | 0:669ef71cba68 | 41 | MotorDirectionData direction8to9; |
t_yamamoto | 0:669ef71cba68 | 42 | |
t_yamamoto | 0:669ef71cba68 | 43 | uint8_t pwm0; |
t_yamamoto | 0:669ef71cba68 | 44 | uint8_t pwm1; |
t_yamamoto | 0:669ef71cba68 | 45 | uint8_t pwm2; |
t_yamamoto | 0:669ef71cba68 | 46 | uint8_t pwm3; |
t_yamamoto | 0:669ef71cba68 | 47 | uint8_t pwm4; |
t_yamamoto | 0:669ef71cba68 | 48 | uint8_t pwm5; |
t_yamamoto | 0:669ef71cba68 | 49 | uint8_t pwm6; |
t_yamamoto | 0:669ef71cba68 | 50 | uint8_t pwm7; |
t_yamamoto | 0:669ef71cba68 | 51 | uint8_t pwm8; |
t_yamamoto | 0:669ef71cba68 | 52 | uint8_t pwm9; |
t_yamamoto | 0:669ef71cba68 | 53 | uint8_t pwm10; |
t_yamamoto | 0:669ef71cba68 | 54 | uint8_t pwm11; |
t_yamamoto | 0:669ef71cba68 | 55 | uint8_t pwm12; |
t_yamamoto | 0:669ef71cba68 | 56 | }AllMotorData; |
t_yamamoto | 0:669ef71cba68 | 57 | |
t_yamamoto | 0:669ef71cba68 | 58 | class Motor { |
t_yamamoto | 0:669ef71cba68 | 59 | public: |
t_yamamoto | 0:669ef71cba68 | 60 | static void Initialize(); |
t_yamamoto | 0:669ef71cba68 | 61 | static void Update(MotorStatus *status); |
t_yamamoto | 0:669ef71cba68 | 62 | static void SetDefault(); |
t_yamamoto | 0:669ef71cba68 | 63 | }; |
t_yamamoto | 0:669ef71cba68 | 64 | } |
t_yamamoto | 0:669ef71cba68 | 65 | |
t_yamamoto | 0:669ef71cba68 | 66 | namespace SOLENOID { |
t_yamamoto | 0:669ef71cba68 | 67 | #define SOLENOID_ON 1 |
t_yamamoto | 0:669ef71cba68 | 68 | #define SOLENOID_OFF 0 |
t_yamamoto | 0:669ef71cba68 | 69 | |
t_yamamoto | 0:669ef71cba68 | 70 | #define ALL_SOLENOID_ON 0xffff |
t_yamamoto | 0:669ef71cba68 | 71 | #define ALL_SOLENOID_OFF 0 |
t_yamamoto | 0:669ef71cba68 | 72 | |
t_yamamoto | 0:669ef71cba68 | 73 | typedef union { |
t_yamamoto | 0:669ef71cba68 | 74 | struct { |
t_yamamoto | 0:669ef71cba68 | 75 | int : 4; |
t_yamamoto | 0:669ef71cba68 | 76 | int solenoid11 : 1; |
t_yamamoto | 0:669ef71cba68 | 77 | int solenoid10 : 1; |
t_yamamoto | 0:669ef71cba68 | 78 | int solenoid9 : 1; |
t_yamamoto | 0:669ef71cba68 | 79 | int solenoid8 : 1; |
t_yamamoto | 0:669ef71cba68 | 80 | int solenoid7 : 1; |
t_yamamoto | 0:669ef71cba68 | 81 | int solenoid6 : 1; |
t_yamamoto | 0:669ef71cba68 | 82 | int solenoid5 : 1; |
t_yamamoto | 0:669ef71cba68 | 83 | int solenoid4 : 1; |
t_yamamoto | 0:669ef71cba68 | 84 | int solenoid3 : 1; |
t_yamamoto | 0:669ef71cba68 | 85 | int solenoid2 : 1; |
t_yamamoto | 0:669ef71cba68 | 86 | int solenoid1 : 1; |
t_yamamoto | 0:669ef71cba68 | 87 | int solenoid0 : 1; |
t_yamamoto | 0:669ef71cba68 | 88 | }; |
t_yamamoto | 0:669ef71cba68 | 89 | uint16_t all; |
t_yamamoto | 0:669ef71cba68 | 90 | }SolenoidStatus; |
t_yamamoto | 0:669ef71cba68 | 91 | |
t_yamamoto | 0:669ef71cba68 | 92 | class Solenoid { |
t_yamamoto | 0:669ef71cba68 | 93 | public: |
t_yamamoto | 0:669ef71cba68 | 94 | static void Initialize(); |
t_yamamoto | 0:669ef71cba68 | 95 | static void Update(SolenoidStatus status); |
t_yamamoto | 0:669ef71cba68 | 96 | }; |
t_yamamoto | 0:669ef71cba68 | 97 | } |
t_yamamoto | 0:669ef71cba68 | 98 | |
t_yamamoto | 0:669ef71cba68 | 99 | class ActuatorHub { |
t_yamamoto | 0:669ef71cba68 | 100 | public: |
t_yamamoto | 0:669ef71cba68 | 101 | static void Update(); |
t_yamamoto | 0:669ef71cba68 | 102 | }; |
t_yamamoto | 0:669ef71cba68 | 103 | } |
t_yamamoto | 0:669ef71cba68 | 104 | |
t_yamamoto | 0:669ef71cba68 | 105 | #endif |