|
| 1 | +/* |
| 2 | + Arduino.h - Main include file for the Arduino SDK |
| 3 | + Copyright (c) 2005-2013 Arduino Team. 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 | +#ifndef Arduino_h |
| 21 | +#define Arduino_h |
| 22 | + |
| 23 | +#include <stdbool.h> |
| 24 | +#include <stdint.h> |
| 25 | +#include <stdarg.h> |
| 26 | +#include <stddef.h> |
| 27 | +#include <stdio.h> |
| 28 | +#include <stdlib.h> |
| 29 | +#include <string.h> |
| 30 | +#include <inttypes.h> |
| 31 | + |
| 32 | +#include "freertos/FreeRTOS.h" |
| 33 | +#include "freertos/task.h" |
| 34 | +#include "freertos/semphr.h" |
| 35 | +#include "esp32-hal.h" |
| 36 | +#include "esp8266-compat.h" |
| 37 | +#include "soc/gpio_reg.h" |
| 38 | + |
| 39 | +#include "stdlib_noniso.h" |
| 40 | +#include "binary.h" |
| 41 | + |
| 42 | +#define PI 3.1415926535897932384626433832795 |
| 43 | +#define HALF_PI 1.5707963267948966192313216916398 |
| 44 | +#define TWO_PI 6.283185307179586476925286766559 |
| 45 | +#define DEG_TO_RAD 0.017453292519943295769236907684886 |
| 46 | +#define RAD_TO_DEG 57.295779513082320876798154814105 |
| 47 | +#define EULER 2.718281828459045235360287471352 |
| 48 | + |
| 49 | +#define SERIAL 0x0 |
| 50 | +#define DISPLAY 0x1 |
| 51 | + |
| 52 | +#define LSBFIRST 0 |
| 53 | +#define MSBFIRST 1 |
| 54 | + |
| 55 | +//Interrupt Modes |
| 56 | +#define RISING 0x01 |
| 57 | +#define FALLING 0x02 |
| 58 | +#define CHANGE 0x03 |
| 59 | +#define ONLOW 0x04 |
| 60 | +#define ONHIGH 0x05 |
| 61 | +#define ONLOW_WE 0x0C |
| 62 | +#define ONHIGH_WE 0x0D |
| 63 | + |
| 64 | +#define DEFAULT 1 |
| 65 | +#define EXTERNAL 0 |
| 66 | + |
| 67 | +#ifndef __STRINGIFY |
| 68 | +#define __STRINGIFY(a) #a |
| 69 | +#endif |
| 70 | + |
| 71 | +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
| 72 | +#define radians(deg) ((deg)*DEG_TO_RAD) |
| 73 | +#define degrees(rad) ((rad)*RAD_TO_DEG) |
| 74 | +#define sq(x) ((x)*(x)) |
| 75 | + |
| 76 | +#define sei() |
| 77 | +#define cli() |
| 78 | +#define interrupts() sei() |
| 79 | +#define noInterrupts() cli() |
| 80 | + |
| 81 | +#define clockCyclesPerMicrosecond() ( (long int)getCpuFrequencyMhz() ) |
| 82 | +#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) |
| 83 | +#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) |
| 84 | + |
| 85 | +#define lowByte(w) ((uint8_t) ((w) & 0xff)) |
| 86 | +#define highByte(w) ((uint8_t) ((w) >> 8)) |
| 87 | + |
| 88 | +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) |
| 89 | +#define bitSet(value, bit) ((value) |= (1UL << (bit))) |
| 90 | +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) |
| 91 | +#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit)) |
| 92 | + |
| 93 | +// avr-libc defines _NOP() since 1.6.2 |
| 94 | +#ifndef _NOP |
| 95 | +#define _NOP() do { __asm__ volatile ("nop"); } while (0) |
| 96 | +#endif |
| 97 | + |
| 98 | +#define bit(b) (1UL << (b)) |
| 99 | +#define _BV(b) (1UL << (b)) |
| 100 | + |
| 101 | +#define digitalPinToPort(pin) (((pin)>31)?1:0) |
| 102 | +#define digitalPinToBitMask(pin) (1UL << (((pin)>31)?((pin)-32):(pin))) |
| 103 | +#define digitalPinToTimer(pin) (0) |
| 104 | +#define analogInPinToBit(P) (P) |
| 105 | +#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG)) |
| 106 | +#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG)) |
| 107 | +#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG)) |
| 108 | + |
| 109 | +#define NOT_A_PIN -1 |
| 110 | +#define NOT_A_PORT -1 |
| 111 | +#define NOT_AN_INTERRUPT -1 |
| 112 | +#define NOT_ON_TIMER 0 |
| 113 | + |
| 114 | +typedef bool boolean; |
| 115 | +typedef uint8_t byte; |
| 116 | +typedef unsigned int word; |
| 117 | + |
| 118 | +void setup(void); |
| 119 | +void loop(void); |
| 120 | + |
| 121 | +long random(long, long); |
| 122 | +void randomSeed(unsigned long); |
| 123 | +long map(long, long, long, long, long); |
| 124 | + |
| 125 | +#ifdef __cplusplus |
| 126 | +extern "C" { |
| 127 | +#endif |
| 128 | + |
| 129 | +void init(void); |
| 130 | +void initVariant(void); |
| 131 | +void initArduino(void); |
| 132 | + |
| 133 | +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); |
| 134 | +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); |
| 135 | + |
| 136 | +uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); |
| 137 | +void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); |
| 138 | + |
| 139 | +#ifdef __cplusplus |
| 140 | +} |
| 141 | + |
| 142 | +#include <algorithm> |
| 143 | +#include <cmath> |
| 144 | + |
| 145 | +#include "WCharacter.h" |
| 146 | +#include "WString.h" |
| 147 | +#include "Stream.h" |
| 148 | +#include "Printable.h" |
| 149 | +#include "Print.h" |
| 150 | +#include "IPAddress.h" |
| 151 | +#include "Client.h" |
| 152 | +#include "Server.h" |
| 153 | +#include "Udp.h" |
| 154 | +#include "HardwareSerial.h" |
| 155 | +#include "Esp.h" |
| 156 | + |
| 157 | +using std::abs; |
| 158 | +using std::isinf; |
| 159 | +using std::isnan; |
| 160 | +using std::max; |
| 161 | +using std::min; |
| 162 | +using ::round; |
| 163 | + |
| 164 | +uint16_t makeWord(uint16_t w); |
| 165 | +uint16_t makeWord(byte h, byte l); |
| 166 | + |
| 167 | +#define word(...) makeWord(__VA_ARGS__) |
| 168 | + |
| 169 | +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); |
| 170 | +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); |
| 171 | + |
| 172 | +extern "C" bool getLocalTime(struct tm * info, uint32_t ms = 5000); |
| 173 | +extern "C" void configTime(long gmtOffset_sec, int daylightOffset_sec, |
| 174 | + const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); |
| 175 | +extern "C" void configTzTime(const char* tz, |
| 176 | + const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); |
| 177 | + |
| 178 | +// WMath prototypes |
| 179 | +long random(long); |
| 180 | +#endif /* __cplusplus */ |
| 181 | + |
| 182 | +#define _min(a,b) ((a)<(b)?(a):(b)) |
| 183 | +#define _max(a,b) ((a)>(b)?(a):(b)) |
| 184 | + |
| 185 | +#include "pins_arduino.h" |
| 186 | + |
| 187 | +#endif /* _ESP32_CORE_ARDUINO_H_ */ |
0 commit comments