librpipGpioPinRead

uint32_t librpipGpioPinRead(uint32_t pin, uint32_t* value);

Description

Gets the current value of a pin. The pin can be set either for input or output.

Parameters

  • uint32_t pin
    The pin number to read. The pin should be valid.
  • uint32_t* value
    A pointer to a uint32_t that will hold the current value. 0 = off, >=1 = on.

Returns

0 on failure, 1 on success.

Example

Setup GPIO pin 16 for input, and then read its current value :

uint32_t feature_set, pin;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
if(feature_set & LIBRPIP_FEATURE_GPIO) { 
        librpipGpioConfigPinWrite(16, LIBRPIP_GPIO_FLAG_FNC_IN);
        librpipGpioPinRead(16, &pin);
        if(pin) {// pin is on }
} 
librpipClose();