mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
Prep support ESP32 enum SerialConfig
This commit is contained in:
parent
efa7ae492e
commit
326c605122
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
/*******************************************************************************************\
|
/*******************************************************************************************\
|
||||||
* ESP32/S2/S3/C3... PWM analog support
|
* ESP32/S2/S3/C3... PWM analog support
|
||||||
*
|
*
|
||||||
* The following supersedes Arduino framework and provides more granular control:
|
* The following supersedes Arduino framework and provides more granular control:
|
||||||
* - fine grained phase control (in addition to duty cycle)
|
* - fine grained phase control (in addition to duty cycle)
|
||||||
* - fine control of PWM frequency and resolution per GPIO
|
* - fine control of PWM frequency and resolution per GPIO
|
||||||
*
|
*
|
||||||
* By default, all PWM are using the same timer called Timer 0.
|
* By default, all PWM are using the same timer called Timer 0.
|
||||||
* Changes in frequency of resolution apply to all PWM using Timer 0.
|
* Changes in frequency of resolution apply to all PWM using Timer 0.
|
||||||
*
|
*
|
||||||
* You can specify a different a different resolution/frequency for
|
* You can specify a different a different resolution/frequency for
|
||||||
* specific GPIOs, this will internally assign a new timer to the GPIO.
|
* specific GPIOs, this will internally assign a new timer to the GPIO.
|
||||||
* The limit is 3 specific values in addition to the global value.
|
* The limit is 3 specific values in addition to the global value.
|
||||||
@ -129,7 +129,7 @@ uint32_t analogGetTimerFrequency(uint8_t timer);
|
|||||||
#define os_delay_us ets_delay_us
|
#define os_delay_us ets_delay_us
|
||||||
// Serial minimal type to hold the config
|
// Serial minimal type to hold the config
|
||||||
typedef int SerConfu8;
|
typedef int SerConfu8;
|
||||||
typedef int SerialConfig;
|
//typedef int SerialConfig; // Will be replaced enum in esp32_hal-uart.h (#7926)
|
||||||
|
|
||||||
//
|
//
|
||||||
// UDP
|
// UDP
|
||||||
|
@ -1252,10 +1252,10 @@ void sml_shift_in(uint32_t meters, uint32_t shard) {
|
|||||||
mp->sbuff[count] = mp->sbuff[count + 1];
|
mp->sbuff[count] = mp->sbuff[count + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t iob;
|
uint8_t iob;
|
||||||
if (mp->srcpin != TCP_MODE_FLG) {
|
if (mp->srcpin != TCP_MODE_FLG) {
|
||||||
iob = (uint8_t)mp->meter_ss->read();
|
iob = (uint8_t)mp->meter_ss->read();
|
||||||
} else {
|
} else {
|
||||||
iob = (uint8_t)mp->client->read();
|
iob = (uint8_t)mp->client->read();
|
||||||
}
|
}
|
||||||
@ -1447,7 +1447,7 @@ uint32_t meters;
|
|||||||
sml_shift_in(meters, 0);
|
sml_shift_in(meters, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef USE_SML_TCP
|
#ifdef USE_SML_TCP
|
||||||
while (mp->client->available()){
|
while (mp->client->available()){
|
||||||
sml_shift_in(meters, 0);
|
sml_shift_in(meters, 0);
|
||||||
}
|
}
|
||||||
@ -2625,7 +2625,7 @@ struct METER_DESC *mp = &meter_desc[mnum];
|
|||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
cp += 2;
|
cp += 2;
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
mp->uart_index = strtol(cp, &cp, 10);
|
mp->uart_index = strtol(cp, &cp, 10);
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
break;
|
break;
|
||||||
@ -3096,7 +3096,7 @@ next_line:
|
|||||||
mp->client = new WiFiClientSecure;
|
mp->client = new WiFiClientSecure;
|
||||||
//client(new BearSSL::WiFiClientSecure_light(1024,1024)) {
|
//client(new BearSSL::WiFiClientSecure_light(1024,1024)) {
|
||||||
mp->client->setInsecure();
|
mp->client->setInsecure();
|
||||||
#else
|
#else
|
||||||
mp->client = new WiFiClient;
|
mp->client = new WiFiClient;
|
||||||
#endif
|
#endif
|
||||||
int32_t err = mp->client->connect(mp->ip_addr, mp->params);
|
int32_t err = mp->client->connect(mp->ip_addr, mp->params);
|
||||||
@ -3142,7 +3142,7 @@ next_line:
|
|||||||
|
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
SerialConfig smode = SERIAL_8N1;
|
uint32_t smode = SERIAL_8N1;
|
||||||
|
|
||||||
if (mp->sopt & 0xf0) {
|
if (mp->sopt & 0xf0) {
|
||||||
// new serial config
|
// new serial config
|
||||||
@ -3178,14 +3178,14 @@ next_line:
|
|||||||
mp->meter_ss->flush();
|
mp->meter_ss->flush();
|
||||||
}
|
}
|
||||||
if (mp->meter_ss->hardwareSerial()) {
|
if (mp->meter_ss->hardwareSerial()) {
|
||||||
Serial.begin(mp->params, smode);
|
Serial.begin(mp->params, (SerialConfig)smode); // void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin, bool invert)
|
||||||
ClaimSerial();
|
ClaimSerial();
|
||||||
//Serial.setRxBufferSize(512);
|
//Serial.setRxBufferSize(512);
|
||||||
}
|
}
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
mp->meter_ss->begin(mp->params, smode, mp->srcpin, mp->trxpin);
|
mp->meter_ss->begin(mp->params, smode, mp->srcpin, mp->trxpin); // void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd)
|
||||||
#ifdef USE_ESP32_SW_SERIAL
|
#ifdef USE_ESP32_SW_SERIAL
|
||||||
mp->meter_ss->setRxBufferSize(mp->sibsiz);
|
mp->meter_ss->setRxBufferSize(mp->sibsiz);
|
||||||
#endif
|
#endif
|
||||||
@ -3293,7 +3293,7 @@ uint32_t SML_Write(int32_t meter, char *hstr) {
|
|||||||
hstr++;
|
hstr++;
|
||||||
// currently only 8 bits and ignore stopbits
|
// currently only 8 bits and ignore stopbits
|
||||||
hstr++;
|
hstr++;
|
||||||
SerialConfig smode;
|
uint32_t smode;
|
||||||
switch (*hstr) {
|
switch (*hstr) {
|
||||||
case 'N':
|
case 'N':
|
||||||
smode = SERIAL_8N1;
|
smode = SERIAL_8N1;
|
||||||
@ -3307,9 +3307,9 @@ uint32_t SML_Write(int32_t meter, char *hstr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
Serial.begin(baud, smode);
|
Serial.begin(baud, (SerialConfig)smode); // void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin, bool invert)
|
||||||
#else
|
#else
|
||||||
meter_desc[meter].meter_ss->begin(baud, smode, sml_globs.mp[meter].srcpin, sml_globs.mp[meter].trxpin);
|
meter_desc[meter].meter_ss->begin(baud, smode, sml_globs.mp[meter].srcpin, sml_globs.mp[meter].trxpin); // void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user