test

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ActuatorHub.h Source File

ActuatorHub.h

00001 #ifndef ACTUATORHUB_H_
00002 #define ACTUATORHUB_H_
00003 
00004 #include "../../../CommonLibraries/RingBuffer/RingBuffer.h"
00005 
00006 extern RINGBUFFER::RingBuffer RS485SendBuffer;
00007 extern RINGBUFFER::RingBuffer BluetoothSendBuffer;
00008 
00009 namespace ACTUATORHUB {
00010     #define MOTOR_ADDR      'M'
00011     #define MOTOR2_ADDR     'N'
00012     #define MOTOR3_ADDR     'O'
00013     #define SOLENOID_ADDR   'S'
00014     #define BLUETOOTH_ADDR  'B'
00015 
00016     namespace MOTOR {
00017         #define FREE    0
00018         #define BACK    1
00019         #define FOR     2
00020         #define BRAKE   3
00021 
00022         typedef struct {
00023             uint8_t dir;
00024             uint8_t pwm;
00025         }MotorStatus;
00026 
00027         typedef union {
00028             struct {
00029                 int data3 : 2;
00030                 int data2 : 2;
00031                 int data1 : 2;
00032                 int data0 : 2;
00033             };
00034             uint8_t all;
00035         }MotorDirectionData;
00036 
00037         typedef struct {
00038             MotorDirectionData direction0to3;
00039             MotorDirectionData direction4to7;
00040             MotorDirectionData direction8to9;
00041 
00042             uint8_t pwm0;
00043             uint8_t pwm1;
00044             uint8_t pwm2;
00045             uint8_t pwm3;
00046             uint8_t pwm4;
00047             uint8_t pwm5;
00048             uint8_t pwm6;
00049             uint8_t pwm7;
00050             uint8_t pwm8;
00051             uint8_t pwm9;
00052             uint8_t pwm10;
00053             uint8_t pwm11;
00054             uint8_t pwm12;
00055         }AllMotorData;
00056 
00057         class Motor {
00058             public:
00059             static void Initialize();
00060             static void Update(MotorStatus *status);
00061             static void SetDefault();
00062         };
00063     }
00064 
00065     namespace SOLENOID {
00066         #define SOLENOID_ON     1
00067         #define SOLENOID_OFF    0
00068 
00069         #define ALL_SOLENOID_ON     0xffff
00070         #define ALL_SOLENOID_OFF    0
00071 
00072         typedef union {
00073             struct {
00074                 int : 4;
00075                 int solenoid11 : 1;
00076                 int solenoid10 : 1;
00077                 int solenoid9 : 1;
00078                 int solenoid8 : 1;
00079                 int solenoid7 : 1;
00080                 int solenoid6 : 1;
00081                 int solenoid5 : 1;
00082                 int solenoid4 : 1;
00083                 int solenoid3 : 1;
00084                 int solenoid2 : 1;
00085                 int solenoid1 : 1;
00086                 int solenoid0 : 1;
00087             };
00088             uint16_t all;
00089         }SolenoidStatus;
00090 
00091         class Solenoid {
00092             public:
00093             static void Initialize();
00094             static void Update(SolenoidStatus status);
00095         };
00096     }
00097 
00098     class ActuatorHub {
00099         public:
00100         static void Update();
00101     };
00102 }
00103 
00104 #endif