AM273x MCU+ SDK  08.01.01

Introduction

This module contains APIs to program and use the MIBSPI module. The APIs can be used by other drivers to get access to MIBSPI and also by application to initiate data transfer operation.

Sub Modules

 MIBSPI Feature defines
 MIBSPI_FEATURE_* macros indicate presence of a particular features in SPI instance on the given SoC. Used internally in driver.
 

Files

file  mibspi/v0/mibspi.h
 MIBSPI Driver API/interface file.
 

Data Structures

struct  MIBSPI_HW_Stats
 SPI Driver Statistics. More...
 
struct  MIBSPI_Stats
 MIBSPI_Stats data structure is used with SPI_getStats() to get driver statistics. More...
 
struct  MIBSPI_SlaveProfile
 MIBSPI slave profile Parameters. More...
 
struct  MIBSPI_SlaveModeParams
 MIBSPI slave mode Parameters. More...
 
struct  MIBSPI_DriverDmaInfo
 SPI Driver Info for Master. More...
 
struct  MIBSPI_DMAReqlineCfg
 MIBSPI Driver DMA request line tie up for the SoC. More...
 
struct  MIBSPI_DMAXferAddrInfo
 MIBSPI Driver DMA module Address info definition. More...
 
struct  MIBSPI_DMAXferSizeInfo
 MIBSPI Driver DMA module Transfer size definition. More...
 
struct  MIBSPI_DMAXferInfo
 MIBSPI Driver DMA module Transfer Info definition. More...
 
struct  MIBSPI_Transaction
 MIBSPI_Transaction data structure is used with MIBSPI_transfer(). It indicates how many MIBSPI_FrameFormat frames are sent and received from the buffers pointed to txBuf and rxBuf. More...
 
struct  MIBSPI_TransactionState
 MIBSPI Driver DMA module Tranaction state definition. More...
 
struct  MIBSPI_MasterModeParams
 MIBSPI master Parameters. More...
 
struct  MIBSPI_EDMAChParams
 MIBSPI EDMA Parameters. More...
 
struct  MIBSPI_OpenParams
 MIBSPI Parameters. More...
 
struct  MIBSPI_Attrs
 MIBSPI Driver HW configuration. More...
 
struct  MIBSPI_Object
 SPI Driver Object. More...
 
struct  MIBSPI_Config
 MIBSPI Instance configuration. More...
 

Functions

void MIBSPI_init (void)
 This function initializes the MIBSPI module. More...
 
void MIBSPI_deinit (void)
 This function de-initializes the MIBSPI module. More...
 
MIBSPI_Handle MIBSPI_open (uint32_t index, MIBSPI_OpenParams *params)
 This function opens a given instance of the MIBSPI peripheral. More...
 
void MIBSPI_close (MIBSPI_Handle handle)
 Function to close a instance of a MIBSPI peripheral specified by the MIBSPI handle. More...
 
int32_t MIBSPI_transfer (MIBSPI_Handle handle, MIBSPI_Transaction *transaction)
 Function to perform MIBSPI transactions on a instance of a MIBSPI peripheral specified by the MIBSPI handle for a specific slave. More...
 
void MIBSPI_transferCancel (MIBSPI_Handle handle)
 Function to cancel MIBSPI transactions on instance of a MIBSPI peripheral specified by the MIBSPI handle. More...
 
int32_t MIBSPI_enableLoopback (MIBSPI_Handle handle, MIBSPI_LoopBackType loopbacktype)
 This function enables the Loopback mode for self test. Loopback is SPI master only feature. More...
 
int32_t MIBSPI_disableLoopback (MIBSPI_Handle handle)
 This function disable the Loopback mode. More...
 
int32_t MIBSPI_setClockPhasePolarity (MIBSPI_Handle handle, uint8_t clockFmt)
 This function sets the Polarity and phase for MibSpi as requested. More...
 
int32_t MIBSPI_getDrvStats (MIBSPI_Handle handle, MIBSPI_Stats *ptrStats)
 Get SPI driver internal stats. More...
 
void MIBSPI_dmaDoneCb (MIBSPI_Handle mibspiHandle)
 Function invoked by the SoC DMA implementation to the driver on DMA transfer completion. More...
 
