![]() |
Synergy Software Package User's Manual
|
RTOS-integrated SPI Framework. More...
Data Structures | |
| struct | sf_spi_instance_ctrl_t |
Functions | |
| ssp_err_t | SF_SPI_Open (sf_spi_ctrl_t *const p_api_ctrl, sf_spi_cfg_t const *const p_cfg) |
| Initialize a SPI bus and open low level SPI driver. More... | |
| ssp_err_t | SF_SPI_Read (sf_spi_ctrl_t *const p_api_ctrl, void *const p_dest, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout) |
| Starts the transfer process and receives data from SPI device. More... | |
| ssp_err_t | SF_SPI_Write (sf_spi_ctrl_t *const p_api_ctrl, void *const p_src, uint32_t const length, spi_bit_width_t const bit_width, uint32_t const timeout) |
| Starts the transfer process and writes data to SPI device. More... | |
| ssp_err_t | SF_SPI_WriteRead (sf_spi_ctrl_t *const p_api_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 SPI device while receiving data from SPI device(full duplex). More... | |
| ssp_err_t | SF_SPI_Close (sf_spi_ctrl_t *const p_api_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. More... | |
| ssp_err_t | SF_SPI_Lock (sf_spi_ctrl_t *const p_api_ctrl) |
| Lock the bus for a device. More... | |
| ssp_err_t | SF_SPI_Unlock (sf_spi_ctrl_t *const p_api_ctrl) |
| Unlock the bus for a particular device and make the bus usable for other devices. More... | |
| ssp_err_t | SF_SPI_VersionGet (ssp_version_t *const p_version) |
| Get the version information of the framework. More... | |
| ssp_err_t | SF_SPI_LockWait (sf_spi_ctrl_t *const p_api_ctrl, uint32_t const timeout) |
| Lock the SPI bus resource. Once bus is locked by a device it can not be used by other devices. More... | |
RTOS-integrated SPI Framework.
| ssp_err_t SF_SPI_Close | ( | sf_spi_ctrl_t *const | p_api_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.
| SSP_SUCCESS | SPI channel is successfully closed. |
| SSP_ERR_ASSERTION | p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Device not opened. |
Check whether device is open.
Acquire the device count mutex before accessing the shared resource in close.
Check the count of opened devices on the bus. If there are no devices opened or all other devices on the bus are closed then close the low level SPI driver and release the RTOS services used by the bus.
Get the low level control in use.
Close low level driver.
Delete RTOS services used by the bus.
Decrement device count.
Delete the device count mutex
Decrement device count.
Release the device count mutex
Set device to closed state
| ssp_err_t SF_SPI_Lock | ( | sf_spi_ctrl_t *const | p_api_ctrl | ) |
Lock the bus for a device.
| SSP_SUCCESS | SPI bus is successfully locked. |
| SSP_ERR_ASSERTION | p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Device not opened. |
| SSP_ERR_IN_USE | In-use error. |
Check whether device is open.
Get the mutex for this device.
Start transfer process - check lock, check reconfiguration, check bus compatibility, enable chip select.
Release the mutex
Set lock flag.
| ssp_err_t SF_SPI_LockWait | ( | sf_spi_ctrl_t *const | p_api_ctrl, |
| uint32_t const | timeout | ||
| ) |
Lock the SPI bus resource. Once bus is locked by a device it can not be used by other devices.
| SSP_SUCCESS | SPI channel is successfully locked within the specified timeout. |
| SSP_ERR_ASSERTION | Pointer to SPI control block is NULL. |
| SSP_ERR_NOT_OPEN | Device not opened. |
| SSP_ERR_TIMEOUT | Mutex not available in timeout. |
Check whether device is open.
Get the mutex for this device.
Set lock flag.
Enable slave.
| ssp_err_t SF_SPI_Open | ( | sf_spi_ctrl_t *const | p_api_ctrl, |
| sf_spi_cfg_t const *const | p_cfg | ||
| ) |
Initialize a SPI bus and open low level SPI driver.
| SSP_SUCCESS | SPI channel is successfully opened. |
| SSP_ERR_ASSERTION | One of the following parameters is NULL: p_api_ctrl, p_cfg, Pointer to Open, Close, Read, Write, or Writeread API interfaces, p_cfg->p_bus or p_cfg->p_lower_lvl_cfg. |
| SSP_ERR_INTERNAL | Internal error occurred. |
| SSP_ERR_ALREADY_OPEN | Same SPI framework device is already open. |
Check whether device is already opened or not.
Copy bus to control
Copy chip_select to control
Copy chip_select level to control
Initialize bus lock to false
Set framework level callback function.
Save context for use in ISRs.
Use bus channel in device open.
Enter a critical section before checking the device count mutex status.
Check if device count mutex is already created. If not then create the mutex.
Create device_count_mutex. This is used to protect shared variable device_count in bus control structure.
If mutex create fails, return error.
Exit critical section
Acquire the device count mutex before accessing the shared resource. Try again if the mutex was deleted in close.
Increment device count.
Save device configuration for reconfiguration.
Set device state as Opened.
Initialize chip select.
| ssp_err_t SF_SPI_Read | ( | sf_spi_ctrl_t *const | p_api_ctrl, |
| void *const | p_dest, | ||
| uint32_t const | length, | ||
| spi_bit_width_t const | bit_width, | ||
| uint32_t const | timeout | ||
| ) |
Starts the transfer process and receives data from SPI device.
| SSP_SUCCESS | Data read completed successfully. |
| SSP_ERR_ASSERTION | One of the following parameters is NULL: p_api_ctrl, p_dest, length. |
| SSP_ERR_NOT_OPEN | Device not opened. |
Check whether device is open.
Get mutex for this bus.
Start transfer process - check lock, check reconfiguration, check bus compatibility, enable chip select.
Release the mutex
Perform read.
Finish transfer.
| ssp_err_t SF_SPI_Unlock | ( | sf_spi_ctrl_t *const | p_api_ctrl | ) |
Unlock the bus for a particular device and make the bus usable for other devices.
| SSP_SUCCESS | SPI bus is successfully unlocked. |
| SSP_ERR_ASSERTION | p_api_ctrl is NULL. |
| SSP_ERR_NOT_OPEN | Device not opened. |
| SSP_ERR_IN_USE | In-use error. |
Check whether device is open.
Acquire the mutex.
Clear lock flag.
Disable slave.
Release the mutex so that others can use the bus.
| ssp_err_t SF_SPI_VersionGet | ( | ssp_version_t *const | p_version | ) |
Get the version information of the framework.
| SSP_ERR_ASSERTION | p_version is NULL. |
| SSP_SUCCESS | Successful return. |
Checks error. Further parameter checking can be done at the driver layer.
| ssp_err_t SF_SPI_Write | ( | sf_spi_ctrl_t *const | p_api_ctrl, |
| void *const | p_src, | ||
| uint32_t const | length, | ||
| spi_bit_width_t const | bit_width, | ||
| uint32_t const | timeout | ||
| ) |
Starts the transfer process and writes data to SPI device.
| SSP_SUCCESS | Data write completed successfully. |
| SSP_ERR_ASSERTION | One of the following parameters may be NULL: p_api_ctrl, p_src, length. |
| SSP_ERR_NOT_OPEN | Device not opened. |
Check whether device is open.
Get mutex for this bus.
Start transfer process - check lock, check reconfiguration, check bus compatibility, enable chip select.
Release the mutex
Perform write.
Finish transfer.
| ssp_err_t SF_SPI_WriteRead | ( | sf_spi_ctrl_t *const | p_api_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 SPI device while receiving data from SPI device(full duplex).
| SSP_SUCCESS | Data write completed successfully. |
| SSP_ERR_ASSERTION | One of the following parameters may be NULL: p_api_ctrl, p_src, p_dest, length. |
| SSP_ERR_NOT_OPEN | Device not opened. |
Check whether device is open.
Get mutex for this bus.
Start transfer process - check lock, check reconfiguration, check bus compatibility, enable chip select.
Release the mutex
Perform write read.
Finish transfer.