pihwm
A lightweight C library for Raspberry Pi hardware modules.
 All Data Structures Files Functions Groups Pages
SPI

SPI library functions. More...

Functions

int spi_init (uint8_t channel)
 Initialises the spidev interface.
 
int spi_config (int fd, uint8_t mode, uint8_t bits, uint32_t speed, uint16_t delay)
 Configures the spidev interface.
 
int spi_config_default (int fd)
 Configures the spidev interface with default values.
 
int spi_transfer (int fd, uint8_t txbuf[], uint8_t rxbuf[], uint8_t len)
 Initiates SPI transfers.
 

Detailed Description

SPI library functions.

Function Documentation

int spi_config ( int  fd,
uint8_t  mode,
uint8_t  bits,
uint32_t  speed,
uint16_t  delay 
)

Configures the spidev interface.

Parameters
fdFile descriptor to use, can be acquired via spi_init()
modeSPI mode
bitsNumber of bits
speedBus speed
delayAmount of delay
Returns
1 for success, -1 for failure

Definition at line 116 of file pi_spi.c.

int spi_config_default ( int  fd)

Configures the spidev interface with default values.

Parameters
fdFile descriptor to use, can be acquired via spi_init()
Returns
1 for success, -1 for failure

Definition at line 155 of file pi_spi.c.

int spi_init ( uint8_t  channel)

Initialises the spidev interface.

Parameters
channelSPI channel to use (0 or 1)
Returns
1 for success, -1 for failure

Definition at line 53 of file pi_spi.c.

int spi_transfer ( int  fd,
uint8_t  txbuf[],
uint8_t  rxbuf[],
uint8_t  len 
)

Initiates SPI transfers.

Parameters
fdFile descriptor to use, can be acquired via spi_init()
txbufTransmit buffer array
rxbufReceive buffer array
lenLength of transfer
Returns
1 for success, -1 for failure

Definition at line 175 of file pi_spi.c.