Appearance
SPI
SPI Driver.
Functions for interacting with peripheral devices over a serial peripheral bus (SPI)
Sysprops
| sysprop | description |
|---|---|
| gpio_mosi | the master out GPIO |
| gpio_miso | the master in GPIO |
| gpio_cs | the chip select (low active) GPIO |
| gpio_clk | the master clock GPIO |
| baudrate | the desired baudrate |
Functions Overview
| Name | |
|---|---|
| CW_DRIVER_FUNC | spi_transfer(int hDev, const uint8_t * data_out, uint8_t * data_in, size_t len) Performs a SPI transfer on the specified device. |
| CW_DRIVER_FUNC | spi_read(int hDev, uint8_t * data, uint32_t len) read data from the SPI |
| CW_DRIVER_FUNC | spi_write(int hDev, const uint8_t * data, uint32_t len) write data to the SPI |
Function Details
function spi_transfer
cpp
CW_DRIVER_FUNC spi_transfer(
int hDev,
const uint8_t * data_out,
uint8_t * data_in,
size_t len
)Performs a SPI transfer on the specified device.
Parameters:
- hDev The handle of the device.
- data_out Pointer to the data to be transmitted.
- data_in Pointer to the buffer for received data.
- len The number of bytes to transfer.
Return: CW_DRIVER_OK if the transfer was successful, otherwise an error code.
This function transfers data between the device and the SPI bus.
function spi_read
cpp
CW_DRIVER_FUNC spi_read(
int hDev,
uint8_t * data,
uint32_t len
)read data from the SPI
Parameters:
- hDev device handle as returned by open(const char*)
- data
- len
Return:
convenience function that simply transmits 0xff characters to the communications partner
function spi_write
cpp
CW_DRIVER_FUNC spi_write(
int hDev,
const uint8_t * data,
uint32_t len
)write data to the SPI
Parameters:
- hDev device handle as returned by open(const char*)
- data buffer holding the data to be written
- len length of the buffer
Return:
convenience function that simply discards received bytes during the transfer