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) send to and receive from the SPI at the same time. |
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
)
send to and receive from the SPI at the same time.
Parameters:
- hDev device handle as returned by open(const char*)
- data_out
- data_in
- len
Return:
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