junkfix / esp32-ds18b20

Arduino Library for ESP32 DS18B20 Non Blocking Onewire RMT protocol, no dependencies, minimal
MIT License
15 stars 4 forks source link

OneWireESP32.cpp:57:39: error: no match for 'operator=' (operand types are 'volatile gpio_dev_s::<unnamed union>' and 'int') #8

Closed huster-songtao closed 1 month ago

huster-songtao commented 3 months ago

XIAO_ESP32C3 Arduino IDE 2.3.2 ds18b20.ino, sample code

#include "OneWireESP32.h"
const uint8_t MaxDevs = 2;

float currTemp[MaxDevs];

void tempTask(void *pvParameters){
    OneWire32 ds(D7, 0, 1, 0); //gpio pin, tx, rx, parasite power
    // There are 8 RMT channels (0-7) available on ESP32 for tx/rx

    uint64_t addr[MaxDevs];

    //uint64_t addr[] = {
    //  0x183c01f09506f428,
    //  0xf33c01e07683de28,
    //};

    //to find addresses
    uint8_t devices = ds.search(addr, MaxDevs);
    for (uint8_t i = 0; i < devices; i += 1) {
        Serial.printf("%d: 0x%llx,\n", i, addr[i]);
        //char buf[20]; snprintf( buf, 20, "0x%llx,", addr[i] ); Serial.println(buf);
    }
    //end

    for(;;){
        ds.request();
        vTaskDelay(750 / portTICK_PERIOD_MS);
        for(byte i = 0; i < MaxDevs; i++){
            uint8_t err = ds.getTemp(addr[i], currTemp[i]);
            if(err){
                const char *errt[] = {"", "CRC", "BAD","DC","DRV"};
                Serial.print(i); Serial.print(": "); Serial.println(errt[err]);
            }else{
                Serial.print(i); Serial.print(": "); Serial.println(currTemp[i]);
            }
        }
        vTaskDelay(3000 / portTICK_PERIOD_MS);
    }
} // tempTask

void setup() {
    delay(1000);
    Serial.begin(115200);
    xTaskCreatePinnedToCore(tempTask, "tempTask", 2048,  NULL,  1,  NULL, 0);
}

void loop() {}

d:\Arduino\Sketchbook\libraries\esp32-ds18b20\OneWireESP32.cpp: In constructor 'OneWire32::OneWire32(uint8_t, uint8_t, uint8_t, uint8_t)': d:\Arduino\Sketchbook\libraries\esp32-ds18b20\OneWireESP32.cpp:57:39: error: no match for 'operator=' (operand types are 'volatile gpio_dev_s::' and 'int') GPIO.enable_w1ts = (0x1 << owpin); ^ In file included from C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/soc/include/soc/gpio_periph.h:18, from C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/hal/include/hal/gpio_types.h:17, from C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/esp_hw_support/include/esp_sleep.h:13, from C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\cores\esp32/esp32-hal.h:33, from C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\cores\esp32/Arduino.h:36, from d:\Arduino\Sketchbook\libraries\esp32-ds18b20\OneWireESP32.cpp:13: C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h:61:11: note: candidate: 'gpio_dev_s::& gpio_dev_s::::operator=(const gpio_dev_s::&)' union { ^ C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h:61:11: note: no known conversion for argument 1 from 'int' to 'const gpio_dev_s::&' C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h:61:11: note: candidate: 'gpio_dev_s::& gpio_dev_s::::operator=(gpio_dev_s::&&)' C:\Users\tao\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/gpio_struct.h:61:11: note: no known conversion for argument 1 from 'int' to 'gpio_dev_s::&&' d:\Arduino\Sketchbook\libraries\esp32-ds18b20\OneWireESP32.cpp:59:12: error: 'gpio_dev_t' {aka 'volatile struct gpio_dev_s'} has no member named 'enable1_w1ts'; did you mean 'enable_w1ts'? GPIO.enable1_w1ts.data = (0x1 << (owpin - 32)); ^~~~ enable_w1ts

exit status 1

Compilation error: exit status 1