.
Dependencies: SDHCFileSystem mbed
main.cpp@2:55b2357f0cf9, 2012-12-01 (annotated)
- Committer:
- TickTock
- Date:
- Sat Dec 01 16:03:14 2012 +0000
- Revision:
- 2:55b2357f0cf9
- Parent:
- 1:dafb963c3c14
- Child:
- 3:51134a275609
Got speed up to 2ms send rate but still drop a few every second on sdwrite
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TickTock | 0:1596b8644523 | 1 | #include "mbed.h" |
TickTock | 0:1596b8644523 | 2 | #include "CAN.h" |
TickTock | 1:dafb963c3c14 | 3 | #include "SDHCFileSystem.h" |
TickTock | 0:1596b8644523 | 4 | |
TickTock | 1:dafb963c3c14 | 5 | #define upLine "\033[1A" |
TickTock | 1:dafb963c3c14 | 6 | |
TickTock | 1:dafb963c3c14 | 7 | //CANcan.cpp |
TickTock | 1:dafb963c3c14 | 8 | |
TickTock | 1:dafb963c3c14 | 9 | //LEAF OBD |
TickTock | 1:dafb963c3c14 | 10 | //1: |
TickTock | 1:dafb963c3c14 | 11 | //2: |
TickTock | 1:dafb963c3c14 | 12 | //3: AVCAN-L White/Blue |
TickTock | 1:dafb963c3c14 | 13 | //4: |
TickTock | 1:dafb963c3c14 | 14 | //5: VSS Brown,White/Brown |
TickTock | 1:dafb963c3c14 | 15 | //6: CARCAN-H Green |
TickTock | 1:dafb963c3c14 | 16 | //7: |
TickTock | 1:dafb963c3c14 | 17 | //8: 12V-SW Orange,White/Orange |
TickTock | 1:dafb963c3c14 | 18 | //9: |
TickTock | 1:dafb963c3c14 | 19 | //10: |
TickTock | 1:dafb963c3c14 | 20 | //11: AVCAN-H Blue |
TickTock | 1:dafb963c3c14 | 21 | //12: EVCAN-L White/Grey |
TickTock | 1:dafb963c3c14 | 22 | //13: EVCAN-H Grey |
TickTock | 1:dafb963c3c14 | 23 | //14: CARCAN-L White/Green |
TickTock | 1:dafb963c3c14 | 24 | //15: |
TickTock | 1:dafb963c3c14 | 25 | //16: 12V-AON Red/Blue,Blue/Red |
TickTock | 1:dafb963c3c14 | 26 | |
TickTock | 0:1596b8644523 | 27 | //VP230 |
TickTock | 1:dafb963c3c14 | 28 | //1:D |
TickTock | 1:dafb963c3c14 | 29 | //2:GND |
TickTock | 1:dafb963c3c14 | 30 | //3:VCC |
TickTock | 1:dafb963c3c14 | 31 | //4:R |
TickTock | 1:dafb963c3c14 | 32 | //5:Vref |
TickTock | 1:dafb963c3c14 | 33 | //6:CANL |
TickTock | 1:dafb963c3c14 | 34 | //7:CANH |
TickTock | 1:dafb963c3c14 | 35 | //8:RS |
TickTock | 0:1596b8644523 | 36 | |
TickTock | 0:1596b8644523 | 37 | //LPC1768 |
TickTock | 0:1596b8644523 | 38 | //1: VSS |
TickTock | 1:dafb963c3c14 | 39 | //2: NC:VIN (4.5-9V supply) |
TickTock | 0:1596b8644523 | 40 | //3: NC:VB |
TickTock | 0:1596b8644523 | 41 | //4: NC:nR |
TickTock | 0:1596b8644523 | 42 | //5: SPI:MOSI --> 6:SDRAM:DI |
TickTock | 0:1596b8644523 | 43 | //6: SPI:MISO --> 2:SDRAM:DO |
TickTock | 0:1596b8644523 | 44 | //7: SPI:SCLK --> 4:SDRAM:SCLK |
TickTock | 0:1596b8644523 | 45 | //8: CS --> 7:SDRAM:CS |
TickTock | 1:dafb963c3c14 | 46 | //9: CAN1:RX --> 4:CAN1:R |
TickTock | 1:dafb963c3c14 | 47 | //10: CAN1:TX --> 1:CAN1:D |
TickTock | 0:1596b8644523 | 48 | //11: RS --> 4:LCD:RS |
TickTock | 0:1596b8644523 | 49 | //12: E --> 6:LCD:E |
TickTock | 0:1596b8644523 | 50 | //13: D4 --> 11:LCD:D4 |
TickTock | 0:1596b8644523 | 51 | //14: D5 --> 12:LCD:D5 |
TickTock | 0:1596b8644523 | 52 | //15: D6 --> 13:LCD:D6 |
TickTock | 0:1596b8644523 | 53 | //16: D7 --> 14:LCD:D7 |
TickTock | 0:1596b8644523 | 54 | //17: CD --> 1:SDRAM:CD |
TickTock | 1:dafb963c3c14 | 55 | //18: MON12V --> 4K to 12V, 1K to VSS (To be implemented) |
TickTock | 0:1596b8644523 | 56 | //19: PB2 |
TickTock | 0:1596b8644523 | 57 | //20: PB1 |
TickTock | 0:1596b8644523 | 58 | //21: Spkr+ |
TickTock | 1:dafb963c3c14 | 59 | //22: Spkr- (optional complimentary output for more volume) |
TickTock | 0:1596b8644523 | 60 | //23: NC:pwm |
TickTock | 1:dafb963c3c14 | 61 | //24: LEDBLU --> 18:LCD:BLU (only used for tri-color displays) |
TickTock | 1:dafb963c3c14 | 62 | //25: LEDGRN --> 17:LCD:GRN (only used for tri-color displays) |
TickTock | 1:dafb963c3c14 | 63 | //26: LEDRED --> 16:LCD:RED |
TickTock | 0:1596b8644523 | 64 | //27: CAN1:Sleep --> 8:CAN1:RS |
TickTock | 0:1596b8644523 | 65 | //28: CAN2:Sleep --> 8:CAN2:RS |
TickTock | 1:dafb963c3c14 | 66 | //29: CAN2:TX --> 1:CAN2:D |
TickTock | 1:dafb963c3c14 | 67 | //30: CAN2:RX --> 4:CAN2:R |
TickTock | 0:1596b8644523 | 68 | //31: NC:USB_D+ |
TickTock | 0:1596b8644523 | 69 | //32: NC:USB_D- |
TickTock | 0:1596b8644523 | 70 | //33: NC:Eth_TD+ |
TickTock | 0:1596b8644523 | 71 | //34: NC:Eth_TD- |
TickTock | 0:1596b8644523 | 72 | //35: NC:Eth_RD+ |
TickTock | 0:1596b8644523 | 73 | //36: NC:Eth_RD- |
TickTock | 0:1596b8644523 | 74 | //37: NC:IF+ |
TickTock | 0:1596b8644523 | 75 | //38: NC:IF- |
TickTock | 1:dafb963c3c14 | 76 | //39: NC:5Vout (only available when connected as USB device) |
TickTock | 0:1596b8644523 | 77 | //40: VCC3.3 |
TickTock | 0:1596b8644523 | 78 | |
TickTock | 1:dafb963c3c14 | 79 | extern bool LogCreated; |
TickTock | 1:dafb963c3c14 | 80 | void Log (char *message); |
TickTock | 1:dafb963c3c14 | 81 | void LogErr (char *message); |
TickTock | 1:dafb963c3c14 | 82 | |
TickTock | 1:dafb963c3c14 | 83 | time_t seconds ; |
TickTock | 1:dafb963c3c14 | 84 | DigitalIn CD(p17); |
TickTock | 2:55b2357f0cf9 | 85 | DigitalIn PB1( p20 ); |
TickTock | 1:dafb963c3c14 | 86 | SDFileSystem sd(p5, p6, p7, p8, "sd" ); // SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) |
TickTock | 0:1596b8644523 | 87 | Ticker ticker; |
TickTock | 1:dafb963c3c14 | 88 | Timer timer; |
TickTock | 0:1596b8644523 | 89 | DigitalOut led1(LED1); |
TickTock | 0:1596b8644523 | 90 | DigitalOut led2(LED2); |
TickTock | 0:1596b8644523 | 91 | DigitalOut led3(LED3); |
TickTock | 0:1596b8644523 | 92 | DigitalOut led4(LED4); |
TickTock | 1:dafb963c3c14 | 93 | CAN can1(p9, p10); // CAN1 uses pins 9 and 10 (rx, tx) and pin 27 (rs) |
TickTock | 2:55b2357f0cf9 | 94 | DigitalOut can1_SleepMode(p27); // Use pin 27 to control the sleep mode of can1 |
TickTock | 1:dafb963c3c14 | 95 | CAN can2(p30, p29); // CAN2 uses pins 30 and 29 (rx, tx) and pin 28 (rs) |
TickTock | 2:55b2357f0cf9 | 96 | DigitalOut can2_SleepMode(p28); // Use pin 28 to control the sleep mode of can2 |
TickTock | 1:dafb963c3c14 | 97 | bool logCreated = false; |
TickTock | 2:55b2357f0cf9 | 98 | char counter = 0; |
TickTock | 2:55b2357f0cf9 | 99 | FILE *file; |
TickTock | 2:55b2357f0cf9 | 100 | char fileName[32] = "" ; |
TickTock | 2:55b2357f0cf9 | 101 | char writeBuffer[512][13]; |
TickTock | 2:55b2357f0cf9 | 102 | int bufPointer = 0; |
TickTock | 0:1596b8644523 | 103 | |
TickTock | 0:1596b8644523 | 104 | Serial pc(USBTX, USBRX); // tx, rx default settings (9600 8N1) |
TickTock | 0:1596b8644523 | 105 | |
TickTock | 2:55b2357f0cf9 | 106 | extern "C" void RTC_IRQHandler() { |
TickTock | 2:55b2357f0cf9 | 107 | timer.reset() ; // zero ms at the-seconds-tick |
TickTock | 2:55b2357f0cf9 | 108 | file = fopen(fileName, "a"); |
TickTock | 0:1596b8644523 | 109 | if (file == NULL) { |
TickTock | 1:dafb963c3c14 | 110 | if (logCreated) |
TickTock | 1:dafb963c3c14 | 111 | logCreated = false; |
TickTock | 2:55b2357f0cf9 | 112 | } else { |
TickTock | 2:55b2357f0cf9 | 113 | for (int i = 0; i<bufPointer; i++) { |
TickTock | 2:55b2357f0cf9 | 114 | for (int j = 0; j<13; j++){ |
TickTock | 2:55b2357f0cf9 | 115 | fprintf(file,"%c",writeBuffer[i][j]); |
TickTock | 2:55b2357f0cf9 | 116 | } |
TickTock | 2:55b2357f0cf9 | 117 | } |
TickTock | 1:dafb963c3c14 | 118 | fclose(file); |
TickTock | 1:dafb963c3c14 | 119 | } |
TickTock | 2:55b2357f0cf9 | 120 | bufPointer = 0; |
TickTock | 2:55b2357f0cf9 | 121 | LPC_RTC->ILR |= (1<<0); // turn on Low Bit - works |
TickTock | 2:55b2357f0cf9 | 122 | } |
TickTock | 2:55b2357f0cf9 | 123 | |
TickTock | 2:55b2357f0cf9 | 124 | extern "C" void RTC_Init (void) { |
TickTock | 2:55b2357f0cf9 | 125 | LPC_RTC->ILR=0x00; // set up the RTC interrupts |
TickTock | 2:55b2357f0cf9 | 126 | //LPC_RTC->CIIR=0x02; // interrupts each minute |
TickTock | 2:55b2357f0cf9 | 127 | LPC_RTC->CIIR=0x01; // interrupts each second |
TickTock | 2:55b2357f0cf9 | 128 | //LPC_RTC->CCR = 0x11; // use for interrupts every minute ???? |
TickTock | 2:55b2357f0cf9 | 129 | //LPC_RTC->CCR = 0x00; // Stop the RTC (apparently) |
TickTock | 2:55b2357f0cf9 | 130 | LPC_RTC->CCR = 0x01; // Start RTC (apparently use for interrupt every second) |
TickTock | 2:55b2357f0cf9 | 131 | // NVIC_SetPriority( RTC_IRQn, LOW_PR ); |
TickTock | 2:55b2357f0cf9 | 132 | NVIC_EnableIRQ( RTC_IRQn ); |
TickTock | 2:55b2357f0cf9 | 133 | } |
TickTock | 2:55b2357f0cf9 | 134 | |
TickTock | 2:55b2357f0cf9 | 135 | unsigned short getTimeStamp() { |
TickTock | 2:55b2357f0cf9 | 136 | int msec = timer.read_ms() ; // read ms from the timer |
TickTock | 2:55b2357f0cf9 | 137 | unsigned long secs = time(NULL); // seconds past 12:00:00 AM 1 Jan 1900 |
TickTock | 2:55b2357f0cf9 | 138 | int isecs = secs%60 ; // modulo 60 for 0-59 seconds from RTC |
TickTock | 2:55b2357f0cf9 | 139 | return ((isecs<<10)+msec) ; // return the two byte time stamp |
TickTock | 1:dafb963c3c14 | 140 | } |
TickTock | 1:dafb963c3c14 | 141 | |
TickTock | 2:55b2357f0cf9 | 142 | void readLog (){ |
TickTock | 2:55b2357f0cf9 | 143 | unsigned char c; |
TickTock | 2:55b2357f0cf9 | 144 | int i=0; |
TickTock | 2:55b2357f0cf9 | 145 | char lastMsgNum=0; |
TickTock | 2:55b2357f0cf9 | 146 | char curMsgNum=0; |
TickTock | 2:55b2357f0cf9 | 147 | pc.printf("printing file\n"); |
TickTock | 2:55b2357f0cf9 | 148 | file = fopen(fileName, "r"); |
TickTock | 2:55b2357f0cf9 | 149 | if (file == NULL) { |
TickTock | 2:55b2357f0cf9 | 150 | pc.printf("no file found\n"); |
TickTock | 1:dafb963c3c14 | 151 | } |
TickTock | 2:55b2357f0cf9 | 152 | while (!feof(file)) { |
TickTock | 2:55b2357f0cf9 | 153 | c=fgetc(file); |
TickTock | 2:55b2357f0cf9 | 154 | pc.printf("%02x ",c); |
TickTock | 2:55b2357f0cf9 | 155 | if (i==5){ |
TickTock | 2:55b2357f0cf9 | 156 | curMsgNum=c; |
TickTock | 2:55b2357f0cf9 | 157 | } |
TickTock | 2:55b2357f0cf9 | 158 | if (++i>12) { |
TickTock | 2:55b2357f0cf9 | 159 | if (curMsgNum>(lastMsgNum+1)) { |
TickTock | 2:55b2357f0cf9 | 160 | pc.printf(" ***"); |
TickTock | 2:55b2357f0cf9 | 161 | } |
TickTock | 2:55b2357f0cf9 | 162 | lastMsgNum=curMsgNum; |
TickTock | 2:55b2357f0cf9 | 163 | pc.printf("\n"); |
TickTock | 2:55b2357f0cf9 | 164 | i=0; |
TickTock | 2:55b2357f0cf9 | 165 | } |
TickTock | 2:55b2357f0cf9 | 166 | } |
TickTock | 2:55b2357f0cf9 | 167 | pc.printf("\n\n"); |
TickTock | 2:55b2357f0cf9 | 168 | fclose(file); |
TickTock | 2:55b2357f0cf9 | 169 | } |
TickTock | 1:dafb963c3c14 | 170 | |
TickTock | 2:55b2357f0cf9 | 171 | void logCan (char mtype, CANMessage canRXmsg) { |
TickTock | 2:55b2357f0cf9 | 172 | unsigned short ts = getTimeStamp(); |
TickTock | 2:55b2357f0cf9 | 173 | writeBuffer[bufPointer][0]=mtype; |
TickTock | 2:55b2357f0cf9 | 174 | writeBuffer[bufPointer][1]=ts>>8; |
TickTock | 2:55b2357f0cf9 | 175 | writeBuffer[bufPointer][2]=ts&0xff; |
TickTock | 2:55b2357f0cf9 | 176 | writeBuffer[bufPointer][3]=canRXmsg.id&0xff; |
TickTock | 2:55b2357f0cf9 | 177 | writeBuffer[bufPointer][4]=(canRXmsg.id>>8)+(canRXmsg.len<<4); |
TickTock | 2:55b2357f0cf9 | 178 | for (int i = 5; i<13; i++){ |
TickTock | 2:55b2357f0cf9 | 179 | writeBuffer[bufPointer][i]=canRXmsg.data[i-5]; |
TickTock | 0:1596b8644523 | 180 | } |
TickTock | 2:55b2357f0cf9 | 181 | bufPointer++; |
TickTock | 1:dafb963c3c14 | 182 | } |
TickTock | 0:1596b8644523 | 183 | |
TickTock | 1:dafb963c3c14 | 184 | void send1() { |
TickTock | 1:dafb963c3c14 | 185 | static char counter = 0; // use for fake data |
TickTock | 1:dafb963c3c14 | 186 | can1.write(CANMessage(0x350, &counter, 1)); |
TickTock | 1:dafb963c3c14 | 187 | counter++; |
TickTock | 2:55b2357f0cf9 | 188 | /*can1.write(CANMessage(0x351, &counter, 1)); |
TickTock | 2:55b2357f0cf9 | 189 | counter++; |
TickTock | 2:55b2357f0cf9 | 190 | can1.write(CANMessage(0x352, &counter, 1)); |
TickTock | 2:55b2357f0cf9 | 191 | counter++;*/ |
TickTock | 0:1596b8644523 | 192 | } |
TickTock | 0:1596b8644523 | 193 | |
TickTock | 0:1596b8644523 | 194 | void recieve1() { |
TickTock | 2:55b2357f0cf9 | 195 | CANMessage msg1; |
TickTock | 2:55b2357f0cf9 | 196 | unsigned short msgTime=getTimeStamp(); |
TickTock | 0:1596b8644523 | 197 | can1.read(msg1); |
TickTock | 2:55b2357f0cf9 | 198 | //pc.printf("%sCan1 Message received: %d \n", upLine, msg1.data[0]); |
TickTock | 1:dafb963c3c14 | 199 | if(logCreated) { |
TickTock | 2:55b2357f0cf9 | 200 | if((PB1==0)||(CD==0)) { |
TickTock | 1:dafb963c3c14 | 201 | logCreated=false; |
TickTock | 1:dafb963c3c14 | 202 | pc.printf("Stopping log\n", counter); |
TickTock | 1:dafb963c3c14 | 203 | readLog(); |
TickTock | 2:55b2357f0cf9 | 204 | } else { |
TickTock | 2:55b2357f0cf9 | 205 | logCan(1, msg1); |
TickTock | 1:dafb963c3c14 | 206 | } |
TickTock | 1:dafb963c3c14 | 207 | } |
TickTock | 0:1596b8644523 | 208 | led2 = !led2; |
TickTock | 0:1596b8644523 | 209 | } |
TickTock | 2:55b2357f0cf9 | 210 | |
TickTock | 0:1596b8644523 | 211 | void recieve2() { |
TickTock | 2:55b2357f0cf9 | 212 | CANMessage msg2; |
TickTock | 2:55b2357f0cf9 | 213 | unsigned short msgTime=getTimeStamp(); |
TickTock | 2:55b2357f0cf9 | 214 | static int lastMsg = 0; |
TickTock | 0:1596b8644523 | 215 | can2.read(msg2); |
TickTock | 2:55b2357f0cf9 | 216 | if (msg2.data[0]>(lastMsg+1)) { |
TickTock | 2:55b2357f0cf9 | 217 | pc.printf("%sCan2 Message %d missed! \n\n\n", upLine, msg2.data[0]-1); |
TickTock | 2:55b2357f0cf9 | 218 | } |
TickTock | 2:55b2357f0cf9 | 219 | lastMsg=msg2.data[0]; |
TickTock | 2:55b2357f0cf9 | 220 | //pc.printf("%sCan2 Message received: %d \n", upLine, msg2.data[0]); |
TickTock | 1:dafb963c3c14 | 221 | if(logCreated) { |
TickTock | 2:55b2357f0cf9 | 222 | if((PB1==0)||(CD==0)) { |
TickTock | 1:dafb963c3c14 | 223 | logCreated=false; |
TickTock | 1:dafb963c3c14 | 224 | pc.printf("Stopping log\n\n", counter); |
TickTock | 1:dafb963c3c14 | 225 | readLog(); |
TickTock | 2:55b2357f0cf9 | 226 | } else { |
TickTock | 2:55b2357f0cf9 | 227 | logCan(2, msg2); |
TickTock | 1:dafb963c3c14 | 228 | } |
TickTock | 1:dafb963c3c14 | 229 | } |
TickTock | 0:1596b8644523 | 230 | led3 = !led3; |
TickTock | 0:1596b8644523 | 231 | } |
TickTock | 0:1596b8644523 | 232 | |
TickTock | 0:1596b8644523 | 233 | int main() { |
TickTock | 2:55b2357f0cf9 | 234 | pc.baud(460800); // change serial interface to pc to 115200, 8N1 |
TickTock | 2:55b2357f0cf9 | 235 | CANMessage tsMsg; |
TickTock | 1:dafb963c3c14 | 236 | can1.frequency(1000000); |
TickTock | 1:dafb963c3c14 | 237 | can2.frequency(1000000); |
TickTock | 2:55b2357f0cf9 | 238 | can1_SleepMode = 0; // Enable TX |
TickTock | 2:55b2357f0cf9 | 239 | can2_SleepMode = 0; // Enable TX |
TickTock | 1:dafb963c3c14 | 240 | //can1_SleepMode = 1; // Turn on Monitor_only Mode |
TickTock | 1:dafb963c3c14 | 241 | //can2_SleepMode = 1; // Turn on Monitor_only Mode |
TickTock | 0:1596b8644523 | 242 | CD.mode(PullUp) ; //SDRAM Chip Detect |
TickTock | 2:55b2357f0cf9 | 243 | PB1.mode(PullUp) ; //Pushbutton 1 |
TickTock | 0:1596b8644523 | 244 | can1.attach(&recieve1); |
TickTock | 0:1596b8644523 | 245 | can2.attach(&recieve2); |
TickTock | 1:dafb963c3c14 | 246 | |
TickTock | 1:dafb963c3c14 | 247 | timer.start() ; |
TickTock | 2:55b2357f0cf9 | 248 | RTC_Init(); // start the RTC Interrupts that sync the timer |
TickTock | 2:55b2357f0cf9 | 249 | wait(1.1); // give time to sync |
TickTock | 1:dafb963c3c14 | 250 | |
TickTock | 0:1596b8644523 | 251 | if(CD == 1) { |
TickTock | 2:55b2357f0cf9 | 252 | int fileNum = 0; |
TickTock | 2:55b2357f0cf9 | 253 | sprintf(fileName,"/sd/canary%d.evc",fileNum); |
TickTock | 2:55b2357f0cf9 | 254 | file = fopen(fileName, "r"); |
TickTock | 2:55b2357f0cf9 | 255 | while ((file != NULL)&&(fileNum++<100)) { |
TickTock | 2:55b2357f0cf9 | 256 | fclose(file); |
TickTock | 2:55b2357f0cf9 | 257 | sprintf(fileName,"/sd/canary%d.evc",fileNum); |
TickTock | 2:55b2357f0cf9 | 258 | file = fopen(fileName, "r"); |
TickTock | 2:55b2357f0cf9 | 259 | } |
TickTock | 2:55b2357f0cf9 | 260 | |
TickTock | 2:55b2357f0cf9 | 261 | file = fopen(fileName, "wb"); |
TickTock | 2:55b2357f0cf9 | 262 | if(file==NULL){ |
TickTock | 2:55b2357f0cf9 | 263 | pc.printf("\nUnable to open canlog\n\n\n\n"); |
TickTock | 2:55b2357f0cf9 | 264 | } else { |
TickTock | 2:55b2357f0cf9 | 265 | logCreated = true; |
TickTock | 2:55b2357f0cf9 | 266 | pc.printf("\nStarting Can Log %s\n\n\n\n",fileName); |
TickTock | 2:55b2357f0cf9 | 267 | unsigned long secs = time(NULL); // seconds past 12:00:00 AM 1 Jan 1900 |
TickTock | 2:55b2357f0cf9 | 268 | tsMsg.id=0xfff; |
TickTock | 2:55b2357f0cf9 | 269 | tsMsg.len=0xf; |
TickTock | 2:55b2357f0cf9 | 270 | tsMsg.data[0]=secs&0xff; |
TickTock | 2:55b2357f0cf9 | 271 | tsMsg.data[1]=(secs>>0)&0xff; |
TickTock | 2:55b2357f0cf9 | 272 | tsMsg.data[2]=(secs>>16)&0xff; |
TickTock | 2:55b2357f0cf9 | 273 | tsMsg.data[3]=secs>>24; |
TickTock | 2:55b2357f0cf9 | 274 | tsMsg.data[4]=0xff; |
TickTock | 2:55b2357f0cf9 | 275 | tsMsg.data[5]=0xff; |
TickTock | 2:55b2357f0cf9 | 276 | tsMsg.data[6]=0xff; |
TickTock | 2:55b2357f0cf9 | 277 | tsMsg.data[7]=0xff; |
TickTock | 2:55b2357f0cf9 | 278 | logCan(0,tsMsg); //write full timestamp |
TickTock | 2:55b2357f0cf9 | 279 | fclose(file); |
TickTock | 2:55b2357f0cf9 | 280 | |
TickTock | 2:55b2357f0cf9 | 281 | } |
TickTock | 2:55b2357f0cf9 | 282 | } else { |
TickTock | 2:55b2357f0cf9 | 283 | pc.printf("\nNo SDRAM Inserted.\n\n\n\n"); |
TickTock | 0:1596b8644523 | 284 | } |
TickTock | 2:55b2357f0cf9 | 285 | |
TickTock | 2:55b2357f0cf9 | 286 | |
TickTock | 2:55b2357f0cf9 | 287 | //.02 logs all; .01 misses some when logging; |
TickTock | 2:55b2357f0cf9 | 288 | //.05 gets all when not logging;.02 misses some always |
TickTock | 2:55b2357f0cf9 | 289 | ticker.attach(&send1, .002); //start sending messages |
TickTock | 0:1596b8644523 | 290 | } |