PDK API Guide for J721E
|
Multi-Channel SPI driver interface
Files | |
file | MCSPI.h |
Multi-Channel SPI driver interface. | |
Data Structures | |
struct | MCSPI_Params |
MCSPI Parameters. More... | |
struct | MCSPI_FxnTable |
The definition of a MCSPI function table that contains the required set of functions to control a specific MCSPI driver implementation. More... | |
struct | MCSPI_Config |
MCSPI Global configuration. More... | |
Functions | |
void | MCSPI_close (MCSPI_Handle handle) |
Function to close a channel of a SPI peripheral specified by the MCSPI handle. More... | |
int32_t | MCSPI_control (MCSPI_Handle handle, uint32_t cmd, void *arg) |
Function performs implementation specific features on a channel of a SPI peripheral specified by the MCSPI handle. More... | |
void | MCSPI_init (void) |
This function initializes the MCSPI module. More... | |
MCSPI_Handle | MCSPI_open (uint32_t idx, uint32_t channel, MCSPI_Params *params) |
This function opens a given channel of a given MCSPI peripheral. More... | |
void | MCSPI_Params_init (MCSPI_Params *params) |
Function to initialize the MCSPI_Params struct to its defaults. More... | |
bool | MCSPI_transfer (MCSPI_Handle handle, SPI_Transaction *spiTrans) |
Function to perform SPI transactions on a channel of a SPI peripheral specified by the MCSPI handle. More... | |
void | MCSPI_transferCancel (MCSPI_Handle handle) |
Function to cancel SPI transactions on channel of a SPI peripheral specified by the MCSPI handle. More... | |
Typedefs | |
typedef struct MCSPI_Config_s * | MCSPI_Handle |
A handle that is returned from a MCSPI_open() call. More... | |
typedef void(* | MCSPI_CallbackFxn) (MCSPI_Handle handle, SPI_Transaction *transaction) |
The definition of a callback function used by the MCSPI driver when used in SPI_MODE_CALLBACK. More... | |
typedef void(* | MCSPI_CloseFxn) (MCSPI_Handle handle) |
A function pointer to a driver specific implementation of MCSPI_close(). More... | |
typedef int32_t(* | MCSPI_ControlFxn) (MCSPI_Handle handle, uint32_t cmd, const void *arg) |
A function pointer to a driver specific implementation of MCSPI_control(). More... | |
typedef void(* | MCSPI_InitFxn) (MCSPI_Handle handle) |
A function pointer to a driver specific implementation of MCSPI_init(). More... | |
typedef MCSPI_Handle(* | MCSPI_OpenFxn) (MCSPI_Handle handle, const MCSPI_Params *params) |
A function pointer to a driver specific implementation of MCSPI_open(). More... | |
typedef bool(* | MCSPI_TransferFxn) (MCSPI_Handle handle, SPI_Transaction *transaction) |
A function pointer to a driver specific implementation of MCSPI_transfer(). More... | |
typedef void(* | MCSPI_TransferCancelFxn) (MCSPI_Handle handle) |
A function pointer to a driver specific implementation of MCSPI_transferCancel(). More... | |
typedef MCSPI_Config | MCSPI_config_list[MCSPI_MAX_NUM_INSTANCES][MCSPI_MAX_NUM_CHANNELS] |
Macros | |
#define | MCSPI_MAX_NUM_INSTANCES (SPI_MAX_CONFIG_CNT) |
Max number of MCSPI peripheral instances. More... | |
#define | MCSPI_MAX_NUM_CHANNELS (4U) |
Max number of channels of a MCSPI peripheral instance. More... | |
#define MCSPI_MAX_NUM_INSTANCES (SPI_MAX_CONFIG_CNT) |
Max number of MCSPI peripheral instances.
#define MCSPI_MAX_NUM_CHANNELS (4U) |
Max number of channels of a MCSPI peripheral instance.
typedef struct MCSPI_Config_s* MCSPI_Handle |
A handle that is returned from a MCSPI_open() call.
typedef void(* MCSPI_CallbackFxn) (MCSPI_Handle handle, SPI_Transaction *transaction) |
The definition of a callback function used by the MCSPI driver when used in SPI_MODE_CALLBACK.
typedef void(* MCSPI_CloseFxn) (MCSPI_Handle handle) |
A function pointer to a driver specific implementation of MCSPI_close().
typedef int32_t(* MCSPI_ControlFxn) (MCSPI_Handle handle, uint32_t cmd, const void *arg) |
A function pointer to a driver specific implementation of MCSPI_control().
typedef void(* MCSPI_InitFxn) (MCSPI_Handle handle) |
A function pointer to a driver specific implementation of MCSPI_init().
typedef MCSPI_Handle(* MCSPI_OpenFxn) (MCSPI_Handle handle, const MCSPI_Params *params) |
A function pointer to a driver specific implementation of MCSPI_open().
typedef bool(* MCSPI_TransferFxn) (MCSPI_Handle handle, SPI_Transaction *transaction) |
A function pointer to a driver specific implementation of MCSPI_transfer().
typedef void(* MCSPI_TransferCancelFxn) (MCSPI_Handle handle) |
A function pointer to a driver specific implementation of MCSPI_transferCancel().
typedef MCSPI_Config MCSPI_config_list[MCSPI_MAX_NUM_INSTANCES][MCSPI_MAX_NUM_CHANNELS] |
void MCSPI_close | ( | MCSPI_Handle | handle | ) |
Function to close a channel of a SPI peripheral specified by the MCSPI handle.
handle | A MCSPI handle returned from MCSPI_open() |
int32_t MCSPI_control | ( | MCSPI_Handle | handle, |
uint32_t | cmd, | ||
void * | arg | ||
) |
Function performs implementation specific features on a channel of a SPI peripheral specified by the MCSPI handle.
handle | A MCSPI handle returned from MCSPI_open() |
cmd | A command value defined by the driver specific implementation |
arg | An optional R/W (read/write) argument that is accompanied with cmd |
void MCSPI_init | ( | void | ) |
This function initializes the MCSPI module.
MCSPI_Handle MCSPI_open | ( | uint32_t | idx, |
uint32_t | channel, | ||
MCSPI_Params * | params | ||
) |
This function opens a given channel of a given MCSPI peripheral.
idx | Logical peripheral number for the MCSPI indexed into the MCSPI_config table |
channel | Channel number of the SPI peripheral |
params | Pointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only). |
void MCSPI_Params_init | ( | MCSPI_Params * | params | ) |
Function to initialize the MCSPI_Params struct to its defaults.
params | An pointer to MCSPI_Params structure for initialization |
Defaults values are: transferMode = SPI_MODE_BLOCKING transferTimeout = SPI_WAIT_FOREVER transferCallbackFxn = NULL mode = SPI_MASTER bitRate = 1000000 (Hz) dataSize = 8 (bits) frameFormat = SPI_POL0_PHA0
bool MCSPI_transfer | ( | MCSPI_Handle | handle, |
SPI_Transaction * | spiTrans | ||
) |
Function to perform SPI transactions on a channel of a SPI peripheral specified by the MCSPI handle.
If the MCSPI is in SPI_MASTER mode, it will immediately start the transaction. If the MCSPI is in SPI_SLAVE mode, it prepares itself for a transaction with a SPI master.
In SPI_MODE_BLOCKING, MCSPI_transfer will block task execution until the transaction has completed.
In SPI_MODE_CALLBACK, MCSPI_transfer() does not block task execution and calls a MCSPI_CallbackFxn. This makes the MCSPI_tranfer() safe to be used within a Task, Swi, or Hwi context. The SPI_Transaction structure must stay persistent until the MCSPI_transfer function has completed!
handle | A MCSPI_Handle |
spiTrans | A pointer to a SPI_Transaction. All of the fields within transaction except SPI_Transaction.count and SPI_Transaction.status are WO (write-only) unless otherwise noted in the driver implementations. If a transaction timeout has occured, SPI_Transaction.count will contain the number of frames that were transferred. |
void MCSPI_transferCancel | ( | MCSPI_Handle | handle | ) |
Function to cancel SPI transactions on channel of a SPI peripheral specified by the MCSPI handle.
In SPI_MODE_BLOCKING, MCSPI_transferCancel has no effect.
In SPI_MODE_CALLBACK, MCSPI_transferCancel() will stop an MCSPI transfer if if one is in progress. If a transaction was in progress, its callback function will be called in context from which this API is called from. The MCSPI_CallbackFxn function can determine if the transaction was successful or not by reading the SPI_Status status value in the SPI_Transaction structure.
handle | A MCSPI_Handle |