20
20
#ifndef Arduino_h
21
21
#define Arduino_h
22
22
23
- #include <stdlib.h>
24
- #include <stdbool.h>
25
- #include <string.h>
26
- #include <math.h>
23
+ #include "api/ArduinoAPI.h"
27
24
28
25
#include <avr/pgmspace.h>
29
26
#include <avr/io.h>
30
27
#include <avr/interrupt.h>
31
28
32
- #include "binary.h"
33
-
34
29
#ifdef __cplusplus
35
30
extern "C" {
36
31
#endif
37
32
38
- void yield (void );
39
-
40
- #define HIGH 0x1
41
- #define LOW 0x0
42
-
43
- #define INPUT 0x0
44
- #define OUTPUT 0x1
45
- #define INPUT_PULLUP 0x2
46
-
47
- #define PI 3.1415926535897932384626433832795
48
- #define HALF_PI 1.5707963267948966192313216916398
49
- #define TWO_PI 6.283185307179586476925286766559
50
- #define DEG_TO_RAD 0.017453292519943295769236907684886
51
- #define RAD_TO_DEG 57.295779513082320876798154814105
52
- #define EULER 2.718281828459045235360287471352
53
-
54
- #define SERIAL 0x0
55
- #define DISPLAY 0x1
56
-
57
- #define LSBFIRST 0
58
- #define MSBFIRST 1
59
-
60
- #define CHANGE 1
61
- #define FALLING 2
62
- #define RISING 3
63
-
64
33
#if defined(__AVR_ATtiny24__ ) || defined(__AVR_ATtiny44__ ) || defined(__AVR_ATtiny84__ )
65
34
#define DEFAULT 0
66
35
#define EXTERNAL 1
@@ -84,75 +53,18 @@ void yield(void);
84
53
#define EXTERNAL 0
85
54
#endif
86
55
87
- // undefine stdlib's abs if encountered
88
- #ifdef abs
89
- #undef abs
90
- #endif
91
-
92
- #define min (a ,b ) ((a)<(b)?(a):(b))
93
- #define max (a ,b ) ((a)>(b)?(a):(b))
94
- #define abs (x ) ((x)>0?(x):-(x))
95
- #define constrain (amt ,low ,high ) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
96
- #define round (x ) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
97
- #define radians (deg ) ((deg)*DEG_TO_RAD)
98
- #define degrees (rad ) ((rad)*RAD_TO_DEG)
99
- #define sq (x ) ((x)*(x))
100
-
101
56
#define interrupts () sei()
102
57
#define noInterrupts () cli()
103
58
104
59
#define clockCyclesPerMicrosecond () ( F_CPU / 1000000L )
105
60
#define clockCyclesToMicroseconds (a ) ( (a) / clockCyclesPerMicrosecond() )
106
61
#define microsecondsToClockCycles (a ) ( (a) * clockCyclesPerMicrosecond() )
107
62
108
- #define lowByte (w ) ((uint8_t) ((w) & 0xff))
109
- #define highByte (w ) ((uint8_t) ((w) >> 8))
110
-
111
- #define bitRead (value , bit ) (((value) >> (bit)) & 0x01)
112
- #define bitSet (value , bit ) ((value) |= (1UL << (bit)))
113
- #define bitClear (value , bit ) ((value) &= ~(1UL << (bit)))
114
- #define bitWrite (value , bit , bitvalue ) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
115
-
116
63
// avr-libc defines _NOP() since 1.6.2
117
64
#ifndef _NOP
118
65
#define _NOP () do { __asm__ volatile ("nop"); } while (0)
119
66
#endif
120
67
121
- typedef unsigned int word ;
122
-
123
- #define bit (b ) (1UL << (b))
124
-
125
- typedef bool boolean ;
126
- typedef uint8_t byte ;
127
-
128
- void init (void );
129
- void initVariant (void );
130
-
131
- int atexit (void (* func )()) __attribute__((weak ));
132
-
133
- void pinMode (uint8_t , uint8_t );
134
- void digitalWrite (uint8_t , uint8_t );
135
- int digitalRead (uint8_t );
136
- int analogRead (uint8_t );
137
- void analogReference (uint8_t mode );
138
- void analogWrite (uint8_t , int );
139
-
140
- unsigned long millis (void );
141
- unsigned long micros (void );
142
- void delay (unsigned long );
143
- void delayMicroseconds (unsigned int us );
144
- unsigned long pulseIn (uint8_t pin , uint8_t state , unsigned long timeout );
145
- unsigned long pulseInLong (uint8_t pin , uint8_t state , unsigned long timeout );
146
-
147
- void shiftOut (uint8_t dataPin , uint8_t clockPin , uint8_t bitOrder , uint8_t val );
148
- uint8_t shiftIn (uint8_t dataPin , uint8_t clockPin , uint8_t bitOrder );
149
-
150
- void attachInterrupt (uint8_t , void (* )(void ), int mode );
151
- void detachInterrupt (uint8_t );
152
-
153
- void setup (void );
154
- void loop (void );
155
-
156
68
// Get the bit location within the hardware port of the given virtual pin.
157
69
// This comes from the pins_*.c file for the active board configuration.
158
70
@@ -227,31 +139,14 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
227
139
#endif
228
140
229
141
#ifdef __cplusplus
230
- #include "WCharacter .h"
231
- #include "WString .h"
232
- #include "HardwareSerial .h"
233
- #include "USBAPI .h"
142
+ #include "UART .h"
143
+ #include "USBCore .h"
144
+ #include "CDC .h"
145
+ #include "MSC .h"
234
146
#if defined(HAVE_HWSERIAL0 ) && defined(HAVE_CDCSERIAL )
235
147
#error "Targets with both UART0 and CDC serial not supported"
236
148
#endif
237
149
238
- uint16_t makeWord (uint16_t w );
239
- uint16_t makeWord (byte h , byte l );
240
-
241
- #define word (...) makeWord(__VA_ARGS__)
242
-
243
- unsigned long pulseIn (uint8_t pin , uint8_t state , unsigned long timeout = 1000000L );
244
- unsigned long pulseInLong (uint8_t pin , uint8_t state , unsigned long timeout = 1000000L );
245
-
246
- void tone (uint8_t _pin , unsigned int frequency , unsigned long duration = 0 );
247
- void noTone (uint8_t _pin );
248
-
249
- // WMath prototypes
250
- long random (long );
251
- long random (long , long );
252
- void randomSeed (unsigned long );
253
- long map (long , long , long , long , long );
254
-
255
150
#endif
256
151
257
152
#include "pins_arduino.h"
0 commit comments