librpipGpioPinEvent

uint32_t librpipGpioPinEvent(uint32_t pin, uint32_t* event);

Description

Checks to see if a preconfigured event has been triggered on a pin. Events allow you to check for basic changes in a pin state without having to poll pins at high rates (mHz). The pins still need to be polled for events but that can be done at a much lower rate (kHz). Oh yes I’d really like to see interrupts being implemented somehow so no polling is required at all but current kernel module doesn’t allow that…

Parameters

  • uint32_t pin
    The pin number to check. The pin should be valid.
  • uint32_t* event
    A pointer to a uint32_t that will hold the current event state. 0 = no event trigger, >=1 = event trigger has occurred. Note that the event occurred flag, if set,  gets cleared on check.

Returns

0 on failure, 1 on success.

Example

Setup GPIO pin 16 for rise event and then see if it has occurred :

uint32_t feature_set, triggered;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
if(feature_set & LIBRPIP_FEATURE_GPIO) { 
        librpipGpioConfigPinWrite(16, LIBRPIP_GPIO_FLAG_FNC_IN | LIBRPIP_GPIO_FLAG_ED_RISE);
        { ...do stuff... }
        librpipGpioPinEvent(16, &triggered);
        if(triggered) {// pin rose while stuff was being done } 
} 
librpipClose();