1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

Merge pull request #1 from esp8266/esp8266

Get latest
This commit is contained in:
Michael Miller 2015-05-07 12:53:52 -07:00
commit 9977276ba9
6 changed files with 1410 additions and 4 deletions

View File

@ -8,7 +8,7 @@ This project brings support for ESP8266 chip to the Arduino environment. ESP8266
| OS | Build status | Latest release | Alpha Version |
| --- | ------------ | -------------- | --------------- |
| Linux | [![Linux build status](http://img.shields.io/travis/igrr/Arduino.svg)](https://travis-ci.org/igrr/Arduino) | [arduino-1.6.1-linux64.tar.xz](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-linux64.tar.xz) | |
| Windows | [![Windows build status](http://img.shields.io/appveyor/ci/igrr/Arduino.svg)](https://ci.appveyor.com/project/igrr/Arduino) | [arduino-1.6.1-p1-windows.zip](https://github.com/igrr/Arduino/releases/download/1.6.1-esp8266-1/arduino-1.6.1-p1-windows.zip) | [appveyor Build](https://ci.appveyor.com/project/igrr/Arduino/build/artifacts) |
| Windows | [![Windows build status](http://img.shields.io/appveyor/ci/igrr/Arduino.svg)](https://ci.appveyor.com/project/igrr/Arduino) | [arduino-1.6.1-p1-windows.zip](https://github.com/igrr/Arduino/releases/download/1.6.1-esp8266-1/arduino-1.6.1-p1-windows.zip) | [appveyor 64Bit Build](https://ci.appveyor.com/project/igrr/Arduino/build/artifacts) |
| OS X | | [arduino-1.6.1-macosx-java-latest-signed.zip](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-macosx-java-latest-signed.zip) | |
@ -181,8 +181,48 @@ Libraries that don't rely on low-level access to AVR registers should work well.
#### Upload via serial port ####
Pick the correct serial port.
You need to put ESP8266 into bootloader mode before uploading code (pull GPIO0 low and
toggle power).
You need to put ESP8266 into bootloader mode before uploading code.
#### Minimal hardware Setup for Bootloading and usage ####
ESPxx Hardware
| PIN | Resistor | Serial Adapter |
| ------------- | -------- | -------------- |
| VCC | | VCC (3.3V) |
| GND | | GND |
| TX or GPIO2* | | RX |
| RX | | TX |
| GPIO0 | PullUp | DTR |
| Reset* | | RTS |
| GPIO15* | PullDown | |
| CH_PD | PullUp | |
* Note
- GPIO15 is also named MTDO
- Reset is also named RSBT or REST (adding PullUp improves the stability of the Module)
- GPIO2 is alternative TX for the boot loader mode
ESP01 example:
![ESP01 connect](https://raw.githubusercontent.com/Links2004/Arduino/esp8266/docs/ESP01_connect.jpg)
#### Minimal hardware Setup for Bootloading only ####
ESPxx Hardware
| PIN | Resistor | Serial Adapter |
| ------------- | -------- | -------------- |
| VCC | | VCC (3.3V) |
| GND | | GND |
| TX or GPIO2 | | RX |
| RX | | TX |
| GPIO0 | | GND |
| Reset | | RTS* |
| GPIO15 | PullDown | |
| CH_PD | PullUp | |
* Note
- if no RTS is used a manual power toggle is needed
### Issues and support ###

View File

@ -1,6 +1,7 @@
menu.UploadSpeed=Upload Speed
menu.CpuFrequency=CPU Frequency
menu.FlashSize=Flash size
##############################################################
generic.name=Generic ESP8266 Module
@ -56,6 +57,52 @@ generic.menu.FlashSize.2M.build.flash_size=2M
generic.menu.FlashSize.4M=4M
generic.menu.FlashSize.4M.build.flash_size=4M
##############################################################
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
modwifi.upload.tool=esptool
modwifi.upload.speed=115200
modwifi.upload.resetmethod=ck
modwifi.upload.maximum_size=2097152
modwifi.upload.wait_for_upload_port=true
modwifi.serial.disableDTR=true
modwifi.serial.disableRTS=true
modwifi.build.mcu=esp8266
modwifi.build.f_cpu=80000000L
modwifi.build.board=MOD_WIFI_ESP8266
modwifi.build.core=esp8266
modwifi.build.variant=generic
# Winbond W25Q16 flash
modwifi.build.flash_mode=qio
modwifi.build.flash_size=2M
modwifi.build.flash_freq=40
modwifi.menu.CpuFrequency.80=80 MHz
modwifi.menu.CpuFrequency.80.build.f_cpu=80000000L
modwifi.menu.CpuFrequency.160=160 MHz
modwifi.menu.CpuFrequency.160.build.f_cpu=160000000L
modwifi.menu.UploadSpeed.115200=115200
modwifi.menu.UploadSpeed.115200.upload.speed=115200
modwifi.menu.UploadSpeed.9600=9600
modwifi.menu.UploadSpeed.9600.upload.speed=9600
modwifi.menu.UploadSpeed.57600=57600
modwifi.menu.UploadSpeed.57600.upload.speed=57600
modwifi.menu.UploadSpeed.256000.windows=256000
modwifi.menu.UploadSpeed.256000.upload.speed=256000
modwifi.menu.UploadSpeed.230400.linux=230400
modwifi.menu.UploadSpeed.230400.macosx=230400
modwifi.menu.UploadSpeed.230400.macosx=230400
modwifi.menu.UploadSpeed.230400.upload.speed=230400
modwifi.menu.UploadSpeed.460800.linux=460800
modwifi.menu.UploadSpeed.460800.macosx=460800
modwifi.menu.UploadSpeed.460800.upload.speed=460800
modwifi.menu.UploadSpeed.512000.windows=512000
modwifi.menu.UploadSpeed.512000.upload.speed=512000
modwifi.menu.UploadSpeed.921600=921600
modwifi.menu.UploadSpeed.921600.upload.speed=921600
##############################################################
nodemcu.name=NodeMCU (ESP8266 ESP-12 Module)

View File

@ -132,7 +132,7 @@ static uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C,
#define T1I ESP8266_REG(0x60C) //Interrupt Status Register (1bit) write to clear
//edge interrupt enable register
#define TEIE ESP8266_DREG(0x04)
#define TEIE1 0x02 //it for timer 1
#define TEIE1 0x02 //bit for timer 1
//Timer 2 Registers (32bit CountUp Timer)
#define T2L ESP8266_REG(0x620) //Load Value (Starting Value of Counter)

1157
doc/rgisters_dump.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,161 @@
/*
SDWebServer - Example WebServer with SD Card backend for esp8266
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
This file is part of the ESP8266WebServer library for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Have a FAT Formatted SD Card connected to the SPI port of the ESP8266
The web root is the SD Card root folder
File extensions with more than 3 charecters are not supported by the SD Library
File Names longer than 8 charecters will be truncated by the SD library, so keep filenames shorter
index.htm is the default index (works on subfolders as well)
*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <SPI.h>
#include <SD.h>
//do not go larger than 1460 bytes as that is the maximum that could fit in a packet
#define WWW_BUF_SIZE 1460
const char* ssid = "**********";
const char* password = "**********";
const char* hostname = "esp8266sd";
MDNSResponder mdns;
ESP8266WebServer server(80);
static bool hasSD = false;
bool loadFromSdCard(String path){
String dataType = "text/plain";
//handle default index
if(path.endsWith("/")) path += "index.htm";
//set proper Content-Type for the most common extensions
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
else if(path.endsWith(".htm")) dataType = "text/html";
else if(path.endsWith(".css")) dataType = "text/css";
else if(path.endsWith(".js")) dataType = "application/javascript";
else if(path.endsWith(".png")) dataType = "image/png";
else if(path.endsWith(".gif")) dataType = "image/gif";
else if(path.endsWith(".jpg")) dataType = "image/jpeg";
else if(path.endsWith(".ico")) dataType = "image/x-icon";
else if(path.endsWith(".xml")) dataType = "text/xml";
else if(path.endsWith(".pdf")) dataType = "application/pdf";
else if(path.endsWith(".zip")) dataType = "application/zip";
//Try to open the file
File dataFile = SD.open(path.c_str());
//if it's a folder, try to open the default index
if(dataFile && dataFile.isDirectory()){
path += "/index.htm";
dataType = "text/html";
dataFile = SD.open(path.c_str());
}
//and finally if the file exists, stream the content to the client
if (dataFile) {
WiFiClient client = server.client();
//send the file headers
String head = "HTTP/1.1 200 OK\r\nContent-Type: ";
head += dataType;
head += "\r\nContent-Length: ";
head += dataFile.size();
head += "\r\n\r\n";
client.print(head);
//partition the data packets to fit in a TCP packet (1460 bytes MAX)
uint8_t obuf[WWW_BUF_SIZE];
while (dataFile.available() > WWW_BUF_SIZE){
dataFile.read(obuf, WWW_BUF_SIZE);
client.write(obuf, WWW_BUF_SIZE);
}
//stream the last data left (size is at most WWW_BUF_SIZE bytes)
uint16_t leftLen = dataFile.available();
dataFile.read(obuf, leftLen);
client.write(obuf, leftLen);
dataFile.close();
return true;
}
return false;
}
void tryLoadFromSdCard(){
String message = "FileNotFound\n\n";
if(hasSD){
//try to load the URL from SD Card
if(loadFromSdCard(server.uri())) return;
} else {
message = "SDCARD Not Detected\n\n";
}
server.send(404, "text/plain", message);
}
void setup(void){
uint8_t i = 0;
Serial.begin(115200);
//setup WiFi
WiFi.begin(ssid, password);
Serial.print("\nConnecting to ");
Serial.println(ssid);
//wait for WiFi to connect
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
//check if we have connected?
if(i == 20){
Serial.print("Could not connect to");
Serial.println(ssid);
//stop execution and wait forever
while(1) delay(500);
}
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
//start mDNS Server
if (mdns.begin(hostname, WiFi.localIP())) {
Serial.println("MDNS responder started");
Serial.print("You can now connect to http://");
Serial.print(hostname);
Serial.println(".local");
}
//Attach handler
server.onNotFound(tryLoadFromSdCard);
//start server
server.begin();
Serial.println("HTTP server started");
//init SD Card
if (SD.begin(SS)){
Serial.println("SD Card initialized.");
hasSD = true;
}
}
void loop(void){
mdns.update();
server.handleClient();
}

View File

@ -169,6 +169,7 @@ class ClientContext {
_size_sent = will_send;
DEBUGV(":wr\r\n");
tcp_output( _pcb );
_send_waiting = true;
delay(5000); // max send timeout
_send_waiting = false;