Library to control Dodge LX (83.3k) CAN devices

Dependents:   DodgeRadioEmulatorv30

Committer:
rtgree01
Date:
Fri Jan 25 04:04:27 2013 +0000
Revision:
2:ade5ba8a9d37
Parent:
0:ab4c4438577e
Library to control Dodge LX (83.3k) CAN devices

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rtgree01 0:ab4c4438577e 1 #ifndef RADIOEMULATOR_H
rtgree01 0:ab4c4438577e 2 #define RADIOEMULATOR_H
rtgree01 0:ab4c4438577e 3
rtgree01 0:ab4c4438577e 4 #include "mbed.h"
rtgree01 0:ab4c4438577e 5 #include "Eth.h"
rtgree01 0:ab4c4438577e 6
rtgree01 0:ab4c4438577e 7 #include "RadioState.h"
rtgree01 0:ab4c4438577e 8
rtgree01 0:ab4c4438577e 9
rtgree01 0:ab4c4438577e 10 class RadioEmulator : public SocketReceiver
rtgree01 0:ab4c4438577e 11 {
rtgree01 0:ab4c4438577e 12 public:
rtgree01 0:ab4c4438577e 13 RadioEmulator(CAN *can, DigitalOut *rs, InterruptIn *irq, bool wdTO);
rtgree01 0:ab4c4438577e 14 ~RadioEmulator() {};
rtgree01 0:ab4c4438577e 15
rtgree01 0:ab4c4438577e 16 void Operate(void);
rtgree01 0:ab4c4438577e 17
rtgree01 0:ab4c4438577e 18 virtual void ReceivedData(int status, int size, char *data);
rtgree01 0:ab4c4438577e 19
rtgree01 0:ab4c4438577e 20 private:
rtgree01 0:ab4c4438577e 21
rtgree01 0:ab4c4438577e 22 CAN *CANDevice;
rtgree01 0:ab4c4438577e 23 CANMessage can_MsgRx;
rtgree01 0:ab4c4438577e 24 DigitalOut *can_RS;
rtgree01 0:ab4c4438577e 25 InterruptIn *canIRQ;
rtgree01 0:ab4c4438577e 26 UDPSock *HostSock;
rtgree01 0:ab4c4438577e 27
rtgree01 0:ab4c4438577e 28 RadioState status;
rtgree01 0:ab4c4438577e 29 char siriusdata[512];
rtgree01 0:ab4c4438577e 30 int prevSWC;
rtgree01 0:ab4c4438577e 31
rtgree01 0:ab4c4438577e 32 // void readInitFile();
rtgree01 0:ab4c4438577e 33 // void writeInitFile();
rtgree01 0:ab4c4438577e 34
rtgree01 0:ab4c4438577e 35 void PowerUp(void);
rtgree01 0:ab4c4438577e 36 void PowerDown();
rtgree01 0:ab4c4438577e 37
rtgree01 0:ab4c4438577e 38 enum {standalone, slave} opMode;
rtgree01 0:ab4c4438577e 39
rtgree01 0:ab4c4438577e 40 void readCANbus(void);
rtgree01 0:ab4c4438577e 41
rtgree01 0:ab4c4438577e 42 void SendOnMsg();
rtgree01 0:ab4c4438577e 43 void SendEVICMsg();
rtgree01 0:ab4c4438577e 44 void SendRadioModeMsg();
rtgree01 0:ab4c4438577e 45 void SendStereoSettingsMsg();
rtgree01 0:ab4c4438577e 46 void SendHostMessages();
rtgree01 0:ab4c4438577e 47
rtgree01 0:ab4c4438577e 48 void ChangeSiriusStation(int station, bool turn_on);
rtgree01 0:ab4c4438577e 49
rtgree01 0:ab4c4438577e 50 void StandaloneSWI();
rtgree01 0:ab4c4438577e 51
rtgree01 0:ab4c4438577e 52 void ParseCANMessage(CANMessage can_MsgRx);
rtgree01 0:ab4c4438577e 53 void ReadSiriusText(char *data);
rtgree01 0:ab4c4438577e 54
rtgree01 0:ab4c4438577e 55 Ticker CANBusTicker;
rtgree01 0:ab4c4438577e 56 bool writeCANFlag;
rtgree01 0:ab4c4438577e 57 void WriteCANMessages();
rtgree01 0:ab4c4438577e 58 std::list<CANMessage> hostMessages;
rtgree01 0:ab4c4438577e 59
rtgree01 0:ab4c4438577e 60 Ticker statusTicker;
rtgree01 0:ab4c4438577e 61 bool statusFlag;
rtgree01 0:ab4c4438577e 62 void SendStatusToHost();
rtgree01 0:ab4c4438577e 63
rtgree01 0:ab4c4438577e 64 Ticker CANTimeout;
rtgree01 0:ab4c4438577e 65 bool CANTimeoutFlag;
rtgree01 0:ab4c4438577e 66 void CheckCANTimeout(void);
rtgree01 0:ab4c4438577e 67 void CANActivity(void);
rtgree01 0:ab4c4438577e 68 bool ReceivedCANMsg;
rtgree01 0:ab4c4438577e 69 bool needToParseCANMessage;
rtgree01 0:ab4c4438577e 70 int powerUpIRQCounter;
rtgree01 0:ab4c4438577e 71 bool sleeping;
rtgree01 0:ab4c4438577e 72 bool needToWakeUp;
rtgree01 0:ab4c4438577e 73
rtgree01 0:ab4c4438577e 74 Ticker HostTimeout;
rtgree01 0:ab4c4438577e 75 bool hostTimeoutFlag;
rtgree01 0:ab4c4438577e 76 void CheckHostTimeout(void);
rtgree01 0:ab4c4438577e 77 bool ReceivedHostMsg;
rtgree01 0:ab4c4438577e 78
rtgree01 0:ab4c4438577e 79
rtgree01 0:ab4c4438577e 80 static char unlock[6];
rtgree01 0:ab4c4438577e 81 static char lock[6];
rtgree01 0:ab4c4438577e 82 static char trunk[6];
rtgree01 0:ab4c4438577e 83 };
rtgree01 0:ab4c4438577e 84
rtgree01 0:ab4c4438577e 85 #endif