struct librpip_tx* librpipTransactionCreate(uint8_t mode, uint8_t bpw);


Creates an empty transaction. Transactions are data structures that are constructed once and used repeatably. They represent an entire ‘conversation’ with a piece of hardware whilst also proving a common interface regardless of the underlying system being used to actually perform the communication.

It it important to realise that the transactions are converted into specific I2C and SPI data structures for transmission. These data structures are processed in one hit – that is the CS line remains low the entire time for SPI and start bits are sent between bytes with a single stop bit and the end with I2C. When you read data sheets for devices the examples they give are usually transactions and you need to analyse there examples to work out what transactions does the device accept and what are the the message segments within these transactions so you can add these with librpipTransactionMsgAdd()librpipTransactionMsgAddRegRead()librpipTransactionMsgAddRegWrite(), and librpipTransactionMsgVarAdd().


  • uint8_t mode
    The type of transaction. One of the LIBRPIP_TX_MODE_* constants.
  • uint8_t bpw
    The word size being used. Currently only 8 bits per word is supported but that will change in future releases.


A pointer to a librpip_tx structure. This pointer is required for all future actions with the created transaction.


Create a transaction to read an I2C sensor, then actually read it and print it 5 times:

uint32_t feature_set,i;
uint8_t result;
struct librpip_tx* MySensor;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
MySensor=librpipTransactionCreate(LIBRPIP_TX_MODE_I2C, 8);
librpipTransactionMsgAddRegRead(MySensor, 0x01, 1);
for(i=0;i<5;i++) {
        librpipTransactionSend(MySensor, 0, 0x30); 
        librpipTransactionRead(MySensor, &result, 1);
        fprintf(stdout,"The sensor is %u\n",result);