UoS³ Flight Computer Firmware
 All Data Structures Files Functions Groups Pages
Files | Functions

SPI Peripheral Driver. More...

Files

file  spi.c
 SPI Driver - gnulinux platform.
 
file  spi.c
 SPI Driver - uos3-proto board.
 

Functions

uint8_t SPI_cmd (uint8_t spi_num, uint8_t cmd)
 
uint8_t SPI_read8 (uint8_t spi_num, uint8_t addr, uint8_t *data)
 
uint8_t SPI_write8 (uint8_t spi_num, uint8_t addr, uint8_t *data)
 
uint8_t SPI_burstread8 (uint8_t spi_num, uint8_t addr, uint8_t *data, uint32_t len)
 
uint8_t SPI_burstwrite8 (uint8_t spi_num, uint8_t addr, uint8_t *data, uint32_t len)
 
uint8_t SPI_read16 (uint8_t spi_num, uint16_t addr, uint8_t *data)
 
uint8_t SPI_write16 (uint8_t spi_num, uint16_t addr, uint8_t *data)
 
uint8_t SPI_burstread16 (uint8_t spi_num, uint16_t addr, uint8_t *data, uint32_t len)
 
uint8_t SPI_burstwrite16 (uint8_t spi_num, uint16_t addr, uint8_t *data, uint32_t len)
 
uint8_t SPI_read32 (uint8_t spi_num, uint32_t addr, uint8_t *data)
 
uint8_t SPI_write32 (uint8_t spi_num, uint32_t addr, uint8_t *data)
 
uint8_t SPI_burstread32 (uint8_t spi_num, uint32_t addr, uint8_t *data, uint32_t len)
 
uint8_t SPI_burstwrite32 (uint8_t spi_num, uint32_t addr, uint8_t *data, uint32_t len)
 

Detailed Description

SPI Peripheral Driver.

Hardware SPI Peripheral Driver.

SPI ports for each board are defined in ${board}/board.h

The relevant SPI Port/Peripheral is initialised if required on any function call.

Function Documentation

uint8_t SPI_cmd ( uint8_t  spi_num,
uint8_t  cmd 
)

Sends a single 'command' byte on the specified SPI peripheral

Parameters
spi_numID of the SPI peripheral
cmdCommand byte to be sent
Returns
Status byte

Public Functions

Definition at line 15 of file spi.c.

uint8_t SPI_read8 ( uint8_t  spi_num,
uint8_t  addr,
uint8_t *  data 
)

Reads a byte from an address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrAddress of the slave device register
dataPointer to a byte for storage of the data retrieved
Returns
Status byte

Definition at line 23 of file spi.c.

uint8_t SPI_write8 ( uint8_t  spi_num,
uint8_t  addr,
uint8_t *  data 
)

Writes a byte to an address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrAddress of the slave device register
dataPointer to a byte containing the data to be written
Returns
Status byte

Definition at line 42 of file spi.c.

uint8_t SPI_burstread8 ( uint8_t  spi_num,
uint8_t  addr,
uint8_t *  data,
uint32_t  len 
)

Reads a number of bytes from an address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrAddress of the slave device register
dataPointer to bytes for storage of the data retrieved
lenNumber of bytes to be read
Returns
Status byte

Definition at line 32 of file spi.c.

uint8_t SPI_burstwrite8 ( uint8_t  spi_num,
uint8_t  addr,
uint8_t *  data,
uint32_t  len 
)

Writes a number of bytes to an address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrAddress of the slave device register
dataPointer to bytes containing the data to be written
lenNumber of bytes to be written
Returns
Status byte

Definition at line 51 of file spi.c.

uint8_t SPI_read16 ( uint8_t  spi_num,
uint16_t  addr,
uint8_t *  data 
)

Reads a byte from an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to a byte for storage of the data retrieved
Returns
Status byte

Definition at line 61 of file spi.c.

uint8_t SPI_write16 ( uint8_t  spi_num,
uint16_t  addr,
uint8_t *  data 
)

Writes a byte to an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to a byte containing the data to be written
Returns
Status byte

Definition at line 80 of file spi.c.

uint8_t SPI_burstread16 ( uint8_t  spi_num,
uint16_t  addr,
uint8_t *  data,
uint32_t  len 
)

Reads a number of bytes from an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to bytes for storage of the data retrieved
lenNumber of bytes to be read
Returns
Status byte

Definition at line 70 of file spi.c.

uint8_t SPI_burstwrite16 ( uint8_t  spi_num,
uint16_t  addr,
uint8_t *  data,
uint32_t  len 
)

Writes a number of bytes to an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to bytes containing the data to be written
lenNumber of bytes to be written
Returns
Status byte

Definition at line 89 of file spi.c.

uint8_t SPI_read32 ( uint8_t  spi_num,
uint32_t  addr,
uint8_t *  data 
)

Reads a byte from an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to a byte for storage of the data retrieved
Returns
Status byte

Definition at line 99 of file spi.c.

uint8_t SPI_write32 ( uint8_t  spi_num,
uint32_t  addr,
uint8_t *  data 
)

Writes a byte to an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to a byte containing the data to be written
Returns
Status byte

Definition at line 118 of file spi.c.

uint8_t SPI_burstread32 ( uint8_t  spi_num,
uint32_t  addr,
uint8_t *  data,
uint32_t  len 
)

Reads a number of bytes from an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to bytes for storage of the data retrieved
lenNumber of bytes to be read
Returns
Status byte

Definition at line 108 of file spi.c.

uint8_t SPI_burstwrite32 ( uint8_t  spi_num,
uint32_t  addr,
uint8_t *  data,
uint32_t  len 
)

Writes a number of bytes to an extended address of the slave device on the specified SPI peripheral.

Parameters
spi_numID of the SPI peripheral
addrExtended address of the slave device register
dataPointer to bytes containing the data to be written
lenNumber of bytes to be written
Returns
Status byte

Definition at line 127 of file spi.c.