mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-28 16:57:16 +00:00
updata tasmota serial, add sml driver
This commit is contained in:
parent
022df89950
commit
e96bf9af4e
0
lib/TasmotaSerial-2.3.1/README.md → lib/TasmotaSerial-2.3.2/README.md
Normal file → Executable file
0
lib/TasmotaSerial-2.3.1/README.md → lib/TasmotaSerial-2.3.2/README.md
Normal file → Executable file
0
lib/TasmotaSerial-2.3.1/examples/swsertest/swsertest.ino → lib/TasmotaSerial-2.3.2/examples/swsertest/swsertest.ino
Normal file → Executable file
0
lib/TasmotaSerial-2.3.1/examples/swsertest/swsertest.ino → lib/TasmotaSerial-2.3.2/examples/swsertest/swsertest.ino
Normal file → Executable file
0
lib/TasmotaSerial-2.3.1/keywords.txt → lib/TasmotaSerial-2.3.2/keywords.txt
Normal file → Executable file
0
lib/TasmotaSerial-2.3.1/keywords.txt → lib/TasmotaSerial-2.3.2/keywords.txt
Normal file → Executable file
2
lib/TasmotaSerial-2.3.1/library.json → lib/TasmotaSerial-2.3.2/library.json
Normal file → Executable file
2
lib/TasmotaSerial-2.3.1/library.json → lib/TasmotaSerial-2.3.2/library.json
Normal file → Executable file
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TasmotaSerial",
|
"name": "TasmotaSerial",
|
||||||
"version": "2.3.0",
|
"version": "2.3.2",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"serial", "io", "TasmotaSerial"
|
"serial", "io", "TasmotaSerial"
|
||||||
],
|
],
|
2
lib/TasmotaSerial-2.3.1/library.properties → lib/TasmotaSerial-2.3.2/library.properties
Normal file → Executable file
2
lib/TasmotaSerial-2.3.1/library.properties → lib/TasmotaSerial-2.3.2/library.properties
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
name=TasmotaSerial
|
name=TasmotaSerial
|
||||||
version=2.3.0
|
version=2.3.2
|
||||||
author=Theo Arends
|
author=Theo Arends
|
||||||
maintainer=Theo Arends <theo@arends.com>
|
maintainer=Theo Arends <theo@arends.com>
|
||||||
sentence=Implementation of software serial with hardware serial fallback for ESP8266.
|
sentence=Implementation of software serial with hardware serial fallback for ESP8266.
|
66
lib/TasmotaSerial-2.3.1/src/TasmotaSerial.cpp → lib/TasmotaSerial-2.3.2/src/TasmotaSerial.cpp
Normal file → Executable file
66
lib/TasmotaSerial-2.3.1/src/TasmotaSerial.cpp → lib/TasmotaSerial-2.3.2/src/TasmotaSerial.cpp
Normal file → Executable file
@ -76,12 +76,13 @@ static void (*ISRList[16])() = {
|
|||||||
tms_isr_15
|
tms_isr_15
|
||||||
};
|
};
|
||||||
|
|
||||||
TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback)
|
TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode)
|
||||||
{
|
{
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
m_hardserial = 0;
|
m_hardserial = 0;
|
||||||
m_hardswap = 0;
|
m_hardswap = 0;
|
||||||
m_stop_bits = 1;
|
m_stop_bits = 1;
|
||||||
|
m_nwmode = nwmode;
|
||||||
if (!((isValidGPIOpin(receive_pin)) && (isValidGPIOpin(transmit_pin) || transmit_pin == 16))) {
|
if (!((isValidGPIOpin(receive_pin)) && (isValidGPIOpin(transmit_pin) || transmit_pin == 16))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,7 +104,8 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal
|
|||||||
m_bit_time = ESP.getCpuFreqMHz() * 1000000 / TM_SERIAL_BAUDRATE;
|
m_bit_time = ESP.getCpuFreqMHz() * 1000000 / TM_SERIAL_BAUDRATE;
|
||||||
pinMode(m_rx_pin, INPUT);
|
pinMode(m_rx_pin, INPUT);
|
||||||
tms_obj_list[m_rx_pin] = this;
|
tms_obj_list[m_rx_pin] = this;
|
||||||
attachInterrupt(m_rx_pin, ISRList[m_rx_pin], FALLING);
|
if (m_nwmode) attachInterrupt(m_rx_pin, ISRList[m_rx_pin], CHANGE);
|
||||||
|
else attachInterrupt(m_rx_pin, ISRList[m_rx_pin], FALLING);
|
||||||
}
|
}
|
||||||
if (m_tx_pin > -1) {
|
if (m_tx_pin > -1) {
|
||||||
pinMode(m_tx_pin, OUTPUT);
|
pinMode(m_tx_pin, OUTPUT);
|
||||||
@ -240,6 +242,7 @@ void ICACHE_RAM_ATTR TasmotaSerial::rxRead()
|
|||||||
void TasmotaSerial::rxRead()
|
void TasmotaSerial::rxRead()
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
if (!m_nwmode) {
|
||||||
// Advance the starting point for the samples but compensate for the
|
// Advance the starting point for the samples but compensate for the
|
||||||
// initial delay which occurs before the interrupt is delivered
|
// initial delay which occurs before the interrupt is delivered
|
||||||
unsigned long wait = m_bit_time + m_bit_time/3 - 500;
|
unsigned long wait = m_bit_time + m_bit_time/3 - 500;
|
||||||
@ -265,4 +268,63 @@ void TasmotaSerial::rxRead()
|
|||||||
// Must clear this bit in the interrupt register,
|
// Must clear this bit in the interrupt register,
|
||||||
// it gets set even when interrupts are disabled
|
// it gets set even when interrupts are disabled
|
||||||
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rx_pin);
|
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rx_pin);
|
||||||
|
} else {
|
||||||
|
uint8_t diff;
|
||||||
|
uint8_t level;
|
||||||
|
|
||||||
|
#define LASTBIT 9
|
||||||
|
|
||||||
|
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rx_pin);
|
||||||
|
|
||||||
|
level=digitalRead(m_rx_pin);
|
||||||
|
|
||||||
|
if (!level && !ss_index) {
|
||||||
|
// start condition
|
||||||
|
ss_bstart=ESP.getCycleCount()-(m_bit_time/4);
|
||||||
|
ss_byte=0;
|
||||||
|
ss_index++;
|
||||||
|
//digitalWrite(1, LOW);
|
||||||
|
} else {
|
||||||
|
// now any bit changes go here
|
||||||
|
// calc bit number
|
||||||
|
diff=(ESP.getCycleCount()-ss_bstart)/m_bit_time;
|
||||||
|
//digitalWrite(1, level);
|
||||||
|
|
||||||
|
if (!level && diff>LASTBIT) {
|
||||||
|
// start bit of next byte, store and restart
|
||||||
|
// leave irq at change
|
||||||
|
for (uint8_t i=ss_index;i<=LASTBIT;i++) {
|
||||||
|
ss_byte|=(1<<i);
|
||||||
|
}
|
||||||
|
//stobyte(0,ssp->ss_byte>>1);
|
||||||
|
unsigned int next = (m_in_pos+1) % TM_SERIAL_BUFFER_SIZE;
|
||||||
|
if (next != (int)m_out_pos) {
|
||||||
|
m_buffer[m_in_pos] = ss_byte>>1;
|
||||||
|
m_in_pos = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss_bstart=ESP.getCycleCount()-(m_bit_time/4);
|
||||||
|
ss_byte=0;
|
||||||
|
ss_index=1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (diff>=LASTBIT) {
|
||||||
|
// bit zero was 0,
|
||||||
|
//stobyte(0,ssp->ss_byte>>1);
|
||||||
|
unsigned int next = (m_in_pos+1) % TM_SERIAL_BUFFER_SIZE;
|
||||||
|
if (next != (int)m_out_pos) {
|
||||||
|
m_buffer[m_in_pos] = ss_byte>>1;
|
||||||
|
m_in_pos = next;
|
||||||
|
}
|
||||||
|
ss_byte=0;
|
||||||
|
ss_index=0;
|
||||||
|
} else {
|
||||||
|
// shift in
|
||||||
|
for (uint8_t i=ss_index;i<diff;i++) {
|
||||||
|
if (!level) ss_byte|=(1<<i);
|
||||||
|
}
|
||||||
|
ss_index=diff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
6
lib/TasmotaSerial-2.3.1/src/TasmotaSerial.h → lib/TasmotaSerial-2.3.2/src/TasmotaSerial.h
Normal file → Executable file
6
lib/TasmotaSerial-2.3.1/src/TasmotaSerial.h → lib/TasmotaSerial-2.3.2/src/TasmotaSerial.h
Normal file → Executable file
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
class TasmotaSerial : public Stream {
|
class TasmotaSerial : public Stream {
|
||||||
public:
|
public:
|
||||||
TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0);
|
TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0,int nwmode = 0);
|
||||||
virtual ~TasmotaSerial();
|
virtual ~TasmotaSerial();
|
||||||
|
|
||||||
bool begin(long speed, int stop_bits = 1);
|
bool begin(long speed, int stop_bits = 1);
|
||||||
@ -61,12 +61,16 @@ class TasmotaSerial : public Stream {
|
|||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
|
bool m_nwmode;
|
||||||
bool m_hardserial;
|
bool m_hardserial;
|
||||||
bool m_hardswap;
|
bool m_hardswap;
|
||||||
bool m_high_speed;
|
bool m_high_speed;
|
||||||
int m_rx_pin;
|
int m_rx_pin;
|
||||||
int m_tx_pin;
|
int m_tx_pin;
|
||||||
int m_stop_bits;
|
int m_stop_bits;
|
||||||
|
int ss_byte;
|
||||||
|
unsigned long ss_bstart;
|
||||||
|
int ss_index;
|
||||||
unsigned long m_bit_time;
|
unsigned long m_bit_time;
|
||||||
unsigned int m_in_pos;
|
unsigned int m_in_pos;
|
||||||
unsigned int m_out_pos;
|
unsigned int m_out_pos;
|
2094
sonoff/xsns_53_sml.ino
Normal file
2094
sonoff/xsns_53_sml.ino
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user