2020#ifndef Arduino_h
2121#define Arduino_h
2222
23- #include <stdlib.h>
24- #include <stdbool.h>
25- #include <string.h>
26- #include <math.h>
23+ #include "api/ArduinoAPI.h"
2724
2825#include <avr/pgmspace.h>
2926#include <avr/io.h>
3027#include <avr/interrupt.h>
3128
32- #include "binary.h"
33-
3429#ifdef __cplusplus
3530extern "C" {
3631#endif
3732
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-
6433#if defined(__AVR_ATtiny24__ ) || defined(__AVR_ATtiny44__ ) || defined(__AVR_ATtiny84__ )
6534 #define DEFAULT 0
6635 #define EXTERNAL 1
@@ -84,75 +53,18 @@ void yield(void);
8453#define EXTERNAL 0
8554#endif
8655
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-
10156#define interrupts () sei()
10257#define noInterrupts () cli()
10358
10459#define clockCyclesPerMicrosecond () ( F_CPU / 1000000L )
10560#define clockCyclesToMicroseconds (a ) ( (a) / clockCyclesPerMicrosecond() )
10661#define microsecondsToClockCycles (a ) ( (a) * clockCyclesPerMicrosecond() )
10762
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-
11663// avr-libc defines _NOP() since 1.6.2
11764#ifndef _NOP
11865#define _NOP () do { __asm__ volatile ("nop"); } while (0)
11966#endif
12067
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-
15668// Get the bit location within the hardware port of the given virtual pin.
15769// This comes from the pins_*.c file for the active board configuration.
15870
@@ -227,31 +139,14 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
227139#endif
228140
229141#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"
234146#if defined(HAVE_HWSERIAL0 ) && defined(HAVE_CDCSERIAL )
235147#error "Targets with both UART0 and CDC serial not supported"
236148#endif
237149
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-
255150#endif
256151
257152#include "pins_arduino.h"
0 commit comments