/*H**************************************************************************
* NAME: compiler.h
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE: snd1c-refd-nf-4_0_3
* REVISION: 1.8
*----------------------------------------------------------------------------
* PURPOSE:
* This file redefines dedicated KEIL and TASKINKG C51/C251 keywords in order
* to ensure that any source file can be processed by both compilers.
*****************************************************************************/
#ifndef _COMPILER_H_
#define _COMPILER_H_
/*_____ I N C L U D E S ____________________________________________________*/
/*_____ M A C R O S ________________________________________________________*/
/*** Type definition ***/
typedef unsigned char Byte;
typedef unsigned char Uchar;
typedef unsigned char uchar;
typedef unsigned int Uint16;
typedef unsigned int uint;
typedef unsigned char Uint8;
typedef int Int16;
typedef float Float16;
typedef unsigned long int Uint32;
typedef long int Int32;
typedef unsigned char Bool;
typedef bit BOOL;
typedef union
{
Uint32 l;
Uint16 w[2];
Byte b[4];
} Union32;
typedef union
{
Uint16 w;
Byte b[2];
} Union16;
/*** General purpose defines ***/
#define FALSE 0
#define TRUE 1
#define KO 0
#define OK 1
#define OFF 0
#define ON 1
#define CLR 0
#define SET 1
#define LOW(U16) ((Byte)U16)
#define HIGH(U16) ((Byte)(U16>>8))
/* little endian conversion */
#define LE16(b) (((b & 0xFF) > 8))
#define LE32(b) (((b & 0xFF) ((b & 0xFF0000) >> 8) | ((b & 0xFF000000) >> 24))
#define TST_BIT_X(addrx,mask) (*addrx & mask)
#define SET_BIT_X(addrx,mask) (*addrx = (*addrx | mask))
#define CLR_BIT_X(addrx,mask) (*addrx = (*addrx & ~mask))
#define OUT_X(addrx,value) (*addrx = value)
#define IN_X(addrx) (*addrx)
/***********************************************************
SET_SFR_BIT macro
parameters
sfr_reg : defined value in include file for sfr register
bit_pos : defined value B_XX in include file for particular
bit of sfr register
bit_val : CLR / SET
************************************************************/
#define SET_SFR_BIT(sfr_reg, bit_pos, bit_val) { sfr_reg &= ~(1
/***********************************************************
TST_SFR_BIT macro
parameters
sfr_reg : defined value in include file for sfr register
bit_pos : defined value B_XX in include file for particular
bit of sfr register
************************************************************/
#define TST_SFR_BIT(sfr_reg, bit_pos) ((sfr_reg & (1(bit_pos))
/*** KEIL compiler ***/
//#ifdef KEIL
//#define KEIL
#define Reentrant(x) x reentrant
#define Sfr(x,y) sfr x = y
#define Sfr16(x,y) sfr16 x = y
#define Sbit(x,y,z) sbit x = y ^ z
#define Interrupt(x,y) x interrupt y
#define At(x) _at_ x
#ifdef __C51__ /* C51 Compiler */
#define far xdata /* far is for 251 only */
#endif
//#endif /* KEIL */
/*** RAISONANCE compiler ***/
//#ifdef RAISONANCE
// #define Reentrant(x) x reentrant
// #define Sfr(x,y) sfr x = y
// #define Sbit(x,y,z) sbit x = y ^ z
// #define Interrupt(x,y) x interrupt y
// #define At(x) _at_ x
// #ifdef __C51__ /* C51 Compiler */
// #define far xdata /* far is for 251 only */
// #endif
//#endif /* RAISONANCE */
/*** TASKING compiler ***/
//#ifdef TASKING
// #include /* Some job already done! */
// #define far _far
// #define Reentrant(x) _reentrant x
// #define Sfr(x,y) _sfrbyte x _at(y)
// #define Sbit(x,y,z) _sfrbit x _atbit(y,z)
// #define Interrupt(x,y) _interrupt(y) x
//#endif /* TASKING */
/*_____ D E F I N I T I O N ________________________________________________*/
/*_____ D E C L A R A T I O N ______________________________________________*/
#endif /* _COMPILER_H_ */