Just4Trionic - CAN and BDM FLASH programmer for Saab cars

Dependencies:   mbed

common.h

Committer:
Just4pLeisure
Date:
2011-06-07
Revision:
3:92dae9083c83
Parent:
2:bf3a2b29259a
Child:
4:682d96ff6d79

File content as of revision 3:92dae9083c83:

/*******************************************************************************

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    0x2        

#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
//-----------------------------------------------------------------------------