gcc_compiler.h

Go to the documentation of this file.
00001 //******************************************************************************
00020 //******************************************************************************
00021 
00022 
00023 #ifndef _GCC_COMPILER_H_
00024 #define _GCC_COMPILER_H_
00025 
00026 #ifndef __GNUC__
00027 #error  Include error, the compiler must be: GCC.
00028 #endif  // GNU Compiler
00029 
00030 //_____ D E C L A R A T I O N S ________________________________________________
00031 
00032 typedef unsigned char       Bool;
00033 
00034 typedef unsigned char       U8 ;
00035 typedef unsigned short      U16;
00036 typedef unsigned long       U32;
00037 typedef unsigned long long  U64;
00038 typedef signed   char       S8 ;
00039 typedef signed   short      S16;
00040 typedef signed   long       S32;
00041 typedef signed   long long  S64;
00042 
00043 typedef float               Float16;
00044 
00045 
00046 typedef unsigned char       Uchar;
00047 
00048 
00049 typedef unsigned char       Uint8;
00050 typedef unsigned int        Uint16;
00051 typedef unsigned long int   Uint32;
00052 
00053 typedef char                Int8;
00054 typedef int                 Int16;
00055 typedef long int            Int32;
00056 
00057 typedef unsigned char       Byte;
00058 typedef unsigned int        Word;
00059 typedef unsigned long int   DWord;
00060 
00061 
00062 typedef union
00063 {
00064   U16 w   ;     // w as WORD
00065   U8  b[2];     // b as BYTE
00066 } Union16;
00067 
00068 typedef union
00069 {
00070   U32 w   ;     // w as WORD
00071   U16 h[2];     // h as HALF-WORD
00072   U8  b[4];     // b as BYTE
00073 } Union32;
00074 
00075 typedef union
00076 {
00077   U64 d   ;     // d as DOUBLE-WORD
00078   U32 w[2];     // w as WORD
00079   U16 h[4];     // h as HALF-WORD
00080   U8  b[8];     // b as BYTE
00081 } Union64;
00082 
00083 //_____ M A C R O S ____________________________________________________________
00084 
00086     // Max(a, b): Take the max between a and b
00087     // Min(a, b): Take the min between a and b
00088     // Align_up(val, n):   Around (up)   the number (val) on the (n) boundary
00089     // Align_down(val, n): Around (down) the number (val) on the (n) boundary
00090 #define Max(a, b)          ( (a)>(b) ? (a) : (b) )
00091 #define Min(a, b)          ( (a)<(b) ? (a) : (b) )
00092 #define Align_up(val, n)   ( ((val)+(n)-1) & ~((n)-1) )
00093 #define Align_down(val, n) (  (val)        & ~((n)-1) )
00094 
00096 #define Low(data_w)                ((U8)data_w)
00097 #define High(data_w)               ((U8)(data_w>>8))
00098 #define Tst_bit_x(addrx,mask)   (*addrx & mask)
00099 #define Set_bit_x(addrx,mask)   (*addrx = (*addrx |  mask))
00100 #define Clr_bit_x(addrx,mask)   (*addrx = (*addrx & ~mask))
00101 
00102 #define LOW(U16)                ((Uchar)U16)
00103 #define HIGH(U16)               ((Uchar)(U16>>8))
00104 
00105 //_____ C O N S T A N T S ______________________________________________________
00106 
00107 #define ENABLE   1
00108 #define ENABLED  1
00109 #define DISABLED 0
00110 #define DISABLE  0
00111 #define FALSE   (0==1)
00112 #define TRUE    (1==1)
00113 #define KO      0
00114 #define OK      1
00115 #define CLR     0
00116 #define SET     1
00117 #define OFF     0
00118 #define ON      1
00119 
00121 #define  NULL              ((void *)0)
00122 
00123 //_____ I A R   C O M P A T I B I L I T Y ______________________________________
00124 
00125 #define __disable_interrupt    { __asm__ __volatile__ ("cli"   : :); }
00126 #define __enable_interrupt     { __asm__ __volatile__ ("sei"   : :); }
00127 #define __no_operation         { __asm__ __volatile__ ("nop"   : :); }
00128 #define __watchdog_reset       { __asm__ __volatile__ ("wdr"   : :); }
00129 #define __clear_watchdog_timer { __asm__ __volatile__ ("wdr"   : :); }
00130 #define __sleep()              { __asm__ __volatile__ ("sleep" : :); }
00131 #define __insert_opcode(op)    { __asm__ __volatile__ (".word %0" : : "n"(op));}
00132 #define __indirect_jump_to(ad) { __asm__ __volatile__ ("ijmp"     : : "z"(ad));}
00133 
00134 //______________________________________________________________________________
00135 
00136 
00137 #define Disable_interrupt()    { __asm__ __volatile__ ("cli"   : :); }
00138 #define Enable_interrupt()     { __asm__ __volatile__ ("sei"   : :); }
00139 
00140 
00141 #define MSB(u16)        (((U8* )&u16)[1])
00142 #define LSB(u16)        (((U8* )&u16)[0])
00143 
00144 typedef unsigned char     bit;
00145 typedef int     p_uart_ptchar;
00146 typedef int     r_uart_ptchar;
00147 typedef int     r_uart_gtchar;
00148 
00149 //#define uart_putchar putchar
00150 //#define uart_getchar getchar
00151 
00152 #define code PROGMEM
00153 
00154 #endif // _GCC_COMPILER_H_

Generated on Tue Sep 16 18:11:19 2008 for Atmel BLDC Sinusoidal on ATAVRMC100 by  doxygen 1.5.3