James Randall / Mbed 2 deprecated Just4Trionic

Dependencies:   mbed

Fork of Just4Trionic by Sophie Dexter

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers t7utils.h Source File

t7utils.h

00001 
00002 // t7utils.h - information and definitions needed for communicating with the T7 ECU
00003 
00004 // (C) 2011, 2012 Sophie Dexter
00005 
00006 #ifndef __T7UTILS_H__
00007 #define __T7UTILS_H__
00008 
00009 #include "mbed.h"
00010 
00011 #include "common.h"
00012 #include "canutils.h"
00013 
00014 #define T7CMNDID 0x220
00015 #define T7RESPID 0x238
00016 #define T7SEC_ID 0x240
00017 #define T7SEC_RX 0x258
00018 #define T7ACK_ID 0x266
00019 #define T7ANYMSG 0x0
00020 
00021 
00022 // initialise T7
00023 
00024 #define T7INITMSG   {0x3F,0x81,0x00,0x11,0x02,0x40,0x00,0x00}
00025 
00026 // authenticate with T7
00027 
00028 #define T7SEC_MSG   {0x40,0xA1,0x02,0x27,0x05,0x00,0x00,0x00}
00029 #define T7KEY_MSG   {0x40,0xA1,0x04,0x27,0x06,0x00,0x00,0x00}
00030 
00031 #define T7ACK_MSG   {0x40,0xA1,0x3F,0x00,0x00,0x00,0x00,0x00}
00032 
00033 // read_trionic7
00034 
00035 #define T7DMP_END   {0x40,0xA1,0x01,0x82,0x00,0x00,0x00,0x00}
00036 //#define T7DMPJP1A   {0x41,0xA1,0x08,0x2C,0xF0,0x03,0x00,0xEF}    // 0x000000 length=0xEF
00037 #define T7DMPJP1A   {0x41,0xA1,0x08,0x2C,0xF0,0x03,0x00,0x80}    // 0x000000 length=0x80 (128 bytes)
00038 #define T7DMPJP1B   {0x00,0xA1,0x00,0x00,0x00,0x00,0x00,0x00}
00039 #define T7DMPPOST   {0x40,0xA1,0x01,0x3E,0x00,0x00,0x00,0x00}
00040 #define T7DMPDATA   {0x40,0xA1,0x02,0x21,0xF0,0x00,0x00,0x00}
00041 #define T7DMP_ACK   {0x40,0xA1,0x20,0x00,0x00,0x00,0x00,0x00}
00042 
00043 // flash_trionic7
00044 
00045 #define T7FLAJP1A   {0x41,0xA1,0x08,0x34,0x00,0x00,0x00,0x00}    // Start  = 0x000000
00046 #define T7FLAJP1B   {0x00,0xA1,0x08,0x00,0x00,0x00,0x00,0x00}    // Length = 0x080000
00047 #define T7FLABINA   {0x41,0xA1,0x08,0x34,0x00,0x00,0x00,0x00}    // Start  = 0x000000
00048 #define T7FLABINB   {0x00,0xA1,0x07,0x00,0x00,0x00,0x00,0x00}    // Length = 0x070000
00049 #define T7FLAHDRA   {0x41,0xA1,0x08,0x34,0x07,0xFF,0x00,0x00}    // Start  = 0x07FF00
00050 #define T7FLAHDRB   {0x00,0xA1,0x00,0x01,0x00,0x00,0x00,0x00}    // Length = 0x000100
00051 #define T7FLA_END   {0x40,0xA1,0x01,0x37,0x00,0x00,0x00,0x00}
00052 #define T7FLAEXIT   {0x40,0xA1,0x02,0x31,0x54,0x00,0x00,0x00}
00053 #define T7FLA_ACK   {0x40,0xA1,0x3F,0x00,0x00,0x00,0x00,0x00}        // 266h
00054 
00055 
00056 #define T7MESSAGETIMEOUT 50             // 50 milliseconds (0.05 of a second) - Seems to be plenty of time to wait for messages on the CAN bus
00057 #define T7LONGERTIMEOUT 500             // 500 milliseconds (0.5 of a second) - Some messages seem to need longer
00058 #define T7CHECKSUMTIMEOUT 2000          // 2 seconds (2,000 milliseconds) - Usually takes less than a second so allowing 2 is plenty
00059 #define T7CONNECTTIMEOUT 5000           // 5 seconds (5,000 milliseconds) - Usually takes 3 seconds so allowing 5 is plenty
00060 #define T7ERASETIMEOUT 40000            // 40 seconds (60,000 milliseconds) - Usually takes less than 20 seconds so allowing 40 is plenty
00061 
00062 extern bool t7_initialise();
00063 extern bool t7_authenticate();
00064 extern bool t7_dump();
00065 extern bool t7_flash();
00066 extern bool t7_flash_raw();
00067 extern bool t7_erase();
00068 /* global constants */
00069 //#define init_msg        { 0x3F, 0x81, 0x00, 0x11, 0x02, 0x40, 0x00, 0x00 }
00070 
00071 // ask_header_trionic7
00072 
00073 //#define query           { 0x40, 0xA1, 0x02, 0x1A, 0x00, 0x00, 0x00, 0x00 }
00074 //#define ack             { 0x40, 0xA1, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00 }
00075 
00076 // ask_header2_trionic7
00077 
00078 //#define query           { 0x40, 0xA1, 0x02, 0x1A, 0x00, 0x00, 0x00, 0x00 }
00079 //#define ack             { 0x40, 0xA1, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00 }
00080 
00081 
00082 // authenticate_trionic7
00083 
00084 #define security_msg        { 0x40, 0xA1, 0x02, 0x27, 0x05, 0x00, 0x00, 0x00 }
00085 #define security_msg_reply  { 0x40, 0xA1, 0x04, 0x27, 0x06, 0x00, 0x00, 0x00 }
00086 #define ack                 { 0x40, 0xA1, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00 }
00087  
00088 
00089 // erase_trionic7
00090 
00091 //#define erase_msg1      { 0x40, 0xA1, 0x02, 0x31, 0x52, 0x00, 0x00, 0x00 }
00092 //#define erase_msg2      { 0x40, 0xA1, 0x02, 0x31, 0x53, 0x00, 0x00, 0x00 }
00093 //#define confirm_msg     { 0x40, 0xA1, 0x01, 0x3E, 0x00, 0x00, 0x00, 0x00 }
00094 
00095 
00096 // program_trionic7
00097 
00098 //#define jump_msg1a          { 0x41, 0xA1, 0x08, 0x34, 0x00, 0x00, 0x00, 0x00 }    // 0x000000 length=0x07B000
00099 #define jump_msg1b          { 0x00, 0xA1, 0x07, 0xB0, 0x00, 0x00, 0x00, 0x00 }
00100 #define jump_msg2a          { 0x41, 0xA1, 0x08, 0x34, 0x07, 0xFF, 0x00, 0x00 }    // 0x07FF00 length=0x000100
00101 #define jump_msg2b          { 0x00, 0xA1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }
00102 #define end_data_msg        { 0x40, 0xA1, 0x01, 0x37, 0x00, 0x00, 0x00, 0x00 }
00103 #define exit_diag_msg       { 0x40, 0xA1, 0x02, 0x31, 0x54, 0x00, 0x00, 0x00 }
00104 #define req_diag_result_msg { 0x3F, 0x81, 0x01, 0x33, 0x02, 0x40, 0x00, 0x00 }  // 220h
00105 #define ack                 { 0x40, 0xA1, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00 }        // 266h
00106 
00107 // program_trionic7_tis
00108 
00109 //#define jump_msg1a          { 0x41, 0xA1, 0x08, 0x34, 0x00, 0x00, 0x00, 0x00 }    // 0x000000 length=0x070000
00110 //#define jump_msg1b          { 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00 }
00111 //#define jump_msg2a          { 0x41, 0xA1, 0x08, 0x34, 0x07, 0xFF, 0x00, 0x00 }    // 0x07FF00 length=0x000100
00112 //#define jump_msg2b          { 0x00, 0xA1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }
00113 //#define end_data_msg        { 0x40, 0xA1, 0x01, 0x37, 0x00, 0x00, 0x00, 0x00 }
00114 //#define exit_diag_msg       { 0x40, 0xA1, 0x02, 0x31, 0x54, 0x00, 0x00, 0x00 }
00115 //#define req_diag_result_msg { 0x3F, 0x81, 0x01, 0x33, 0x02, 0x40, 0x00, 0x00 }  // 220h
00116 //#define ack                 { 0x40, 0xA1, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00 }        // 266h
00117 
00118 
00119 // verify_trionic7
00120 //#define init_msg        { 0x20, 0x81, 0x00, 0x11, 0x02, 0x42, 0x00, 0x00 }
00121 //#define end_data_msg    { 0x40, 0xA1, 0x01, 0x82, 0x00, 0x00, 0x00, 0x00 }
00122 //#define jump_msg1a      { 0x41, 0xA1, 0x08, 0x2C, 0xF0, 0x03, 0x00, 0xEF }    // 0x000000 length=0xEF
00123 //#define jump_msg1b      { 0x00, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
00124 //#define post_jump_msg   { 0x40, 0xA1, 0x01, 0x3E, 0x00, 0x00, 0x00, 0x00 }
00125 //#define data_msg        { 0x40, 0xA1, 0x02, 0x21, 0xF0, 0x00, 0x00, 0x00 }
00126 //#define ack             { 0x40, 0xA1, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00 }
00127 
00128 
00129 #endif