Skip to content

Commit 0ae75a3

Browse files
committed
Merge pull request #171 from Links2004/esp8266
OneWire INPUT_PULLUP, cli and sei, add SPIClass::transfer16
2 parents 245ba5b + 4f3b273 commit 0ae75a3

File tree

7 files changed

+37
-7
lines changed

7 files changed

+37
-7
lines changed

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ This project brings support for ESP8266 chip to the Arduino environment. ESP8266
55

66
### Downloads ###
77

8-
| OS | Build status | Latest release |
9-
| --- | ------------ | -------------- |
10-
| 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) |
11-
| 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) |
12-
| 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) |
8+
| OS | Build status | Latest release | Alpha Version |
9+
| --- | ------------ | -------------- | --------------- |
10+
| 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) | |
11+
| 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) |
12+
| 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) | |
1313

1414

1515
### Building from source ###
@@ -44,6 +44,10 @@ Pin interrupts are supported through ```attachInterrupt```, ```detachInterrupt``
4444
Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt
4545
types are supported: ```CHANGE```, ```RISING```, ```FALLING```.
4646

47+
#### Pin Functions ####
48+
49+
![Pin Functions](https://raw.githubusercontent.com/Links2004/Arduino/esp8266/docs/pin_functions.png)
50+
4751
#### Timing and delays ####
4852
```millis``` and ```micros``` return the number of milliseconds and microseconds elapsed after reset, respectively.
4953

docs/ESP01_connect.jpg

39.5 KB
Loading

docs/pin_functions.png

174 KB
Loading

hardware/esp8266com/esp8266/cores/esp8266/Esp.h

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ typedef enum {
4242
#define wdt_disable() ESP.wdtDisable()
4343
#define wdt_reset() ESP.wdtFeed()
4444

45+
#define cli() ets_intr_lock() // IRQ Disable
46+
#define sei() ets_intr_unlock() // IRQ Enable
47+
4548
enum WakeMode {
4649
WAKE_RF_DEFAULT = 0, // RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
4750
WAKE_RFCAL = 1, // RF_CAL after deep-sleep wake up, there will be large current.

hardware/esp8266com/esp8266/libraries/SPI/SPI.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void SPIClass::setDataMode(uint8_t dataMode) {
5757
}
5858

5959
void SPIClass::setBitOrder(uint8_t bitOrder) {
60-
if (bitOrder == MSBFIRST){
60+
if (bitOrder == MSBFIRST) {
6161
SPI1C &= ~(SPICWBO | SPICRBO);
6262
} else {
6363
SPI1C |= (SPICWBO | SPICRBO);
@@ -76,3 +76,25 @@ uint8_t SPIClass::transfer(uint8_t data) {
7676
return (uint8_t)(SPI1W0 & 0xff);
7777
}
7878

79+
uint16_t SPIClass::transfer16(uint16_t data) {
80+
union {
81+
uint16_t val;
82+
struct {
83+
uint8_t lsb;
84+
uint8_t msb;
85+
};
86+
} in, out;
87+
in.val = data;
88+
89+
if((SPI1C & (SPICWBO | SPICRBO))) {
90+
//MSBFIRST
91+
out.msb = transfer(in.msb);
92+
out.lsb = transfer(in.lsb);
93+
} else {
94+
//LSBFIRST
95+
out.lsb = transfer(in.lsb);
96+
out.msb = transfer(in.msb);
97+
}
98+
return out.val;
99+
}
100+

hardware/esp8266com/esp8266/libraries/SPI/SPI.h

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class SPIClass {
8080
void setClockDivider(uint32_t clockDiv);
8181
void beginTransaction(SPISettings settings);
8282
uint8_t transfer(uint8_t data);
83+
uint16_t transfer16(uint16_t data);
8384
void endTransaction(void);
8485
};
8586

libraries/OneWire/OneWire.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ sample code bearing this copyright.
119119

120120
OneWire::OneWire(uint8_t pin)
121121
{
122-
pinMode(pin, INPUT);
122+
pinMode(pin, INPUT_PULLUP);
123123
bitmask = PIN_TO_BITMASK(pin);
124124
baseReg = PIN_TO_BASEREG(pin);
125125
#if ONEWIRE_SEARCH

0 commit comments

Comments
 (0)