dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

PIOS interface to read and write from SPI ports. More...

Files

file  pios_spi.h
 SPI functions header.
 
file  pios_spi_priv.h
 SPI private definitions.
 

Data Structures

struct  pios_spi_dev
 
struct  pios_spi_cfg
 

Typedefs

typedef struct pios_spi_devpios_spi_t
 

Functions

int32_t PIOS_SPI_Init (pios_spi_t *spi_dev, const struct pios_spi_cfg *cfg)
 
int32_t PIOS_SPI_SetClockSpeed (pios_spi_t spi_dev, uint32_t speed)
 
int32_t PIOS_SPI_RC_PinSet (pios_spi_t spi_dev, uint32_t slave_id, bool pin_value)
 
uint8_t PIOS_SPI_TransferByte (pios_spi_t spi_dev, uint8_t b)
 
int32_t PIOS_SPI_TransferBlock (pios_spi_t spi_dev, const uint8_t *send_buffer, uint8_t *receive_buffer, uint16_t len)
 
int32_t PIOS_SPI_ClaimBus (pios_spi_t spi_dev)
 
int32_t PIOS_SPI_ReleaseBus (pios_spi_t spi_dev)
 

Detailed Description

PIOS interface to read and write from SPI ports.

Typedef Documentation

typedef struct pios_spi_dev* pios_spi_t

Definition at line 36 of file pios_spi.h.

Function Documentation

int32_t PIOS_SPI_ClaimBus ( pios_spi_t  spi_dev)

Claim the SPI bus semaphore.

Parameters
[in]spi_devSPI handle
Returns
0 if no error
-1 if timeout before claiming semaphore
int32_t PIOS_SPI_Init ( pios_spi_t spi_dev,
const struct pios_spi_cfg cfg 
)

Initializes a SPI device.

Parameters
[out]spi_devThe handle of the device
[in]cfgthe SPI configuration
Returns
zero on success, nonzero on failure
int32_t PIOS_SPI_RC_PinSet ( pios_spi_t  spi_dev,
uint32_t  slave_id,
bool  pin_value 
)

Controls the slave select on a SPI port.

Parameters
[in]spi_devthe SPI handle
[in]slave_idthe index of the slave to select/deselect
[in]pin_valuetrue to deselect slave, false to select
Returns
0 if no error
int32_t PIOS_SPI_ReleaseBus ( pios_spi_t  spi_dev)

Release the SPI bus semaphore.

Parameters
[in]spi_devSPI handle
Returns
0 if no error
int32_t PIOS_SPI_SetClockSpeed ( pios_spi_t  spi_dev,
uint32_t  speed 
)

(Re-)initialises SPI peripheral clock rate

Parameters
[in]spiSPI number (0 or 1)
[in]spi_speedconfigures the SPI speed in Hz
Returns
The actual attained/configured speed.
int32_t PIOS_SPI_TransferBlock ( pios_spi_t  spi_dev,
const uint8_t *  send_buffer,
uint8_t *  receive_buffer,
uint16_t  len 
)

Transfers a block of bytes

Parameters
[in]spi_devSPI device handle
[in]send_bufferpointer to buffer which should be sent.
If NULL, 0xff (all-one) will be sent.
[in]receive_bufferpointer to buffer which should get the received values.
If NULL, received bytes will be discarded.
[in]lennumber of bytes which should be transfered
Returns
>= 0 if no error during transfer
uint8_t PIOS_SPI_TransferByte ( pios_spi_t  spi_dev,
uint8_t  b 
)

Transfers a byte to SPI output and reads back the return value from SPI input

Parameters
[in]spi_devSPI handle
[in]bthe byte which should be transfered out
Returns
The received byte