Skip to content

SPI

SPI Driver.

Functions for interacting with peripheral devices over a serial peripheral bus (SPI)

Sysprops

syspropdescription
gpio_mosithe master out GPIO
gpio_misothe master in GPIO
gpio_csthe chip select (low active) GPIO
gpio_clkthe master clock GPIO
baudratethe desired baudrate

Functions Overview

Name
CW_DRIVER_FUNCspi_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_FUNCspi_read(int hDev, uint8_t * data, uint32_t len)
read data from the SPI
CW_DRIVER_FUNCspi_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:

Return:

function spi_read

cpp
CW_DRIVER_FUNC spi_read(
    int hDev,
    uint8_t * data,
    uint32_t len
)

read data from the SPI

Parameters:

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