Attempting to use my new Wio Lite Risc-V board attached to a DHT-22 temperature/humidity sensor. After importing the library to the blink project (without any code added to the blink application except #include “DHT.h”) the project will not compile and has a red collect2.exe: error: ld returned 1 exit status *** [.pio\build\wio_lite_risc-v\firmware.elf] Error 1
error with a yellow main.cpp:(.text.setup+0x14): undefined reference to
digitalRead’` above it.
I am using “DHT by Mark Ruys” specifically.
My platformio.ini:
[env:wio_lite_risc-v]
platform = gd32v
board = gd32vf103v-eval
framework = arduino
upload_protocol = dfu
monitor_speed = 115200
lib_deps =
1671
How do I get the digitalRead() function to work with this?
Baozhu
June 15, 2020, 12:46am
#2
Here is the definition given by digitalRead.
if (LOW != status) {
//gpio_bit_set(PIN_MAP[pinNumber].gpio_device->gpio_port, PIN_MAP[pinNumber].gpio_bit);
GPIO_BOP(digitalPinToPort(pinNumber)) = digitalPinToBitMask(pinNumber);
} else {
//gpio_bit_reset(PIN_MAP[pinNumber].gpio_device->gpio_port, PIN_MAP[pinNumber].gpio_bit);
GPIO_BC(digitalPinToPort(pinNumber)) = digitalPinToBitMask(pinNumber);
}
return;
}
PinStatus digitalRead(pin_size_t pinNumber)
{
if (pinNumber >= VARIANT_GPIO_NUM) return LOW;
if ((uint32_t) LOW != (GPIO_ISTAT(digitalPinToPort(pinNumber)) & digitalPinToBitMask(pinNumber))) {
return HIGH;
} else {
return LOW;
}
}
Baozhu:
PinStatus digitalRead(pin_size_t pinNumber)
{
if (pinNumber >= VARIANT_GPIO_NUM) return LOW;
if ((uint32_t) LOW != (GPIO_ISTAT(digitalPinToPort(pinNumber)) & digitalPinToBitMask(pinNumber))) {
return HIGH;
} else {
return LOW;
}
}
Thank you so much! That is very different from the content of my wiring_digital.c but now it compiles without issue!
PinStatus digitalRead(pin_map_t ulPin)
// {
// if ((uint32_t) LOW != (GPIO_ISTAT(pinToPort(ulPin)) & (pinToGpioPin(ulPin)))) {
// return HIGH;
// } else {
// return LOW;
// }
// }