Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eba6cb6

Browse filesBrowse files
committed
Add arduino headers
1 parent 2777ab3 commit eba6cb6
Copy full SHA for eba6cb6
Expand file treeCollapse file tree

19 files changed

+3482
-0
lines changed

‎src/arduino/Arduino.h

Copy file name to clipboard
+244Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
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 "binary.h"
29+
30+
#ifdef __cplusplus
31+
extern "C"{
32+
#endif
33+
34+
void yield(void);
35+
36+
#define HIGH 0x1
37+
#define LOW 0x0
38+
39+
#define INPUT 0x0
40+
#define OUTPUT 0x1
41+
#define INPUT_PULLUP 0x2
42+
43+
#define PI 3.1415926535897932384626433832795
44+
#define HALF_PI 1.5707963267948966192313216916398
45+
#define TWO_PI 6.283185307179586476925286766559
46+
#define DEG_TO_RAD 0.017453292519943295769236907684886
47+
#define RAD_TO_DEG 57.295779513082320876798154814105
48+
#define EULER 2.718281828459045235360287471352
49+
50+
#define SERIAL 0x0
51+
#define DISPLAY 0x1
52+
53+
#define LSBFIRST 0
54+
#define MSBFIRST 1
55+
56+
#define CHANGE 1
57+
#define FALLING 2
58+
#define RISING 3
59+
60+
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
61+
#define DEFAULT 0
62+
#define EXTERNAL 1
63+
#define INTERNAL1V1 2
64+
#define INTERNAL INTERNAL1V1
65+
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
66+
#define DEFAULT 0
67+
#define EXTERNAL 4
68+
#define INTERNAL1V1 8
69+
#define INTERNAL INTERNAL1V1
70+
#define INTERNAL2V56 9
71+
#define INTERNAL2V56_EXTCAP 13
72+
#else
73+
#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__)
74+
#define INTERNAL1V1 2
75+
#define INTERNAL2V56 3
76+
#else
77+
#define INTERNAL 3
78+
#endif
79+
#define DEFAULT 1
80+
#define EXTERNAL 0
81+
#endif
82+
83+
// undefine stdlib's abs if encountered
84+
#ifdef abs
85+
#undef abs
86+
#endif
87+
88+
#define min(a,b) ((a)<(b)?(a):(b))
89+
#define max(a,b) ((a)>(b)?(a):(b))
90+
#define abs(x) ((x)>0?(x):-(x))
91+
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
92+
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
93+
#define radians(deg) ((deg)*DEG_TO_RAD)
94+
#define degrees(rad) ((rad)*RAD_TO_DEG)
95+
#define sq(x) ((x)*(x))
96+
97+
#define interrupts() sei()
98+
#define noInterrupts() cli()
99+
100+
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
101+
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
102+
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
103+
104+
#define lowByte(w) ((uint8_t) ((w) & 0xff))
105+
#define highByte(w) ((uint8_t) ((w) >> 8))
106+
107+
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
108+
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
109+
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
110+
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
111+
112+
// avr-libc defines _NOP() since 1.6.2
113+
#ifndef _NOP
114+
#define _NOP() do { __asm__ volatile ("nop"); } while (0)
115+
#endif
116+
117+
typedef unsigned int word;
118+
119+
#define bit(b) (1UL << (b))
120+
121+
typedef bool boolean;
122+
typedef uint8_t byte;
123+
124+
void init(void);
125+
void initVariant(void);
126+
127+
int atexit(void (*func)()) __attribute__((weak));
128+
129+
void pinMode(uint8_t, uint8_t);
130+
void digitalWrite(uint8_t, uint8_t);
131+
int digitalRead(uint8_t);
132+
int analogRead(uint8_t);
133+
void analogReference(uint8_t mode);
134+
void analogWrite(uint8_t, int);
135+
136+
unsigned long millis(void);
137+
unsigned long micros(void);
138+
void delay(unsigned long);
139+
void delayMicroseconds(unsigned int us);
140+
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
141+
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
142+
143+
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
144+
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
145+
146+
void attachInterrupt(uint8_t, void (*)(void), int mode);
147+
void detachInterrupt(uint8_t);
148+
149+
void setup(void);
150+
void loop(void);
151+
152+
// Get the bit location within the hardware port of the given virtual pin.
153+
// This comes from the pins_*.c file for the active board configuration.
154+
155+
#define analogInPinToBit(P) (P)
156+
157+
// Get the bit location within the hardware port of the given virtual pin.
158+
// This comes from the pins_*.c file for the active board configuration.
159+
//
160+
// These perform slightly better as macros compared to inline functions
161+
//
162+
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
163+
#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
164+
#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
165+
#define analogInPinToBit(P) (P)
166+
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
167+
#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
168+
#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
169+
170+
#define NOT_A_PIN 0
171+
#define NOT_A_PORT 0
172+
173+
#define NOT_AN_INTERRUPT -1
174+
175+
#ifdef ARDUINO_MAIN
176+
#define PA 1
177+
#define PB 2
178+
#define PC 3
179+
#define PD 4
180+
#define PE 5
181+
#define PF 6
182+
#define PG 7
183+
#define PH 8
184+
#define PJ 10
185+
#define PK 11
186+
#define PL 12
187+
#endif
188+
189+
#define NOT_ON_TIMER 0
190+
#define TIMER0A 1
191+
#define TIMER0B 2
192+
#define TIMER1A 3
193+
#define TIMER1B 4
194+
#define TIMER1C 5
195+
#define TIMER2 6
196+
#define TIMER2A 7
197+
#define TIMER2B 8
198+
199+
#define TIMER3A 9
200+
#define TIMER3B 10
201+
#define TIMER3C 11
202+
#define TIMER4A 12
203+
#define TIMER4B 13
204+
#define TIMER4C 14
205+
#define TIMER4D 15
206+
#define TIMER5A 16
207+
#define TIMER5B 17
208+
#define TIMER5C 18
209+
210+
#ifdef __cplusplus
211+
} // extern "C"
212+
#endif
213+
214+
#ifdef __cplusplus
215+
#include "WCharacter.h"
216+
#include "WString.h"
217+
#include "HardwareSerial.h"
218+
#include "USBAPI.h"
219+
#if defined(HAVE_HWSERIAL0) && defined(HAVE_CDCSERIAL)
220+
#error "Targets with both UART0 and CDC serial not supported"
221+
#endif
222+
223+
uint16_t makeWord(uint16_t w);
224+
uint16_t makeWord(byte h, byte l);
225+
226+
#define word(...) makeWord(__VA_ARGS__)
227+
228+
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
229+
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
230+
231+
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
232+
void noTone(uint8_t _pin);
233+
234+
// WMath prototypes
235+
long random(long);
236+
long random(long, long);
237+
void randomSeed(unsigned long);
238+
long map(long, long, long, long, long);
239+
240+
#endif
241+
242+
#include "pins_arduino.h"
243+
244+
#endif

‎src/arduino/Client.h

Copy file name to clipboard
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Client.h - Base class that provides Client
3+
Copyright (c) 2011 Adrian McEwen. 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 client_h
21+
#define client_h
22+
#include "Print.h"
23+
#include "Stream.h"
24+
#include "IPAddress.h"
25+
26+
class Client : public Stream {
27+
28+
public:
29+
virtual int connect(IPAddress ip, uint16_t port) =0;
30+
virtual int connect(const char *host, uint16_t port) =0;
31+
virtual size_t write(uint8_t) =0;
32+
virtual size_t write(const uint8_t *buf, size_t size) =0;
33+
virtual int available() = 0;
34+
virtual int read() = 0;
35+
virtual int read(uint8_t *buf, size_t size) = 0;
36+
virtual int peek() = 0;
37+
virtual void flush() = 0;
38+
virtual void stop() = 0;
39+
virtual uint8_t connected() = 0;
40+
virtual operator bool() = 0;
41+
protected:
42+
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
43+
};
44+
45+
#endif

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.