I'm trying to access the GPIO pins of a Raspberry Pi 3 model B directly from c++.

This code works fine with wiringPiSetup() and wiringPiSetupGpio() but I want to access the GPIO registers directly and wiringPySetupPhys() doesn't work this way. I tried BCM and wiringPi pin numbering too.

What am I doing wrong? Are there any other way for fast GPIO access in c++?

#include <wiringPi.h>

int main(){

1 Answer 1


You cannot mix "direct register access" with code using GPIO libraries. You have to select one method and stick to it fom beginning do end, no matter how painful it is.

A good example of direct register access, from the author of pigpio: http://abyz.me.uk/rpi/pigpio/code/minimal_gpio.zip

I hope you now understand why pigpio and WiringPi exist in the first place. There is a lot of boilerplate code hidden by them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.