1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-01 09:32:21 +01:00

Add ESP8266 core v2.6.2 (#905)

* Add ESP8266 core v2.6.2

* Upstream ESP8266 Wifi fixes

* Replace disable_interrupt with InterruptLock C++ class

* Update code to use InterruptLock

* Lint

* Update dht.cpp

* Improve InterruptLock docs, mark as ICACHE_RAM_ATTR

* Fixes
This commit is contained in:
Otto Winter
2019-12-04 19:30:10 +01:00
committed by GitHub
parent bba6d6897d
commit 7a6df38515
12 changed files with 291 additions and 180 deletions

View File

@@ -295,24 +295,25 @@ void ICACHE_RAM_ATTR HOT ESP8266SoftwareSerial::write_byte(uint8_t data) {
return;
}
disable_interrupts();
uint32_t wait = this->bit_time_;
const uint32_t start = ESP.getCycleCount();
// Start bit
this->write_bit_(false, &wait, start);
this->write_bit_(data & (1 << 0), &wait, start);
this->write_bit_(data & (1 << 1), &wait, start);
this->write_bit_(data & (1 << 2), &wait, start);
this->write_bit_(data & (1 << 3), &wait, start);
this->write_bit_(data & (1 << 4), &wait, start);
this->write_bit_(data & (1 << 5), &wait, start);
this->write_bit_(data & (1 << 6), &wait, start);
this->write_bit_(data & (1 << 7), &wait, start);
// Stop bit
this->write_bit_(true, &wait, start);
if (this->stop_bits_ == 2)
this->wait_(&wait, start);
enable_interrupts();
{
InterruptLock lock;
uint32_t wait = this->bit_time_;
const uint32_t start = ESP.getCycleCount();
// Start bit
this->write_bit_(false, &wait, start);
this->write_bit_(data & (1 << 0), &wait, start);
this->write_bit_(data & (1 << 1), &wait, start);
this->write_bit_(data & (1 << 2), &wait, start);
this->write_bit_(data & (1 << 3), &wait, start);
this->write_bit_(data & (1 << 4), &wait, start);
this->write_bit_(data & (1 << 5), &wait, start);
this->write_bit_(data & (1 << 6), &wait, start);
this->write_bit_(data & (1 << 7), &wait, start);
// Stop bit
this->write_bit_(true, &wait, start);
if (this->stop_bits_ == 2)
this->wait_(&wait, start);
}
}
void ICACHE_RAM_ATTR ESP8266SoftwareSerial::wait_(uint32_t *wait, const uint32_t &start) {
while (ESP.getCycleCount() - start < *wait)
@@ -323,7 +324,7 @@ bool ICACHE_RAM_ATTR ESP8266SoftwareSerial::read_bit_(uint32_t *wait, const uint
this->wait_(wait, start);
return this->rx_pin_->digital_read();
}
void ESP8266SoftwareSerial::write_bit_(bool bit, uint32_t *wait, const uint32_t &start) {
void ICACHE_RAM_ATTR ESP8266SoftwareSerial::write_bit_(bool bit, uint32_t *wait, const uint32_t &start) {
this->tx_pin_->digital_write(bit);
this->wait_(wait, start);
}