Index

auto-plow / 8c4a05d

A wheelchair motor-propelled battery-powered ESP32-driven remote control snow plow.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
630 Nov 2018 18:364a63c8cInclude Arduino core filesJoshua12590N

Blob @ auto-plow / include / arduino / Arduino.h

text/plain7483 bytesdownload raw
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 <stdlib.h>
24#include <stdbool.h>
25#include <string.h>
26#include <math.h>
27
28#include <avr/pgmspace.h>
29#include <avr/io.h>
30#include <avr/interrupt.h>
31
32#include "binary.h"
33
34#ifdef __cplusplus
35extern "C"{
36#endif
37
38void 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
64#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
65 #define DEFAULT 0
66 #define EXTERNAL 1
67 #define INTERNAL1V1 2
68 #define INTERNAL INTERNAL1V1
69#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
70 #define DEFAULT 0
71 #define EXTERNAL 4
72 #define INTERNAL1V1 8
73 #define INTERNAL INTERNAL1V1
74 #define INTERNAL2V56 9
75 #define INTERNAL2V56_EXTCAP 13
76#else
77#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
78#define INTERNAL1V1 2
79#define INTERNAL2V56 3
80#else
81#define INTERNAL 3
82#endif
83#define DEFAULT 1
84#define EXTERNAL 0
85#endif
86
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
101#define interrupts() sei()
102#define noInterrupts() cli()
103
104#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
105#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
106#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
107
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
116// avr-libc defines _NOP() since 1.6.2
117#ifndef _NOP
118#define _NOP() do { __asm__ volatile ("nop"); } while (0)
119#endif
120
121typedef unsigned int word;
122
123#define bit(b) (1UL << (b))
124
125typedef bool boolean;
126typedef uint8_t byte;
127
128void init(void);
129void initVariant(void);
130
131int atexit(void (*func)()) __attribute__((weak));
132
133void pinMode(uint8_t, uint8_t);
134void digitalWrite(uint8_t, uint8_t);
135int digitalRead(uint8_t);
136int analogRead(uint8_t);
137void analogReference(uint8_t mode);
138void analogWrite(uint8_t, int);
139
140unsigned long millis(void);
141unsigned long micros(void);
142void delay(unsigned long);
143void delayMicroseconds(unsigned int us);
144unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
145unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
146
147void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
148uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
149
150void attachInterrupt(uint8_t, void (*)(void), int mode);
151void detachInterrupt(uint8_t);
152
153void setup(void);
154void loop(void);
155
156// Get the bit location within the hardware port of the given virtual pin.
157// This comes from the pins_*.c file for the active board configuration.
158
159#define analogInPinToBit(P) (P)
160
161// On the ATmega1280, the addresses of some of the port registers are
162// greater than 255, so we can't store them in uint8_t's.
163extern const uint16_t PROGMEM port_to_mode_PGM[];
164extern const uint16_t PROGMEM port_to_input_PGM[];
165extern const uint16_t PROGMEM port_to_output_PGM[];
166
167extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
168// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
169extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
170extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
171
172// Get the bit location within the hardware port of the given virtual pin.
173// This comes from the pins_*.c file for the active board configuration.
174//
175// These perform slightly better as macros compared to inline functions
176//
177#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
178#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
179#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
180#define analogInPinToBit(P) (P)
181#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
182#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
183#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
184
185#define NOT_A_PIN 0
186#define NOT_A_PORT 0
187
188#define NOT_AN_INTERRUPT -1
189
190#ifdef ARDUINO_MAIN
191#define PA 1
192#define PB 2
193#define PC 3
194#define PD 4
195#define PE 5
196#define PF 6
197#define PG 7
198#define PH 8
199#define PJ 10
200#define PK 11
201#define PL 12
202#endif
203
204#define NOT_ON_TIMER 0
205#define TIMER0A 1
206#define TIMER0B 2
207#define TIMER1A 3
208#define TIMER1B 4
209#define TIMER1C 5
210#define TIMER2 6
211#define TIMER2A 7
212#define TIMER2B 8
213
214#define TIMER3A 9
215#define TIMER3B 10
216#define TIMER3C 11
217#define TIMER4A 12
218#define TIMER4B 13
219#define TIMER4C 14
220#define TIMER4D 15
221#define TIMER5A 16
222#define TIMER5B 17
223#define TIMER5C 18
224
225#ifdef __cplusplus
226} // extern "C"
227#endif
228
229#ifdef __cplusplus
230#include "WCharacter.h"
231#include "WString.h"
232#include "HardwareSerial.h"
233#include "USBAPI.h"
234#if defined(HAVE_HWSERIAL0) && defined(HAVE_CDCSERIAL)
235#error "Targets with both UART0 and CDC serial not supported"
236#endif
237
238uint16_t makeWord(uint16_t w);
239uint16_t makeWord(byte h, byte l);
240
241#define word(...) makeWord(__VA_ARGS__)
242
243unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
244unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
245
246void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
247void noTone(uint8_t _pin);
248
249// WMath prototypes
250long random(long);
251long random(long, long);
252void randomSeed(unsigned long);
253long map(long, long, long, long, long);
254
255#endif
256
257#include "pins_arduino.h"
258
259#endif
260