Constants
API
Constant | Description |
---|---|
LIBRPIP_API_VERSION | The API version of the librpip library. See the table on the functions page for details. |
Boards
The library initialisation function librpipInit() requires one of these. Also returned by librpipGetBoardID().
Constant | Description |
---|---|
LIBRPIP_BOARD_DETECT | Try and automatically detect the board librpip is running on. Detection is done by looking at the revision in /proc/cpuinfo. |
LIBRPIP_BOARD_PI_A | Raspberry Pi Model A – The original rPi. 26pin header. |
LIBRPIP_BOARD_PI_A_PLUS | Raspberry Pi Model A+ – 40pin header |
LIBRPIP_BOARD_PI_B_R1 | Raspberry Pi Model B R1 – 26pin header. Has I2C0 & revisions 0x2 and 0x3. |
LIBRPIP_BOARD_PI_B_R2 | Raspberry Pi Model B R2 – 26pin header. Has I2C1 and the additional 6 pin header with GPIO 28,29,30,31. |
LIBRPIP_BOARD_PI_B_PLUS | Raspberry Pi Model B+ – 40pin header |
LIBRPIP_BOARD_PI_COMPUTE | Raspberry Pi Compute Module |
LIBRPIP_BOARD_PI_ZERO | Raspberry Zero – 40pin header |
LIBRPIP_BOARD_PI2_B | Raspberry Pi2 Model B – 40pin header |
LIBRPIP_BOARD_PI3_B | Raspberry Pi3 Model B – 40pin header |
Initialisation Flags
Optionally supplied to the library initialisation function librpipInit(). Several flags can be or’d together. Reasons for skipping would include the device is in use by another program. Note that the detection still occurs (so librpip can determine what GPIO pins are safe to use).
Constant | Description |
---|---|
LIBRPIP_FLAG_DEBUG_ON | Activate debug mode. This will cause librpip to automatically print out any errors and warnings to stderr. Capture and redirect stderr like this. |
LIBRPIP_FLAG_NO_RESET | Do not reset hardware. Normally librpip will reset hardware to a known working configuration during initialisation. |
LIBRPIP_FLAG_SKIP_GPIO | Skip GPIO activation during initialisation (usually because some other programme is using it). A better option would be to tell librpipInit() to ignore specific GPIO pins. |
LIBRPIP_FLAG_SKIP_I2C0 | Skip I2C0 activation during initialisation. |
LIBRPIP_FLAG_SKIP_I2C1 | Skip I2C1 activation during initialisation. |
LIBRPIP_FLAG_SKIP_I2C | Skip activation of any I2C modules during initialisation. |
LIBRPIP_FLAG_SKIP_PWM0 | Skip PWM0 activation during initialisation. |
LIBRPIP_FLAG_SKIP_PWM1 | Skip PWM1 activation during initialisation. |
LIBRPIP_FLAG_SKIP_PWM | Skip activation of any PWM modules during initialisation. |
LIBRPIP_FLAG_SKIP_SPI0 | Skip SPI0 activation during initialisation. |
LIBRPIP_FLAG_SKIP_SPI1 | Skip SPI1 activation during initialisation. |
LIBRPIP_FLAG_SKIP_SPI | Skip activation of any SPI modules during initialisation. |
LIBRPIP_FLAG_SKIP_UART0 | Skip UART0 activation during initialisation. |
LIBRPIP_FLAG_SKIP_UART1 | Skip UART1 activation during initialisation. |
LIBRPIP_FLAG_SKIP_UART | Skip activation of any UART modules during initialisation. |
Feature Set
These are used by librpip to indicate back to the calling process what hardware was found during the initialisation and is available. See librpipInit() for more details.
Constant | Description |
---|---|
LIBRPIP_FEATURE_GPIO | GPIO functions are available. See the librpipGpioGetValidPins() function for details on which pins are available. |
LIBRPIP_FEATURE_I2C0 | I2C functions are available on I2C0. |
LIBRPIP_FEATURE_I2C1 | I2C functions are available on I2C1. |
LIBRPIP_FEATURE_PWM0 | PWM functions are available on PWM0. |
LIBRPIP_FEATURE_PWM1 | PWM functions are available on PWM1. |
LIBRPIP_FEATURE_SPI0 | SPI functions are available on SPI0. |
LIBRPIP_FEATURE_SPI1 | SPI functions are available on SPI1. |
LIBRPIP_FEATURE_UART0 | UART functions are available on UART0. |
LIBRPIP_FEATURE_UART1 | UART functions are available on UART1. |
GPIO Constants
Flags
GPIO pin flags are set with librpipGpioConfigPinWrite() and read with librpipGpioConfigPinRead().
Note that the Pull up/down status persists across power down is not readable. It is up to you, the programmer, to remember what GPIO pins have pull up/downs enabled.
Events are detected with the librpipGpioPinEvent() and librpipGpioPinEventWait() functions.
Constant | Description |
---|---|
LIBRPIP_GPIO_FLAG_FNC_IN | Sets a GPIO pin to be an input. |
LIBRPIP_GPIO_FLAG_FNC_OUT | Sets a GPIO pin to be an output. |
LIBRPIP_GPIO_FLAG_PUD_OFF | Disables any pullup or pulldown active on a GPIO pin. Without a pull up or down a unconnected pin will float and may read 0 or 1. |
LIBRPIP_GPIO_FLAG_PUD_DOWN | Enables pulldown (to 0v) on a GPIO pin. |
LIBRPIP_GPIO_FLAG_PUD_UP | Enables pullup (to 3.3v) on a GPIO pin. |
LIBRPIP_GPIO_FLAG_ED_OFF | Disable a previously set event detection. |
LIBRPIP_GPIO_FLAG_ED_RISE | Configure a synchronous rise event detection. For this event to fire the sequence 0-1-1 must occur on the pin across three consecutive clock cycles. This is of particular use for detecting button presses. |
LIBRPIP_GPIO_FLAG_ED_FALL | Configure a synchronous fall event detection. For this event to fire the sequence 1-0-0 must occur on the pin across three consecutive clock cycles. |
LIBRPIP_GPIO_FLAG_ED_HIGH | Configure a high event detection. |
LIBRPIP_GPIO_FLAG_ED_LOW | Configure a low event detection. |
LIBRPIP_GPIO_FLAG_ED_ARISE | Configure an asynchronous rise event detection. This is a lot more sensitive than the synchronous event detection. |
LIBRPIP_GPIO_FLAG_ED_AFALL | Configure an asynchronous fall event detection. This is a lot more sensitive than the synchronous event detection. |
I2C Constants
Not much in the way of configuration with I2C, a single flag…
Flags
I2C flags are set with librpipI2cConfigWrite() and read with librpipI2cConfigRead().
Constant | Description |
---|---|
LIBRPIP_I2C_FLAG_PEC | Enables Packet Error Checking. |
PWM Constants
Status
The PWM status constants are used to start or stop a PWM with librpipPwmStatusWrite(). The current state of a PWM can be determined by comparing the result of librpipPwmStatusRead() with these constants.
Constant | Description |
---|---|
LIBRPIP_PWM_STATUS_OFF | A PWM with this status is off. Set a PWM with this status to turn it off. |
LIBRPIP_PWM_STATUS_ON | A PWM with this status is on. Set a PWM with this status to turn it on. |
Flags
PWM flags are set with librpipPwmConfigWrite() and read with librpipPwmConfigRead().
Constant | Description |
---|---|
LIBRPIP_PWM_FLAG_POLARITY_NORMAL | PWM starts low. Pulse rises from low to high then back to low. |
LIBRPIP_PWM_FLAG_POLARITY_INVERTED | PWM starts high. Pulse falls from high to low then back to high. |
SPI Constants
Mode
SPI mode is set with librpipSpiConfigWrite() and read with librpipSpiConfigRead().
Constant | Description |
---|---|
LIBRPIP_SPI_MODE_0 | Clock polarity normal (idle is zero), Data read at the start of the clock pulse. CPOL=0, CPHA=0 |
LIBRPIP_SPI_MODE_1 | Clock polarity normal (idle is zero), Data read at the end of the clock pulse. CPOL=0, CPHA=1 |
LIBRPIP_SPI_MODE_2 | Clock polarity inverted (idle is one), Data read at the start of the clock pulse. CPOL=1, CPHA=0 |
LIBRPIP_SPI_MODE_3 | Clock polarity inverted (idle is one), Data read at the end of the clock pulse. CPOL=1, CPHA=1 |
Flags
SPI flags are set with librpipSpiConfigWrite() and read with librpipSpiConfigRead().
Constant | Description |
---|---|
LIBRPIP_SPI_FLAG_CS_HIGH | CS function is inverted. Normally CS is held high and dropped low when a client is being communicated with. With this flag on CS is held low and raised high when a client is being communicated with. |
LIBRPIP_SPI_FLAG_NO_CS | Do not use the CS line (either the client doesn’t need one or another GPIO pin is being used instead) |
Transaction Constants
Modes
Modes are used by the librpipTransactionCreate() function to specify the type of transaction.
Constant | Description |
---|---|
LIBRPIP_TX_MODE_I2C | Configures a transaction to use the I2C. |
LIBRPIP_TX_MODE_SPI | Configures a transaction to use the SPI. Note the only supported message direction is TXRX. (simultaneous write and read) |
LIBRPIP_TX_MODE_SPI_3W | Configures a transaction to use SPI 3 wire mode (where input & output lines are shared). Note not valid for SPI1 |
LIBRPIP_TX_MODE_UART | Configures a transacrtion to use the UART. |
Message Directions
Message directions are use when adding messages to a transaction with librpipTransactionMsgAdd() and librpipTransactionMsgVarAdd().
Constant | Description |
---|---|
LIBRPIP_TX_MSG_TX | A transmit message segment. Valid for I2C, SPI 3wire and UART transactions. |
LIBRPIP_TX_MSG_RX | A receive message segment. Valid for I2C, SPI 3wire and UART transactions. |
LIBRPIP_TX_MSG_TXRX | A simultaneous transmit/receive message. Valid for SPI transactions. |
UART Constants
Where possible UART constants are numerically similar to the value they represent.
Baud Rate
Baud Rate is set with librpipUartConfigWrite() and read with librpipUartConfigRead().
Constant | Description |
---|---|
LIBRPIP_UART_BAUD_1200 | 1200 Baud rate. the integer 1200 can also be used. |
LIBRPIP_UART_BAUD_2400 | 2400 Baud rate. the integer 2400 can also be used. |
LIBRPIP_UART_BAUD_4800 | 4800 Baud rate. the integer 4800 can also be used. |
LIBRPIP_UART_BAUD_9600 | 9600 Baud rate. the integer 9600 can also be used. |
LIBRPIP_UART_BAUD_19200 | 19200 Baud rate. the integer 19200 can also be used. |
LIBRPIP_UART_BAUD_38400 | 38400 Baud rate. the integer 38400 can also be used. |
LIBRPIP_UART_BAUD_57600 | 57600 Baud rate. the integer 57600 can also be used. |
LIBRPIP_UART_BAUD_115200 | 115200 Baud rate. the integer 115200 can also be used. |
LIBRPIP_UART_BAUD_230400 | 230400 Baud rate. the integer 230400 can also be used. |
LIBRPIP_UART_BAUD_460800 | 460800 Baud rate. the integer 460800 can also be used. |
LIBRPIP_UART_BAUD_500000 | 500000 Baud rate. the integer 500000 can also be used. |
LIBRPIP_UART_BAUD_576000 | 576000 Baud rate. the integer 576000 can also be used. |
LIBRPIP_UART_BAUD_921600 | 921600 Baud rate. the integer 921600 can also be used. |
LIBRPIP_UART_BAUD_1000000 | 1000000 Baud rate. the integer 1000000 can also be used. |
LIBRPIP_UART_BAUD_1152000 | 1152000 Baud rate. the integer 1152000 can also be used. |
LIBRPIP_UART_BAUD_1500000 | 1500000Baud rate. the integer 1500000 can also be used. |
LIBRPIP_UART_BAUD_2000000 | 2000000 Baud rate. the integer 2000000 can also be used. |
LIBRPIP_UART_BAUD_2500000 | 2500000 Baud rate. the integer 2500000 can also be used. |
LIBRPIP_UART_BAUD_3000000 | 3000000 Baud rate. the integer 3000000 can also be used. |
LIBRPIP_UART_BAUD_3500000 | 3500000 Baud rate. the integer 3500000 can also be used. |
LIBRPIP_UART_BAUD_4000000 | 4000000 Baud rate. the integer 4000000 can also be used. |
Word Size
Word Size is set with librpipUartConfigWrite() and read with librpipUartConfigRead().
Constant | Description |
---|---|
LIBRPIP_UART_SIZE_5 | 5 bits per word. The integer 5 can also be used. This option is not valid for UART1 |
LIBRPIP_UART_SIZE_6 | 6 bits per word. The integer 6 can also be used.This option is not valid for UART1 |
LIBRPIP_UART_SIZE_7 | 7 bits per word. The integer 7 can also be used. |
LIBRPIP_UART_SIZE_8 | 8 bits per word. The integer 8 can also be used. |
Parity
Parity is set with librpipUartConfigWrite() and read with librpipUartConfigRead().
Constant | Description |
---|---|
LIBRPIP_UART_PARITY_OFF | No parity. The integer 0 can also be used. |
LIBRPIP_UART_PARITY_ODD | Odd Parity. The integer 1 can also be used. This option is not valid for UART1 |
LIBRPIP_UART_PARITY_EVEN | Even Parity. The integer 2 can also be used. This option is not valid for UART1 |
Stop Bits
Stop Bits are set with librpipUartConfigWrite() and read with librpipUartConfigRead().
Constant | Description |
---|---|
LIBRPIP_UART_STOPBITS_1 | One stop bit. The integer 1 can also be used. |
LIBRPIP_UART_STOPBITS_2 | Two stop bits. The integer 2 can also be used. This option is not valid for UART1 |
Mode
Mode is set with librpipUartConfigWrite() and read with librpipUartConfigRead().
Constant | Description |
---|---|
LIBRPIP_UART_MODE_BINARY | No conversion of characters is done. |
LIBRPIP_UART_MODE_ASCII | New line characters are converted to carriage returns. |