Just4Trionic - CAN and BDM FLASH programmer for Saab cars

Dependencies:   mbed

Committer:
Just4pLeisure
Date:
Wed May 19 12:39:18 2010 +0000
Revision:
0:e0b964252a05
Child:
1:d5452e398b76

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Just4pLeisure 0:e0b964252a05 1 /*******************************************************************************
Just4pLeisure 0:e0b964252a05 2
Just4pLeisure 0:e0b964252a05 3 Just4Trionic by Just4pLeisure
Just4pLeisure 0:e0b964252a05 4 *****************************
Just4pLeisure 0:e0b964252a05 5
Just4pLeisure 0:e0b964252a05 6 Whilst I have written this program myself I could not have done it without
Just4pLeisure 0:e0b964252a05 7 a lot of help and the original ideas and programs written by:
Just4pLeisure 0:e0b964252a05 8 Dilemma - Author of the Trionic Suite software programs and general Guru
Just4pLeisure 0:e0b964252a05 9 http://trionic.mobixs.eu/ and http://www.ecuproject.com.
Just4pLeisure 0:e0b964252a05 10 General Failure - Author of the T5CANlib software and regular contributor at
Just4pLeisure 0:e0b964252a05 11 http://www.ecuproject.com.
Just4pLeisure 0:e0b964252a05 12 Tomi Liljemark - Lots of information and programs about the Saab CAN bus
Just4pLeisure 0:e0b964252a05 13 http://pikkupossu.1g.fi/tomi/projects/projects.html.
Just4pLeisure 0:e0b964252a05 14 Scott Howard - Author of the BDM software.
Just4pLeisure 0:e0b964252a05 15 Plus inspiration and ideas from many others, including johnc.
Just4pLeisure 0:e0b964252a05 16
Just4pLeisure 0:e0b964252a05 17 Sophie x
Just4pLeisure 0:e0b964252a05 18
Just4pLeisure 0:e0b964252a05 19 ********************************************************************************
Just4pLeisure 0:e0b964252a05 20
Just4pLeisure 0:e0b964252a05 21 WARNING: Use at your own risk, sadly this software comes with no guarantees.
Just4pLeisure 0:e0b964252a05 22 This software is provided 'free' and in good faith, but the author does not
Just4pLeisure 0:e0b964252a05 23 accept liability for any damage arising from its use.
Just4pLeisure 0:e0b964252a05 24
Just4pLeisure 0:e0b964252a05 25 ********************************************************************************
Just4pLeisure 0:e0b964252a05 26
Just4pLeisure 0:e0b964252a05 27 Version 1 (04/2010)- The basic functions are working, but not very easy to use
Just4pLeisure 0:e0b964252a05 28
Just4pLeisure 0:e0b964252a05 29 I have decided to 'release' this software somewhat prematurely because the FLASH
Just4pLeisure 0:e0b964252a05 30 chips in my spare ECU have 'died' and I don't know when I will be able to do
Just4pLeisure 0:e0b964252a05 31 carry on improving and 'polishing' it. This way others will be able to use and
Just4pLeisure 0:e0b964252a05 32 enhance it without having to wait for me.
Just4pLeisure 0:e0b964252a05 33
Just4pLeisure 0:e0b964252a05 34 For now, only option '5' Trionic ECU CAN interface is working. BDM and Lawicell
Just4pLeisure 0:e0b964252a05 35 CAN232 functions are dummies. The intention is to build a complete suite of CAN
Just4pLeisure 0:e0b964252a05 36 software for Trionic5, 7 and 8 ECU types as well as adding a BDM interface to
Just4pLeisure 0:e0b964252a05 37 make an 'all-in-one' USB programming tool.
Just4pLeisure 0:e0b964252a05 38
Just4pLeisure 0:e0b964252a05 39 To make this you will need an mbed system and the CAN circuit from this page:
Just4pLeisure 0:e0b964252a05 40 http://mbed.org/projects/cookbook/wiki/CanBusExample1
Just4pLeisure 0:e0b964252a05 41
Just4pLeisure 0:e0b964252a05 42 Some ideas for the truly creative and adventurous of you is to make a gizmo that
Just4pLeisure 0:e0b964252a05 43 doesn't even need to be connected to a laptop or PC to use, maybe even a self-
Just4pLeisure 0:e0b964252a05 44 contained vesion of Dilemma's CarPC using ideas from this pages:
Just4pLeisure 0:e0b964252a05 45
Just4pLeisure 0:e0b964252a05 46 http://mbed.org/projects/cookbook/wiki/PS2Keyboard
Just4pLeisure 0:e0b964252a05 47 http://mbed.org/projects/cookbook/wiki/PS2Mouse
Just4pLeisure 0:e0b964252a05 48 http://mbed.org/projects/cookbook/wiki/MobileLCD
Just4pLeisure 0:e0b964252a05 49 http://mbed.org/projects/cookbook/wiki/SDCard
Just4pLeisure 0:e0b964252a05 50
Just4pLeisure 0:e0b964252a05 51 *******************************************************************************/
Just4pLeisure 0:e0b964252a05 52
Just4pLeisure 0:e0b964252a05 53 #include "mbed.h"
Just4pLeisure 0:e0b964252a05 54
Just4pLeisure 0:e0b964252a05 55 #include "strings.h"
Just4pLeisure 0:e0b964252a05 56 #include "BDM.h"
Just4pLeisure 0:e0b964252a05 57 #include "CAN232.h"
Just4pLeisure 0:e0b964252a05 58 #include "Trionic5.h"
Just4pLeisure 0:e0b964252a05 59
Just4pLeisure 0:e0b964252a05 60 Serial pc(USBTX, USBRX); // tx, rx
Just4pLeisure 0:e0b964252a05 61
Just4pLeisure 0:e0b964252a05 62 #define CR 0x0D
Just4pLeisure 0:e0b964252a05 63 #define NL 0x0A
Just4pLeisure 0:e0b964252a05 64 #define BELL 0x07
Just4pLeisure 0:e0b964252a05 65
Just4pLeisure 0:e0b964252a05 66 #define TRUE 1
Just4pLeisure 0:e0b964252a05 67 #define FALSE 0
Just4pLeisure 0:e0b964252a05 68
Just4pLeisure 0:e0b964252a05 69 void ShowHelp();
Just4pLeisure 0:e0b964252a05 70
Just4pLeisure 0:e0b964252a05 71 int main() {
Just4pLeisure 0:e0b964252a05 72 // fast serial speed
Just4pLeisure 0:e0b964252a05 73 // pc.baud(921600);
Just4pLeisure 0:e0b964252a05 74 pc.baud(115200);
Just4pLeisure 0:e0b964252a05 75 // make plenty of space for command from RS232
Just4pLeisure 0:e0b964252a05 76 char command[5];
Just4pLeisure 0:e0b964252a05 77 ShowHelp();
Just4pLeisure 0:e0b964252a05 78 while (1) {
Just4pLeisure 0:e0b964252a05 79 // Only get 2 characters, the command and \r
Just4pLeisure 0:e0b964252a05 80 // For now I cannot work out how to use gets() so only single characters
Just4pLeisure 0:e0b964252a05 81 // can be used for commands :-(
Just4pLeisure 0:e0b964252a05 82 //
Just4pLeisure 0:e0b964252a05 83 // At the moment only option '5' does anything - the Trionic5 functions
Just4pLeisure 0:e0b964252a05 84 //
Just4pLeisure 0:e0b964252a05 85 pc.gets(command,2);
Just4pLeisure 0:e0b964252a05 86 int len = strlen(command);
Just4pLeisure 0:e0b964252a05 87 if (len != 1)
Just4pLeisure 0:e0b964252a05 88 printf ("\a");
Just4pLeisure 0:e0b964252a05 89 else if (ToUpper(command[0]) == 'B')
Just4pLeisure 0:e0b964252a05 90 BDM();
Just4pLeisure 0:e0b964252a05 91 else if (ToUpper(command[0]) == 'O')
Just4pLeisure 0:e0b964252a05 92 CAN232();
Just4pLeisure 0:e0b964252a05 93 else if (ToUpper(command[0]) == '5')
Just4pLeisure 0:e0b964252a05 94 Trionic5();
Just4pLeisure 0:e0b964252a05 95 else if (ToUpper(command[0]) == 'H')
Just4pLeisure 0:e0b964252a05 96 ShowHelp();
Just4pLeisure 0:e0b964252a05 97 // Unrecognised so ring the BELL :(
Just4pLeisure 0:e0b964252a05 98 else
Just4pLeisure 0:e0b964252a05 99 printf ("\a");
Just4pLeisure 0:e0b964252a05 100 }
Just4pLeisure 0:e0b964252a05 101 }
Just4pLeisure 0:e0b964252a05 102
Just4pLeisure 0:e0b964252a05 103 void ShowHelp() {
Just4pLeisure 0:e0b964252a05 104 printf("Just4Trionic Command Menu\r\n");
Just4pLeisure 0:e0b964252a05 105 printf("=========================\r\n");
Just4pLeisure 0:e0b964252a05 106 printf("b/B - Start BDM interface (NOT DONE)\r\n");
Just4pLeisure 0:e0b964252a05 107 printf("o/O - Open Lawicel CAN232 type interface (NOT DONE)\r\n");
Just4pLeisure 0:e0b964252a05 108 printf("5 - Start Trionic5 ECU CAN interface\r\n");
Just4pLeisure 0:e0b964252a05 109 printf("\r\n");
Just4pLeisure 0:e0b964252a05 110 printf("h/H - show this help menu\r\n");
Just4pLeisure 0:e0b964252a05 111 return;
Just4pLeisure 0:e0b964252a05 112 }
Just4pLeisure 0:e0b964252a05 113