]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/arm/mach-at91sam7/libs/armlibdefs.h
Build framework for the AT91SAM7 architecture
[sysless.git] / arch / arm / mach-at91sam7 / libs / armlibdefs.h
1 /*! \file armlibdefs.h \brief ARMlib global defines and macros. */
2 //*****************************************************************************
3 //
4 // File Name    : 'armlibdefs.h'
5 // Title                : ARMlib global defines and macros include file
6 // Author               : Pascal Stang
7 // Created              : 7/12/2001
8 // Revised              : 9/30/2002
9 // Version              : 1.1
10 // Target MCU   : ARM
11 // Editor Tabs  : 4
12 //
13 //      Description : This include file is designed to contain items useful to all
14 //                                      code files and projects, regardless of specific implementation.
15 //
16 // This code is distributed under the GNU Public License
17 //              which can be found at http://www.gnu.org/licenses/gpl.txt
18 //
19 //*****************************************************************************
20
21
22 #ifndef ARMLIBDEFS_H
23 #define ARMLIBDEFS_H
24
25 // MIN/MAX/ABS macros
26 #define MIN(a,b)                        (((a)<(b))?(a):(b))
27 #define MAX(a,b)                        (((a)>(b))?(a):(b))
28 #define ABS(x)                          (((x)>0)?(x):(-x))
29
30 // constants
31 #define PI              3.14159265359
32
33 // some handy defines
34 #ifndef BIT
35 #define BIT(n)                          (1 << (n))
36 #endif
37 #ifndef BV
38 #define BV(n)                           (1 << (n))
39 #endif
40
41 #define sbi(num,bitloc)         (num|=(1<<bitloc))
42 #define cbi(num,bitloc)         (num&=~(1<<bitloc))
43 #define gbi(num,bitloc)         ((num&=(1<<bitloc))>>bitloc)
44
45 #define SET_BIT(x,b) ( x=(x|(1<<(b))) )
46 #define CLR_BIT(x,b) ( x=(x&~(1<<(b))) )
47 #define TGL_BIT(x,b) ( x=(x^(1<<(b))) )
48
49 #define NOP         __asm__ volatile("nop");
50
51 #define bool_val(x) ((x)==0)?FALSE:TRUE
52
53
54 #define IN_RANGE(x,min,max) ((((x)>=(min))&&((x)<=(max))))
55
56
57 // use this for packed structures
58 #define GNUC_PACKED __attribute__((packed)) 
59
60 // port bits
61 #define P00                     BIT(0)          // P0.00
62 #define P01                     BIT(1)          // P0.01
63 #define P02                     BIT(2)          // P0.02
64 #define P03                     BIT(3)          // P0.03
65 #define P04                     BIT(4)          // P0.04
66 #define P05                     BIT(5)          // P0.05
67 #define P06                     BIT(6)          // P0.06
68 #define P07                     BIT(7)          // P0.07
69 #define P08                     BIT(8)          // P0.08
70 #define P09                     BIT(9)          // P0.09
71 #define P10                     BIT(10)         // P0.10
72 #define P11                     BIT(11)         // P0.11
73 #define P12                     BIT(12)         // P0.12
74 #define P13                     BIT(13)         // P0.13
75 #define P14                     BIT(14)         // P0.14
76 #define P15                     BIT(15)         // P0.15
77 #define P16                     BIT(16)         // P0.16
78 #define P17                     BIT(17)         // P0.17
79 #define P18                     BIT(18)         // P0.18
80 #define P19                     BIT(19)         // P0.19
81 #define P20                     BIT(20)         // P0.20
82 #define P21                     BIT(21)         // P0.21
83 #define P22                     BIT(22)         // P0.22
84 #define P23                     BIT(23)         // P0.23
85 #define P24                     BIT(24)         // P0.24
86 #define P25                     BIT(25)         // P0.25
87 #define P26                     BIT(26)         // P0.26
88 #define P27                     BIT(27)         // P0.27
89 #define P28                     BIT(28)         // P0.28
90 #define P29                     BIT(29)         // P0.29
91 #define P30                     BIT(30)         // P0.30
92 #define P31                     BIT(31)         // P0.31
93
94
95 #endif