Function Reference

Note that librpip uses the broadcom GPIO pin numbers. The equivalent rPi header pin numbers are here.

Core Functions

Fundamental functions for using librpip.

uint32_t librpipInit(uint32_t board, uint32_t flags, uint32_t ignore_pins);
void librpipClose(void);
uint32_t librpipGetBoardID(void);
void librpipVersionStr(char* version, int len);
void librpipVersionInt(uint8_t* maj, uint8_t* min, uint8_t* sub);

Error Functions

These functions provide a simple error system for librpip.

uint32_t librpipErrorGetCode(void);
uint32_t librpipErrorGetSeverity(void);
uint32_t librpipErrorGetDescription(char* desc, int len);
void librpipErrorPrint(void);

GPIO Functions

Functions for interacting with GPIO pins.

uint32_t librpipGpioConfigPinRead(uint32_t pin, uint32_t* flags);
uint32_t librpipGpioConfigPinWrite(uint32_t pin, uint32_t flags);
uint32_t librpipGpioPinRead(uint32_t pin, uint32_t* value);
uint32_t librpipGpioPinWrite(uint32_t pin, uint32_t value);
uint32_t librpipGpioPinToggle(uint32_t pin);
uint32_t librpipGpioPinPulse(uint32_t pin, uint32_t length);
uint32_t librpipGpioPinEvent(uint32_t pin, uint32_t* event);
uint32_t librpipGpioPinEventWait(uint32_t pin, uint32_t timeout);
uint32_t librpipGpioGetValidPins(void);

I2C Functions

Functions for I2C devices. Note that actual transmissions are handled by the ‘Transaction‘ functions below.

uint32_t librpipI2cConfigWrite(uint32_t id, uint32_t flags);
uint32_t librpipI2cConfigRead(uint32_t id, uint32_t* flags);

PWM Functions

Functions for hardware PWM. The ‘Servo’ functions are connivence functions optimised for interacting with servos.

uint32_t librpipPwmConfigRead(uint32_t id, uint32_t* pin, uint32_t* period, uint32_t* duty_cycle, uint32_t* flags);
uint32_t librpipPwmConfigWrite(uint32_t id, uint32_t period, uint32_t duty_cycle, uint32_t flags);
uint32_t librpipPwmStatusRead(uint32_t id, uint32_t* status);
uint32_t librpipPwmStatusWrite(uint32_t id, uint32_t status);
uint32_t librpipPwmDutyPercentWrite(uint32_t id, float duty_cycle);
uint32_t librpipServoConfigRead(uint32_t id, uint32_t* range, uint32_t* pmin, uint32_t* pmax);
uint32_t librpipServoConfigWrite(uint32_t id, uint32_t range, uint32_t pmin, uint32_t pmax);
uint32_t librpipServoPositionWrite(uint32_t id, float angle);

SPI Functions

Functions for SPI hardware. Note that actual transmissions are handled by the ‘Transaction‘ functions below.

uint32_t librpipSpiConfigRead(uint32_t id, uint32_t cs, uint32_t* spi_mode, uint32_t* lsb_first, uint32_t* bits_per_word, uint32_t* max_speed, uint32_t* spi_flags);
uint32_t librpipSpiConfigWrite(uint32_t id, uint32_t cs, uint32_t spi_mode, uint32_t max_speed, uint32_t spi_flags);

Transaction Functions

Functions for performing transactions with I2C/SPI/UART devices.

struct librpip_tx* librpipTransactionCreate(uint8_t mode, uint8_t bpw);
void librpipTransactionConfigRead(struct librpip_tx* t, uint8_t* mode, uint8_t* bpw, uint8_t* status, uint16_t* len);
uint32_t librpipTransactionMsgAdd(struct librpip_tx* t, uint8_t dir, void* txbuf, uint16_t len);
uint32_t librpipTransactionMsgAddRegRead(struct librpip_tx* t, uint8_t reg, uint16_t len);
uint32_t librpipTransactionMsgAddRegWrite(struct librpip_tx* t, uint8_t reg, uint8_t value);
uint32_t librpipTransactionMsgVarAdd(struct librpip_tx* t, uint8_t dir, char var);
uint32_t librpipTransactionMsgVarSet(struct librpip_tx* t, char var, void* txbuf, uint16_t len);
uint32_t librpipTransactionSend(struct librpip_tx* t, uint32_t device, uint32_t client);
uint32_t librpipTransactionRead(struct librpip_tx* t, void* result, uint16_t len);
uint32_t librpipTransactionReadSize(struct librpip_tx* t, uint16_t* size);
uint32_t librpipTransactionDestroy(struct librpip_tx* t);

UART Functions

Functions for UART hardware. Like SPI & I2C actual communications can be handled with a transaction, but there is also direct read and write available as serial comms across UARTs is not always transaction based.

uint32_t librpipUartConfigWrite(uint32_t id, uint32_t baud, uint32_t csize, uint32_t parity, uint32_t stop, uint32_t mode);
uint32_t librpipUartConfigRead(uint32_t id, uint32_t* baud, uint32_t* csize, uint32_t* parity, uint32_t* stop, uint32_t* mode);
uint32_t librpipUartWrite(uint32_t id, void* buf, uint16_t len);
uint32_t librpipUartRead(uint32_t id, void* buf, uint16_t len, uint32_t timeout);

API Version

Functions that have been added to the library as as per below:

librpip versions LIBRPIP_API_VERSION Items Added
 0.1.0 – 0.3.2 (not set) Original API
 0.4.0 1.1
  • librpipErrorGetSeverity()
  • librpipTransactionConfigRead()
  • librpipTransactionReadSize()