Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit b289d89

Browse files
authored
Update README.md and Packages Patches
Add note : - HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
1 parent 1198d5a commit b289d89

File tree

3 files changed

+572
-0
lines changed

3 files changed

+572
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
Arduino.h - Main include file for the Arduino SDK
3+
Copyright (c) 2014 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
21+
// to avoid notorious compiler error while uing STL (min and max macro error)
22+
// It's terrible Arduino has just released new core and still don't merge the PR
23+
24+
#ifndef Arduino_h
25+
#define Arduino_h
26+
27+
#include <stdbool.h>
28+
#include <stdint.h>
29+
#include <stdlib.h>
30+
#include <string.h>
31+
#include <math.h>
32+
33+
typedef bool boolean;
34+
typedef uint8_t byte;
35+
typedef uint16_t word;
36+
37+
// some libraries and sketches depend on this AVR stuff,
38+
// assuming Arduino.h or WProgram.h automatically includes it...
39+
//
40+
#include "avr/pgmspace.h"
41+
#include "avr/interrupt.h"
42+
#include "avr/io.h"
43+
44+
#include "binary.h"
45+
#include "itoa.h"
46+
47+
#ifdef __cplusplus
48+
extern "C"{
49+
#endif // __cplusplus
50+
51+
// Include Atmel headers
52+
#include "sam.h"
53+
54+
#include "wiring_constants.h"
55+
56+
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
57+
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
58+
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
59+
60+
void yield( void ) ;
61+
62+
/* system functions */
63+
int main( void );
64+
void init( void );
65+
66+
/* sketch */
67+
void setup( void ) ;
68+
void loop( void ) ;
69+
70+
#include "WVariant.h"
71+
72+
#ifdef __cplusplus
73+
} // extern "C"
74+
#endif
75+
76+
// The following headers are for C++ only compilation
77+
#ifdef __cplusplus
78+
#include "WCharacter.h"
79+
#include "WString.h"
80+
#include "Tone.h"
81+
#include "WMath.h"
82+
#include "HardwareSerial.h"
83+
#include "pulse.h"
84+
#include <bits/stl_algobase.h>
85+
#endif
86+
87+
#include "delay.h"
88+
89+
#ifdef __cplusplus
90+
#include "Uart.h"
91+
#endif
92+
93+
// Include board variant
94+
#include "variant.h"
95+
#include "wiring.h"
96+
#include "wiring_digital.h"
97+
#include "wiring_analog.h"
98+
#include "wiring_shift.h"
99+
#include "WInterrupts.h"
100+
101+
#ifndef __cplusplus
102+
// undefine stdlib's abs if encountered
103+
#ifdef abs
104+
#undef abs
105+
#endif // abs
106+
107+
#define min(a,b) ((a)<(b)?(a):(b))
108+
#define max(a,b) ((a)>(b)?(a):(b))
109+
#define abs(x) ((x)>0?(x):-(x))
110+
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
111+
112+
#else
113+
//using std::min;
114+
//using std::max;
115+
template<class T, class L>
116+
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
117+
{
118+
return (b < a) ? b : a;
119+
}
120+
121+
template<class T, class L>
122+
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
123+
{
124+
return (a < b) ? b : a;
125+
}
126+
#endif
127+
128+
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
129+
#define radians(deg) ((deg)*DEG_TO_RAD)
130+
#define degrees(rad) ((rad)*RAD_TO_DEG)
131+
#define sq(x) ((x)*(x))
132+
133+
#define interrupts() __enable_irq()
134+
#define noInterrupts() __disable_irq()
135+
136+
#define lowByte(w) ((uint8_t) ((w) & 0xff))
137+
#define highByte(w) ((uint8_t) ((w) >> 8))
138+
139+
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
140+
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
141+
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
142+
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
143+
#define bit(b) (1UL << (b))
144+
145+
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
146+
// Interrupts
147+
#define digitalPinToInterrupt(P) ( P )
148+
#endif
149+
150+
// Allows publishing the Beta core under samd-beta / arduino organization
151+
#ifndef ARDUINO_ARCH_SAMD
152+
#define ARDUINO_ARCH_SAMD
153+
#endif
154+
155+
// USB Device
156+
#include "USB/USBDesc.h"
157+
#include "USB/USBCore.h"
158+
#include "USB/USBAPI.h"
159+
#include "USB/USB_host.h"
160+
161+
#ifdef __cplusplus
162+
#include "USB/CDC.h"
163+
#endif
164+
165+
#endif // Arduino_h
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
Arduino.h - Main include file for the Arduino SDK
3+
Copyright (c) 2014 Arduino LLC. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
// KH, This is the fix according to https://github.com/arduino/ArduinoCore-samd/pull/399
21+
// to avoid notorious compiler error while uing STL (min and max macro error)
22+
// It's terrible Arduino has just released new core and still don't merge the PR
23+
24+
#ifndef Arduino_h
25+
#define Arduino_h
26+
27+
#include <stdbool.h>
28+
#include <stdint.h>
29+
#include <stdlib.h>
30+
#include <string.h>
31+
#include <math.h>
32+
33+
typedef bool boolean;
34+
typedef uint8_t byte;
35+
typedef uint16_t word;
36+
37+
// some libraries and sketches depend on this AVR stuff,
38+
// assuming Arduino.h or WProgram.h automatically includes it...
39+
//
40+
#include "avr/pgmspace.h"
41+
#include "avr/interrupt.h"
42+
#include "avr/io.h"
43+
44+
#include "binary.h"
45+
#include "itoa.h"
46+
47+
#ifdef __cplusplus
48+
extern "C"{
49+
#endif // __cplusplus
50+
51+
// Include Atmel headers
52+
#include "sam.h"
53+
54+
#include "wiring_constants.h"
55+
56+
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
57+
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
58+
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
59+
60+
void yield( void ) ;
61+
62+
/* system functions */
63+
int main( void );
64+
void init( void );
65+
66+
/* sketch */
67+
void setup( void ) ;
68+
void loop( void ) ;
69+
70+
#include "WVariant.h"
71+
72+
#ifdef __cplusplus
73+
} // extern "C"
74+
#endif
75+
76+
// The following headers are for C++ only compilation
77+
#ifdef __cplusplus
78+
#include "WCharacter.h"
79+
#include "WString.h"
80+
#include "Tone.h"
81+
#include "WMath.h"
82+
#include "HardwareSerial.h"
83+
#include "pulse.h"
84+
#include <bits/stl_algobase.h>
85+
#endif
86+
87+
#include "delay.h"
88+
89+
#ifdef __cplusplus
90+
#include "Uart.h"
91+
#endif
92+
93+
// Include board variant
94+
#include "variant.h"
95+
#include "wiring.h"
96+
#include "wiring_digital.h"
97+
#include "wiring_analog.h"
98+
#include "wiring_shift.h"
99+
#include "WInterrupts.h"
100+
101+
#ifndef __cplusplus
102+
// undefine stdlib's abs if encountered
103+
#ifdef abs
104+
#undef abs
105+
#endif // abs
106+
107+
#define min(a,b) ((a)<(b)?(a):(b))
108+
#define max(a,b) ((a)>(b)?(a):(b))
109+
#define abs(x) ((x)>0?(x):-(x))
110+
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
111+
112+
#else
113+
//using std::min;
114+
//using std::max;
115+
template<class T, class L>
116+
auto min(const T& a, const L& b) -> decltype((b < a) ? b : a)
117+
{
118+
return (b < a) ? b : a;
119+
}
120+
121+
template<class T, class L>
122+
auto max(const T& a, const L& b) -> decltype((b < a) ? b : a)
123+
{
124+
return (a < b) ? b : a;
125+
}
126+
#endif
127+
128+
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
129+
#define radians(deg) ((deg)*DEG_TO_RAD)
130+
#define degrees(rad) ((rad)*RAD_TO_DEG)
131+
#define sq(x) ((x)*(x))
132+
133+
#define interrupts() __enable_irq()
134+
#define noInterrupts() __disable_irq()
135+
136+
#define lowByte(w) ((uint8_t) ((w) & 0xff))
137+
#define highByte(w) ((uint8_t) ((w) >> 8))
138+
139+
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
140+
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
141+
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
142+
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
143+
#define bit(b) (1UL << (b))
144+
145+
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
146+
// Interrupts
147+
#define digitalPinToInterrupt(P) ( P )
148+
#endif
149+
150+
// Allows publishing the Beta core under samd-beta / arduino organization
151+
#ifndef ARDUINO_ARCH_SAMD
152+
#define ARDUINO_ARCH_SAMD
153+
#endif
154+
155+
// USB Device
156+
#include "USB/USBDesc.h"
157+
#include "USB/USBCore.h"
158+
#include "USB/USBAPI.h"
159+
#include "USB/USB_host.h"
160+
161+
#ifdef __cplusplus
162+
#include "USB/CDC.h"
163+
#endif
164+
165+
#endif // Arduino_h

0 commit comments

Comments
 (0)