Steven Kay / SD20
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SD20.h Source File

SD20.h

00001 /* #####################################################################
00002                                SD20.h
00003                                ------
00004                 
00005                           Surface Ship, Group 5
00006                           ---------------------
00007  
00008  Written by:        Steven Kay
00009  
00010  Date:              February 2016
00011  
00012  Function:          This 
00013  
00014  Version:           1.0
00015  
00016  Version History
00017  ---------------
00018  
00019  1.1                rgdfgdfgdfggdfgdg
00020  
00021  1.0                gdgddfdddgd
00022     
00023  ##################################################################### */
00024 
00025 #ifndef SD20_H
00026 #define SD20_H
00027 
00028 /* I2C Parameters*/
00029 
00030 // SD20 I2C Address
00031 #define SD20_ADDRESS 0xC2
00032 
00033 // SCL Frequency
00034 #define BUS_FREQ 100000
00035 
00036 // Output Buffer Length
00037 #define OUT_BUF_LEN 2
00038 
00039 /* SD20 Internal Register Map */
00040 #define SOFTWARE_REVISION_REG 0x00
00041 #define SERVO_1_REG 0x01
00042 #define SERVO_2_REG 0x02
00043 #define SERVO_3_REG 0x03
00044 #define SERVO_4_REG 0x04
00045 #define SERVO_5_REG 0x05
00046 #define SERVO_6_REG 0x06
00047 #define SERVO_7_REG 0x07
00048 #define SERVO_8_REG 0x08
00049 #define SERVO_9_REG 0x09
00050 #define SERVO_10_REG 0x10
00051 #define SERVO_11_REG 0x11
00052 #define SERVO_12_REG 0x12
00053 #define SERVO_13_REG 0x13
00054 #define SERVO_14_REG 0x14
00055 #define SERVO_15_REG 0x15
00056 #define SERVO_16_REG 0x16
00057 #define SERVO_17_REG 0x17
00058 #define SERVO_18_REG 0x18
00059 #define SERVO_19_REG 0x19
00060 #define SERVO_20_REG 0x20
00061 #define STD_ETD_MODE_CTRL 0x21
00062 #define ETD_MODE_OFST_HIGH 0x22
00063 #define ETD_MODE_OFST_LOW 0x23
00064 
00065 /* SD20 Channel constants*/
00066 #define CHANNEL_1 1
00067 #define CHANNEL_2 2
00068 #define CHANNEL_3 3
00069 #define CHANNEL_4 4
00070 #define CHANNEL_5 5
00071 #define CHANNEL_6 6
00072 #define CHANNEL_7 7
00073 #define CHANNEL_8 8
00074 #define CHANNEL_9 9
00075 #define CHANNEL_10 10
00076 #define CHANNEL_11 11
00077 #define CHANNEL_12 12
00078 #define CHANNEL_13 13
00079 #define CHANNEL_14 14
00080 #define CHANNEL_15 15
00081 #define CHANNEL_16 16
00082 #define CHANNEL_17 17
00083 #define CHANNEL_18 18
00084 #define CHANNEL_19 19
00085 #define CHANNEL_20 20
00086 
00087 #define CHANNEL_STOP 0x00
00088 #define CHANNEL_START 0x01
00089 
00090 #define STD_MODE 0x00
00091 
00092 class SD20
00093 {
00094 
00095 private:
00096     I2C *_bus;
00097     
00098     char updateDutyCycle[2];
00099 public:
00100 
00101     /** Create a SD20 Constructor, connected over I2C Master connection
00102      *  
00103      *  parameter bus:     I2C object
00104      */
00105     SD20(I2C *bus);
00106 
00107     /**
00108      *  Start/Stop PWM output on specificed channel (Standard mode)
00109      *
00110      *  parameter Channel:      Servo Channel to be stopped
00111      *  parameter Start:        Select whether to start[1] or stop [0] a given channel
00112      *  parameter mode:         Select whether debug mode[0] and prints result or implementation mode [1] 
00113      *                          where print commands are skipped to save operational time
00114      */
00115     int StartStopChannel(uint8_t ServoChannel, bool Start);
00116 
00117     /**
00118      *  Update PWM output on specificed channel (Standard mode)
00119      *
00120      *  parameter DataOutput:   Structured as follows: [Servo Channel[1:20], Pulse Width[0x00:0xFF]]
00121      *  parameter mode:         Select whether debug mode[0] and prints result or implementation mode [1] 
00122      *                          where print commands are skipped to save operational time
00123      */
00124     int UpdateChannel(char channelReg, char channelSpeed);
00125 
00126 
00127     int SetStandardMode();
00128 };
00129 
00130 #endif