librpipSpiConfigRead

uint32_t librpipSpiConfigRead(uint32_t id, uint32_t cs, uint32_t* mode, uint32_t* lsb_first, uint32_t* bits_per_word, uint32_t* max_speed, uint32_t* flags);

Description

Reads the config of a SPI master. Note that there are more options returned than is possible to set. This is because the current spi_bcm2835 kernel module only supports a single value for these additional parameters and hence there is nothing for the user to config.

Parameters

  • uint32_t id
    The SPI device id to configure. The SPI device needs to have been detected during the librpipInit().
  • uint32_t cs
    The client select line to configure. SPI0 has two – 0 and 1, SPI1 has three 0,1,2. Yes each client has it’s own discrete config.
  • uint32_t* mode
    A pointer to a unit32_t to hold the current spi mode.
  • uint32_t* lsb_first
    A pointer to a  unit32_t to hold the current lsb mode. Currently this will always be 0 as this is the only value the kernel module supports.
  • uint32_t* bits_per_word
    A pointer to a unit32_t to hold the current bits per word. Currently this will always be 8 as this is the only value the kernel module supports.
  • uint32_t* max_speed
    A pointer to a unit32_t to hold the current clock speed.
  • uint32_t* flags
    A pointer to a unit32_t to hold the current spi flags.

Returns

0 on failure or 1 on success.

Example

Read the current config for SP0, client 0.

uint32_t feature_set, mode, lsb, bpw, speed, flags;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
if(feature_set & LIBRPIP_FEATURE_SPI0) {
        librpipSpiConfigRead(0, 0, &mode, &lsb, &bpw, &speed, &flags);
}