Just4Trionic - CAN and BDM FLASH programmer for Saab cars

Dependencies:   mbed

Revision:
1:d5452e398b76
Child:
2:bf3a2b29259a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common.h	Tue Sep 14 21:02:04 2010 +0000
@@ -0,0 +1,102 @@
+/*******************************************************************************
+
+common.h - information and definitions needed by parts of Just4Trionic
+(c) by 2010 Sophie Dexter
+portions (c) 2009, 2010 by Janis Silins (johnc)
+
+********************************************************************************
+
+WARNING: Use at your own risk, sadly this software comes with no guarantees.
+This software is provided 'free' and in good faith, but the author does not
+accept liability for any damage arising from its use.
+
+*******************************************************************************/
+
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+//#include <stdint.h>
+//#include <stdbool.h>
+
+#include "mbed.h"
+
+#include "sizedefs.h"
+#include "strings.h"
+#include "interfaces.h"
+
+// build configuration
+//#define IGNORE_VCC_PIN            ///< uncomment to ignore the VCC pin
+
+// constants
+#define FW_VERSION_MAJOR    0x1     ///< firmware version
+#define FW_VERSION_MINOR    0x1        
+
+#define CR 0x0D
+#define NL 0x0A
+#define BELL 0x07
+
+#define TRUE 1
+#define FALSE 0
+
+
+// bit macros
+#define SETBIT(x,y)         (x |= (y))                ///< set bit y in byte x
+#define CLEARBIT(x,y)       (x &= (~(y)))            ///< clear bit y in byte x
+#define CHECKBIT(x,y)       (((x) & (y)) == (y))    ///< check bit y in byte x
+
+// command return flags and character constants
+#define TERM_OK             13            ///< command terminator or success flag
+#define TERM_ERR            7            ///< error flag
+#define TERM_BREAK          0x1b        ///< command break flag
+
+#define ERR_COUNT           255            ///< maximum error cycles
+
+#define FILE_BUF_LENGTH      0x1000              ///< file buffer size
+static char file_buffer[FILE_BUF_LENGTH];     ///< file buffer
+
+// FLASH chip manufacturer id values
+#define AMD                 0x01
+#define CSI                 0x31
+#define INTEL               0x89
+
+// FLASH chip type values
+#define INTEL28F512         0xB8
+#define AMD28F512           0x25
+#define INTEL28F010         0xB4
+#define AMD28F010           0xA7
+#define AMD29F010           0x20
+#define AMD29F400T          0x23
+#define AMD29F400B          0xAB
+//#define 29F400T             0x2223
+//#define 29F400B             0x22AB
+
+// TRIONIC ECU Start addresses
+#define T52FLASHSTART       0x60000
+#define T55FLASHSTART       0x40000
+#define T7FLASHSTART        0x00000
+
+// TRIONIC ECU FLASH sizes
+#define T52FLASHSIZE        0x20000
+#define T55FLASHSIZE        0x40000
+#define T7FLASHSIZE         0x80000
+
+// TRIONIC ECU Last address
+#define TRIONICLASTADDR     0x7FFFF
+
+// TRIONIC ECU RAM sizes
+#define T5RAMSIZE           0x8000
+#define T7RAMSIZE           0x8000
+
+// Initial Stack pointer values used by Trionic (1st 4 bytes of BIN file)
+#define T5POINTER           0xFFFFF7FC
+#define T7POINTER           0xFFFFEFFC
+
+// public functions
+void led_on(uint8_t led);
+bool ascii2int(uint32_t* val, const char* str, uint8_t length);
+
+#endif              // __COMMON_H__
+
+//-----------------------------------------------------------------------------
+//    EOF
+//-----------------------------------------------------------------------------