mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
clang formatting
This commit is contained in:
@@ -162,6 +162,9 @@ void Mixing::process_MMStatusMessage(std::shared_ptr<const Telegram> telegram) {
|
|||||||
telegram->read_value(flowSetTemp_, 0);
|
telegram->read_value(flowSetTemp_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
|
||||||
// Mixing on a MM10 - 0xAA
|
// Mixing on a MM10 - 0xAA
|
||||||
// e.g. Thermostat -> Mixing Module, type 0xAA, telegram: 10 21 AA 00 FF 0C 0A 11 0A 32 xx
|
// e.g. Thermostat -> Mixing Module, type 0xAA, telegram: 10 21 AA 00 FF 0C 0A 11 0A 32 xx
|
||||||
void Mixing::process_MMConfigMessage(std::shared_ptr<const Telegram> telegram) {
|
void Mixing::process_MMConfigMessage(std::shared_ptr<const Telegram> telegram) {
|
||||||
@@ -177,4 +180,6 @@ void Mixing::process_MMSetMessage(std::shared_ptr<const Telegram> telegram) {
|
|||||||
// pos 1: position in %
|
// pos 1: position in %
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
@@ -816,8 +816,8 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
|||||||
|
|
||||||
if (flags == EMS_DEVICE_FLAG_RC35) {
|
if (flags == EMS_DEVICE_FLAG_RC35) {
|
||||||
print_value(shell, 2, F("Damped Outdoor temperature"), F_(degrees), Helpers::render_value(buffer, dampedoutdoortemp, 1));
|
print_value(shell, 2, F("Damped Outdoor temperature"), F_(degrees), Helpers::render_value(buffer, dampedoutdoortemp, 1));
|
||||||
print_value(shell, 2, F("Tempsensor 1"), F_(degrees), Helpers::render_value(buffer, tempsensor1, 10));
|
print_value(shell, 2, F("Temp sensor 1"), F_(degrees), Helpers::render_value(buffer, tempsensor1, 10));
|
||||||
print_value(shell, 2, F("Tempsensor 2"), F_(degrees), Helpers::render_value(buffer, tempsensor2, 10));
|
print_value(shell, 2, F("Temp sensor 2"), F_(degrees), Helpers::render_value(buffer, tempsensor2, 10));
|
||||||
}
|
}
|
||||||
if (flags == EMS_DEVICE_FLAG_RC30_1) {
|
if (flags == EMS_DEVICE_FLAG_RC30_1) {
|
||||||
// settings parameters
|
// settings parameters
|
||||||
|
|||||||
@@ -46,21 +46,21 @@ class Thermostat : public EMSdevice {
|
|||||||
}
|
}
|
||||||
~HeatingCircuit() = default;
|
~HeatingCircuit() = default;
|
||||||
|
|
||||||
int16_t setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET;
|
int16_t setpoint_roomTemp = EMS_VALUE_SHORT_NOTSET;
|
||||||
int16_t curr_roomTemp = EMS_VALUE_SHORT_NOTSET;
|
int16_t curr_roomTemp = EMS_VALUE_SHORT_NOTSET;
|
||||||
uint8_t mode = EMS_VALUE_UINT_NOTSET;
|
uint8_t mode = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t mode_type = EMS_VALUE_UINT_NOTSET;
|
uint8_t mode_type = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t summer_mode = EMS_VALUE_UINT_NOTSET;
|
uint8_t summer_mode = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t holiday_mode = EMS_VALUE_UINT_NOTSET;
|
uint8_t holiday_mode = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t daytemp = EMS_VALUE_UINT_NOTSET;
|
uint8_t daytemp = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t nighttemp = EMS_VALUE_UINT_NOTSET;
|
uint8_t nighttemp = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t holidaytemp = EMS_VALUE_UINT_NOTSET;
|
uint8_t holidaytemp = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t heatingtype = EMS_VALUE_UINT_NOTSET; // type of heating: 1 radiator, 2 convectors, 3 floors, 4 room supply
|
uint8_t heatingtype = EMS_VALUE_UINT_NOTSET; // type of heating: 1 radiator, 2 convectors, 3 floors, 4 room supply
|
||||||
uint8_t circuitcalctemp = EMS_VALUE_UINT_NOTSET;
|
uint8_t circuitcalctemp = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t summertemp = EMS_VALUE_UINT_NOTSET;
|
uint8_t summertemp = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t nofrosttemp = EMS_VALUE_UINT_NOTSET;
|
uint8_t nofrosttemp = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t designtemp = EMS_VALUE_UINT_NOTSET; // heatingcurve design temp at MinExtTemp
|
uint8_t designtemp = EMS_VALUE_UINT_NOTSET; // heatingcurve design temp at MinExtTemp
|
||||||
int8_t offsettemp = EMS_VALUE_INT_NOTSET; // heatingcurve offest temp at roomtemp signed!
|
int8_t offsettemp = EMS_VALUE_INT_NOTSET; // heatingcurve offest temp at roomtemp signed!
|
||||||
|
|
||||||
|
|
||||||
uint8_t hc_num() const {
|
uint8_t hc_num() const {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Helpers {
|
|||||||
static char * hextoa(char * result, const uint8_t value);
|
static char * hextoa(char * result, const uint8_t value);
|
||||||
static std::string data_to_hex(const uint8_t * data, const uint8_t length);
|
static std::string data_to_hex(const uint8_t * data, const uint8_t length);
|
||||||
|
|
||||||
static char * render_value(char * result, const float value, const uint8_t format); // format is precision
|
static char * render_value(char * result, const float value, const uint8_t format); // format is the precision
|
||||||
static char * render_value(char * result, const uint8_t value, const uint8_t format);
|
static char * render_value(char * result, const uint8_t value, const uint8_t format);
|
||||||
static char * render_value(char * result, const int8_t value, const uint8_t format);
|
static char * render_value(char * result, const int8_t value, const uint8_t format);
|
||||||
static char * render_value(char * result, const uint16_t value, const uint8_t format);
|
static char * render_value(char * result, const uint16_t value, const uint8_t format);
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ void Roomctrl::check(const uint8_t addr, const uint8_t * data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// reply to writes with write nack byte
|
// reply to writes with write nack byte
|
||||||
if(addr & 0x80) { // it's a write to us
|
if (addr & 0x80) { // it's a write to us
|
||||||
nack_write(); // we don't accept writes.
|
nack_write(); // we don't accept writes.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// for now we only reply to version and remote temperature
|
// for now we only reply to version and remote temperature
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ class Roomctrl {
|
|||||||
static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset);
|
static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset);
|
||||||
static void temperature(uint8_t addr, uint8_t dst);
|
static void temperature(uint8_t addr, uint8_t dst);
|
||||||
static void nack_write();
|
static void nack_write();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ static hw_timer_t * timer = NULL;
|
|||||||
bool drop_next_rx = true;
|
bool drop_next_rx = true;
|
||||||
uint8_t tx_mode_ = 0xFF;
|
uint8_t tx_mode_ = 0xFF;
|
||||||
//portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
|
//portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
uint8_t emsTxBuf[EMS_MAXBUFFERSIZE];
|
uint8_t emsTxBuf[EMS_MAXBUFFERSIZE];
|
||||||
uint8_t emsTxBufIdx;
|
uint8_t emsTxBufIdx;
|
||||||
uint8_t emsTxBufLen;
|
uint8_t emsTxBufLen;
|
||||||
uint32_t emsTxWait;
|
uint32_t emsTxWait;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Task to handle the incoming data
|
* Task to handle the incoming data
|
||||||
@@ -90,7 +90,7 @@ void IRAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() {
|
|||||||
EMS_UART.fifo.rw_byte = emsTxBuf[emsTxBufIdx];
|
EMS_UART.fifo.rw_byte = emsTxBuf[emsTxBufIdx];
|
||||||
timerAlarmWrite(timer, emsTxWait, false);
|
timerAlarmWrite(timer, emsTxWait, false);
|
||||||
timerAlarmEnable(timer);
|
timerAlarmEnable(timer);
|
||||||
} else if (emsTxBufIdx == emsTxBufLen) {
|
} else if (emsTxBufIdx == emsTxBufLen) {
|
||||||
EMS_UART.conf0.txd_brk = 1; // <brk> after send
|
EMS_UART.conf0.txd_brk = 1; // <brk> after send
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,9 +105,9 @@ void EMSuart::start(uint8_t tx_mode) {
|
|||||||
emsTxWait = EMSUART_BIT_TIME * 20;
|
emsTxWait = EMSUART_BIT_TIME * 20;
|
||||||
} else if (tx_mode == EMS_TXMODE_HT3) {
|
} else if (tx_mode == EMS_TXMODE_HT3) {
|
||||||
emsTxWait = EMSUART_BIT_TIME * 17;
|
emsTxWait = EMSUART_BIT_TIME * 17;
|
||||||
} else if(tx_mode > 10 ) {
|
} else if (tx_mode > 10) {
|
||||||
emsTxWait = EMSUART_BIT_TIME * tx_mode;
|
emsTxWait = EMSUART_BIT_TIME * tx_mode;
|
||||||
} else if(tx_mode > 5 ) {
|
} else if (tx_mode > 5) {
|
||||||
emsTxWait = EMSUART_BIT_TIME * tx_mode * 2;
|
emsTxWait = EMSUART_BIT_TIME * tx_mode * 2;
|
||||||
}
|
}
|
||||||
if (tx_mode_ != 0xFF) { // uart already initialized
|
if (tx_mode_ != 0xFF) { // uart already initialized
|
||||||
@@ -138,8 +138,8 @@ void EMSuart::start(uint8_t tx_mode) {
|
|||||||
|
|
||||||
emsTxBufIdx = 0;
|
emsTxBufIdx = 0;
|
||||||
emsTxBufLen = 0;
|
emsTxBufLen = 0;
|
||||||
timer = timerBegin(1, 80, true); // timer prescale to 1 µs, countup
|
timer = timerBegin(1, 80, true); // timer prescale to 1 µs, countup
|
||||||
timerAttachInterrupt(timer, &emsuart_tx_timer_intr_handler, true); // Timer with edge interrupt
|
timerAttachInterrupt(timer, &emsuart_tx_timer_intr_handler, true); // Timer with edge interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -147,7 +147,7 @@ void EMSuart::start(uint8_t tx_mode) {
|
|||||||
*/
|
*/
|
||||||
void EMSuart::stop() {
|
void EMSuart::stop() {
|
||||||
EMS_UART.int_ena.val = 0; // disable all intr.
|
EMS_UART.int_ena.val = 0; // disable all intr.
|
||||||
// timerAlarmDisable(timer);
|
// timerAlarmDisable(timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -159,8 +159,8 @@ void EMSuart::restart() {
|
|||||||
drop_next_rx = true; // and drop first frame
|
drop_next_rx = true; // and drop first frame
|
||||||
}
|
}
|
||||||
EMS_UART.int_ena.brk_det = 1; // activate only break
|
EMS_UART.int_ena.brk_det = 1; // activate only break
|
||||||
emsTxBufIdx = 0;
|
emsTxBufIdx = 0;
|
||||||
emsTxBufLen = 0;
|
emsTxBufLen = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -172,8 +172,8 @@ void EMSuart::send_poll(uint8_t data) {
|
|||||||
EMS_UART.conf0.txd_brk = 1; // <brk> after send
|
EMS_UART.conf0.txd_brk = 1; // <brk> after send
|
||||||
} else {
|
} else {
|
||||||
EMS_UART.fifo.rw_byte = data;
|
EMS_UART.fifo.rw_byte = data;
|
||||||
emsTxBufIdx = 0;
|
emsTxBufIdx = 0;
|
||||||
emsTxBufLen = 1;
|
emsTxBufLen = 1;
|
||||||
timerAlarmWrite(timer, emsTxWait, false);
|
timerAlarmWrite(timer, emsTxWait, false);
|
||||||
timerAlarmEnable(timer);
|
timerAlarmEnable(timer);
|
||||||
}
|
}
|
||||||
@@ -198,8 +198,8 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
emsTxBuf[i] = buf[i];
|
emsTxBuf[i] = buf[i];
|
||||||
}
|
}
|
||||||
EMS_UART.fifo.rw_byte = buf[0];
|
EMS_UART.fifo.rw_byte = buf[0];
|
||||||
emsTxBufIdx = 0;
|
emsTxBufIdx = 0;
|
||||||
emsTxBufLen = len;
|
emsTxBufLen = len;
|
||||||
timerAlarmWrite(timer, emsTxWait, false);
|
timerAlarmWrite(timer, emsTxWait, false);
|
||||||
timerAlarmEnable(timer);
|
timerAlarmEnable(timer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,17 +65,16 @@ class EMSuart {
|
|||||||
EMSuart() = default;
|
EMSuart() = default;
|
||||||
~EMSuart() = default;
|
~EMSuart() = default;
|
||||||
|
|
||||||
static void start(uint8_t tx_mode);
|
static void start(uint8_t tx_mode);
|
||||||
static void send_poll(uint8_t data);
|
static void send_poll(uint8_t data);
|
||||||
static void stop();
|
static void stop();
|
||||||
static void restart();
|
static void restart();
|
||||||
static uint16_t transmit(uint8_t * buf, uint8_t len);
|
static uint16_t transmit(uint8_t * buf, uint8_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void emsuart_recvTask(void * para);
|
static void emsuart_recvTask(void * para);
|
||||||
static void IRAM_ATTR emsuart_rx_intr_handler(void * para);
|
static void IRAM_ATTR emsuart_rx_intr_handler(void * para);
|
||||||
static void IRAM_ATTR emsuart_tx_timer_intr_handler();
|
static void IRAM_ATTR emsuart_tx_timer_intr_handler();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ os_event_t recvTaskQueue[EMSUART_recvTaskQueueLen]; // our Rx queue
|
|||||||
EMSuart::EMSRxBuf_t * pEMSRxBuf;
|
EMSuart::EMSRxBuf_t * pEMSRxBuf;
|
||||||
EMSuart::EMSRxBuf_t * paEMSRxBuf[EMS_MAXBUFFERS];
|
EMSuart::EMSRxBuf_t * paEMSRxBuf[EMS_MAXBUFFERS];
|
||||||
uint8_t emsRxBufIdx = 0;
|
uint8_t emsRxBufIdx = 0;
|
||||||
uint8_t phantomBreak = 0;
|
|
||||||
uint8_t tx_mode_ = 0xFF;
|
uint8_t tx_mode_ = 0xFF;
|
||||||
bool drop_next_rx = true;
|
bool drop_next_rx = true;
|
||||||
uint32_t emsRxTime;
|
uint32_t emsRxTime;
|
||||||
@@ -40,7 +39,6 @@ uint8_t emsTxBufIdx;
|
|||||||
uint8_t emsTxBufLen;
|
uint8_t emsTxBufLen;
|
||||||
uint32_t emsTxWait;
|
uint32_t emsTxWait;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Main interrupt handler
|
// Main interrupt handler
|
||||||
// Important: must not use ICACHE_FLASH_ATTR
|
// Important: must not use ICACHE_FLASH_ATTR
|
||||||
@@ -84,11 +82,6 @@ void ICACHE_FLASH_ATTR EMSuart::emsuart_recvTask(os_event_t * events) {
|
|||||||
uint8_t length = pCurrent->length; // number of bytes including the BRK at the end
|
uint8_t length = pCurrent->length; // number of bytes including the BRK at the end
|
||||||
pCurrent->length = 0;
|
pCurrent->length = 0;
|
||||||
|
|
||||||
if (phantomBreak) {
|
|
||||||
phantomBreak = 0;
|
|
||||||
length--; // remove phantom break from Rx buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
// it's a poll or status code, single byte and ok to send on, then quit
|
// it's a poll or status code, single byte and ok to send on, then quit
|
||||||
if (length == 2) {
|
if (length == 2) {
|
||||||
EMSESP::incoming_telegram((uint8_t *)pCurrent->buffer, 1);
|
EMSESP::incoming_telegram((uint8_t *)pCurrent->buffer, 1);
|
||||||
@@ -124,12 +117,12 @@ void ICACHE_RAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() {
|
|||||||
} else if (emsTxBufIdx == emsTxBufLen) {
|
} else if (emsTxBufIdx == emsTxBufLen) {
|
||||||
USC0(EMSUART_UART) |= (1 << UCBRK); // set <BRK>
|
USC0(EMSUART_UART) |= (1 << UCBRK); // set <BRK>
|
||||||
if (tx_mode_ > 5 || tx_mode_ < 11) {
|
if (tx_mode_ > 5 || tx_mode_ < 11) {
|
||||||
timer1_write(5 * EMSUART_TX_BIT_TIME * 11);
|
timer1_write(5 * EMSUART_TX_BIT_TIME * 11);
|
||||||
USIE(EMSUART_UART) &= ~(1 << UIBD); // disable break interrupt
|
USIE(EMSUART_UART) &= ~(1 << UIBD); // disable break interrupt
|
||||||
}
|
}
|
||||||
} else if (USC0(EMSUART_UART) & (1 << UCBRK)) {
|
} else if (USC0(EMSUART_UART) & (1 << UCBRK)) {
|
||||||
USC0(EMSUART_UART) &= ~(1 << UCBRK); // clear <BRK>
|
USC0(EMSUART_UART) &= ~(1 << UCBRK); // clear <BRK>
|
||||||
USIE(EMSUART_UART) |= (1 << UIBD); // enable break interrupt
|
USIE(EMSUART_UART) |= (1 << UIBD); // enable break interrupt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -137,9 +130,9 @@ void ICACHE_RAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() {
|
|||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR EMSuart::start(uint8_t tx_mode) {
|
void ICACHE_FLASH_ATTR EMSuart::start(uint8_t tx_mode) {
|
||||||
if (tx_mode > 10) {
|
if (tx_mode > 10) {
|
||||||
emsTxWait = 5 * EMSUART_TX_BIT_TIME * tx_mode; // bittimes for tx_mode
|
emsTxWait = 5 * EMSUART_TX_BIT_TIME * tx_mode; // bittimes for tx_mode
|
||||||
} else if (tx_mode > 5) {
|
} else if (tx_mode > 5) {
|
||||||
emsTxWait = 10 * EMSUART_TX_BIT_TIME * tx_mode; // bittimes for tx_mode
|
emsTxWait = 10 * EMSUART_TX_BIT_TIME * tx_mode; // bittimes for tx_mode
|
||||||
}
|
}
|
||||||
if (tx_mode == 5) {
|
if (tx_mode == 5) {
|
||||||
USC0(EMSUART_UART) = 0x2C; // 8N1,5
|
USC0(EMSUART_UART) = 0x2C; // 8N1,5
|
||||||
@@ -171,7 +164,7 @@ void ICACHE_FLASH_ATTR EMSuart::start(uint8_t tx_mode) {
|
|||||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD);
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD);
|
||||||
|
|
||||||
// set 9600, 8 bits, no parity check, 1 stop bit
|
// set 9600, 8 bits, no parity check, 1 stop bit
|
||||||
USD(EMSUART_UART) = (UART_CLK_FREQ / EMSUART_BAUD);
|
USD(EMSUART_UART) = (UART_CLK_FREQ / EMSUART_BAUD);
|
||||||
|
|
||||||
emsuart_flush_fifos();
|
emsuart_flush_fifos();
|
||||||
|
|
||||||
@@ -209,7 +202,6 @@ void ICACHE_FLASH_ATTR EMSuart::start(uint8_t tx_mode) {
|
|||||||
ETS_UART_INTR_ATTACH(emsuart_rx_intr_handler, nullptr);
|
ETS_UART_INTR_ATTACH(emsuart_rx_intr_handler, nullptr);
|
||||||
ETS_UART_INTR_ENABLE();
|
ETS_UART_INTR_ENABLE();
|
||||||
drop_next_rx = true;
|
drop_next_rx = true;
|
||||||
// LOG_INFO(F("UART service for Rx/Tx started"));
|
|
||||||
|
|
||||||
// for sending with large delay in EMS+ mode we use a timer interrupt
|
// for sending with large delay in EMS+ mode we use a timer interrupt
|
||||||
timer1_attachInterrupt(emsuart_tx_timer_intr_handler); // Add ISR Function
|
timer1_attachInterrupt(emsuart_tx_timer_intr_handler); // Add ISR Function
|
||||||
@@ -244,7 +236,6 @@ void ICACHE_FLASH_ATTR EMSuart::restart() {
|
|||||||
* Which is a 11-bit set of zero's (11 cycles)
|
* Which is a 11-bit set of zero's (11 cycles)
|
||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR EMSuart::tx_brk() {
|
void ICACHE_FLASH_ATTR EMSuart::tx_brk() {
|
||||||
|
|
||||||
// must make sure Tx FIFO is empty
|
// must make sure Tx FIFO is empty
|
||||||
while (((USS(EMSUART_UART) >> USTXC) & 0xFF))
|
while (((USS(EMSUART_UART) >> USTXC) & 0xFF))
|
||||||
;
|
;
|
||||||
@@ -277,13 +268,13 @@ void EMSuart::send_poll(uint8_t data) {
|
|||||||
USC0(EMSUART_UART) &= ~(1 << UCBRK);
|
USC0(EMSUART_UART) &= ~(1 << UCBRK);
|
||||||
if (tx_mode_ > 5) { // timer controlled modes
|
if (tx_mode_ > 5) { // timer controlled modes
|
||||||
USF(EMSUART_UART) = data;
|
USF(EMSUART_UART) = data;
|
||||||
emsTxBufIdx = 0;
|
emsTxBufIdx = 0;
|
||||||
emsTxBufLen = 1;
|
emsTxBufLen = 1;
|
||||||
timer1_write(emsTxWait);
|
timer1_write(emsTxWait);
|
||||||
} else if (tx_mode_ >= EMS_TXMODE_NEW) { // hardware controlled modes
|
} else if (tx_mode_ >= EMS_TXMODE_NEW) { // hardware controlled modes
|
||||||
USF(EMSUART_UART) = data;
|
USF(EMSUART_UART) = data;
|
||||||
USC0(EMSUART_UART) |= (1 << UCBRK); // send <BRK> at the end
|
USC0(EMSUART_UART) |= (1 << UCBRK); // send <BRK> at the end
|
||||||
} else { // software controlled modes
|
} else { // software controlled modes
|
||||||
// EMS1.0, EMS+ and HT3
|
// EMS1.0, EMS+ and HT3
|
||||||
USF(EMSUART_UART) = data;
|
USF(EMSUART_UART) = data;
|
||||||
delayMicroseconds(EMSUART_TX_BRK_WAIT);
|
delayMicroseconds(EMSUART_TX_BRK_WAIT);
|
||||||
@@ -306,7 +297,7 @@ uint16_t ICACHE_FLASH_ATTR EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
// if ((uuid::get_uptime() - emsRxTime) > EMS_RX_TO_TX_TIMEOUT)) { // send allowed within 20 ms
|
// if ((uuid::get_uptime() - emsRxTime) > EMS_RX_TO_TX_TIMEOUT)) { // send allowed within 20 ms
|
||||||
// return EMS_TX_STATUS_ERR;
|
// return EMS_TX_STATUS_ERR;
|
||||||
// }
|
// }
|
||||||
// reset tx-brk, just in case it is accidently set
|
// reset tx-brk, just in case it is accidentally set
|
||||||
USC0(EMSUART_UART) &= ~(1 << UCBRK);
|
USC0(EMSUART_UART) &= ~(1 << UCBRK);
|
||||||
|
|
||||||
// timer controlled modes with extra delay
|
// timer controlled modes with extra delay
|
||||||
@@ -314,15 +305,15 @@ uint16_t ICACHE_FLASH_ATTR EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
emsTxBuf[i] = buf[i];
|
emsTxBuf[i] = buf[i];
|
||||||
}
|
}
|
||||||
emsTxBufIdx = 0;
|
emsTxBufIdx = 0;
|
||||||
emsTxBufLen = len;
|
emsTxBufLen = len;
|
||||||
USF(EMSUART_UART) = buf[0];
|
USF(EMSUART_UART) = buf[0];
|
||||||
timer1_write(emsTxWait);
|
timer1_write(emsTxWait);
|
||||||
return EMS_TX_STATUS_OK;
|
return EMS_TX_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// new code from Michael. See https://github.com/proddy/EMS-ESP/issues/380
|
// new code from Michael. See https://github.com/proddy/EMS-ESP/issues/380
|
||||||
if (tx_mode_ >= EMS_TXMODE_NEW) {
|
if (tx_mode_ >= EMS_TXMODE_NEW) { // tx_mode 4
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
USF(EMSUART_UART) = buf[i];
|
USF(EMSUART_UART) = buf[i];
|
||||||
}
|
}
|
||||||
@@ -331,7 +322,7 @@ uint16_t ICACHE_FLASH_ATTR EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EMS+ https://github.com/proddy/EMS-ESP/issues/23#
|
// EMS+ https://github.com/proddy/EMS-ESP/issues/23#
|
||||||
if (tx_mode_ == EMS_TXMODE_EMSPLUS) { // With extra tx delay for EMS+
|
if (tx_mode_ == EMS_TXMODE_EMSPLUS) { // tx_mode 2, with extra tx delay for EMS+
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
USF(EMSUART_UART) = buf[i];
|
USF(EMSUART_UART) = buf[i];
|
||||||
delayMicroseconds(EMSUART_TX_BRK_WAIT); // 2070
|
delayMicroseconds(EMSUART_TX_BRK_WAIT); // 2070
|
||||||
@@ -341,7 +332,7 @@ uint16_t ICACHE_FLASH_ATTR EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Junkers logic by @philrich
|
// Junkers logic by @philrich
|
||||||
if (tx_mode_ == EMS_TXMODE_HT3) {
|
if (tx_mode_ == EMS_TXMODE_HT3) { // tx_mode 3
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
USF(EMSUART_UART) = buf[i];
|
USF(EMSUART_UART) = buf[i];
|
||||||
|
|
||||||
@@ -383,7 +374,6 @@ uint16_t ICACHE_FLASH_ATTR EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
|
|
||||||
// disable rx interrupt
|
// disable rx interrupt
|
||||||
// clear Rx status register, resetting the Rx FIFO and flush it
|
// clear Rx status register, resetting the Rx FIFO and flush it
|
||||||
// noInterrupts();
|
|
||||||
ETS_UART_INTR_DISABLE();
|
ETS_UART_INTR_DISABLE();
|
||||||
// USC0(EMSUART_UART) |= (1 << UCRXRST); // reset uart rx fifo
|
// USC0(EMSUART_UART) |= (1 << UCRXRST); // reset uart rx fifo
|
||||||
emsuart_flush_fifos();
|
emsuart_flush_fifos();
|
||||||
@@ -414,12 +404,8 @@ uint16_t ICACHE_FLASH_ATTR EMSuart::transmit(uint8_t * buf, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
USC0(EMSUART_UART) &= ~(1 << UCBRK); // clear <BRK>
|
USC0(EMSUART_UART) &= ~(1 << UCBRK); // clear <BRK>
|
||||||
// USC0(EMSUART_UART) &= ~((1 << UCBRK) | (1 << UCLBE)); // disable loopback & clear <BRK>
|
|
||||||
// USIC(EMSUART_UART) = (1 << UIBD); // clear BRK detect IRQ
|
|
||||||
// phantomBreak = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// interrupts();
|
|
||||||
ETS_UART_INTR_ENABLE(); // open up the FIFO again to start receiving
|
ETS_UART_INTR_ENABLE(); // open up the FIFO again to start receiving
|
||||||
|
|
||||||
return EMS_TX_STATUS_OK; // send the Tx ok status back
|
return EMS_TX_STATUS_OK; // send the Tx ok status back
|
||||||
|
|||||||
Reference in New Issue
Block a user