mirror of https://github.com/arendst/Tasmota.git
Merge pull request #9826 from Staars/development
OneWire: silence compiler warning, do not redefine global function
This commit is contained in:
commit
26224b5f0d
|
@ -152,9 +152,12 @@ sample code bearing this copyright.
|
||||||
|
|
||||||
#include "OneWire.h"
|
#include "OneWire.h"
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ESP32
|
||||||
#define noInterrupts() {portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;portENTER_CRITICAL(&mux)
|
#define t_noInterrupts() {portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;portENTER_CRITICAL(&mux)
|
||||||
#define interrupts() portEXIT_CRITICAL(&mux);}
|
#define t_interrupts() portEXIT_CRITICAL(&mux);}
|
||||||
|
#else
|
||||||
|
#define t_noInterrupts noInterrupts
|
||||||
|
#define t_interrupts interrupts
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OneWire::OneWire(uint8_t pin)
|
OneWire::OneWire(uint8_t pin)
|
||||||
|
@ -184,23 +187,23 @@ uint8_t OneWire::reset(void)
|
||||||
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
|
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
uint8_t retries = 125;
|
uint8_t retries = 125;
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_MODE_INPUT(reg, mask);
|
DIRECT_MODE_INPUT(reg, mask);
|
||||||
interrupts();
|
t_interrupts();
|
||||||
// wait until the wire is high... just in case
|
// wait until the wire is high... just in case
|
||||||
do {
|
do {
|
||||||
if (--retries == 0) return 0;
|
if (--retries == 0) return 0;
|
||||||
delayMicroseconds(2);
|
delayMicroseconds(2);
|
||||||
} while ( !DIRECT_READ(reg, mask));
|
} while ( !DIRECT_READ(reg, mask));
|
||||||
|
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_WRITE_LOW(reg, mask);
|
DIRECT_WRITE_LOW(reg, mask);
|
||||||
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
|
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
|
||||||
delayMicroseconds(480);
|
delayMicroseconds(480);
|
||||||
DIRECT_MODE_INPUT(reg, mask); // allow it to float
|
DIRECT_MODE_INPUT(reg, mask); // allow it to float
|
||||||
delayMicroseconds(70);
|
delayMicroseconds(70);
|
||||||
r = !DIRECT_READ(reg, mask);
|
r = !DIRECT_READ(reg, mask);
|
||||||
interrupts();
|
t_interrupts();
|
||||||
delayMicroseconds(410);
|
delayMicroseconds(410);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -219,20 +222,20 @@ void OneWire::write_bit(uint8_t v)
|
||||||
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
|
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
|
||||||
|
|
||||||
if (v & 1) {
|
if (v & 1) {
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_WRITE_LOW(reg, mask);
|
DIRECT_WRITE_LOW(reg, mask);
|
||||||
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
|
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
|
||||||
delayMicroseconds(10);
|
delayMicroseconds(10);
|
||||||
DIRECT_WRITE_HIGH(reg, mask); // drive output high
|
DIRECT_WRITE_HIGH(reg, mask); // drive output high
|
||||||
interrupts();
|
t_interrupts();
|
||||||
delayMicroseconds(55);
|
delayMicroseconds(55);
|
||||||
} else {
|
} else {
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_WRITE_LOW(reg, mask);
|
DIRECT_WRITE_LOW(reg, mask);
|
||||||
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
|
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
|
||||||
delayMicroseconds(65);
|
delayMicroseconds(65);
|
||||||
DIRECT_WRITE_HIGH(reg, mask); // drive output high
|
DIRECT_WRITE_HIGH(reg, mask); // drive output high
|
||||||
interrupts();
|
t_interrupts();
|
||||||
delayMicroseconds(5);
|
delayMicroseconds(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,14 +254,14 @@ uint8_t OneWire::read_bit(void)
|
||||||
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
|
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
|
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_MODE_OUTPUT(reg, mask);
|
DIRECT_MODE_OUTPUT(reg, mask);
|
||||||
DIRECT_WRITE_LOW(reg, mask);
|
DIRECT_WRITE_LOW(reg, mask);
|
||||||
delayMicroseconds(3);
|
delayMicroseconds(3);
|
||||||
DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise
|
DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise
|
||||||
delayMicroseconds(10);
|
delayMicroseconds(10);
|
||||||
r = DIRECT_READ(reg, mask);
|
r = DIRECT_READ(reg, mask);
|
||||||
interrupts();
|
t_interrupts();
|
||||||
delayMicroseconds(53);
|
delayMicroseconds(53);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -277,10 +280,10 @@ void OneWire::write(uint8_t v, uint8_t power /* = 0 */) {
|
||||||
OneWire::write_bit( (bitMask & v)?1:0);
|
OneWire::write_bit( (bitMask & v)?1:0);
|
||||||
}
|
}
|
||||||
if ( !power) {
|
if ( !power) {
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_MODE_INPUT(baseReg, bitmask);
|
DIRECT_MODE_INPUT(baseReg, bitmask);
|
||||||
DIRECT_WRITE_LOW(baseReg, bitmask);
|
DIRECT_WRITE_LOW(baseReg, bitmask);
|
||||||
interrupts();
|
t_interrupts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +291,10 @@ void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0
|
||||||
for (uint16_t i = 0 ; i < count ; i++)
|
for (uint16_t i = 0 ; i < count ; i++)
|
||||||
write(buf[i]);
|
write(buf[i]);
|
||||||
if (!power) {
|
if (!power) {
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_MODE_INPUT(baseReg, bitmask);
|
DIRECT_MODE_INPUT(baseReg, bitmask);
|
||||||
DIRECT_WRITE_LOW(baseReg, bitmask);
|
DIRECT_WRITE_LOW(baseReg, bitmask);
|
||||||
interrupts();
|
t_interrupts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,9 +338,9 @@ void OneWire::skip()
|
||||||
|
|
||||||
void OneWire::depower()
|
void OneWire::depower()
|
||||||
{
|
{
|
||||||
noInterrupts();
|
t_noInterrupts();
|
||||||
DIRECT_MODE_INPUT(baseReg, bitmask);
|
DIRECT_MODE_INPUT(baseReg, bitmask);
|
||||||
interrupts();
|
t_interrupts();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ONEWIRE_SEARCH
|
#if ONEWIRE_SEARCH
|
||||||
|
@ -615,11 +618,4 @@ uint16_t OneWire::crc16(const uint8_t* input, uint16_t len, uint16_t crc)
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
|
||||||
#undef noInterrupts()
|
|
||||||
#undef interrupts()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue