Browse Source

#25

pull/188/head
mstroh76 8 months ago
parent
commit
417d54649d
3 changed files with 15 additions and 1 deletions
  1. +1
    -1
      gpio/gpio.c
  2. +13
    -0
      wiringPi/wiringPi.c
  3. +1
    -0
      wiringPi/wiringPi.h

+ 1
- 1
gpio/gpio.c View File

@@ -1338,7 +1338,7 @@ static void doVersion (char *argv [])
}
}

if (stat ("/dev/gpiomem", &statBuf) == 0) // User level GPIO is GO
if (wiringPiUserLevelAccess()) // User level GPIO is GO
printf (" * This Raspberry Pi supports user-level GPIO access.\n") ;
else
printf (" * Root or sudo required for GPIO access.\n") ;


+ 13
- 0
wiringPi/wiringPi.c View File

@@ -2553,6 +2553,19 @@ void wiringPiVersion (int *major, int *minor)
}


int wiringPiUserLevelAccess(void)
{
struct stat statBuf ;
const char* gpiomemModule = gpiomem_BCM;

if (PI_MODEL_5 == RaspberryPiModel) {
gpiomemModule = gpiomem_RP1;
}

return stat(gpiomemModule, &statBuf) == 0 ? 1 : 0;
}


/*
* wiringPiSetup:
* Must be called once at the start of your program execution.


+ 1
- 0
wiringPi/wiringPi.h View File

@@ -206,6 +206,7 @@ extern struct wiringPiNodeStruct *wiringPiNewNode (int pinBase, int numPins) ;
extern int GPIOToSysFS(const int pin) ;

extern void wiringPiVersion (int *major, int *minor) ;
extern int wiringPiUserLevelAccess (void) ;
extern int wiringPiSetup (void) ;
extern int wiringPiSetupSys (void) ;
extern int wiringPiSetupGpio (void) ;


Loading…
Cancel
Save