Dual CANbus monitor and instrumentation cluster
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary by
Diff: utility.cpp
- Revision:
- 31:082372c83f68
- Parent:
- 26:462ccb580472
- Child:
- 32:c9d9b6cb5de1
--- a/utility.cpp Sat Mar 16 16:33:11 2013 +0000 +++ b/utility.cpp Sun Mar 17 12:17:33 2013 +0000 @@ -11,7 +11,7 @@ LPC_RTC->ILR |= (1<<0); // clear interrupt to prepare for next } -extern "C" void RTC_Init (void) { +void RTC_Init (void) { LPC_RTC->ILR=0x00; // set up the RTC interrupts LPC_RTC->CIIR=0x01; // interrupts each second LPC_RTC->CCR = 0x01; // Clock enable @@ -155,9 +155,55 @@ can1.monitor(true); // set to snoop mode } +void msgSend() { + //char sTemp[40]; + char data[8] = {0x02, 0x21, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff}; + if (CPcount<30) { + switch (CPcount) { + case 0: + can1.monitor(false); // set to active mode + can1SleepMode = 0; // enable TX + //data[8] = {0x02, 0x21, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff}; + data[2] = 0x02; + //sprintf(sTemp,"Sending cp request\n"); + //logMsg(sTemp); + break; + default: + data[0]=0x30; //change to request next line message + data[1]=0x01; + data[2]=0x00; + break; + } + can1.write(CANMessage(0x79b, data, 8)); + CPcount+=1; + } else if (Tcount<4) { + switch (Tcount) { + case 0: + //data[8] = {0x02, 0x21, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff}; + data[2] = 0x04; + //sprintf(sTemp,"Sending temp request\n"); + //logMsg(sTemp); + break; + default: + data[0]=0x30; //change to request next line message + data[1]=0x01; + data[2]=0x00; + break; + } + can1.write(CANMessage(0x79b, data, 8)); + Tcount+=1; + } else if (Tcount<5){ + showCP=true; + Tcount+=1; + can1SleepMode = 1; // disable TX + can1.monitor(true); // set to snoop mode + } +} + void tickerISR() { //This is the ticker ISR for auto-polling - pollCP=true; //Set a flag to do in main loop instead of here -} //since ticker blocks other interrupts + CPcount=0; //reset CP message counter + Tcount=0; //reset Temp message counter +} void recieve1() { CANMessage msg1;