Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FatFileSystem MSCFileSystem SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary_corrupt by
Diff: utility.cpp
- Revision:
- 33:a277743ebdeb
- Parent:
- 32:c9d9b6cb5de1
- Child:
- 34:4751a8259b18
--- a/utility.cpp Tue Mar 19 01:23:26 2013 +0000
+++ b/utility.cpp Tue Mar 19 04:43:43 2013 +0000
@@ -11,7 +11,7 @@
LPC_RTC->ILR |= (1<<0); // clear interrupt to prepare for next
}
-void RTC_Init (void) {
+extern "C" 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
@@ -73,7 +73,9 @@
msgChanged[indexLastMsg[canRXmsg.id]]=changed;
}
lastMsg[indexLastMsg[canRXmsg.id]]=canRXmsg; //Store in table
- if((mType==1)&&(canRXmsg.id==0x7bb)){ // is battery data? Need to store all responses
+ if((mType==2)&&(canRXmsg.id==0x358)){ // is daylight sensor
+ daylight = (canRXmsg.data[1]&0x80)?false:true;
+ } else if((mType==1)&&(canRXmsg.id==0x7bb)){ // is battery data? Need to store all responses
if(canRXmsg.data[0]<0x20){
if(canRXmsg.data[3]==2){//cellpair data
bdi=0;
@@ -121,7 +123,7 @@
logCan(0,tsMsg);
}
-/*void sendCPreq() {
+void sendCPreq() {
char i;
char data[8] = {0x02, 0x21, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff};
can1.monitor(false); // set to active mode
@@ -153,63 +155,17 @@
}
can1SleepMode = 1; // disable TX
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; // Trigger display update
- Tcount+=1;
- can1SleepMode = 1; // disable TX
- can1.monitor(true); // set to snoop mode
- }
}
void tickerISR() { //This is the ticker ISR for auto-polling
- CPcount=0; //reset CP message counter
- Tcount=0; //reset Temp message counter
-}
+ pollCP=true; //Set a flag to do in main loop instead of here
+} //since ticker blocks other interrupts
void recieve1() {
CANMessage msg1;
secsNoMsg=0; // reset deadman switch
can1.read(msg1);
- logCan(1, msg1);
+ logCan(1, msg1); //EVcan
led1 = !led1;
}
@@ -217,7 +173,7 @@
CANMessage msg2;
secsNoMsg=0; // reset deadman switch
can2.read(msg2);
- logCan(2, msg2);
+ logCan(2, msg2); //CARcan
led2 = !led2;
}