static void MIBSPI_Params_init (MIBSPI_OpenParams *openPrms)
 Function to initialize the MIBSPI_OpenParams struct to its defaults. More...
 

Typedefs

typedef void * MIBSPI_Handle
 A handle that is returned from a MIBSPI_open() call. More...
 
typedef void(* MIBSPI_CallbackFxn) (MIBSPI_Handle handle, MIBSPI_Transaction *transaction)
 The definition of a callback function used by the SPI driver when used in MIBSPI_MODE_CALLBACK. More...
 

Enumerations

enum  MIBSPI_EdmaCBFlag_e { MIBSPI_NONE_EDMA_CALLBACK_OCCURED = 0x0U, MIBSPI_TX_EDMA_CALLBACK_OCCURED = 0x1U, MIBSPI_RX_EDMA_CALLBACK_OCCURED = 0x2U }
 Enum used to track status of EDMA callbacks internally in driver. More...
 
enum  MIBSPI_XferErr_e { MIBSPI_XFER_ERR_NONE, MIBSPI_XFER_ERR_RXOR, MIBSPI_XFER_ERR_BE, MIBSPI_XFER_ERR_TIMEOUT }
 SPI_v3 transfer error code. More...
 
enum  MIBSPI_Status {
  MIBSPI_TRANSFER_COMPLETED = 0, MIBSPI_TRANSFER_STARTED, MIBSPI_TRANSFER_CANCELED, MIBSPI_TRANSFER_FAILED,
  MIBSPI_TRANSFER_CSN_DEASSERT, MIBSPI_TRANSFER_TIMEOUT
}
 Status codes that are set by the SPI driver. More...
 
enum  MIBSPI_PinMode { MIBSPI_PINMODE_3PIN = 0, MIBSPI_PINMODE_4PIN_CS = 1 }
 Definitions for MIBSPI Pins Operation Mode. More...
 
enum  MIBSPI_DataShiftFmt { MIBSPI_MSB_FIRST = 0, MIBSPI_LSB_FIRST = 1 }
 Definitions for MIBSPI Data shift format. More...
 
enum  MIBSPI_LoopBackType { MIBSPI_LOOPBK_DIGITAL = 0, MIBSPI_LOOPBK_ANALOG = 1, MIBSPI_LOOPBK_NONE = 2 }
 Definitions for MIBSPI loopback modes. More...
 
enum  MIBSPI_Mode { MIBSPI_MASTER = 0, MIBSPI_SLAVE = 1 }
 Definitions for various SPI modes of operation. More...
 
enum  MIBSPI_FrameFormat { MIBSPI_POL0_PHA0 = 0, MIBSPI_POL0_PHA1 = 1, MIBSPI_POL1_PHA0 = 2, MIBSPI_POL1_PHA1 = 3 }
 Definitions for various SPI data frame formats. More...
 
enum  MIBSPI_TransferMode { MIBSPI_MODE_BLOCKING, MIBSPI_MODE_CALLBACK }
 MIBSPI transfer mode determines the whether the MIBSPI controller operates synchronously or asynchronously. In MIBSPI_MODE_BLOCKING mode MIBSPI_transfer() blocks code execution until the MIBSPI transaction has completed. In MIBSPI_MODE_CALLBACK MIBSPI_transfer() does not block code execution and instead calls a MIBSPI_CallbackFxn callback function when the transaction has completed. More...
 
enum  MIBSPI_DmaCtrlChType { MIBSPI_DMACTRL_CH_TX, MIBSPI_DMACTRL_CH_RX, MIBSPI_DMACTRL_CH_BOTH }
 Definitions for DMA controller channel type. More...
 

Macros

#define MIBSPI_RAM_BUFFER_MODE   (7U)
 MibSPI RAM buffer mode. More...
 
#define MIBSPI_SLAVEMODE_TRANS_GROUP   (0U)
 Transfer group used in slave mode. More...
 
#define MIBSPI_INT_LEVEL   (1U)
 MIBSPI interrupt level. More...
 
#define MIBSPI_RAM_MAX_ELEM   (128U)
 Maximum element in MibSPI RAM. For 8bit data size, the maximum transfer size is 64 bytes For 16bit data size, the maximum transfer size is 128 bytes. More...
 
