JoachimSchurig / CppGPIO

C++14 GPIO library for embedded systems on Linux
102 stars 26 forks source link

Raspberry pi4, pullup seems to be not effective. #18

Open michalpelka opened 1 year ago

michalpelka commented 1 year ago

Hi, foremost thank you for awesome work!

I have slight issue with button class.

#include <cppgpio.hpp>
#include <thread>
int main(int argc, char **argv) {
    health_server::setStatusHandler(mandeye::produceReport);
    std::thread http_thread1(health_server::server_worker);
    GPIO::DigitalOut out(21);
    GPIO::PushButton in(20, GPIO::GPIO_PULL::UP);

    in.f_pushed  = [&](){
        out.on();
        std::this_thread::sleep_for(std::chrono::milliseconds (500));
        out.off();
    };
    in.start();
    // blink once to test GPIO21
    in.f_pushed();
    for (;;) {
    }
    return 0;
}

It is basic code that is to trigger blink of led on output GPIO21 when GPIO20 is connected to GND. However, it is not working, raspi-gpio says it is still pulldown mode:

pi@raspberrypi:~ $ raspi-gpio get 20
GPIO 20: level=0 fsel=0 func=INPUT pull=DOWN

When I connect to GPIO21 3.3V the GPIO20 blinks.

From my initial debbugging GPIOBase::pullupdown is not called. I am opening issue since I do not know if I am experiencing a bug, or done smth wrong. Kindly ask for assistance.

Repository state : 017564088be26b36cdfaa418becc62a7ed52da94
Static linking
Raspberry pi 4 
Raspbian GNU/Linux 10 (buster)