20
20
#ifndef Arduino_h
21
21
#define Arduino_h
22
22
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)
42
28
43
29
#ifdef __cplusplus
44
30
extern "C" {
@@ -47,86 +33,73 @@ extern "C"{
47
33
// Include Atmel headers
48
34
#include "sam.h"
49
35
50
- #include "wiring_constants.h"
51
-
52
36
#define clockCyclesPerMicrosecond () ( SystemCoreClock / 1000000L )
53
37
#define clockCyclesToMicroseconds (a ) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
54
38
#define microsecondsToClockCycles (a ) ( (a) * (SystemCoreClock / 1000000L) )
55
39
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
-
66
40
#include "WVariant.h"
67
41
68
42
#ifdef __cplusplus
69
43
} // extern "C"
70
44
#endif
71
45
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
-
86
46
// Include board variant
87
47
#include "variant.h"
88
48
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
94
56
95
57
// undefine stdlib's abs if encountered
96
58
#ifdef abs
97
59
#undef abs
98
60
#endif // abs
99
61
100
- #define min (a ,b ) ((a)<(b)?(a):(b))
101
- #define max (a ,b ) ((a)>(b)?(a):(b))
102
62
#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))
108
63
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
111
68
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 ;
114
84
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 );
119
91
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 );
121
98
122
- #if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606 )
123
- // Interrupts
124
- #define digitalPinToInterrupt (P ) ( P )
125
- #endif
99
+ extern void analogOutputInit ( void ) ;
126
100
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
+ }
130
103
#endif
131
104
132
105
// USB Device
@@ -135,8 +108,7 @@ void loop( void ) ;
135
108
#include "USB/USBAPI.h"
136
109
#include "USB/USB_host.h"
137
110
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"
141
113
142
114
#endif // Arduino_h
0 commit comments