#define MIBSPI_SLAVE_MAX   (3U)
 Max number of slaves supported when MibSPI is configured as master. More...
 
#define MIBSPI_DMA_REQLINE_MAX   (3U)
 Max number of DMA REQ lines supported by MIBSPI. More...
 
#define MIBSPI_MAX_CS   (MIBSPI_SLAVE_MAX)
 Maximum CS supported for the device. More...
 
#define MIBSPI_NUM_TRANS_GROUP   (8U)
 Max number of transport group. More...
 
#define MIBSPI_NUM_DMA_GROUP   (8U)
 Max number of DMA group. More...
 
#define MIBSPI_CS_NONE   (0xFFU)
 CS configuration value when none of the CS is activated. More...
 

Macro Definition Documentation

◆ MIBSPI_RAM_BUFFER_MODE

#define MIBSPI_RAM_BUFFER_MODE   (7U)

MibSPI RAM buffer mode.

◆ MIBSPI_SLAVEMODE_TRANS_GROUP

#define MIBSPI_SLAVEMODE_TRANS_GROUP   (0U)

Transfer group used in slave mode.

◆ MIBSPI_INT_LEVEL

#define MIBSPI_INT_LEVEL   (1U)

MIBSPI interrupt level.

◆ MIBSPI_RAM_MAX_ELEM

#define MIBSPI_RAM_MAX_ELEM   (128U)

Maximum element in MibSPI RAM. For 8bit data size, the maximum transfer size is 64 bytes For 16bit data size, the maximum transfer size is 128 bytes.

◆ MIBSPI_SLAVE_MAX

#define MIBSPI_SLAVE_MAX   (3U)

Max number of slaves supported when MibSPI is configured as master.

◆ MIBSPI_DMA_REQLINE_MAX

#define MIBSPI_DMA_REQLINE_MAX   (3U)

Max number of DMA REQ lines supported by MIBSPI.

◆ MIBSPI_MAX_CS

#define MIBSPI_MAX_CS   (MIBSPI_SLAVE_MAX)

Maximum CS supported for the device.

◆ MIBSPI_NUM_TRANS_GROUP

#define MIBSPI_NUM_TRANS_GROUP   (8U)

Max number of transport group.

◆ MIBSPI_NUM_DMA_GROUP

#define MIBSPI_NUM_DMA_GROUP   (8U)

Max number of DMA group.

◆ MIBSPI_CS_NONE

#define MIBSPI_CS_NONE   (0xFFU)

CS configuration value when none of the CS is activated.

Typedef Documentation

◆ MIBSPI_Handle

typedef void* MIBSPI_Handle

A handle that is returned from a MIBSPI_open() call.

◆ MIBSPI_CallbackFxn

typedef void(* MIBSPI_CallbackFxn) (MIBSPI_Handle handle, MIBSPI_Transaction *transaction)

The definition of a callback function used by the SPI driver when used in MIBSPI_MODE_CALLBACK.

Parameters
handleMIBSPI_Handle
transaction*MIBSPI_Transaction*

Enumeration Type Documentation

◆ MIBSPI_EdmaCBFlag_e

Enum used to track status of EDMA callbacks internally in driver.

Enumerator
MIBSPI_NONE_EDMA_CALLBACK_OCCURED 

Flag to indicate that Transmission EDMA callback has occured

MIBSPI_TX_EDMA_CALLBACK_OCCURED 

Flag to indicate that Transmission EDMA callback has occured

MIBSPI_RX_EDMA_CALLBACK_OCCURED 

Flag to indicate that Reception EDMA callback has occured

◆ MIBSPI_XferErr_e

SPI_v3 transfer error code.

Enumerator
MIBSPI_XFER_ERR_NONE 
MIBSPI_XFER_ERR_RXOR 
MIBSPI_XFER_ERR_BE 
MIBSPI_XFER_ERR_TIMEOUT 

◆ MIBSPI_Status

Status codes that are set by the SPI driver.

Enumerator
MIBSPI_TRANSFER_COMPLETED 
MIBSPI_TRANSFER_STARTED 
MIBSPI_TRANSFER_CANCELED 
MIBSPI_TRANSFER_FAILED 
MIBSPI_TRANSFER_CSN_DEASSERT 
MIBSPI_TRANSFER_TIMEOUT 

