WConstants.h
Go to the documentation of this file.
1 /* $Id: WConstants.h 1156 2011-06-07 04:01:16Z bhagman $
2 ||
3 || @author Hernando Barragan <b@wiring.org.co>
4 || @url http://wiring.org.co/
5 || @contribution Brett Hagman <bhagman@wiring.org.co>
6 || @contribution Alexander Brevig <abrevig@wiring.org.co>
7 ||
8 || @description
9 || | Main constant and macro definitions for Wiring.
10 || |
11 || | Wiring Common API
12 || #
13 ||
14 || @license Please see cores/Common/License.txt.
15 ||
16 */
17 
18 #pragma once
19 
20 #include <cstdint>
21 
22 // Wiring API version for libraries
23 // this is passed in at compile-time
24 #ifndef WIRING
25 #define WIRING 101
26 #endif
27 
28 // passed in at compile-time
29 #ifndef F_CPU
30 #define F_CPU 80000000L
31 #endif
32 
33 /*************************************************************
34  * Constants
35  *************************************************************/
36 
37 #define LOW 0x0
38 #define HIGH 0x1
39 //#define HIGH 0xFF
40 
41 //GPIO FUNCTIONS
42 #define INPUT 0x00
43 #define INPUT_PULLUP 0x02
44 #define INPUT_PULLDOWN_16 0x04 // PULLDOWN only possible for pin16
45 #define OUTPUT 0x01
46 #define OUTPUT_OPEN_DRAIN 0x03
47 #define WAKEUP_PULLUP 0x05
48 #define WAKEUP_PULLDOWN 0x07
49 #define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
50 #define FUNCTION_0 0x08
51 #define FUNCTION_1 0x18
52 #define FUNCTION_2 0x28
53 #define FUNCTION_3 0x38
54 #define FUNCTION_4 0x48
55 
56 #define CHANGE 32 // to avoid conflict with HIGH value
57 #define FALLING 2
58 #define RISING 3
59 
60 #define LSBFIRST 0x0
61 #define MSBFIRST 0x1
62 
63 #define null NULL
64 
65 #define DEC 10
66 #define HEX 16
67 #define OCT 8
68 #define BIN 2
69 
70 #define PI (3.1415926535897932384626433832795)
71 #define TWO_PI (6.283185307179586476925286766559)
72 #define HALF_PI (1.5707963267948966192313216916398)
73 #define EPSILON (0.0001)
74 #define DEG_TO_RAD (0.017453292519943295769236907684886)
75 #define RAD_TO_DEG (57.295779513082320876798154814105)
76 
77 
78 /*************************************************************
79  * Digital Constants
80  *************************************************************/
81 
82 #define PORT0 0
83 #define PORT1 1
84 #define PORT2 2
85 #define PORT3 3
86 #define PORT4 4
87 #define PORT5 5
88 #define PORT6 6
89 #define PORT7 7
90 #define PORT8 8
91 #define PORT9 9
92 
93 
94 /*************************************************************
95  * Useful macros
96  *************************************************************/
97 
98 #define word(...) makeWord(__VA_ARGS__)
99 
100 #define sq(x) ((x)*(x))
101 #define radians(deg) ((deg)*DEG_TO_RAD)
102 #define degrees(rad) ((rad)*RAD_TO_DEG)
103 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
104 
105 #define lowByte(x) ((uint8_t) ((x) & 0x00ff))
106 #define highByte(x) ((uint8_t) ((x)>>8))
107 
108 
109 #define clockCyclesPerMicrosecond() (F_CPU / 1000000L)
110 #define clockCyclesToMicroseconds(a) ((a) / clockCyclesPerMicrosecond())
111 #define microsecondsToClockCycles(a) ((a) * clockCyclesPerMicrosecond())
112 
113 
114 
115 /*************************************************************
116  * Typedefs
117  *************************************************************/
118 
119 typedef unsigned int word;
120 typedef uint8_t byte;
121 typedef uint8_t boolean;
122 typedef void (*voidFuncPtr)(void);
#define word(...)
Definition: WConstants.h:98
uint8_t byte
Definition: WConstants.h:120
void(* voidFuncPtr)(void)
Definition: WConstants.h:122
uint8_t boolean
Definition: WConstants.h:121