2020#ifndef Arduino_h
2121#define Arduino_h
2222
23- #include <stdbool.h>
24- #include <stdint.h>
25- #include <stdlib.h>
26- #include <string.h>
27- #include <math.h>
28-
29- typedef bool boolean ;
30- typedef uint8_t byte ;
31- typedef uint16_t word ;
32-
33- // some libraries and sketches depend on this AVR stuff,
34- // assuming Arduino.h or WProgram.h automatically includes it...
35- //
36- #include "avr/pgmspace.h"
37- #include "avr/interrupt.h"
38- #include "avr/io.h"
39-
40- #include "binary.h"
41- #include "itoa.h"
23+ #include "api/ArduinoAPI.h"
24+
25+ #define RAMSTART (HMCRAMC0_ADDR)
26+ #define RAMSIZE (HMCRAMC0_SIZE)
27+ #define RAMEND (RAMSTART + RAMSIZE - 1)
4228
4329#ifdef __cplusplus
4430extern "C" {
@@ -47,86 +33,73 @@ extern "C"{
4733// Include Atmel headers
4834#include "sam.h"
4935
50- #include "wiring_constants.h"
51-
5236#define clockCyclesPerMicrosecond () ( SystemCoreClock / 1000000L )
5337#define clockCyclesToMicroseconds (a ) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
5438#define microsecondsToClockCycles (a ) ( (a) * (SystemCoreClock / 1000000L) )
5539
56- void yield ( void ) ;
57-
58- /* system functions */
59- int main ( void );
60- void init ( void );
61-
62- /* sketch */
63- void setup ( void ) ;
64- void loop ( void ) ;
65-
6640#include "WVariant.h"
6741
6842#ifdef __cplusplus
6943} // extern "C"
7044#endif
7145
72- // The following headers are for C++ only compilation
73- #ifdef __cplusplus
74- #include "WCharacter.h"
75- #include "WString.h"
76- #include "Tone.h"
77- #include "WMath.h"
78- #include "HardwareSerial.h"
79- #include "pulse.h"
80- #endif
81- #include "delay.h"
82- #ifdef __cplusplus
83- #include "Uart.h"
84- #endif
85-
8646// Include board variant
8747#include "variant.h"
8848
89- #include "wiring.h"
90- #include "wiring_digital.h"
91- #include "wiring_analog.h"
92- #include "wiring_shift.h"
93- #include "WInterrupts.h"
49+ #define interrupts () __enable_irq()
50+ #define noInterrupts () __disable_irq()
51+
52+ #if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606 )
53+ // Interrupts
54+ #define digitalPinToInterrupt (P ) ( P )
55+ #endif
9456
9557// undefine stdlib's abs if encountered
9658#ifdef abs
9759#undef abs
9860#endif // abs
9961
100- #define min (a ,b ) ((a)<(b)?(a):(b))
101- #define max (a ,b ) ((a)>(b)?(a):(b))
10262#define abs (x ) ((x)>0?(x):-(x))
103- #define constrain (amt ,low ,high ) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
104- #define round (x ) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
105- #define radians (deg ) ((deg)*DEG_TO_RAD)
106- #define degrees (rad ) ((rad)*RAD_TO_DEG)
107- #define sq (x ) ((x)*(x))
10863
109- #define interrupts () __enable_irq()
110- #define noInterrupts () __disable_irq()
64+ // Allows publishing the Beta core under samd-beta / arduino organization
65+ #ifndef ARDUINO_ARCH_SAMD
66+ #define ARDUINO_ARCH_SAMD
67+ #endif
11168
112- #define lowByte (w ) ((uint8_t) ((w) & 0xff))
113- #define highByte (w ) ((uint8_t) ((w) >> 8))
69+ #ifdef __cplusplus
70+ extern "C" {
71+ #endif
72+ /*
73+ * \brief SAMD products have only one reference for ADC
74+ */
75+ typedef enum _eAnalogReference
76+ {
77+ AR_DEFAULT ,
78+ AR_INTERNAL ,
79+ AR_EXTERNAL ,
80+ AR_INTERNAL1V0 ,
81+ AR_INTERNAL1V65 ,
82+ AR_INTERNAL2V23
83+ } eAnalogReference ;
11484
115- #define bitRead (value , bit ) (((value) >> (bit)) & 0x01)
116- #define bitSet (value , bit ) ((value) |= (1UL << (bit)))
117- #define bitClear (value , bit ) ((value) &= ~(1UL << (bit)))
118- #define bitWrite (value , bit , bitvalue ) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
85+ /*
86+ * \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023).
87+ *
88+ * \param res
89+ */
90+ extern void analogReadResolution (int res );
11991
120- #define bit (b ) (1UL << (b))
92+ /*
93+ * \brief Set the resolution of analogWrite parameters. Default is 8 bits (range from 0 to 255).
94+ *
95+ * \param res
96+ */
97+ extern void analogWriteResolution (int res );
12198
122- #if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606 )
123- // Interrupts
124- #define digitalPinToInterrupt (P ) ( P )
125- #endif
99+ extern void analogOutputInit ( void ) ;
126100
127- // Allows publishing the Beta core under samd-beta / arduino organization
128- #ifndef ARDUINO_ARCH_SAMD
129- #define ARDUINO_ARCH_SAMD
101+ #ifdef __cplusplus
102+ }
130103#endif
131104
132105// USB Device
@@ -135,8 +108,7 @@ void loop( void ) ;
135108#include "USB/USBAPI.h"
136109#include "USB/USB_host.h"
137110
138- #ifdef __cplusplus
139- #include "USB/CDC.h"
140- #endif
111+ // ARM toolchain doesn't provide itoa etc, provide them
112+ #include "api/itoa.h"
141113
142114#endif // Arduino_h
0 commit comments