◆ MIBSPI_PinMode

Definitions for MIBSPI Pins Operation Mode.

Enumerator
MIBSPI_PINMODE_3PIN 

3 Pin operation Mode

MIBSPI_PINMODE_4PIN_CS 

4 Pin operation Mode with CS signal

◆ MIBSPI_DataShiftFmt

Definitions for MIBSPI Data shift format.

Enumerator
MIBSPI_MSB_FIRST 

MSB shift out first

MIBSPI_LSB_FIRST 

LSB shift out first

◆ MIBSPI_LoopBackType

Definitions for MIBSPI loopback modes.

Enumerator
MIBSPI_LOOPBK_DIGITAL 

MIBSPI digital loopback mode

MIBSPI_LOOPBK_ANALOG 

MIBSPI analog loopback mode

MIBSPI_LOOPBK_NONE 

MIBSPI loopback disable

◆ MIBSPI_Mode

Definitions for various SPI modes of operation.

Enumerator
MIBSPI_MASTER 

SPI in master mode

MIBSPI_SLAVE 

SPI in slave mode

◆ MIBSPI_FrameFormat

Definitions for various SPI data frame formats.

Enumerator
MIBSPI_POL0_PHA0 

SPI mode Polarity 0 Phase 0

MIBSPI_POL0_PHA1 

SPI mode Polarity 0 Phase 1

MIBSPI_POL1_PHA0 

SPI mode Polarity 1 Phase 0

MIBSPI_POL1_PHA1 

SPI mode Polarity 1 Phase 1

◆ MIBSPI_TransferMode

MIBSPI transfer mode determines the whether the MIBSPI controller operates synchronously or asynchronously. In MIBSPI_MODE_BLOCKING mode MIBSPI_transfer() blocks code execution until the MIBSPI transaction has completed. In MIBSPI_MODE_CALLBACK MIBSPI_transfer() does not block code execution and instead calls a MIBSPI_CallbackFxn callback function when the transaction has completed.

Enumerator
MIBSPI_MODE_BLOCKING 

MIBSPI_transfer() blocks execution. This mode can only be used when called within a Task context

MIBSPI_MODE_CALLBACK 

MIBSPI_transfer() does not block code execution and will call a MIBSPI_CallbackFxn. This mode can be used in a Task, Swi, or Hwi context.

◆ MIBSPI_DmaCtrlChType

Definitions for DMA controller channel type.

Enumerator
MIBSPI_DMACTRL_CH_TX 

Configure DMA channel as transmit only

MIBSPI_DMACTRL_CH_RX 

Configure DMA channel as receive only

MIBSPI_DMACTRL_CH_BOTH 

Configure DMA channel as transmit and receive

Function Documentation

◆ MIBSPI_init()

void MIBSPI_init ( void  )

This function initializes the MIBSPI module.

◆ MIBSPI_deinit()

void MIBSPI_deinit ( void  )

This function de-initializes the MIBSPI module.

◆ MIBSPI_open()

MIBSPI_Handle MIBSPI_open ( uint32_t  index,
MIBSPI_OpenParams params 
)

This function opens a given instance of the MIBSPI peripheral.

Precondition
MIBSPI controller has been initialized using MIBSPI_init()
Parameters
indexId of the SPI instance.
paramsPointer to an parameter block, if NULL it will use default values.
Returns
A MIBSPI_Handle on success or a NULL on an error or if it has been opened already.
See also
MIBSPI_init()
MIBSPI_close()
MIBSPI_Params_init()

◆ MIBSPI_close()

void MIBSPI_close ( MIBSPI_Handle  handle)

Function to close a instance of a MIBSPI peripheral specified by the MIBSPI handle.

Precondition
MIBSPI_open() has to be called first.
Parameters
handleMIBSPI_Handle returned from MIBSPI_open()
See also
MIBSPI_open()

◆ MIBSPI_transfer()

int32_t MIBSPI_transfer ( MIBSPI_Handle  handle,
MIBSPI_Transaction transaction 
)

Function to perform MIBSPI transactions on a instance of a MIBSPI peripheral specified by the MIBSPI handle for a specific slave.

