mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
remove emsuart debug messages
This commit is contained in:
@@ -924,7 +924,6 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
|||||||
// Assume at this point we have something that vaguely resembles a telegram in the format [src] [dest] [type] [offset] [data] [crc]
|
// Assume at this point we have something that vaguely resembles a telegram in the format [src] [dest] [type] [offset] [data] [crc]
|
||||||
// validate the CRC, if it's bad ignore it
|
// validate the CRC, if it's bad ignore it
|
||||||
if (telegram[length - 1] != _crcCalculator(telegram, length)) {
|
if (telegram[length - 1] != _crcCalculator(telegram, length)) {
|
||||||
LA_PULSE(200);
|
|
||||||
EMS_Sys_Status.emxCrcErr++;
|
EMS_Sys_Status.emxCrcErr++;
|
||||||
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
|
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
|
||||||
_debugPrintTelegram("Corrupt telegram: ", &EMS_RxTelegram, COLOR_RED, true);
|
_debugPrintTelegram("Corrupt telegram: ", &EMS_RxTelegram, COLOR_RED, true);
|
||||||
|
|||||||
62
src/ems.h
62
src/ems.h
@@ -4,7 +4,6 @@
|
|||||||
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
|
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
|
||||||
*
|
*
|
||||||
* See ChangeLog.md for history
|
* See ChangeLog.md for history
|
||||||
* See README.md for Acknowledgments
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,67 +12,8 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <list> // std::list
|
#include <list> // std::list
|
||||||
|
|
||||||
/* debug helper for logic analyzer
|
|
||||||
* create marker puls on GPIOx
|
|
||||||
* ° for Rx, we use GPIO14
|
|
||||||
* ° for Tx, we use GPIO12
|
|
||||||
*/
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#ifdef LOGICANALYZER
|
|
||||||
#define RX_MARK_PIN 14
|
|
||||||
#define TX_MARK_PIN 12
|
|
||||||
|
|
||||||
#define RX_MARK_MASK (1 << RX_MARK_PIN)
|
|
||||||
#define TX_MARK_MASK (1 << TX_MARK_PIN)
|
|
||||||
#define MARKERS_MASK (RX_MARK_PIN | TX_MARK_PIN)
|
|
||||||
|
|
||||||
#define GPIO_H(mask) (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, (mask)))
|
|
||||||
#define GPIO_L(mask) (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, (mask)))
|
|
||||||
|
|
||||||
#define RX_PULSE(pulse) \
|
|
||||||
do { \
|
|
||||||
GPIO_H(RX_MARK_MASK); \
|
|
||||||
delayMicroseconds(pulse); \
|
|
||||||
GPIO_L(RX_MARK_MASK); \
|
|
||||||
} while (0)
|
|
||||||
#define TX_PULSE(pulse) \
|
|
||||||
do { \
|
|
||||||
GPIO_H(TX_MARK_MASK); \
|
|
||||||
delayMicroseconds(pulse); \
|
|
||||||
GPIO_L(TX_MARK_MASK); \
|
|
||||||
} while (0)
|
|
||||||
#define LA_PULSE(pulse) \
|
|
||||||
do { \
|
|
||||||
GPIO_H(MARKERS_MASK); \
|
|
||||||
delayMicroseconds(pulse); \
|
|
||||||
GPIO_L(MARKERS_MASK); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define INIT_MARKERS(void) \
|
|
||||||
do { \
|
|
||||||
pinMode(RX_MARK_PIN, OUTPUT); \
|
|
||||||
pinMode(TX_MARK_PIN, OUTPUT); \
|
|
||||||
GPIO_L(MARKERS_MASK); \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
#define RX_PULSE(pulse) \
|
|
||||||
{}
|
|
||||||
#define TX_PULSE(pulse) \
|
|
||||||
{}
|
|
||||||
#define LA_PULSE(pulse) \
|
|
||||||
{}
|
|
||||||
#define INIT_MARKERS(void) \
|
|
||||||
{}
|
|
||||||
#define RX_MARK_MASK
|
|
||||||
#define TX_MARK_MASK
|
|
||||||
#define GPIO_H(mask)
|
|
||||||
#define GPIO_L(mask)
|
|
||||||
#endif
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// EMS tx_mode types
|
// EMS tx_mode types
|
||||||
#define EMS_TXMODE_DEFAULT 1 // Default (was previously known as tx_mode 2)
|
#define EMS_TXMODE_DEFAULT 1 // Default (was previously known as tx_mode 2 in v1.8.x)
|
||||||
#define EMS_TXMODE_EMSPLUS 2 // EMS+
|
#define EMS_TXMODE_EMSPLUS 2 // EMS+
|
||||||
#define EMS_TXMODE_HT3 3 // Junkers HT3
|
#define EMS_TXMODE_HT3 3 // Junkers HT3
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ static void emsuart_rx_intr_handler(void * para) {
|
|||||||
EMS_Sys_Status.emsRxStatus = EMS_RX_STATUS_BUSY; // status set to busy
|
EMS_Sys_Status.emsRxStatus = EMS_RX_STATUS_BUSY; // status set to busy
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
GPIO_H(RX_MARK_MASK);
|
|
||||||
// fill IRQ buffer, by emptying Rx FIFO
|
// fill IRQ buffer, by emptying Rx FIFO
|
||||||
if (USIS(EMSUART_UART) & ((1 << UIFF) | (1 << UITO) | (1 << UIBD))) {
|
if (USIS(EMSUART_UART) & ((1 << UIFF) | (1 << UITO) | (1 << UIBD))) {
|
||||||
while ((USS(EMSUART_UART) >> USRXC) & 0xFF) {
|
while ((USS(EMSUART_UART) >> USRXC) & 0xFF) {
|
||||||
@@ -41,7 +40,6 @@ static void emsuart_rx_intr_handler(void * para) {
|
|||||||
// clear Rx FIFO full and Rx FIFO timeout interrupts
|
// clear Rx FIFO full and Rx FIFO timeout interrupts
|
||||||
USIC(EMSUART_UART) = (1 << UIFF) | (1 << UITO);
|
USIC(EMSUART_UART) = (1 << UIFF) | (1 << UITO);
|
||||||
}
|
}
|
||||||
GPIO_L(RX_MARK_MASK);
|
|
||||||
|
|
||||||
// BREAK detection = End of EMS data block
|
// BREAK detection = End of EMS data block
|
||||||
if (USIS(EMSUART_UART) & ((1 << UIBD))) {
|
if (USIS(EMSUART_UART) & ((1 << UIBD))) {
|
||||||
@@ -55,7 +53,6 @@ static void emsuart_rx_intr_handler(void * para) {
|
|||||||
ETS_UART_INTR_ENABLE(); // re-enable UART interrupts
|
ETS_UART_INTR_ENABLE(); // re-enable UART interrupts
|
||||||
|
|
||||||
system_os_post(EMSUART_recvTaskPrio, 0, 0); // call emsuart_recvTask() at next opportunity
|
system_os_post(EMSUART_recvTaskPrio, 0, 0); // call emsuart_recvTask() at next opportunity
|
||||||
RX_PULSE(EMSUART_BIT_TIME / 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,13 +73,11 @@ static void ICACHE_FLASH_ATTR emsuart_recvTask(os_event_t * events) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (length == 2) {
|
if (length == 2) {
|
||||||
RX_PULSE(20);
|
|
||||||
// it's a poll or status code, single byte and ok to send on
|
// it's a poll or status code, single byte and ok to send on
|
||||||
ems_parseTelegram((uint8_t *)pCurrent->buffer, 1);
|
ems_parseTelegram((uint8_t *)pCurrent->buffer, 1);
|
||||||
} else if ((length > 4) && (length <= EMS_MAXBUFFERSIZE + 1)) {
|
} else if ((length > 4) && (length <= EMS_MAXBUFFERSIZE + 1)) {
|
||||||
// ignore double BRK at the end, possibly from the Tx loopback
|
// ignore double BRK at the end, possibly from the Tx loopback
|
||||||
// also telegrams with no data value
|
// also telegrams with no data value
|
||||||
RX_PULSE(40);
|
|
||||||
ems_parseTelegram((uint8_t *)pCurrent->buffer, length - 1); // transmit EMS buffer, excluding the BRK
|
ems_parseTelegram((uint8_t *)pCurrent->buffer, length - 1); // transmit EMS buffer, excluding the BRK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +183,6 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
|
|||||||
// To create a 11-bit <BRK> we set TXD_BRK bit so the break signal will
|
// To create a 11-bit <BRK> we set TXD_BRK bit so the break signal will
|
||||||
// automatically be sent when the tx fifo is empty
|
// automatically be sent when the tx fifo is empty
|
||||||
tmp = (1 << UCBRK);
|
tmp = (1 << UCBRK);
|
||||||
GPIO_H(TX_MARK_MASK);
|
|
||||||
USC0(EMSUART_UART) |= (tmp); // set bit
|
USC0(EMSUART_UART) |= (tmp); // set bit
|
||||||
|
|
||||||
if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_EMSPLUS) { // EMS+ mode
|
if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_EMSPLUS) { // EMS+ mode
|
||||||
@@ -198,7 +192,6 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
USC0(EMSUART_UART) &= ~(tmp); // clear bit
|
USC0(EMSUART_UART) &= ~(tmp); // clear bit
|
||||||
GPIO_L(TX_MARK_MASK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -212,18 +205,14 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
LA_PULSE(50);
|
|
||||||
|
|
||||||
if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_EMSPLUS) { // With extra tx delay for EMS+
|
if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_EMSPLUS) { // With extra tx delay for EMS+
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
TX_PULSE(EMSUART_BIT_TIME / 4);
|
|
||||||
USF(EMSUART_UART) = buf[i];
|
USF(EMSUART_UART) = buf[i];
|
||||||
delayMicroseconds(EMSUART_TX_BRK_WAIT); // https://github.com/proddy/EMS-ESP/issues/23#
|
delayMicroseconds(EMSUART_TX_BRK_WAIT); // https://github.com/proddy/EMS-ESP/issues/23#
|
||||||
}
|
}
|
||||||
emsuart_tx_brk(); // send <BRK>
|
emsuart_tx_brk(); // send <BRK>
|
||||||
} else if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_HT3) { // Junkers logic by @philrich
|
} else if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_HT3) { // Junkers logic by @philrich
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
TX_PULSE(EMSUART_BIT_TIME / 4);
|
|
||||||
USF(EMSUART_UART) = buf[i];
|
USF(EMSUART_UART) = buf[i];
|
||||||
|
|
||||||
// just to be safe wait for tx fifo empty (needed?)
|
// just to be safe wait for tx fifo empty (needed?)
|
||||||
@@ -256,11 +245,6 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
* We set EMS_Sys_Status.emsTxStatus to EMS_TX_BRK_DETECT and return
|
* We set EMS_Sys_Status.emsTxStatus to EMS_TX_BRK_DETECT and return
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// shorter busy poll...
|
|
||||||
#define EMSUART_BUSY_WAIT (EMSUART_BIT_TIME / 8)
|
|
||||||
#define EMS_TX_TO_CHARS (2 + 20)
|
|
||||||
#define EMS_TX_TO_COUNT ((EMS_TX_TO_CHARS)*10 * 8)
|
|
||||||
uint16_t wdc = EMS_TX_TO_COUNT;
|
uint16_t wdc = EMS_TX_TO_COUNT;
|
||||||
ETS_UART_INTR_DISABLE(); // disable rx interrupt
|
ETS_UART_INTR_DISABLE(); // disable rx interrupt
|
||||||
|
|
||||||
@@ -270,13 +254,10 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
|
|
||||||
// throw out the telegram...
|
// throw out the telegram...
|
||||||
for (uint8_t i = 0; i < len && result == EMS_TX_STATUS_OK;) {
|
for (uint8_t i = 0; i < len && result == EMS_TX_STATUS_OK;) {
|
||||||
GPIO_H(TX_MARK_MASK);
|
|
||||||
|
|
||||||
wdc = EMS_TX_TO_COUNT;
|
wdc = EMS_TX_TO_COUNT;
|
||||||
volatile uint8_t _usrxc = (USS(EMSUART_UART) >> USRXC) & 0xFF;
|
volatile uint8_t _usrxc = (USS(EMSUART_UART) >> USRXC) & 0xFF;
|
||||||
USF(EMSUART_UART) = buf[i++]; // send each Tx byte
|
USF(EMSUART_UART) = buf[i++]; // send each Tx byte
|
||||||
// wait for echo from busmaster
|
// wait for echo from busmaster
|
||||||
GPIO_L(TX_MARK_MASK);
|
|
||||||
while (((USS(EMSUART_UART) >> USRXC) & 0xFF) == _usrxc) {
|
while (((USS(EMSUART_UART) >> USRXC) & 0xFF) == _usrxc) {
|
||||||
delayMicroseconds(EMSUART_BUSY_WAIT); // burn CPU cycles...
|
delayMicroseconds(EMSUART_BUSY_WAIT); // burn CPU cycles...
|
||||||
if (--wdc == 0) {
|
if (--wdc == 0) {
|
||||||
@@ -294,18 +275,14 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
// on Rx-BRK (bus collision), we simply enable Rx and leave it
|
// on Rx-BRK (bus collision), we simply enable Rx and leave it
|
||||||
// otherwise we send the final Tx-BRK in the loopback and re=enable Rx-INT.
|
// otherwise we send the final Tx-BRK in the loopback and re=enable Rx-INT.
|
||||||
// worst case, we'll see an additional Rx-BRK...
|
// worst case, we'll see an additional Rx-BRK...
|
||||||
if (result != EMS_TX_STATUS_OK) {
|
if (result == EMS_TX_STATUS_OK) {
|
||||||
LA_PULSE(200); // mark Tx error
|
|
||||||
} else {
|
|
||||||
// neither bus collision nor timeout - send terminating BRK signal
|
// neither bus collision nor timeout - send terminating BRK signal
|
||||||
GPIO_H(TX_MARK_MASK);
|
|
||||||
if (!(USIS(EMSUART_UART) & (1 << UIBD))) {
|
if (!(USIS(EMSUART_UART) & (1 << UIBD))) {
|
||||||
// no bus collision - send terminating BRK signal
|
// no bus collision - send terminating BRK signal
|
||||||
USC0(EMSUART_UART) |= (1 << UCLBE) | (1 << UCBRK); // enable loopback & set <BRK>
|
USC0(EMSUART_UART) |= (1 << UCLBE) | (1 << UCBRK); // enable loopback & set <BRK>
|
||||||
|
|
||||||
// wait until BRK detected...
|
// wait until BRK detected...
|
||||||
while (!(USIR(EMSUART_UART) & (1 << UIBD))) {
|
while (!(USIR(EMSUART_UART) & (1 << UIBD))) {
|
||||||
// delayMicroseconds(EMSUART_BUSY_WAIT);
|
|
||||||
delayMicroseconds(EMSUART_BIT_TIME);
|
delayMicroseconds(EMSUART_BIT_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +290,6 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
|||||||
USIC(EMSUART_UART) = (1 << UIBD); // clear BRK detect IRQ
|
USIC(EMSUART_UART) = (1 << UIBD); // clear BRK detect IRQ
|
||||||
phantomBreak = 1;
|
phantomBreak = 1;
|
||||||
}
|
}
|
||||||
GPIO_L(TX_MARK_MASK);
|
|
||||||
}
|
}
|
||||||
ETS_UART_INTR_ENABLE(); // receive anything from FIFO...
|
ETS_UART_INTR_ENABLE(); // receive anything from FIFO...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,15 @@
|
|||||||
#define EMSUART_BIT_TIME 104 // bit time @9600 baud
|
#define EMSUART_BIT_TIME 104 // bit time @9600 baud
|
||||||
|
|
||||||
#define EMSUART_TX_BRK_WAIT 2070 // the BRK from Boiler master is roughly 1.039ms, so accounting for hardware lag using around 2078 (for half-duplex) - 8 (lag)
|
#define EMSUART_TX_BRK_WAIT 2070 // the BRK from Boiler master is roughly 1.039ms, so accounting for hardware lag using around 2078 (for half-duplex) - 8 (lag)
|
||||||
#define EMSUART_TX_WAIT_BYTE EMSUART_BIT_TIME * 10 // Time to send one Byte (8 Bits, 1 Start Bit, 1 Stop Bit)
|
#define EMSUART_TX_WAIT_BYTE (EMSUART_BIT_TIME * 10) // Time to send one Byte (8 Bits, 1 Start Bit, 1 Stop Bit)
|
||||||
#define EMSUART_TX_WAIT_BRK EMSUART_BIT_TIME * 11 // Time to send a BRK Signal (11 Bit)
|
#define EMSUART_TX_WAIT_BRK (EMSUART_BIT_TIME * 11) // Time to send a BRK Signal (11 Bit)
|
||||||
#define EMSUART_TX_WAIT_GAP EMSUART_BIT_TIME * 7 // Gap between to Bytes
|
#define EMSUART_TX_WAIT_GAP (EMSUART_BIT_TIME * 7) // Gap between to Bytes
|
||||||
#define EMSUART_TX_LAG 8
|
#define EMSUART_TX_LAG 8
|
||||||
|
|
||||||
|
#define EMSUART_BUSY_WAIT (EMSUART_BIT_TIME / 8)
|
||||||
|
#define EMS_TX_TO_CHARS (2 + 20)
|
||||||
|
#define EMS_TX_TO_COUNT ((EMS_TX_TO_CHARS)*10 * 8)
|
||||||
|
|
||||||
#define EMSUART_recvTaskPrio 1
|
#define EMSUART_recvTaskPrio 1
|
||||||
#define EMSUART_recvTaskQueueLen 64
|
#define EMSUART_recvTaskQueueLen 64
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define APP_VERSION "1.9.2b8"
|
#define APP_VERSION "1.9.2b9"
|
||||||
|
|||||||
Reference in New Issue
Block a user