Sophie Dexter
/
Just4Trionic
Just4Trionic - CAN and BDM FLASH programmer for Saab cars
Embed:
(wiki syntax)
Show/hide line numbers
gmlan.h
00001 00002 // gmlan.h - information and definitions needed for communicating with GMLAN 00003 00004 // (C) 2013 Sophie Dexter 00005 00006 #ifndef __GMLAN_H__ 00007 #define __GMLAN_H__ 00008 00009 #include "mbed.h" 00010 00011 #include "common.h" 00012 #include "canutils.h" 00013 00014 #define T8REQID 0x7E0 00015 #define T8RESPID 0x7E8 00016 00017 #define T8USDTREQID 0x011 00018 #define T8UUDTRESPID 0x311 00019 #define T8USDTRESPID 0x411 00020 00021 #define GMLANALLNODES 0x101 00022 00023 #define GMLANMESSAGETIMEOUT 50 // 50 milliseconds (0.05 of a second) - Seems to be plenty of time to wait for messages on the CAN bus 00024 #define GMLANPTCT 150 // 150 milliseconds Timeout between tester request and ECU response or multiple ECU responses 00025 #define GMLANPTCTENHANCED 5100 // 5100 milliseconds Enhanced response timing value for tester P2CT timer. 00026 00027 // Tester Present message, must be sent at least once every 5 seconds for some types of activity 00028 // NOTE however that 2 seconds has been suggested as a good interval 00029 #define GMLANTesterPresentPhysical {0x01,0x3E,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} 00030 #define GMLANTesterPresentFunctional {0xFE,0x01,0x3E,0xaa,0xaa,0xaa,0xaa,0xaa} 00031 extern void GMLANTesterPresentAll(); 00032 extern void GMLANTesterPresent(uint32_t ReqID, uint32_t RespID); 00033 00034 // All steps needed in preparation for using a bootloader ('Utility File' in GMLAN parlance) 00035 bool GMLANprogrammingSetupProcess(uint32_t ReqID, uint32_t RespID); 00036 00037 // All steps needed to transfer and start a bootloader ('Utility File' in GMLAN parlance) 00038 bool GMLANprogrammingUtilityFileProcess(uint32_t ReqID, uint32_t RespID, const uint8_t UtilityFile[]); 00039 00040 00041 // Start a Diagnostic Session 00042 #define GMLANinitiateDiagnosticOperation {0x02,0x10,0x02,0xaa,0xaa,0xaa,0xaa,0xaa} 00043 #define GMLANdisableAllDTCs 0x02 00044 bool GMLANinitiateDiagnostic(uint32_t ReqID, uint32_t RespID, char level); 00045 00046 00047 // Tell T8 To disable normal communication messages 00048 #define GMLANdisableCommunication {0x01,0x28,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} 00049 bool GMLANdisableNormalCommunication(uint32_t ReqID, uint32_t RespID); 00050 00051 00052 // Tell T8 To report programmed state 00053 #define GMLANReportProgrammed {0x01,0xA2,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} 00054 bool GMLANReportProgrammedState(uint32_t ReqID, uint32_t RespID); 00055 00056 // Tell T8 To request or initiate programming 00057 #define GMLANProgramming {0x02,0xA5,0x00,0xaa,0xaa,0xaa,0xaa,0xaa} 00058 #define GMLANRequestProgrammingNormal 0x01 // I or P-Bus speed 00059 #define GMLANRequestProgrammingFast 0x02 // 83.333 kbps for single-wire CAN 00060 #define GMLANEnableProgrammingMode 0x03 // Tell T8 To initiate programming 00061 bool GMLANProgrammingMode(uint32_t ReqID, uint32_t RespID, char mode); 00062 00063 // authenticate with T8 00064 #define GMLANSecurityAccessSeed {0x02,0x27,0x01,0xaa,0xaa,0xaa,0xaa,0xaa} 00065 bool GMLANSecurityAccessRequest(uint32_t ReqID, uint32_t RespID, char level, uint16_t& seed); 00066 #define GMLANSecurityAccessKey {0x04,0x27,0x02,0xCA,0xFE,0xaa,0xaa,0xaa} 00067 bool GMLANSecurityAccessSendKey(uint32_t ReqID, uint32_t RespID, char level, uint16_t key); 00068 00069 // Tell T8 We are Requesting a download session 00070 #define GMLANRequestDownloadMessage {0x06,0x34,0x00,0x00,0x00,0x00,0x00,0xaa} 00071 #define GMLANRequestDownloadModeNormal 0x00 00072 #define GMLANRequestDownloadModeEncrypted 0x01 00073 #define GMLANRequestDownloadModeCompressed 0x10 00074 #define GMLANRequestDownloadModeCompressedEncrypted 0x11 00075 bool GMLANRequestDownload(uint32_t ReqID, uint32_t RespID, char dataFormatIdentifier); 00076 00077 // Data blocks are sent using this message type 00078 #define GMLANDataTransferMessage {0x10,0xF0,0x36,0x00,0xCA,0xFE,0xBA,0xBE} 00079 #define GMLANDOWNLOAD 0x00 00080 #define GMLANEXECUTE 0x80 00081 bool GMLANDataTransfer(uint32_t ReqID, uint32_t RespID, char length, char function, uint32_t address); 00082 bool GMLANDataTransferFirstFrame(uint32_t ReqID, uint32_t RespID, char length, char function, uint32_t address); 00083 bool GMLANDataTransferConsecutiveFrame(uint32_t ReqID, char framenumber, char data[7]); 00084 bool GMLANDataTransferBlockAcknowledge(uint32_t RespID); 00085 00086 // Tell T8 ECU to return to normal mode after FLASHing 00087 #define GMLANReturnToNormalModeMessage {0x01,0x20,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa} 00088 bool GMLANReturnToNormalMode(uint32_t ReqID, uint32_t RespID); 00089 00090 00091 // Show a description of GMLAN Return Codes when an error occurs 00092 void GMLANShowReturnCode(char returnCode); 00093 00094 #endif
Generated on Fri Jul 15 2022 00:43:05 by 1.7.2