lknds

Dependencies:   mbed TrapezoidControl Pulse QEI

Committer:
t_yamamoto
Date:
Sat Sep 08 06:05:22 2018 +0000
Revision:
0:669ef71cba68
Child:
11:028a150943b5
???????

Who changed what in which revision?

UserRevisionLine numberNew 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'
t_yamamoto 0:669ef71cba68 15
t_yamamoto 0:669ef71cba68 16 namespace MOTOR {
t_yamamoto 0:669ef71cba68 17 #define FREE 0
t_yamamoto 0:669ef71cba68 18 #define BACK 1
t_yamamoto 0:669ef71cba68 19 #define FOR 2
t_yamamoto 0:669ef71cba68 20 #define BRAKE 3
t_yamamoto 0:669ef71cba68 21
t_yamamoto 0:669ef71cba68 22 typedef struct {
t_yamamoto 0:669ef71cba68 23 uint8_t dir;
t_yamamoto 0:669ef71cba68 24 uint8_t pwm;
t_yamamoto 0:669ef71cba68 25 }MotorStatus;
t_yamamoto 0:669ef71cba68 26
t_yamamoto 0:669ef71cba68 27 typedef union {
t_yamamoto 0:669ef71cba68 28 struct {
t_yamamoto 0:669ef71cba68 29 int data3 : 2;
t_yamamoto 0:669ef71cba68 30 int data2 : 2;
t_yamamoto 0:669ef71cba68 31 int data1 : 2;
t_yamamoto 0:669ef71cba68 32 int data0 : 2;
t_yamamoto 0:669ef71cba68 33 };
t_yamamoto 0:669ef71cba68 34 uint8_t all;
t_yamamoto 0:669ef71cba68 35 }MotorDirectionData;
t_yamamoto 0:669ef71cba68 36
t_yamamoto 0:669ef71cba68 37 typedef struct {
t_yamamoto 0:669ef71cba68 38 MotorDirectionData direction0to3;
t_yamamoto 0:669ef71cba68 39 MotorDirectionData direction4to7;
t_yamamoto 0:669ef71cba68 40 MotorDirectionData direction8to9;
t_yamamoto 0:669ef71cba68 41
t_yamamoto 0:669ef71cba68 42 uint8_t pwm0;
t_yamamoto 0:669ef71cba68 43 uint8_t pwm1;
t_yamamoto 0:669ef71cba68 44 uint8_t pwm2;
t_yamamoto 0:669ef71cba68 45 uint8_t pwm3;
t_yamamoto 0:669ef71cba68 46 uint8_t pwm4;
t_yamamoto 0:669ef71cba68 47 uint8_t pwm5;
t_yamamoto 0:669ef71cba68 48 uint8_t pwm6;
t_yamamoto 0:669ef71cba68 49 uint8_t pwm7;
t_yamamoto 0:669ef71cba68 50 uint8_t pwm8;
t_yamamoto 0:669ef71cba68 51 uint8_t pwm9;
t_yamamoto 0:669ef71cba68 52 uint8_t pwm10;
t_yamamoto 0:669ef71cba68 53 uint8_t pwm11;
t_yamamoto 0:669ef71cba68 54 uint8_t pwm12;
t_yamamoto 0:669ef71cba68 55 }AllMotorData;
t_yamamoto 0:669ef71cba68 56
t_yamamoto 0:669ef71cba68 57 class Motor {
t_yamamoto 0:669ef71cba68 58 public:
t_yamamoto 0:669ef71cba68 59 static void Initialize();
t_yamamoto 0:669ef71cba68 60 static void Update(MotorStatus *status);
t_yamamoto 0:669ef71cba68 61 static void SetDefault();
t_yamamoto 0:669ef71cba68 62 };
t_yamamoto 0:669ef71cba68 63 }
t_yamamoto 0:669ef71cba68 64
t_yamamoto 0:669ef71cba68 65 namespace SOLENOID {
t_yamamoto 0:669ef71cba68 66 #define SOLENOID_ON 1
t_yamamoto 0:669ef71cba68 67 #define SOLENOID_OFF 0
t_yamamoto 0:669ef71cba68 68
t_yamamoto 0:669ef71cba68 69 #define ALL_SOLENOID_ON 0xffff
t_yamamoto 0:669ef71cba68 70 #define ALL_SOLENOID_OFF 0
t_yamamoto 0:669ef71cba68 71
t_yamamoto 0:669ef71cba68 72 typedef union {
t_yamamoto 0:669ef71cba68 73 struct {
t_yamamoto 0:669ef71cba68 74 int : 4;
t_yamamoto 0:669ef71cba68 75 int solenoid11 : 1;
t_yamamoto 0:669ef71cba68 76 int solenoid10 : 1;
t_yamamoto 0:669ef71cba68 77 int solenoid9 : 1;
t_yamamoto 0:669ef71cba68 78 int solenoid8 : 1;
t_yamamoto 0:669ef71cba68 79 int solenoid7 : 1;
t_yamamoto 0:669ef71cba68 80 int solenoid6 : 1;
t_yamamoto 0:669ef71cba68 81 int solenoid5 : 1;
t_yamamoto 0:669ef71cba68 82 int solenoid4 : 1;
t_yamamoto 0:669ef71cba68 83 int solenoid3 : 1;
t_yamamoto 0:669ef71cba68 84 int solenoid2 : 1;
t_yamamoto 0:669ef71cba68 85 int solenoid1 : 1;
t_yamamoto 0:669ef71cba68 86 int solenoid0 : 1;
t_yamamoto 0:669ef71cba68 87 };
t_yamamoto 0:669ef71cba68 88 uint16_t all;
t_yamamoto 0:669ef71cba68 89 }SolenoidStatus;
t_yamamoto 0:669ef71cba68 90
t_yamamoto 0:669ef71cba68 91 class Solenoid {
t_yamamoto 0:669ef71cba68 92 public:
t_yamamoto 0:669ef71cba68 93 static void Initialize();
t_yamamoto 0:669ef71cba68 94 static void Update(SolenoidStatus status);
t_yamamoto 0:669ef71cba68 95 };
t_yamamoto 0:669ef71cba68 96 }
t_yamamoto 0:669ef71cba68 97
t_yamamoto 0:669ef71cba68 98 class ActuatorHub {
t_yamamoto 0:669ef71cba68 99 public:
t_yamamoto 0:669ef71cba68 100 static void Update();
t_yamamoto 0:669ef71cba68 101 };
t_yamamoto 0:669ef71cba68 102 }
t_yamamoto 0:669ef71cba68 103
t_yamamoto 0:669ef71cba68 104 #endif