Library to control Dodge LX (83.3k) CAN devices

Dependencies:   DodgeRadioLib EthernetWrapperLib OBDIILib mbed

Files at this revision

API Documentation at this revision

Comitter:
rtgree01
Date:
Fri Dec 30 20:23:00 2011 +0000
Parent:
0:4d16a55d0eec
Child:
2:e8b13ea2881b
Commit message:
HU emulator; CAN Monitor; OBD2 reader (started)

Changed in this revision

RadioState.h Show annotated file Show diff for this revision Revisions of this file
WatchDogTimer.cpp Show annotated file Show diff for this revision Revisions of this file
ecu_reader.cpp Show annotated file Show diff for this revision Revisions of this file
ecu_reader.h Show annotated file Show diff for this revision Revisions of this file
radioEmulator.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RadioState.h	Sat Aug 20 14:20:13 2011 +0000
+++ b/RadioState.h	Fri Dec 30 20:23:00 2011 +0000
@@ -57,6 +57,7 @@
     int _rearDefrost;
     int _fuel;
     int _speed;
+    int _odometer;
     
     int SWCButtons;
         
--- a/WatchDogTimer.cpp	Sat Aug 20 14:20:13 2011 +0000
+++ b/WatchDogTimer.cpp	Fri Dec 30 20:23:00 2011 +0000
@@ -1,18 +1,18 @@
-#include "WatchDogTimer.h"
-
-void WatchDogTimer::kick(float s)
-{
-    LPC_WDT->WDCLKSEL = 0x1;                // Set CLK src to PCLK
-    uint32_t clk = SystemCoreClock / 16;    // WD has a fixed /4 prescaler, PCLK default is /4
-    LPC_WDT->WDTC = s * (float)clk;
-    LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset
-    kick();
-}
-
-// "kick" or "feed" the dog - reset the watchdog timer
-// by writing this required bit pattern
-void WatchDogTimer::kick()
-{
-    LPC_WDT->WDFEED = 0xAA;
-    LPC_WDT->WDFEED = 0x55;
-}
+#include "WatchDogTimer.h"
+
+void WatchDogTimer::kick(float s)
+{
+    LPC_WDT->WDCLKSEL = 0x1;                // Set CLK src to PCLK
+    uint32_t clk = SystemCoreClock / 16;    // WD has a fixed /4 prescaler, PCLK default is /4
+    LPC_WDT->WDTC = s * (float)clk;
+    LPC_WDT->WDMOD = 0x3;                   // Enabled and Reset
+    kick();
+}
+
+// "kick" or "feed" the dog - reset the watchdog timer
+// by writing this required bit pattern
+void WatchDogTimer::kick()
+{
+    LPC_WDT->WDFEED = 0xAA;
+    LPC_WDT->WDFEED = 0x55;
+}
--- a/ecu_reader.cpp	Sat Aug 20 14:20:13 2011 +0000
+++ b/ecu_reader.cpp	Fri Dec 30 20:23:00 2011 +0000
@@ -68,7 +68,7 @@
                 break;
                 
                 case FUEL_LEVEL:
-                    data.fuel = 100 * can_mMsgRx.data[3] / 255;
+                    data.fuel = 100 * can_MsgRx.data[3] / 255;
                 break;
             }
         }
--- a/ecu_reader.h	Sat Aug 20 14:20:13 2011 +0000
+++ b/ecu_reader.h	Fri Dec 30 20:23:00 2011 +0000
@@ -39,6 +39,7 @@
         int mafSensor;
         int throttle;
         int o2Voltage;
+        int fuel;
         float mpg;
     } data;
 };
--- a/radioEmulator.cpp	Sat Aug 20 14:20:13 2011 +0000
+++ b/radioEmulator.cpp	Fri Dec 30 20:23:00 2011 +0000
@@ -83,6 +83,8 @@
 
     opMode = standalone;
     HostTimeout.attach(this, &RadioEmulator::CheckHostTimeout, 1);
+    
+    printf("Initialized\n\r");
 }
 
 void RadioEmulator::readInitFile()
@@ -283,9 +285,12 @@
 
 void RadioEmulator::SendHostMessages()
 {
-    can2->write(hostMessages.front());
-    
-    hostMessages.pop_front();
+    if (hostMessages.size() > 0)
+    {
+        can2->write(hostMessages.front());
+        
+        hostMessages.pop_front();
+    }
 }
 
 void RadioEmulator::ChangeSiriusStation(int station, bool turn_on)
@@ -327,7 +332,7 @@
             radioOn = false;
         }
     }
-    
+
     // this message seems to be a message requesting all other devices
     // to start announcing their presence
     if ((can_MsgRx.id >= 0x400) && (can_MsgRx.data[0] == 0xfd))
@@ -392,7 +397,7 @@
     else if (can_MsgRx.id == 0x002)
     {
         status._rpm = (can_MsgRx.data[0] << 8) + can_MsgRx.data[1];
-        status._speed = ((can_MsgRx.data[2] << 8) + can_MsgRx.data[3]) / 200;
+        status._speed = ((can_MsgRx.data[2] << 8) + can_MsgRx.data[3]) >> 7;
     }
     else if (can_MsgRx.id == 0x003)
     {
@@ -495,6 +500,7 @@
             status._dimmer = can_MsgRx.data[1];
         }
     }
+
 }
 
 void RadioEmulator::ReadSiriusText(char *data)