1 | /*
|
---|
2 | Copyright (c) 2014 Arduino. All right reserved.
|
---|
3 |
|
---|
4 | This library is free software; you can redistribute it and/or
|
---|
5 | modify it under the terms of the GNU Lesser General Public
|
---|
6 | License as published by the Free Software Foundation; either
|
---|
7 | version 2.1 of the License, or (at your option) any later version.
|
---|
8 |
|
---|
9 | This library is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
12 | See the GNU Lesser General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU Lesser General Public
|
---|
15 | License along with this library; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef _WIRING_CONSTANTS_
|
---|
20 | #define _WIRING_CONSTANTS_
|
---|
21 |
|
---|
22 | #ifdef __cplusplus
|
---|
23 | extern "C"{
|
---|
24 | #endif // __cplusplus
|
---|
25 |
|
---|
26 | #define true (0x1)
|
---|
27 | #define false (0x0)
|
---|
28 |
|
---|
29 | #define PI 3.1415926535897932384626433832795
|
---|
30 | #define HALF_PI 1.5707963267948966192313216916398
|
---|
31 | #define TWO_PI 6.283185307179586476925286766559
|
---|
32 | #define DEG_TO_RAD 0.017453292519943295769236907684886
|
---|
33 | #define RAD_TO_DEG 57.295779513082320876798154814105
|
---|
34 | #define EULER 2.718281828459045235360287471352
|
---|
35 |
|
---|
36 | #define SERIAL 0x0
|
---|
37 | #define DISPLAY 0x1
|
---|
38 |
|
---|
39 | enum BitOrder {
|
---|
40 | LSBFIRST = 0,
|
---|
41 | MSBFIRST = 1
|
---|
42 | };
|
---|
43 |
|
---|
44 | #ifndef min
|
---|
45 | #define min(a,b) ((a)<(b)?(a):(b))
|
---|
46 | #endif // min
|
---|
47 |
|
---|
48 | #ifndef max
|
---|
49 | #define max(a,b) ((a)>(b)?(a):(b))
|
---|
50 | #endif // max
|
---|
51 |
|
---|
52 | //#define abs(x) ((x)>0?(x):-(x))
|
---|
53 | #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
---|
54 | #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
---|
55 | #define radians(deg) ((deg)*DEG_TO_RAD)
|
---|
56 | #define degrees(rad) ((rad)*RAD_TO_DEG)
|
---|
57 | #define sq(x) ((x)*(x))
|
---|
58 |
|
---|
59 | #define interrupts() __enable_irq()
|
---|
60 | #define noInterrupts() __disable_irq()
|
---|
61 |
|
---|
62 | #define lowByte(w) ((uint8_t) ((w) & 0xff))
|
---|
63 | #define highByte(w) ((uint8_t) ((w) >> 8))
|
---|
64 |
|
---|
65 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
---|
66 | #define bitSet(value, bit) ((value) |= (1UL << (bit)))
|
---|
67 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
|
---|
68 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
|
---|
69 |
|
---|
70 | typedef unsigned int word;
|
---|
71 |
|
---|
72 | #define bit(b) (1UL << (b))
|
---|
73 |
|
---|
74 | // TODO: to be checked
|
---|
75 | typedef uint8_t boolean ;
|
---|
76 | typedef uint8_t byte ;
|
---|
77 |
|
---|
78 | #ifdef __cplusplus
|
---|
79 | } // extern "C"
|
---|
80 | #endif // __cplusplus
|
---|
81 |
|
---|
82 | #endif /* _WIRING_CONSTANTS_ */
|
---|