spi_setcfg()

The spi_setcfg() function sets the configuration for a specific device on the SPI bus. The prototype for this function is:

int spi_setcfg( int fd,
                uint32_t device,
                spi_cfg_t *cfg );

The arguments are:

fd
The file descriptor obtained by calling spi_open().
device
The device ID. You can OR it with SPI_DEV_DEFAULT to set the device as the default for this file descriptor.
cfg
A pointer to the configuration structure. This structure is:
typedef struct {
    uint32_t    mode;
    uint32_t    clock_rate;
} spi_cfg_t;
  

The possible mode settings are defined in <hw/spi-master.h>.

This function returns EOK if the configuration is successful.