RasPi Direct Hardware Access
Integrated peripheral access without operating system drivers.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Macros | Functions
SPI Master (SPI0)

These functions allow direct access to the Raspberry Pi's SPI0 master peripheral without using the regular Linux device driver. More...

Macros

#define raspi_SPI_FIFOSIZE   16
 Size of both, the read and the write FIFO.
 

Functions

static void spi_init (uint32_t speed)
 Configure SPI hardware for speed bit/s.
 
static void spi_start (int destination)
 Start SPI transfer to destination (0 or 1, corresponding to the available chip select lines). The receive FIFO will be cleared.
 
static void spi_stop (void)
 Stop SPI transfer. Block until all pending data is transmitted.
 
static int spi_poll (int num)
 Return true if at least num bytes are available in the receive FIFO. Only guaranteed to work correctly with num == 1. Larger values may return true even if less bytes (but at least one) are available.
 
static uint8_t spi_read (void)
 Read a single byte received via SPI. Block if FIFO is currently empty. Note that SPI only receives while sending, so each spi_read() must be paired with an spi_write().
 
static void spi_write (uint8_t data)
 Send data via SPI. Block if FIFO is currently full. spi_start() must be called before.
 
static void spi_flush (void)
 Block until transmit FIFO is empty.
 

Detailed Description

These functions allow direct access to the Raspberry Pi's SPI0 master peripheral without using the regular Linux device driver.

This is useful when running under Xenomai or a similar real-time OS. Note that you must unload the SPI kernel module, or these functions will not work correctly.

Declared in raspi/spi.h.