test
Dependencies: MODDMA MODSERIAL mbed
Fork of IRIS_MBED by
main.h@7:49aba2a2e847, 2015-04-09 (annotated)
- Committer:
- JonathanAshworth
- Date:
- Thu Apr 09 20:07:15 2015 +0000
- Revision:
- 7:49aba2a2e847
- Parent:
- 6:8ffc6d3a7c1d
latest version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JonathanAshworth | 6:8ffc6d3a7c1d | 1 | /*********************************************************************** |
JonathanAshworth | 6:8ffc6d3a7c1d | 2 | PROJECT IRIS |
JonathanAshworth | 6:8ffc6d3a7c1d | 3 | Multidisciplinary Group Project |
JonathanAshworth | 6:8ffc6d3a7c1d | 4 | ENG701S2 (Year 4 - MENG) at the University of Portsmouth |
JonathanAshworth | 6:8ffc6d3a7c1d | 5 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 6 | Filename: main.h |
JonathanAshworth | 6:8ffc6d3a7c1d | 7 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 8 | Description: Header file for the main root source file (main.cpp). |
JonathanAshworth | 6:8ffc6d3a7c1d | 9 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 10 | Original Created: 05/04/2015 |
JonathanAshworth | 6:8ffc6d3a7c1d | 11 | Original Author: Jonathan Ashworth |
JonathanAshworth | 6:8ffc6d3a7c1d | 12 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 13 | --------------------------Change Log-------------------------------- |
JonathanAshworth | 6:8ffc6d3a7c1d | 14 | Date | Author | Details |
JonathanAshworth | 6:8ffc6d3a7c1d | 15 | 06/04/05 Jonathan Ashworth |
JonathanAshworth | 6:8ffc6d3a7c1d | 16 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 17 | ***********************************************************************/ |
JonathanAshworth | 6:8ffc6d3a7c1d | 18 | |
JonathanAshworth | 4:1017848d2fe1 | 19 | /* |
JonathanAshworth | 0:2676c97df44e | 20 | |
JonathanAshworth | 0:2676c97df44e | 21 | void serialTx (void); |
JonathanAshworth | 0:2676c97df44e | 22 | void usbTimeout(void); |
JonathanAshworth | 0:2676c97df44e | 23 | void shutdown(void); |
JonathanAshworth | 0:2676c97df44e | 24 | void serialRx_ISR(void); |
JonathanAshworth | 0:2676c97df44e | 25 | void usbTimer_ISR(void); |
JonathanAshworth | 4:1017848d2fe1 | 26 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 27 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 28 | if(0) { |
JonathanAshworth | 6:8ffc6d3a7c1d | 29 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 30 | //servos |
JonathanAshworth | 6:8ffc6d3a7c1d | 31 | for (i=0; i<PC_SERVO_REQUEST_COUNT; i++) { |
JonathanAshworth | 6:8ffc6d3a7c1d | 32 | PCRxData[(15*i)+0] = 0x00; //CID |
JonathanAshworth | 6:8ffc6d3a7c1d | 33 | PCRxData[(15*i)+1] = i+2; //SID |
JonathanAshworth | 6:8ffc6d3a7c1d | 34 | PCRxData[(15*i)+2] = 0x03; //FC |
JonathanAshworth | 6:8ffc6d3a7c1d | 35 | PCRxData[(15*i)+3] = 0x00; //Byte0... |
JonathanAshworth | 6:8ffc6d3a7c1d | 36 | PCRxData[(15*i)+4] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 37 | PCRxData[(15*i)+5] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 38 | PCRxData[(15*i)+6] = 0x00; //... |
JonathanAshworth | 6:8ffc6d3a7c1d | 39 | PCRxData[(15*i)+7] = 0x00; //Byte1... |
JonathanAshworth | 6:8ffc6d3a7c1d | 40 | PCRxData[(15*i)+8] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 41 | PCRxData[(15*i)+9] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 42 | PCRxData[(15*i)+10] = 0x00; //... |
JonathanAshworth | 6:8ffc6d3a7c1d | 43 | PCRxData[(15*i)+11] = 0x00; //Byte2... |
JonathanAshworth | 6:8ffc6d3a7c1d | 44 | PCRxData[(15*i)+12] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 45 | PCRxData[(15*i)+13] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 46 | PCRxData[(15*i)+14] = 0x00; //... |
JonathanAshworth | 6:8ffc6d3a7c1d | 47 | } |
JonathanAshworth | 6:8ffc6d3a7c1d | 48 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 49 | //motors |
JonathanAshworth | 6:8ffc6d3a7c1d | 50 | for (i=0; i<PC_MOTOR_REQUEST_COUNT; i++) { |
JonathanAshworth | 6:8ffc6d3a7c1d | 51 | PCRxData[(7*15)+(7*i)+0] = 0x00; //CID |
JonathanAshworth | 6:8ffc6d3a7c1d | 52 | PCRxData[(7*15)+(7*i)+1] = i+9; //SID |
JonathanAshworth | 6:8ffc6d3a7c1d | 53 | PCRxData[(7*15)+(7*i)+2] = 0x01; //FC |
JonathanAshworth | 6:8ffc6d3a7c1d | 54 | PCRxData[(7*15)+(7*i)+3] = 0x00; //Byte0... |
JonathanAshworth | 6:8ffc6d3a7c1d | 55 | PCRxData[(7*15)+(7*i)+4] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 56 | PCRxData[(7*15)+(7*i)+5] = 0x00; //. |
JonathanAshworth | 6:8ffc6d3a7c1d | 57 | PCRxData[(7*15)+(7*i)+6] = 0x00; //... |
JonathanAshworth | 6:8ffc6d3a7c1d | 58 | } |
JonathanAshworth | 6:8ffc6d3a7c1d | 59 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 60 | PCRxData[(7*15)+(7*i)+0] = 0x00; //CID |
JonathanAshworth | 6:8ffc6d3a7c1d | 61 | PCRxData[(7*15)+(7*i)+1] = 0x01; //SID |
JonathanAshworth | 6:8ffc6d3a7c1d | 62 | PCRxData[(7*15)+(7*i)+2] = 0x03; //FC |
JonathanAshworth | 6:8ffc6d3a7c1d | 63 | PCRxData[(7*15)+(7*i)+3] = 0x02; //Byte0... |
JonathanAshworth | 6:8ffc6d3a7c1d | 64 | PCRxData[(7*15)+(7*i)+4] = 0x0a; |
JonathanAshworth | 6:8ffc6d3a7c1d | 65 | PCRxData[(7*15)+(7*i)+5] = 0x0d; |
JonathanAshworth | 6:8ffc6d3a7c1d | 66 | flags.rxNewData = 1; |
JonathanAshworth | 6:8ffc6d3a7c1d | 67 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 68 | } |
JonathanAshworth | 6:8ffc6d3a7c1d | 69 | |
JonathanAshworth | 4:1017848d2fe1 | 70 | */ |
JonathanAshworth | 4:1017848d2fe1 | 71 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 72 | #ifndef MAIN_H |
JonathanAshworth | 6:8ffc6d3a7c1d | 73 | #define MAIN_H |
JonathanAshworth | 6:8ffc6d3a7c1d | 74 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 75 | #include "mbed.h" |
JonathanAshworth | 6:8ffc6d3a7c1d | 76 | #include "MODDMA.h" |
JonathanAshworth | 6:8ffc6d3a7c1d | 77 | #include "MODSERIAL.h" |
JonathanAshworth | 6:8ffc6d3a7c1d | 78 | #include "botStateHandler.h" |
JonathanAshworth | 6:8ffc6d3a7c1d | 79 | //#include "HCSR04/HCSR04.h" |
JonathanAshworth | 6:8ffc6d3a7c1d | 80 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 81 | #define SERVO_ARM_BASE_CHAN 0 |
JonathanAshworth | 6:8ffc6d3a7c1d | 82 | #define SERVO_ARM_SHOULDER_CHAN 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 83 | #define SERVO_ARM_ELBOW_CHAN 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 84 | #define SERVO_ARM_WRIST_CHAN 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 85 | #define SERVO_ARM_MANIPULATOR_CHAN 4 |
JonathanAshworth | 6:8ffc6d3a7c1d | 86 | #define SERVO_VISION_PITCH_CHAN 5 |
JonathanAshworth | 6:8ffc6d3a7c1d | 87 | #define SERVO_VISION_YAW_CHAN 6 |
JonathanAshworth | 6:8ffc6d3a7c1d | 88 | #define SERVO_POSITION_MIN 600 |
JonathanAshworth | 6:8ffc6d3a7c1d | 89 | #define SERVO_POSITION_MAX 2300 |
JonathanAshworth | 6:8ffc6d3a7c1d | 90 | #define SERVO_POSITION_CENTRE 1500 |
JonathanAshworth | 6:8ffc6d3a7c1d | 91 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 92 | #define SID_PC 0x00 |
JonathanAshworth | 6:8ffc6d3a7c1d | 93 | #define SID_MBED 0x01 |
JonathanAshworth | 6:8ffc6d3a7c1d | 94 | #define SID_ARM_BASE 0x02 |
JonathanAshworth | 6:8ffc6d3a7c1d | 95 | #define SID_ARM_SHOULDER 0x03 |
JonathanAshworth | 6:8ffc6d3a7c1d | 96 | #define SID_ARM_ELBOW 0x04 |
JonathanAshworth | 6:8ffc6d3a7c1d | 97 | #define SID_ARM_WRIST 0x05 |
JonathanAshworth | 6:8ffc6d3a7c1d | 98 | #define SID_ARM_MANIPULATOR 0x06 |
JonathanAshworth | 6:8ffc6d3a7c1d | 99 | #define SID_VISION_PITCH 0x07 |
JonathanAshworth | 6:8ffc6d3a7c1d | 100 | #define SID_VISION_YAW 0x08 |
JonathanAshworth | 6:8ffc6d3a7c1d | 101 | #define SID_DRIVE_NS 0x09 |
JonathanAshworth | 6:8ffc6d3a7c1d | 102 | #define SID_DRIVE_OS 0x0a |
JonathanAshworth | 6:8ffc6d3a7c1d | 103 | #define SID_RESERVED 0x0b |
JonathanAshworth | 6:8ffc6d3a7c1d | 104 | #define SID_9DOF_ACC 0x0c |
JonathanAshworth | 6:8ffc6d3a7c1d | 105 | #define SID_9DOF_GYRO 0x0d |
JonathanAshworth | 6:8ffc6d3a7c1d | 106 | #define SID_9DOF_MAG 0x0e |
JonathanAshworth | 6:8ffc6d3a7c1d | 107 | #define SID_GPS 0x0f |
JonathanAshworth | 6:8ffc6d3a7c1d | 108 | #define SID_TEMP 0x10 |
JonathanAshworth | 6:8ffc6d3a7c1d | 109 | #define SID_HUM 0x11 |
JonathanAshworth | 6:8ffc6d3a7c1d | 110 | #define SID_BATT_VOL 0x12 |
JonathanAshworth | 6:8ffc6d3a7c1d | 111 | #define SID_BATT_CUR 0x13 |
JonathanAshworth | 6:8ffc6d3a7c1d | 112 | #define SID_PIR 0x14 |
JonathanAshworth | 6:8ffc6d3a7c1d | 113 | #define SID_USOUND_1 0x15 |
JonathanAshworth | 6:8ffc6d3a7c1d | 114 | #define SID_USOUND_2 0x16 |
JonathanAshworth | 6:8ffc6d3a7c1d | 115 | #define SID_USOUND_3 0x17 |
JonathanAshworth | 6:8ffc6d3a7c1d | 116 | #define SID_USOUND_4 0x18 |
JonathanAshworth | 6:8ffc6d3a7c1d | 117 | #define SID_USOUND_5 0x19 |
JonathanAshworth | 6:8ffc6d3a7c1d | 118 | #define SID_USOUND_6 0x1a |
JonathanAshworth | 6:8ffc6d3a7c1d | 119 | #define SID_FIRSTSERVO_LOCATION 0x02 |
JonathanAshworth | 6:8ffc6d3a7c1d | 120 | #define SID_LASTSERVO_LOCATION 0x08 |
JonathanAshworth | 6:8ffc6d3a7c1d | 121 | #define SID_FIRSTMOTOR_LOCATION 0x09 |
JonathanAshworth | 6:8ffc6d3a7c1d | 122 | #define SID_LASTMOTOR_LOCATION 0x0a |
JonathanAshworth | 6:8ffc6d3a7c1d | 123 | #define SID_FIRSTUSOUND_LOCATION 0x15 |
JonathanAshworth | 6:8ffc6d3a7c1d | 124 | #define SID_LASTUSOUND_LOCATION 0x1a |
JonathanAshworth | 6:8ffc6d3a7c1d | 125 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 126 | #define PC_BAUDRATE 115200 |
JonathanAshworth | 6:8ffc6d3a7c1d | 127 | #define PC_TX_BUFFER_SIZE 1024 |
JonathanAshworth | 6:8ffc6d3a7c1d | 128 | #define PC_RX_BUFFER_SIZE 1024 |
JonathanAshworth | 6:8ffc6d3a7c1d | 129 | #define PC_TX_PIN USBTX //Serial tx |
JonathanAshworth | 6:8ffc6d3a7c1d | 130 | #define PC_RX_PIN USBRX //Serial rx |
JonathanAshworth | 6:8ffc6d3a7c1d | 131 | #define PC_TIMEOUT_MESSAGE "MBED detected a timeout - eStop!" |
JonathanAshworth | 6:8ffc6d3a7c1d | 132 | #define PC_TIMEOUT_PERIOD 200 |
JonathanAshworth | 6:8ffc6d3a7c1d | 133 | #define PC_BEGIN_PHRASE "IRIS:INIT" |
JonathanAshworth | 6:8ffc6d3a7c1d | 134 | //const char PC_BEGIN_PHRASE[] = {"IRIS:INIT"}; |
JonathanAshworth | 6:8ffc6d3a7c1d | 135 | //#define PC_TERMINATION_PHRASE 0xefffffff //Packet termination sequence |
JonathanAshworth | 6:8ffc6d3a7c1d | 136 | const unsigned int PC_TERMINATION_PHRASE = 0xefffffff; |
JonathanAshworth | 6:8ffc6d3a7c1d | 137 | #define PC_SERVO_REQUEST_LENGTH 15 // Length of a write request |
JonathanAshworth | 6:8ffc6d3a7c1d | 138 | #define PC_MOTOR_REQUEST_LENGTH 7 // Length of a write request |
JonathanAshworth | 6:8ffc6d3a7c1d | 139 | #define PC_USOUND_RESPONSE_LENGTH 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 140 | #define PC_PIR_RESPONSE_LENGTH 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 141 | #define PC_BATTCURRENT_RESPONSE_LENGTH 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 142 | #define PC_BATTVOLTAGE_RESPONSE_LENGTH 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 143 | #define PC_HUMIDITY_RESPONSE_LENGTH 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 144 | #define PC_TEMPERATURE_RESPONSE_LENGTH 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 145 | #define PC_GPS_RESPONSE_LENGTH 15 |
JonathanAshworth | 6:8ffc6d3a7c1d | 146 | #define PC_9DOFACC_RESPONSE_LENGTH 15 |
JonathanAshworth | 6:8ffc6d3a7c1d | 147 | #define PC_9DOFGYR_RESPONSE_LENGTH 15 |
JonathanAshworth | 6:8ffc6d3a7c1d | 148 | #define PC_9DOFMAG_RESPONSE_LENGTH 15 |
JonathanAshworth | 6:8ffc6d3a7c1d | 149 | #define PC_SERVO_REQUEST_COUNT 7 // Number of servo write requests avaliable |
JonathanAshworth | 6:8ffc6d3a7c1d | 150 | #define PC_MOTOR_REQUEST_COUNT 2 // Number of motor write requests avaliable |
JonathanAshworth | 6:8ffc6d3a7c1d | 151 | #define PC_SENTENCE_COUNT 0x0a |
JonathanAshworth | 6:8ffc6d3a7c1d | 152 | #define PC_CID_LOCATION 0 |
JonathanAshworth | 6:8ffc6d3a7c1d | 153 | #define PC_SID_LOCATION 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 154 | #define PC_FIELDCOUNT_LOCATION 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 155 | #define PC_FLOAT0_LOCATION 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 156 | #define PC_FLOAT1_LOCATION 7 |
JonathanAshworth | 6:8ffc6d3a7c1d | 157 | #define PC_FLOAT2_LOCATION 11 |
JonathanAshworth | 6:8ffc6d3a7c1d | 158 | #define PC_REQUESTEDSID_BYTE0_LOCATION 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 159 | #define PC_CID_LENGTH 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 160 | #define PC_SID_LENGTH 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 161 | #define PC_FIELDCOUNT_LENGTH 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 162 | #define PC_LONGESTRESPONSESENTENCE PC_SERVO_REQUEST_LENGTH |
JonathanAshworth | 6:8ffc6d3a7c1d | 163 | #define PC_REQUESTEDSID_MAXCOUNT 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 164 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 165 | #define SSC32_BAUDRATE 115200 |
JonathanAshworth | 6:8ffc6d3a7c1d | 166 | #define SSC32_TX_BUFFER_SIZE 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 167 | #define SSC32_RX_BUFFER_SIZE 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 168 | #define SSC32_TX_PIN p13 //Serial tx |
JonathanAshworth | 6:8ffc6d3a7c1d | 169 | #define SSC32_RX_PIN p14 //Serial rx |
JonathanAshworth | 6:8ffc6d3a7c1d | 170 | #define SSC32_STOP "\e" //Command to stop previous command |
JonathanAshworth | 6:8ffc6d3a7c1d | 171 | #define SSC32_STOPPOSITION_ARM_BASE 1500 |
JonathanAshworth | 6:8ffc6d3a7c1d | 172 | #define SSC32_STOPPOSITION_ARM_SHOULDER 600 |
JonathanAshworth | 6:8ffc6d3a7c1d | 173 | #define SSC32_STOPPOSITION_ARM_ELBOW 2350 |
JonathanAshworth | 6:8ffc6d3a7c1d | 174 | #define SSC32_STOPPOSITION_ARM_WRIST 2300 |
JonathanAshworth | 6:8ffc6d3a7c1d | 175 | #define SSC32_STOPPOSITION_ARM_MANIPULATOR 1500 |
JonathanAshworth | 6:8ffc6d3a7c1d | 176 | #define SSC32_STOPPOSITION_VISION_PITCH 1500 |
JonathanAshworth | 6:8ffc6d3a7c1d | 177 | #define SSC32_STOPPOSITION_VISION_YAW 1500 |
JonathanAshworth | 6:8ffc6d3a7c1d | 178 | #define SSC32_STOPPOSITION_TIME 4000 // TODO: replace with speed |
JonathanAshworth | 6:8ffc6d3a7c1d | 179 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 180 | #define GPS_BAUDRATE 115200 |
JonathanAshworth | 6:8ffc6d3a7c1d | 181 | #define GPS_TX_BUFFER_SIZE 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 182 | #define GPS_RX_BUFFER_SIZE 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 183 | #define GPS_TX_PIN p28 //Serial tx |
JonathanAshworth | 6:8ffc6d3a7c1d | 184 | #define GPS_RX_PIN p27 //Serial rx |
JonathanAshworth | 6:8ffc6d3a7c1d | 185 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 186 | /* XBEES NOT INCLUDED IN SOLUTION (Recommend a pro version with I2C support) |
JonathanAshworth | 6:8ffc6d3a7c1d | 187 | #define XBEE_TX_BUFFER_SIZE 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 188 | #define XBEE_RX_BUFFER_SIZE 512 |
JonathanAshworth | 6:8ffc6d3a7c1d | 189 | #define XBEE_TX_PIN 0 //PIN UNALLOCATED |
JonathanAshworth | 6:8ffc6d3a7c1d | 190 | #define XBEE_RX_PIN 0 //PIN UNALLOCATED |
JonathanAshworth | 6:8ffc6d3a7c1d | 191 | */ |
JonathanAshworth | 6:8ffc6d3a7c1d | 192 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 193 | #define ULTRASOUND_TRIGGER_PIN p11//Digital out |
JonathanAshworth | 6:8ffc6d3a7c1d | 194 | #define ULTRASOUND_ECHO_PIN p12 //Digital (PWM) in (from mux common) |
JonathanAshworth | 6:8ffc6d3a7c1d | 195 | #define BATTERY_VOLTAGE_PIN p16 //Analogue in |
JonathanAshworth | 6:8ffc6d3a7c1d | 196 | #define BATTERY_CURRENT_PIN p15 //Analogue in |
JonathanAshworth | 6:8ffc6d3a7c1d | 197 | #define MUX_D0_PIN p5 //Digital out |
JonathanAshworth | 6:8ffc6d3a7c1d | 198 | #define MUX_D1_PIN p6 //Digital out |
JonathanAshworth | 6:8ffc6d3a7c1d | 199 | #define MUX_D2_PIN p7 //Digital out |
JonathanAshworth | 6:8ffc6d3a7c1d | 200 | #define MUX_D3_PIN p8 //Digital out |
JonathanAshworth | 6:8ffc6d3a7c1d | 201 | #define I2C_SDA p9 //I2C data line |
JonathanAshworth | 6:8ffc6d3a7c1d | 202 | #define I2C_SCL p10 //I2C clock line |
JonathanAshworth | 6:8ffc6d3a7c1d | 203 | #define PIR_PIN p20 //Digital in |
JonathanAshworth | 6:8ffc6d3a7c1d | 204 | #define DRIVE_NS_PIN p21 //PWM out |
JonathanAshworth | 6:8ffc6d3a7c1d | 205 | #define DRIVE_OS_PIN p22 //PWM out |
JonathanAshworth | 6:8ffc6d3a7c1d | 206 | #define DRIVE_DEMAND_MIN 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 207 | #define DRIVE_DEMAND_MAX -1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 208 | #define DRIVE_DEMAND_NEUTRAL 0 //Demand value for neutral |
JonathanAshworth | 6:8ffc6d3a7c1d | 209 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 210 | #define BOTDATA_FIELDNUMBER_SERVO_CHANNEL 0 |
JonathanAshworth | 6:8ffc6d3a7c1d | 211 | #define BOTDATA_FIELDNUMBER_SERVO_POSITION 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 212 | #define BOTDATA_FIELDNUMBER_SERVO_SPEED 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 213 | #define BOTDATA_FIELDNUMBER_SERVO_TIME 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 214 | #define BOTDATA_FIELDNUMBER_9DOF_ACCEL_X 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 215 | #define BOTDATA_FIELDNUMBER_9DOF_ACCEL_Y 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 216 | #define BOTDATA_FIELDNUMBER_9DOF_ACCEL_Z 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 217 | #define BOTDATA_FIELDNUMBER_9DOF_MAG_X 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 218 | #define BOTDATA_FIELDNUMBER_9DOF_MAG_Y 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 219 | #define BOTDATA_FIELDNUMBER_9DOF_MAG_Z 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 220 | #define BOTDATA_FIELDNUMBER_9DOF_GYRO_X 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 221 | #define BOTDATA_FIELDNUMBER_9DOF_GYRO_Y 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 222 | #define BOTDATA_FIELDNUMBER_9DOF_GYRO_Z 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 223 | #define BOTDATA_FIELDNUMBER_GPS_LAT 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 224 | #define BOTDATA_FIELDNUMBER_GPS_LONG 2 |
JonathanAshworth | 6:8ffc6d3a7c1d | 225 | #define BOTDATA_FIELDNUMBER_GPS_SPEED 3 |
JonathanAshworth | 6:8ffc6d3a7c1d | 226 | #define BOTDATA_FIELDNUMBER_TEMPERATURE 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 227 | #define BOTDATA_FIELDNUMBER_HUMIDITY 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 228 | #define BOTDATA_FIELDNUMBER_VOLTAGE 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 229 | #define BOTDATA_FIELDNUMBER_CURRENT 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 230 | #define BOTDATA_FIELDNUMBER_PIR 1 |
JonathanAshworth | 6:8ffc6d3a7c1d | 231 | #define BOTDATA_FIELDNUMBER_DRIVE_DEMAND 0 |
JonathanAshworth | 6:8ffc6d3a7c1d | 232 | #define BOTDATA_FIELDNUMBER_USOUND_DISTANCE 0 |
JonathanAshworth | 6:8ffc6d3a7c1d | 233 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 234 | #define BYTELENGTH_OF_A_FLOAT 4 |
JonathanAshworth | 6:8ffc6d3a7c1d | 235 | #define BYTELENGTH_OF_AN_INT 4 |
JonathanAshworth | 6:8ffc6d3a7c1d | 236 | #define BITLENGTH_OF_A_BYTE 8 |
JonathanAshworth | 4:1017848d2fe1 | 237 | |
JonathanAshworth | 4:1017848d2fe1 | 238 | enum servoStatus {ToBeMoved = 0, Moving = 1, InPosition = 2}; |
JonathanAshworth | 4:1017848d2fe1 | 239 | enum dataErrors {Timeout = 0, RequestDataBad = 1}; |
JonathanAshworth | 4:1017848d2fe1 | 240 | |
JonathanAshworth | 4:1017848d2fe1 | 241 | struct Flags |
JonathanAshworth | 4:1017848d2fe1 | 242 | { |
JonathanAshworth | 4:1017848d2fe1 | 243 | bool rxNewData; |
JonathanAshworth | 6:8ffc6d3a7c1d | 244 | bool txNewData; |
JonathanAshworth | 4:1017848d2fe1 | 245 | bool txSentData; |
JonathanAshworth | 4:1017848d2fe1 | 246 | bool PCTimeout; |
JonathanAshworth | 6:8ffc6d3a7c1d | 247 | bool PCBegin; |
JonathanAshworth | 4:1017848d2fe1 | 248 | }; |
JonathanAshworth | 4:1017848d2fe1 | 249 | |
JonathanAshworth | 4:1017848d2fe1 | 250 | void initialise(void); |
JonathanAshworth | 6:8ffc6d3a7c1d | 251 | //void getServoData(Servo *servo); |
JonathanAshworth | 6:8ffc6d3a7c1d | 252 | //void readUltrasound(UltrasoundSensor *sensor); |
JonathanAshworth | 6:8ffc6d3a7c1d | 253 | void constructTxData(char *SIDs, char numberOfSensors); |
JonathanAshworth | 6:8ffc6d3a7c1d | 254 | void parseRequestData(void); |
JonathanAshworth | 6:8ffc6d3a7c1d | 255 | unsigned int translateMotorDemandToPWM(float demand); |
JonathanAshworth | 6:8ffc6d3a7c1d | 256 | void PCTimeout(void); |
JonathanAshworth | 6:8ffc6d3a7c1d | 257 | void shutdown(void); |
JonathanAshworth | 6:8ffc6d3a7c1d | 258 | void timerISR(void); |
JonathanAshworth | 4:1017848d2fe1 | 259 | void dmaPCSerialRx(MODSERIAL_IRQ_INFO *q); |
JonathanAshworth | 6:8ffc6d3a7c1d | 260 | bool string_compare(char *a, char *b, unsigned int length); |
JonathanAshworth | 6:8ffc6d3a7c1d | 261 | void sendPCSerialData(void); |
JonathanAshworth | 4:1017848d2fe1 | 262 | void dmaSSC32SerialRx(MODSERIAL_IRQ_INFO *q); |
JonathanAshworth | 4:1017848d2fe1 | 263 | void dmaGPSSerialRx(MODSERIAL_IRQ_INFO *q); |
JonathanAshworth | 6:8ffc6d3a7c1d | 264 | long readUltrasound(void); |
JonathanAshworth | 6:8ffc6d3a7c1d | 265 | |
JonathanAshworth | 6:8ffc6d3a7c1d | 266 | #endif /* MAIN_H */ |