Synergy Software Package User's Manual

#include <sf_spi_api.h>

Data Fields

ssp_err_t(* open )(sf_spi_ctrl_t *p_ctrl, sf_spi_cfg_t const *const p_cfg)
 Open a designated SPI device on a bus. More...
 
ssp_err_t(* read )(sf_spi_ctrl_t *const p_ctrl, void *const p_dest, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout)
 Receive data from SPI device. More...
 
ssp_err_t(* write )(sf_spi_ctrl_t *const p_ctrl, void *const p_src, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout)
 Transmit data to SPI device. More...
 
ssp_err_t(* writeRead )(sf_spi_ctrl_t *const p_ctrl, void *const p_src, void *const p_dest, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout)
 Simultaneously transmit data to an SPI device while receiving data from an SPI device (full duplex). More...
 
ssp_err_t(* close )(sf_spi_ctrl_t *const p_ctrl)
 Disable the SPI device designated by the control handle and close the RTOS services used by the bus if no devices are connected to the bus. This function removes power to the SPI channel designated by the handle and disables the associated interrupts. More...
 
ssp_err_t(* lock )(sf_spi_ctrl_t *const p_ctrl)
 Lock the bus for a device. The locking allows devices to reserve a bus to themselves for a given period of time (i.e. between lock and unlock). This allows devices to complete several reads and writes on the bus without interrupt. More...
 
ssp_err_t(* lockWait )(sf_spi_ctrl_t *const p_ctrl, uint32_t const timeout)
 Lock the bus for a device. The locking allows devices to reserve a bus to themselves for a given period of time (i.e. between lock and unlock). This allows devices to complete several reads and writes on the bus without interrupt. The wait option allows thread to wait for the specified timeout when acquiring the bus mutex. More...
 
ssp_err_t(* unlock )(sf_spi_ctrl_t *const p_ctrl)
 Unlock the bus for a particular device and make the bus usable for other devices. More...
 
ssp_err_t(* version )(ssp_version_t *const p_version)
 Get the version information of the underlying driver. More...
 

Detailed Description

Definition of the SPI framework interface.

Field Documentation

◆ close

ssp_err_t(* sf_spi_api_t::close) (sf_spi_ctrl_t *const p_ctrl)

Disable the SPI device designated by the control handle and close the RTOS services used by the bus if no devices are connected to the bus. This function removes power to the SPI channel designated by the handle and disables the associated interrupts.

Parameters
[in]p_ctrlPointer to the control block for the device.

◆ lock

ssp_err_t(* sf_spi_api_t::lock) (sf_spi_ctrl_t *const p_ctrl)

Lock the bus for a device. The locking allows devices to reserve a bus to themselves for a given period of time (i.e. between lock and unlock). This allows devices to complete several reads and writes on the bus without interrupt.

Parameters
[in]p_ctrlPointer to the control block for the device.

◆ lockWait

ssp_err_t(* sf_spi_api_t::lockWait) (sf_spi_ctrl_t *const p_ctrl, uint32_t const timeout)

Lock the bus for a device. The locking allows devices to reserve a bus to themselves for a given period of time (i.e. between lock and unlock). This allows devices to complete several reads and writes on the bus without interrupt. The wait option allows thread to wait for the specified timeout when acquiring the bus mutex.

Implemented as
Parameters
[in]p_ctrlPointer to the control block for the device.
[in]timeoutThreadX timeout. Options include TX_NO_WAIT (0x00000000), TX_WAIT_FOREVER (0xFFFFFFFF), and timeout value (0x00000001 through 0xFFFFFFFE) in ThreadX tick counts.

◆ open

ssp_err_t(* sf_spi_api_t::open) (sf_spi_ctrl_t *p_ctrl, sf_spi_cfg_t const *const p_cfg)

Open a designated SPI device on a bus.

Parameters
[in,out]p_ctrlPointer to user-provided storage for the control block.
[in]p_cfgPointer to SPI Framework configuration structure.

◆ read

ssp_err_t(* sf_spi_api_t::read) (sf_spi_ctrl_t *const p_ctrl, void *const p_dest, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout)

Receive data from SPI device.

Precondition
Call sf_spi_api_t::open to configure the SPI device before using this function.
Parameters
[in]p_ctrlPointer to the control block for the device.
[out]p_destPointer to destination buffer into which data will be copied that is received from a SPI device. It is the responsibility of the caller to ensure that adequate space is available to hold the requested data count.
[in]lengthIndicates the number of units of data to be transferred (unit size specified by the bit_width).
[in]bit_widthIndicates data bit width to be transferred.
[in]timeoutTimeout. Options include TX_NO_WAIT (0x00000000), TX_WAIT_FOREVER (0xFFFFFFFF), and timeout value (0x00000001 through 0xFFFFFFFE) in ThreadX tick counts.

◆ unlock

ssp_err_t(* sf_spi_api_t::unlock) (sf_spi_ctrl_t *const p_ctrl)

Unlock the bus for a particular device and make the bus usable for other devices.

Parameters
[in]p_ctrlPointer to the control block for the device.

◆ version

ssp_err_t(* sf_spi_api_t::version) (ssp_version_t *const p_version)

Get the version information of the underlying driver.

Parameters
[out]p_versionpointer to memory location to return version number

◆ write

ssp_err_t(* sf_spi_api_t::write) (sf_spi_ctrl_t *const p_ctrl, void *const p_src, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout)

Transmit data to SPI device.

Precondition
Call sf_spi_api_t::open to configure the SPI device before using this function.
Parameters
[in]p_ctrlPointer to the control block for the device.
[in]p_srcPointer to a source data buffer from which data will be transmitted to a SPI device.
The argument must not be NULL.
[in]lengthIndicates the number of units of data to be transferred (unit size specified by the bit_width).
[in]bit_widthIndicates data bit width to be transferred.
[in]timeoutTimeout. Options include TX_NO_WAIT (0x00000000), TX_WAIT_FOREVER (0xFFFFFFFF), and timeout value (0x00000001 through 0xFFFFFFFE) in ThreadX tick counts.

◆ writeRead

ssp_err_t(* sf_spi_api_t::writeRead) (sf_spi_ctrl_t *const p_ctrl, void *const p_src, void *const p_dest, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout)

Simultaneously transmit data to an SPI device while receiving data from an SPI device (full duplex).

The writeread API gets mutex object, handles SPI data transmission at SPI HAL layer and receive data from the SPI HAL layer. The API uses the event flag wait to synchronize to completion of data transfer .

Precondition
Call sf_spi_api_t::open to configure the SPI before using this function.
Parameters
[in]p_ctrlPointer to the control block for the channel.
[in]p_srcPointer to a source data buffer from which data will be transmitted to a SPI device.
The argument must not be NULL.
[out]p_destPointer to destination buffer into which data will be copied that is received from a SPI device. It is the responsibility of the caller to ensure that adequate space is available to hold the requested data count.
[in]lengthIndicates the number of units of data to be transferred (unit size specified by the bit_width).
[in]bit_widthIndicates data bit width to be transferred.
[in]timeoutTimeout. Options include TX_NO_WAIT (0x00000000), TX_WAIT_FOREVER (0xFFFFFFFF), and timeout value (0x00000001 through 0xFFFFFFFE) in ThreadX tick counts.

The documentation for this struct was generated from the following file: