Skip to content

Commit 04fe8e8

Browse files
author
Ivan Grokhotkov
committed
Basic support for esp8266 platform
This includes empty stubs for most core Arduino functions. Need to actually implement all those digital reads writes whatever. Need to prebuild toolchains (xtensa-elf-lx106) for 3 platforms and put them on some download server. Need to do the same with esptool. Need to fix 0x40000 binary generation and add correct upload commands. Maybe even implement uploads over WiFi.
0 parents  commit 04fe8e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+10017
-0
lines changed

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
app/bin/
2+
app/pde.jar
3+
build/macosx/work/
4+
core/bin/
5+
core/core.jar
6+
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.o
7+
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.lst
8+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.sym
9+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.o
10+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.map
11+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lst
12+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss
13+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
14+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
15+
hardware/arduino/bootloaders/caterina_LUFA/.dep/
16+
build/libastylej-*.zip
17+
build/windows/work/
18+
build/windows/jre.zip
19+
build/windows/libastylej*
20+
build/windows/arduino-*.zip
21+
build/windows/dist/gcc-*.tar.gz
22+
build/windows/launch4j-*
23+
build/windows/launcher/launch4j
24+
build/windows/WinAVR-*.zip
25+
build/macosx/arduino-*.zip
26+
build/macosx/dist/gcc-*.tar.gz
27+
build/macosx/libastylej*
28+
build/macosx/appbundler*.jar
29+
build/linux/work/
30+
build/linux/dist/*.tar.gz
31+
build/linux/dist/*.tar.bz2
32+
build/linux/*.tgz
33+
build/linux/*.zip
34+
build/linux/libastylej*
35+
test-bin
36+
*.iml
37+
.idea
38+
.DS_Store
39+
build/windows/launch4j-*
40+
build/windows/launcher/launch4j
41+
build/windows/WinAVR-*.zip
42+
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
43+
avr-toolchain-*.zip

README.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Arduino
2+
========
3+
4+
* Arduino is an open-source physical computing platform based on a simple i/o
5+
board and a development environment that implements the Processing/Wiring
6+
language. Arduino can be used to develop stand-alone interactive objects or
7+
can be connected to software on your computer (e.g. Flash, Processing, MaxMSP).
8+
The boards can be assembled by hand or purchased preassembled; the open-source
9+
IDE can be downloaded for free.
10+
11+
* For more information, see the website at: http://www.arduino.cc/
12+
or the forums at: http://arduino.cc/forum/
13+
14+
* To report a *bug* in the software or to request *a simple enhancement* go to:
15+
http://github.com/arduino/Arduino/issues
16+
17+
* More complex requests and technical discussion should go on the Arduino Developers
18+
mailing list:
19+
https://groups.google.com/a/arduino.cc/forum/#!forum/developers
20+
21+
* If you're interested in modifying or extending the Arduino software, we strongly
22+
suggest discussing your ideas on the Developers mailing list *before* starting
23+
to work on them. That way you can coordinate with the Arduino Team and others,
24+
giving your work a higher chance of being integrated into the official release
25+
https://groups.google.com/a/arduino.cc/forum/#!forum/developers
26+
27+
Installation
28+
------------
29+
Detailed instructions are in reference/Guide_Windows.html and
30+
reference/Guide_MacOSX.html. For Linux, see the Arduino playground:
31+
http://www.arduino.cc/playground/Learning/Linux
32+
33+
Credits
34+
--------
35+
Arduino is an open source project, supported by many.
36+
37+
The Arduino team is composed of Massimo Banzi, David Cuartielles, Tom Igoe,
38+
Gianluca Martino, Daniela Antonietti, and David A. Mellis.
39+
40+
Arduino uses the [GNU avr-gcc toolchain](http://gcc.gnu.org/wiki/avr-gcc), [avrdude](http://www.nongnu.org/avrdude/), [avr-libc](http://www.nongnu.org/avr-libc/), and code from
41+
[Processing](http://www.processing.org) and [Wiring](http://wiring.org.co).
42+
43+
Icon and about image designed by [ToDo](http://www.todo.to.it/)
44+

boards.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
##############################################################
2+
esp01.name=ESP-01
3+
4+
esp01.upload.tool=esptool
5+
esp01.upload.speed=57600
6+
esp01.upload.wait_for_upload_port=true
7+
8+
esp01.build.mcu=esp8266
9+
esp01.build.f_cpu=80000000L
10+
esp01.build.board=ESP8266_ESP01
11+
esp01.build.core=esp8266
12+
esp01.build.variant=esp01

cores/esp8266/Arduino.h

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

cores/esp8266/Client.h

+45
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)