Add HLW8032 8N1

This commit is contained in:
Theo Arends 2023-01-09 11:04:52 +01:00
parent 24105a74b2
commit a4fe1b88f9
3 changed files with 14 additions and 8 deletions

View File

@ -825,7 +825,7 @@ const uint16_t kGpioNiceList[] PROGMEM = {
#endif #endif
#ifdef USE_CSE7766 #ifdef USE_CSE7766
AGPIO(GPIO_CSE7766_TX), // CSE7766 Serial interface (S31 and Pow R2) AGPIO(GPIO_CSE7766_TX), // CSE7766 Serial interface (S31 and Pow R2)
AGPIO(GPIO_CSE7766_RX), // CSE7766 Serial interface (S31 and Pow R2) AGPIO(GPIO_CSE7766_RX) + 2, // CSE7766 Serial interface (S31 and Pow R2) (1 = RX1 (8E1), 2 = RX2 (8N1))
#endif #endif
#ifdef USE_MCP39F501 #ifdef USE_MCP39F501
AGPIO(GPIO_MCP39F5_TX), // MCP39F501 Serial interface (Shelly2) AGPIO(GPIO_MCP39F5_TX), // MCP39F501 Serial interface (Shelly2)

View File

@ -225,11 +225,17 @@ void CseEverySecond(void) {
void CseSnsInit(void) { void CseSnsInit(void) {
// Software serial init needs to be done here as earlier (serial) interrupts may lead to Exceptions // Software serial init needs to be done here as earlier (serial) interrupts may lead to Exceptions
// CseSerial = new TasmotaSerial(Pin(GPIO_CSE7766_RX), Pin(GPIO_CSE7766_TX), 1); uint32_t pin_rx = Pin(GPIO_CSE7766_RX, GPIO_ANY);
CseSerial = new TasmotaSerial(Pin(GPIO_CSE7766_RX), -1, 1); // CseSerial = new TasmotaSerial(pin_rx, Pin(GPIO_CSE7766_TX), 1);
if (CseSerial->begin(4800, SERIAL_8E1)) { CseSerial = new TasmotaSerial(pin_rx, -1, 1);
// 0 (1 = RX1 (8E1)), 1 (2 = RX2 (8N1))
uint32_t option = GetPin(pin_rx) - AGPIO(GPIO_CSE7766_RX);
uint32_t config = (1 == option) ? SERIAL_8N1 : SERIAL_8E1;
if (CseSerial->begin(4800, config)) {
if (CseSerial->hardwareSerial()) { if (CseSerial->hardwareSerial()) {
SetSerial(4800, TS_SERIAL_8E1); config = (1 == option) ? TS_SERIAL_8N1 : TS_SERIAL_8E1;
SetSerial(4800, config);
ClaimSerial(); ClaimSerial();
} }
if (0 == Settings->param[P_CSE7766_INVALID_POWER]) { if (0 == Settings->param[P_CSE7766_INVALID_POWER]) {
@ -243,8 +249,8 @@ void CseSnsInit(void) {
} }
void CseDrvInit(void) { void CseDrvInit(void) {
// if (PinUsed(GPIO_CSE7766_RX) && PinUsed(GPIO_CSE7766_TX)) { // if (PinUsed(GPIO_CSE7766_RX, GPIO_ANY) && PinUsed(GPIO_CSE7766_TX)) {
if (PinUsed(GPIO_CSE7766_RX)) { if (PinUsed(GPIO_CSE7766_RX, GPIO_ANY)) {
Cse.rx_buffer = (uint8_t*)(malloc(CSE_BUFFER_SIZE)); Cse.rx_buffer = (uint8_t*)(malloc(CSE_BUFFER_SIZE));
if (Cse.rx_buffer != nullptr) { if (Cse.rx_buffer != nullptr) {
TasmotaGlobal.energy_driver = XNRG_02; TasmotaGlobal.energy_driver = XNRG_02;

View File

@ -189,7 +189,7 @@ void We517SnsInit(void) {
if (result) { if (result) {
if (2 == result) { if (2 == result) {
// AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED); // AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED);
// Serial.begin(WE517_SPEED, SERIAL_8E1); Serial.begin(WE517_SPEED, SERIAL_8E1);
ClaimSerial(); ClaimSerial();
} }
Energy.phase_count = 3; Energy.phase_count = 3;