mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Merge pull request #171 from Links2004/esp8266
OneWire INPUT_PULLUP, cli and sei, add SPIClass::transfer16
This commit is contained in:
14
README.md
14
README.md
@ -5,11 +5,11 @@ This project brings support for ESP8266 chip to the Arduino environment. ESP8266
|
|||||||
|
|
||||||
### Downloads ###
|
### Downloads ###
|
||||||
|
|
||||||
| OS | Build status | Latest release |
|
| OS | Build status | Latest release | Alpha Version |
|
||||||
| --- | ------------ | -------------- |
|
| --- | ------------ | -------------- | --------------- |
|
||||||
| Linux | [](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) |
|
| Linux | [](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 | [](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) |
|
| Windows | [](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) |
|
||||||
| 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) |
|
| 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) | |
|
||||||
|
|
||||||
|
|
||||||
### Building from source ###
|
### Building from source ###
|
||||||
@ -44,6 +44,10 @@ Pin interrupts are supported through ```attachInterrupt```, ```detachInterrupt``
|
|||||||
Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt
|
Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt
|
||||||
types are supported: ```CHANGE```, ```RISING```, ```FALLING```.
|
types are supported: ```CHANGE```, ```RISING```, ```FALLING```.
|
||||||
|
|
||||||
|
#### Pin Functions ####
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### Timing and delays ####
|
#### Timing and delays ####
|
||||||
```millis``` and ```micros``` return the number of milliseconds and microseconds elapsed after reset, respectively.
|
```millis``` and ```micros``` return the number of milliseconds and microseconds elapsed after reset, respectively.
|
||||||
|
|
||||||
|
BIN
docs/ESP01_connect.jpg
Normal file
BIN
docs/ESP01_connect.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
BIN
docs/pin_functions.png
Normal file
BIN
docs/pin_functions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 KiB |
@ -42,6 +42,9 @@ typedef enum {
|
|||||||
#define wdt_disable() ESP.wdtDisable()
|
#define wdt_disable() ESP.wdtDisable()
|
||||||
#define wdt_reset() ESP.wdtFeed()
|
#define wdt_reset() ESP.wdtFeed()
|
||||||
|
|
||||||
|
#define cli() ets_intr_lock() // IRQ Disable
|
||||||
|
#define sei() ets_intr_unlock() // IRQ Enable
|
||||||
|
|
||||||
enum WakeMode {
|
enum WakeMode {
|
||||||
WAKE_RF_DEFAULT = 0, // RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
|
WAKE_RF_DEFAULT = 0, // RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
|
||||||
WAKE_RFCAL = 1, // RF_CAL after deep-sleep wake up, there will be large current.
|
WAKE_RFCAL = 1, // RF_CAL after deep-sleep wake up, there will be large current.
|
||||||
|
@ -57,7 +57,7 @@ void SPIClass::setDataMode(uint8_t dataMode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SPIClass::setBitOrder(uint8_t bitOrder) {
|
void SPIClass::setBitOrder(uint8_t bitOrder) {
|
||||||
if (bitOrder == MSBFIRST){
|
if (bitOrder == MSBFIRST) {
|
||||||
SPI1C &= ~(SPICWBO | SPICRBO);
|
SPI1C &= ~(SPICWBO | SPICRBO);
|
||||||
} else {
|
} else {
|
||||||
SPI1C |= (SPICWBO | SPICRBO);
|
SPI1C |= (SPICWBO | SPICRBO);
|
||||||
@ -76,3 +76,25 @@ uint8_t SPIClass::transfer(uint8_t data) {
|
|||||||
return (uint8_t)(SPI1W0 & 0xff);
|
return (uint8_t)(SPI1W0 & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t SPIClass::transfer16(uint16_t data) {
|
||||||
|
union {
|
||||||
|
uint16_t val;
|
||||||
|
struct {
|
||||||
|
uint8_t lsb;
|
||||||
|
uint8_t msb;
|
||||||
|
};
|
||||||
|
} in, out;
|
||||||
|
in.val = data;
|
||||||
|
|
||||||
|
if((SPI1C & (SPICWBO | SPICRBO))) {
|
||||||
|
//MSBFIRST
|
||||||
|
out.msb = transfer(in.msb);
|
||||||
|
out.lsb = transfer(in.lsb);
|
||||||
|
} else {
|
||||||
|
//LSBFIRST
|
||||||
|
out.lsb = transfer(in.lsb);
|
||||||
|
out.msb = transfer(in.msb);
|
||||||
|
}
|
||||||
|
return out.val;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
void setClockDivider(uint32_t clockDiv);
|
void setClockDivider(uint32_t clockDiv);
|
||||||
void beginTransaction(SPISettings settings);
|
void beginTransaction(SPISettings settings);
|
||||||
uint8_t transfer(uint8_t data);
|
uint8_t transfer(uint8_t data);
|
||||||
|
uint16_t transfer16(uint16_t data);
|
||||||
void endTransaction(void);
|
void endTransaction(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ sample code bearing this copyright.
|
|||||||
|
|
||||||
OneWire::OneWire(uint8_t pin)
|
OneWire::OneWire(uint8_t pin)
|
||||||
{
|
{
|
||||||
pinMode(pin, INPUT);
|
pinMode(pin, INPUT_PULLUP);
|
||||||
bitmask = PIN_TO_BITMASK(pin);
|
bitmask = PIN_TO_BITMASK(pin);
|
||||||
baseReg = PIN_TO_BASEREG(pin);
|
baseReg = PIN_TO_BASEREG(pin);
|
||||||
#if ONEWIRE_SEARCH
|
#if ONEWIRE_SEARCH
|
||||||
|
Reference in New Issue
Block a user