20
20
#define _WIRING_CONSTANTS_
21
21
22
22
#ifdef __cplusplus
23
- extern "C" {
24
- #endif // __cplusplus
23
+ extern "C" {
24
+ #endif // __cplusplus
25
25
26
26
#define HIGH 0x1
27
27
#define LOW 0x0
28
28
29
- // 0X00 NA
30
- #define INPUT_PULLDOWN 0x01
31
- #define INPUT INPUT_PULLDOWN
32
- #define OUTPUT 0x02
33
- #define INPUT_PULLUP 0x03
34
- #define INPUT_PULLNONE 0x04
35
- #define OUTPUT_OPENDRAIN 0x05
36
- #define INPUT_IRQ_FALL 0x06
37
- #define INPUT_IRQ_RISE 0x07
38
- #define INPUT_IRQ_LOW 0x08
39
- #define INPUT_IRQ_HIGH 0x09
40
- #define INPUT_IRQ_CHANGE 0x0a
41
-
42
- #define true 0x1
43
- #define false 0x0
44
-
45
- #define PI 3.1415926535897932384626433832795
46
- #define HALF_PI 1.5707963267948966192313216916398
47
- #define TWO_PI 6.283185307179586476925286766559
48
- #define DEG_TO_RAD 0.017453292519943295769236907684886
49
- #define RAD_TO_DEG 57.295779513082320876798154814105
50
- #define EULER 2.718281828459045235360287471352
51
-
52
- #define SERIAL 0x0
53
- #define DISPLAY 0x1
29
+ // 0X00 NA
30
+ #define INPUT_PULLDOWN 0x01
31
+ #define INPUT INPUT_PULLDOWN
32
+ #define OUTPUT 0x02
33
+ #define INPUT_PULLUP 0x03
34
+ #define INPUT_PULLNONE 0x04
35
+ #define OUTPUT_OPENDRAIN 0x05
36
+ #define INPUT_IRQ_FALL 0x06
37
+ #define INPUT_IRQ_RISE 0x07
38
+ #define INPUT_IRQ_LOW 0x08
39
+ #define INPUT_IRQ_HIGH 0x09
40
+ #define INPUT_IRQ_CHANGE 0x0a
41
+
42
+ #define true 0x1
43
+ #define false 0x0
44
+
45
+ #define PI 3.1415926535897932384626433832795
46
+ #define HALF_PI 1.5707963267948966192313216916398
47
+ #define TWO_PI 6.283185307179586476925286766559
48
+ #define DEG_TO_RAD 0.017453292519943295769236907684886
49
+ #define RAD_TO_DEG 57.295779513082320876798154814105
50
+ #define EULER 2.718281828459045235360287471352
51
+
52
+ #define SERIAL 0x0
53
+ #define DISPLAY 0x1
54
54
55
55
enum BitOrder {
56
56
LSBFIRST = 0 ,
@@ -59,59 +59,57 @@ enum BitOrder {
59
59
60
60
// LOW 0
61
61
// HIGH 1
62
- #define CHANGE 2
63
- #define FALLING 3
64
- #define RISING 4
62
+ #define CHANGE 2
63
+ #define FALLING 3
64
+ #define RISING 4
65
65
66
- #define DEFAULT 1
67
- #define EXTERNAL 0
66
+ #define DEFAULT 1
67
+ #define EXTERNAL 0
68
68
69
69
// undefine stdlib's abs if encountered
70
70
#ifdef abs
71
71
#undef abs
72
- #endif // abs
72
+ #endif // abs
73
73
74
- #ifndef Arduino_STD_PRINTF
75
- #ifndef min
76
- #define min (a ,b ) ((a)<(b)?(a):(b))
77
- #endif // min
74
+ #ifndef min
75
+ #define min (a , b ) ((a) < (b) ? (a) : (b))
76
+ #endif // min
78
77
#ifndef max
79
- #define max (a ,b ) ((a)>(b)?(a):(b))
80
- #endif // max
81
- #endif // Arduino_STD_PRINTF
78
+ #define max (a , b ) ((a) > (b) ? (a) : (b))
79
+ #endif // max
82
80
83
- #define abs (x ) ((x)>0? (x): -(x))
84
- #define constrain (amt ,low ,high ) ((amt)< (low)? (low): ((amt)> (high)? (high): (amt)))
85
- #define round (x ) ((x)>=0? (long)((x)+ 0.5): (long)((x)-0.5))
86
- #define radians (deg ) ((deg)* DEG_TO_RAD)
87
- #define degrees (rad ) ((rad)* RAD_TO_DEG)
88
- #define sq (x ) ((x)* (x))
81
+ #define abs (x ) ((x) > 0 ? (x) : -(x))
82
+ #define constrain (amt , low , high ) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
83
+ #define round (x ) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x)-0.5))
84
+ #define radians (deg ) ((deg) * DEG_TO_RAD)
85
+ #define degrees (rad ) ((rad) * RAD_TO_DEG)
86
+ #define sq (x ) ((x) * (x))
89
87
90
88
extern uint32_t ulSetInterruptMaskFromISR (void );
91
89
extern void vClearInterruptMaskFromISR (uint32_t ulNewMask );
92
90
93
- #define interrupts () vClearInterruptMaskFromISR(0)
91
+ #define interrupts () vClearInterruptMaskFromISR(0)
94
92
#define noInterrupts () ulSetInterruptMaskFromISR()
95
93
96
- #define lowByte (w ) ((uint8_t) ((w) & 0xff))
97
- #define highByte (w ) ((uint8_t) ((w) >> 8))
94
+ #define lowByte (w ) ((uint8_t)((w) & 0xff))
95
+ #define highByte (w ) ((uint8_t)((w) >> 8))
98
96
99
- #define bitRead (value , bit ) (((value) >> (bit)) & 0x01)
100
- #define bitSet (value , bit ) ((value) |= (1UL << (bit)))
101
- #define bitClear (value , bit ) ((value) &= ~(1UL << (bit)))
97
+ #define bitRead (value , bit ) (((value) >> (bit)) & 0x01)
98
+ #define bitSet (value , bit ) ((value) |= (1UL << (bit)))
99
+ #define bitClear (value , bit ) ((value) &= ~(1UL << (bit)))
102
100
#define bitWrite (value , bit , bitvalue ) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
103
101
104
102
typedef unsigned int word ;
105
103
106
104
#define bit (b ) (1UL << (b))
107
105
108
106
// TODO: to be checked
109
- typedef uint8_t boolean ;
110
- typedef uint8_t byte ;
107
+ typedef uint8_t boolean ;
108
+ typedef uint8_t byte ;
111
109
112
110
113
111
#ifdef __cplusplus
114
- } // extern "C"
115
- #endif // __cplusplus
112
+ } // extern "C"
113
+ #endif // __cplusplus
116
114
117
115
#endif /* _WIRING_CONSTANTS_ */
0 commit comments