PIOS interface to read and write from SPI ports.
More...
PIOS interface to read and write from SPI ports.
Claim the SPI bus semaphore.
- Parameters
-
- Returns
- 0 if no error
-
-1 if timeout before claiming semaphore
Initializes a SPI device.
- Parameters
-
[out] | spi_dev | The handle of the device |
[in] | cfg | the 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_dev | the SPI handle |
[in] | slave_id | the index of the slave to select/deselect |
[in] | pin_value | true to deselect slave, false to select |
- Returns
- 0 if no error
Release the SPI bus semaphore.
- Parameters
-
- 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] | spi | SPI number (0 or 1) |
[in] | spi_speed | configures 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_dev | SPI device handle |
[in] | send_buffer | pointer to buffer which should be sent.
If NULL, 0xff (all-one) will be sent. |
[in] | receive_buffer | pointer to buffer which should get the received values.
If NULL, received bytes will be discarded. |
[in] | len | number 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_dev | SPI handle |
[in] | b | the byte which should be transfered out |
- Returns
- The received byte