mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 23:45:25 +00:00
Trying to get ESP32S2 to work
This commit is contained in:
parent
c5c8fbc2a0
commit
6f7eacddff
@ -498,9 +498,13 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
|
||||
if(pin == 9) {
|
||||
hwSerial = &Serial1;
|
||||
}
|
||||
if(pin == 16) {
|
||||
hwSerial = &Serial2;
|
||||
}
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
if(pin == 16) {
|
||||
hwSerial = &Serial2;
|
||||
}
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(pin == 0) {
|
||||
|
||||
@ -17,7 +17,7 @@ void HwTools::setup(GpioConfig* config, AmsConfiguration* amsConf) {
|
||||
if(config->vccPin > 0 && config->vccPin < 40) {
|
||||
getAdcChannel(config->vccPin, voltAdc);
|
||||
if(voltAdc.unit != 0xFF) {
|
||||
#if defined(ESP32)
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
if(voltAdc.unit == ADC_UNIT_1) {
|
||||
voltAdcChar = (esp_adc_cal_characteristics_t*) calloc(1, sizeof(esp_adc_cal_characteristics_t));
|
||||
esp_adc_cal_value_t adcVal = esp_adc_cal_characterize((adc_unit_t) voltAdc.unit, ADC_ATTEN_DB_6, ADC_WIDTH_BIT_12, 1100, voltAdcChar);
|
||||
@ -156,13 +156,7 @@ void HwTools::getAdcChannel(uint8_t pin, AdcConfig& config) {
|
||||
double HwTools::getVcc() {
|
||||
double volts = 0.0;
|
||||
if(config->vccPin != 0xFF) {
|
||||
#if defined(ESP8266)
|
||||
uint32_t x = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
x += analogRead(config->vccPin);
|
||||
}
|
||||
volts = x / 10240;
|
||||
#elif defined(ESP32)
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
if(voltAdc.unit != 0xFF) {
|
||||
uint32_t x = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@ -184,6 +178,12 @@ double HwTools::getVcc() {
|
||||
}
|
||||
volts = x / 40950;
|
||||
}
|
||||
#else
|
||||
uint32_t x = 0;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
x += analogRead(config->vccPin);
|
||||
}
|
||||
volts = x / 10240;
|
||||
#endif
|
||||
} else {
|
||||
#if defined(ESP8266)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user