If the MIBSPI is in MIBSPI_MASTER mode, it will immediately start the transaction. If the MIBSPI is in MIBSPI_SLAVE mode, it prepares itself for a transaction with a SPI master.

In MIBSPI_MODE_BLOCKING, MIBSPI_transfer will block task execution until the transaction has completed.

In MIBSPI_MODE_CALLBACK, MIBSPI_transfer() does not block task execution and calls a MIBSPI_CallbackFxn. This makes the MIBSPI_tranfer() safe to be used within a Task, Swi, or Hwi context. The MIBSPI_Transaction structure must stay persistent until the MIBSPI_transfer function has completed!

Parameters
handleMIBSPI_Handle
transactionA pointer to a MIBSPI_Transaction. All of the fields within transaction except MIBSPI_Transaction.count and MIBSPI_Transaction.status are WO (write-only) unless otherwise noted in the driver implementations. If a transaction timeout has occured, MIBSPI_Transaction.count will contain the number of frames that were transferred.
Returns
true if started successfully; else false
See also
MIBSPI_open
MIBSPI_transferCancel

◆ MIBSPI_transferCancel()

void MIBSPI_transferCancel ( MIBSPI_Handle  handle)

Function to cancel MIBSPI transactions on instance of a MIBSPI peripheral specified by the MIBSPI handle.

In MIBSPI_MODE_BLOCKING, MIBSPI_transferCancel has no effect.

In MIBSPI_MODE_CALLBACK, MIBSPI_transferCancel() will stop an SPI 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 MIBSPI_CallbackFxn function can determine if the transaction was successful or not by reading the MIBSPI_Status status value in the MIBSPI_Transaction structure.

Parameters
handleMIBSPI_Handle
See also
MIBSPI_open
MIBSPI_transfer

◆ MIBSPI_enableLoopback()

int32_t MIBSPI_enableLoopback ( MIBSPI_Handle  handle,
MIBSPI_LoopBackType  loopbacktype 
)

This function enables the Loopback mode for self test. Loopback is SPI master only feature.

Parameters
[in]handleMIBSPI_Handle
[in]loopbacktypeDigital or Analog
Returns
On success returns SystemP_SUCCESS. Negative values indicate unsuccessful operations.

◆ MIBSPI_disableLoopback()

int32_t MIBSPI_disableLoopback ( MIBSPI_Handle  handle)

This function disable the Loopback mode.

Parameters
[in]handleMIBSPI_Handle
Returns
On success returns SystemP_SUCCESS. Negative values indicate unsuccessful operations.

◆ MIBSPI_setClockPhasePolarity()

int32_t MIBSPI_setClockPhasePolarity ( MIBSPI_Handle  handle,
uint8_t  clockFmt 
)

This function sets the Polarity and phase for MibSpi as requested.

Parameters
[in]handleMIBSPI_Handle MibSpiSPI
[in]clockFmtMIBSPI functional mode (clock/polarity)
Returns
On success returns SystemP_SUCCESS. Negative values indicate unsuccessful operations.

◆ MIBSPI_getDrvStats()

int32_t MIBSPI_getDrvStats ( MIBSPI_Handle  handle,
MIBSPI_Stats ptrStats 
)

Get SPI driver internal stats.

Parameters
[in]handleSPI device handle
[in]ptrStatspointer to SPI driver stats structure
Returns
On success returns SystemP_SUCCESS. Negative values indicate unsuccessful operations.
See also
MIBSPI_open
MIBSPI_transfer

◆ MIBSPI_dmaDoneCb()

void MIBSPI_dmaDoneCb ( MIBSPI_Handle  mibspiHandle)

Function invoked by the SoC DMA implementation to the driver on DMA transfer completion.

Parameters
mibspiHandleA MIBSPI_Handle

◆ MIBSPI_Params_init()

static void MIBSPI_Params_init ( MIBSPI_OpenParams openPrms)
inlinestatic

Function to initialize the MIBSPI_OpenParams struct to its defaults.

Parameters
openPrmsPointer to MIBSPI_OpenParams structure for initialization

Variable Documentation

◆ gMibspiConfig

MIBSPI_Config gMibspiConfig[]
extern

Externally defined driver configuration array.

◆ gMibspiConfigNum

uint32_t gMibspiConfigNum
extern

Externally defined driver configuration array size.