MCUSW
Loading...
Searching...
No Matches
SPI Handler and Driver API

Introduction

The SPI Driver MCAL provides low level access to SPI peripheral present on Device.
The SPI Driver implements a standardized interface specified in the AUTOSAR_SWS_SPIHandlerDriver document.

Limitations of the driver:

See also
SPI Configuration
Defines Interrupt Handler for all SPI instances
Defines variables that could be used to driver

Sub Modules

 Defines Interrupt Handler for all SPI instances
 
 Defines variables that could be used to driver
 
 SPI Configuration
 

SPI Buffer Definition

typedef uint8 Spi_DataBufferType
 Type of application data buffer elements.
 
typedef uint16 Spi_NumberOfDataType
 Type for defining the number of data elements of the type Spi_DataBufferType to send and / or receive by Channel.
 
typedef uint8 Spi_ChannelType
 Specifies the identification (ID) for a Channel.
 
typedef uint16 Spi_JobType
 Specifies the identification (ID) for a Job.
 
typedef uint8 Spi_SequenceType
 Specifies the identification (ID) for a sequence of jobs.
 
typedef uint8 Spi_HWUnitType
 Specifies the identification (ID) for a SPI Hardware micro controller peripheral (unit)
 
#define SPI_IB   (0U)
 Buffer definitions IB - internal buffers.
 
#define SPI_EB   (1U)
 Buffer definitions EB - external buffers. Only this is supported.
 
#define SPI_IB_EB   (2U)
 Buffer definitions IB/EB - internal/external buffers.
 

SPI Config Ids

The Config Ids used for different SPI Configuration builds

typedef void(* Spi_CacheWbInv) (uint8 *BufPtr, uint16 LenByte)
 Cache write-back invalidate function.
 
typedef void(* Spi_CacheWb) (uint8 *BufPtr, uint16 LenByte)
 Cache write-back function.
 
typedef void(* Spi_CacheInv) (uint8 *BufPtr, uint16 LenByte)
 Cache invalidate function.
 
#define SPI_CFG_ID_0   (0x01U)
 Config 0 (All configurations ON), Scaleability level 2)
 
#define SPI_CFG_ID_1   (0x02U)
 Config 1 (All configurations OFF). SPI_CFG_ID_1 is used only for compile check.
 
#define SPI_CFG_ID_2   (0x04U)
 Config 2 (All configurations ON except DET OFF)
 
#define SPI_CFG_ID_3   (0x08U)
 Config 3 (Configurator auto generated file)
 
#define SPI_CFG_ID_4   (0x10U)
 Config 4 (Config is used only by Unit Test, Scaleability level 0)
 
#define SPI_CFG_ID_5   (0x20U)
 Config 5 (Config is used only by Unit Test for DMA

 
#define SPI_CFG_ID_6   (0x40U)
 Config 6 (Config is used only by Unit Test for DMA.
 
#define SPI_CFG_ID_7   (0x80U)
 Config 7 (Performance testing only, level 2, asynch, no DMA)
 
enum  Spi_StatusType { SPI_UNINIT = 0U , SPI_IDLE = 1U , SPI_BUSY = 2U }
 This type defines a range of specific status for SPI Handler/Driver. More...
 
enum  Spi_JobResultType { SPI_JOB_OK = 0U , SPI_JOB_PENDING = 1U , SPI_JOB_FAILED = 2U , SPI_JOB_QUEUED = 3U }
 This type defines a range of specific Jobs status for SPI Handler/Driver. More...
 
enum  Spi_SeqResultType { SPI_SEQ_OK = 0U , SPI_SEQ_PENDING = 1U , SPI_SEQ_FAILED = 2U , SPI_SEQ_CANCELLED = 3U }
 This type defines a range of specific Sequences status for SPI Handler/Driver. More...
 
enum  Spi_HwUnitResultType { SPI_HW_UNIT_OK = 0U , SPI_HW_UNIT_PENDING = 1U , SPI_HW_UNIT_FAILED = 2U }
 This type defines a range of specific HW unit status for SPI Handler/Driver. More...
 
enum  Spi_AsyncModeType { SPI_POLLING_MODE = 0U , SPI_INTERRUPT_MODE = 1U }
 Specifies the asynchronous mechanism mode for SPI busses handled asynchronously in LEVEL 2. More...
 
enum  Spi_TransferType { SPI_MSB = 0U , SPI_LSB = 1U }
 Word transfer order - MSB first or LSB first. More...
 
enum  Spi_LevelType { SPI_LOW = STD_LOW , SPI_HIGH }
 Type for SPI Chip Select Polarity and Clock Idle Level. More...
 
enum  Spi_CsPinType { SPI_CS0 = 0U , SPI_CS1 , SPI_CS2 , SPI_CS3 }
 SPI Chip Select Pin. More...
 
enum  Spi_ClkMode { SPI_CLK_MODE_0 = 0x00U , SPI_CLK_MODE_1 = 0x01U , SPI_CLK_MODE_2 = 0x02U , SPI_CLK_MODE_3 = 0x03U }
 SPI Clock Mode - sets the clock polarity and phase. Note: These values are a direct register mapping. So don't change value. More...
 
enum  Spi_TxRxMode { SPI_TX_RX_MODE_BOTH = 0x00U , SPI_TX_RX_MODE_TX_ONLY = 0x02U }
 SPI TX/RX Mode. More...
 
enum  Spi_JobPriorityType { SPI_JOB_PRIORITY_0 = 0U , SPI_JOB_PRIORITY_1 , SPI_JOB_PRIORITY_2 , SPI_JOB_PRIORITY_3 }
 SPI Job Priority. More...
 
enum  Spi_CsModeType { SPI_SINGLE = 0U , SPI_CONTINUOUS = 1U }
 SPI Chip Select Mode. More...
 
enum  Spi_DataDelayType { SPI_DATADELAY_0 = 0U , SPI_DATADELAY_1 = 1U , SPI_DATADELAY_2 = 2U , SPI_DATADELAY_3 = 3U }
 Spi_DataDelayType defines the number of interface clock cycles between CS toggling and first or last edge of MCSPI clock. More...
 
enum  Spi_DataLineReceiveType { DATA_LINE_0_RECEPTION = 0U , DATA_LINE_1_RECEPTION = 1U }
 Spi_DataLineReceiveType defines the lines selected for reception. More...
 
enum  Spi_DataLineTransmitType { DATA_LINE_NO_TRANSMISSION = 0x3U , DATA_LINE_0_TRANSMISSION = 0x2U , DATA_LINE_1_TRANSMISSION = 0x1U , DATA_LINE_BOTH_TRANSMISSION = 0x0U }
 Spi_DataLineTransmitType defines the lines selected for transmission. More...
 
enum  Mcspi_IrqStatusType { SPI_NO_EVENT = 0U , SPI_EVENT_PENDING = 1U , SPI_STATUS_READ_FAIL = 2U }
 Irq status and std return type. More...
 
void Spi_Init (const Spi_ConfigType *CfgPtr)
 Service for SPI initialization.
 
Std_ReturnType Spi_DeInit (void)
 Service for SPI de-initialization.
 
Spi_StatusType Spi_GetStatus (void)
 Service returns the SPI Handler/Driver software module status.
 
Spi_JobResultType Spi_GetJobResult (Spi_JobType Job)
 This service returns the last transmission result of the specified Job.
 
Spi_SeqResultType Spi_GetSequenceResult (Spi_SequenceType Sequence)
 This service returns the last transmission result of the specified Sequence.
 
void Spi_GetVersionInfo (Std_VersionInfoType *versioninfo)
 This service returns the version information of this module.
 
Spi_StatusType Spi_GetHWUnitStatus (Spi_HWUnitType HWUnit)
 This service returns the status of the specified SPI Hardware microcontroller peripheral.
 
Std_ReturnType Spi_WriteIB (Spi_ChannelType Channel, const Spi_DataBufferType *DataBufferPtr)
 Service for writing one or more data to an IB SPI Handler/Driver Channel specified by parameter.
 
Std_ReturnType Spi_ReadIB (Spi_ChannelType Channel, Spi_DataBufferType *DataBufferPointer)
 Service for reading synchronously one or more data from an IB SPI Handler/Driver Channel specified by parameter.
 
Std_ReturnType Spi_SetupEB (Spi_ChannelType Channel, const Spi_DataBufferType *SrcDataBufferPtr, Spi_DataBufferType *DesDataBufferPtr, Spi_NumberOfDataType Length)
 Service to setup the buffers and the length of data for the EB SPI Handler/Driver Channel specified.
 
Std_ReturnType Spi_AsyncTransmit (Spi_SequenceType Sequence)
 Service to transmit data on the SPI bus.
 
void Spi_Cancel (Spi_SequenceType Sequence)
 Service cancels the specified on-going sequence transmission.
 
Std_ReturnType Spi_SyncTransmit (Spi_SequenceType Sequence)
 Service to transmit data on the SPI bus.
 
Std_ReturnType Spi_SetAsyncMode (Spi_AsyncModeType Mode)
 Service to set the asynchronous mechanism mode for SPI busses handled asynchronously.
 
void Spi_MainFunction_Handling (void)
 This function polls the SPI interrupts linked to HW Units allocated to the transmission of SPI sequences to enable the evolution of transmission state machine.
 
Std_ReturnType Spi_RegisterReadback (Spi_HWUnitType HWUnit, Spi_RegisterReadbackType *RegRbPtr)
 This function reads the important registers of the hardware unit and returns the value in the structure.
 
Std_ReturnType Spi_dataOverflowUnderflowIntrEnable (Spi_HWUnitType HWUnit, uint32 intFlags)
 This function Enable Under/Overflow Interupts of the hardware unit and returns the status.
 
Std_ReturnType Spi_dataOverflowUnderflowIntrDisable (Spi_HWUnitType HWUnit, uint32 intFlags)
 This function Disable Under/Overflow Interupts of the hardware unit and returns the status.
 
Mcspi_IrqStatusType Spi_dataOverflowUnderflowIntrGetStatus (Spi_HWUnitType HWUnit, uint32 intFlags)
 This function status Under/Overflow Interupts of the hardware unit and returns the status.
 
Std_ReturnType Spi_dataOverflowUnderflowIntrStatusClear (Spi_HWUnitType HWUnit, uint32 intFlags)
 This function status clear Under/Overflow Interupts of the hardware unit and returns the status.
 

SPI Driver Module SW Version Info

Defines for SPI Driver version used for compatibility checks

#define SPI_SW_MAJOR_VERSION   (9U)
 Driver Implementation Major Version.
 
#define SPI_SW_MINOR_VERSION   (1U)
 Driver Implementation Minor Version.
 
#define SPI_SW_PATCH_VERSION   (0U)
 Driver Implementation Patch Version.
 

SPI Driver Module AUTOSAR Version Info

Defines for SPI Driver AUTOSAR version used for compatibility checks

#define SPI_AR_RELEASE_MAJOR_VERSION   (4U)
 AUTOSAR Major version specification implemented by SPI Driver.
 
#define SPI_AR_RELEASE_MINOR_VERSION   (3U)
 AUTOSAR Minor version specification implemented by SPI Driver.
 
#define SPI_AR_RELEASE_REVISION_VERSION   (1U)
 AUTOSAR Patch version specification implemented by SPI Driver.
 

SPI Driver ID Info

#define SPI_VENDOR_ID   ((uint16) 44U)
 Texas Instruments Vendor ID.
 
#define SPI_MODULE_ID   ((uint16) 83U)
 SPI Driver Module ID.
 
#define SPI_INSTANCE_ID   ((uint8) 0U)
 SPI Driver Instance ID.
 

SPI Error Codes

Error codes returned by SPI functions

#define SPI_E_PARAM_CHANNEL   ((uint8) 0x0AU)
 API service called with wrong parameter.
 
#define SPI_E_PARAM_JOB   ((uint8) 0x0BU)
 API service called with wrong parameter.
 
#define SPI_E_PARAM_SEQ   ((uint8) 0x0CU)
 API service called with wrong parameter.
 
#define SPI_E_PARAM_LENGTH   ((uint8) 0x0DU)
 API service called with wrong parameter.
 
#define SPI_E_PARAM_UNIT   ((uint8) 0x0EU)
 API service called with wrong parameter.
 
#define SPI_E_PARAM_POINTER   ((uint8) 0x10U)
 APIs called with a Null Pointer.
 
#define SPI_E_UNINIT   ((uint8) 0x1AU)
 API service used without module initiali-zation.
 
#define SPI_E_SEQ_PENDING   ((uint8) 0x2AU)
 Services called in a wrong sequence.
 
#define SPI_E_SEQ_IN_PROCESS   ((uint8) 0x3AU)
 Synchronous transmission service called at wrong time.
 
#define SPI_E_ALREADY_INITIALIZED   ((uint8) 0x4AU)
 API Spi_Init service called while the SPI driver has already been initialized.
 
#define SPI_E_SEQUENCE_NOT_OK   ((uint8) 0x5AU)
 Sequence did not complete successfully.
 

SPI Service Ids

The Service Id is one of the argument to Det_ReportError function and is used to identify the source of the error

#define SPI_SID_INIT   ((uint8) 0x00U)
 Spi_Init() API Service ID.
 
#define SPI_SID_DEINIT   ((uint8) 0x01U)
 Spi_DeInit() API Service ID.
 
#define SPI_SID_WRITE_IB   ((uint8) 0x02U)
 Spi_WriteIB() API Service ID.
 
#define SPI_SID_ASYNC_TRANSMIT   ((uint8) 0x03U)
 Spi_AsyncTransmit() API Service ID.
 
#define SPI_SID_READ_IB   ((uint8) 0x04U)
 Spi_ReadIB() API Service ID.
 
#define SPI_SID_SETUP_EB   ((uint8) 0x05U)
 Spi_SetupEB() API Service ID.
 
#define SPI_SID_GET_STATUS   ((uint8) 0x06U)
 Spi_GetStatus() API Service ID.
 
#define SPI_SID_GET_JOB_RESULT   ((uint8) 0x07U)
 Spi_GetJobResult() API Service ID.
 
#define SPI_SID_GET_SEQ_RESULT   ((uint8) 0x08U)
 Spi_GetSequenceResult() API Service ID.
 
#define SPI_SID_GET_VERSION_INFO   ((uint8) 0x09U)
 Spi_GetVersionInfo() API Service ID.
 
#define SPI_SID_SYNC_TRANSMIT   ((uint8) 0x0AU)
 Spi_SyncTransmit() API Service ID.
 
#define SPI_SID_GET_HW_UNIT_STATUS   ((uint8) 0x0BU)
 Spi_GetHWUnitStatus() API Service ID.
 
#define SPI_SID_CANCEL   ((uint8) 0x0CU)
 Spi_Cancel() API Service ID.
 
#define SPI_SID_SET_ASYNC_MODE   ((uint8) 0x0DU)
 Spi_SetAsyncMode() API Service ID.
 
#define SPI_SID_MAINFUNCTION_HANDLING   ((uint8) 0x10U)
 Spi_MainFunction_Handling() API Service ID.
 
#define SPI_MCSPI_FCLK   (48000000U)
 MCSPI functional clock input in Hz. This clock is used to generate the serial clock output after the divider.
 

Macro Definition Documentation

◆ SPI_SW_MAJOR_VERSION

#define SPI_SW_MAJOR_VERSION   (9U)

Driver Implementation Major Version.

◆ SPI_SW_MINOR_VERSION

#define SPI_SW_MINOR_VERSION   (1U)

Driver Implementation Minor Version.

◆ SPI_SW_PATCH_VERSION

#define SPI_SW_PATCH_VERSION   (0U)

Driver Implementation Patch Version.

◆ SPI_AR_RELEASE_MAJOR_VERSION

#define SPI_AR_RELEASE_MAJOR_VERSION   (4U)

AUTOSAR Major version specification implemented by SPI Driver.

◆ SPI_AR_RELEASE_MINOR_VERSION

#define SPI_AR_RELEASE_MINOR_VERSION   (3U)

AUTOSAR Minor version specification implemented by SPI Driver.

◆ SPI_AR_RELEASE_REVISION_VERSION

#define SPI_AR_RELEASE_REVISION_VERSION   (1U)

AUTOSAR Patch version specification implemented by SPI Driver.

◆ SPI_VENDOR_ID

#define SPI_VENDOR_ID   ((uint16) 44U)

Texas Instruments Vendor ID.

◆ SPI_MODULE_ID

#define SPI_MODULE_ID   ((uint16) 83U)

SPI Driver Module ID.

◆ SPI_INSTANCE_ID

#define SPI_INSTANCE_ID   ((uint8) 0U)

SPI Driver Instance ID.

◆ SPI_IB

#define SPI_IB   (0U)

Buffer definitions IB - internal buffers.

◆ SPI_EB

#define SPI_EB   (1U)

Buffer definitions EB - external buffers. Only this is supported.

◆ SPI_IB_EB

#define SPI_IB_EB   (2U)

Buffer definitions IB/EB - internal/external buffers.

◆ SPI_E_PARAM_CHANNEL

#define SPI_E_PARAM_CHANNEL   ((uint8) 0x0AU)

API service called with wrong parameter.

◆ SPI_E_PARAM_JOB

#define SPI_E_PARAM_JOB   ((uint8) 0x0BU)

API service called with wrong parameter.

◆ SPI_E_PARAM_SEQ

#define SPI_E_PARAM_SEQ   ((uint8) 0x0CU)

API service called with wrong parameter.

◆ SPI_E_PARAM_LENGTH

#define SPI_E_PARAM_LENGTH   ((uint8) 0x0DU)

API service called with wrong parameter.

◆ SPI_E_PARAM_UNIT

#define SPI_E_PARAM_UNIT   ((uint8) 0x0EU)

API service called with wrong parameter.

◆ SPI_E_PARAM_POINTER

#define SPI_E_PARAM_POINTER   ((uint8) 0x10U)

APIs called with a Null Pointer.

◆ SPI_E_UNINIT

#define SPI_E_UNINIT   ((uint8) 0x1AU)

API service used without module initiali-zation.

◆ SPI_E_SEQ_PENDING

#define SPI_E_SEQ_PENDING   ((uint8) 0x2AU)

Services called in a wrong sequence.

◆ SPI_E_SEQ_IN_PROCESS

#define SPI_E_SEQ_IN_PROCESS   ((uint8) 0x3AU)

Synchronous transmission service called at wrong time.

◆ SPI_E_ALREADY_INITIALIZED

#define SPI_E_ALREADY_INITIALIZED   ((uint8) 0x4AU)

API Spi_Init service called while the SPI driver has already been initialized.

◆ SPI_E_SEQUENCE_NOT_OK

#define SPI_E_SEQUENCE_NOT_OK   ((uint8) 0x5AU)

Sequence did not complete successfully.

◆ SPI_SID_INIT

#define SPI_SID_INIT   ((uint8) 0x00U)

Spi_Init() API Service ID.

◆ SPI_SID_DEINIT

#define SPI_SID_DEINIT   ((uint8) 0x01U)

Spi_DeInit() API Service ID.

◆ SPI_SID_WRITE_IB

#define SPI_SID_WRITE_IB   ((uint8) 0x02U)

Spi_WriteIB() API Service ID.

◆ SPI_SID_ASYNC_TRANSMIT

#define SPI_SID_ASYNC_TRANSMIT   ((uint8) 0x03U)

Spi_AsyncTransmit() API Service ID.

◆ SPI_SID_READ_IB

#define SPI_SID_READ_IB   ((uint8) 0x04U)

Spi_ReadIB() API Service ID.

◆ SPI_SID_SETUP_EB

#define SPI_SID_SETUP_EB   ((uint8) 0x05U)

Spi_SetupEB() API Service ID.

◆ SPI_SID_GET_STATUS

#define SPI_SID_GET_STATUS   ((uint8) 0x06U)

Spi_GetStatus() API Service ID.

◆ SPI_SID_GET_JOB_RESULT

#define SPI_SID_GET_JOB_RESULT   ((uint8) 0x07U)

Spi_GetJobResult() API Service ID.

◆ SPI_SID_GET_SEQ_RESULT

#define SPI_SID_GET_SEQ_RESULT   ((uint8) 0x08U)

Spi_GetSequenceResult() API Service ID.

◆ SPI_SID_GET_VERSION_INFO

#define SPI_SID_GET_VERSION_INFO   ((uint8) 0x09U)

Spi_GetVersionInfo() API Service ID.

◆ SPI_SID_SYNC_TRANSMIT

#define SPI_SID_SYNC_TRANSMIT   ((uint8) 0x0AU)

Spi_SyncTransmit() API Service ID.

◆ SPI_SID_GET_HW_UNIT_STATUS

#define SPI_SID_GET_HW_UNIT_STATUS   ((uint8) 0x0BU)

Spi_GetHWUnitStatus() API Service ID.

◆ SPI_SID_CANCEL

#define SPI_SID_CANCEL   ((uint8) 0x0CU)

Spi_Cancel() API Service ID.

◆ SPI_SID_SET_ASYNC_MODE

#define SPI_SID_SET_ASYNC_MODE   ((uint8) 0x0DU)

Spi_SetAsyncMode() API Service ID.

◆ SPI_SID_MAINFUNCTION_HANDLING

#define SPI_SID_MAINFUNCTION_HANDLING   ((uint8) 0x10U)

Spi_MainFunction_Handling() API Service ID.

◆ SPI_MCSPI_FCLK

#define SPI_MCSPI_FCLK   (48000000U)

MCSPI functional clock input in Hz. This clock is used to generate the serial clock output after the divider.

Note: This is given here for reference and can't be changed.

◆ SPI_CFG_ID_0

#define SPI_CFG_ID_0   (0x01U)

Config 0 (All configurations ON), Scaleability level 2)

◆ SPI_CFG_ID_1

#define SPI_CFG_ID_1   (0x02U)

Config 1 (All configurations OFF). SPI_CFG_ID_1 is used only for compile check.

◆ SPI_CFG_ID_2

#define SPI_CFG_ID_2   (0x04U)

Config 2 (All configurations ON except DET OFF)

◆ SPI_CFG_ID_3

#define SPI_CFG_ID_3   (0x08U)

Config 3 (Configurator auto generated file)

◆ SPI_CFG_ID_4

#define SPI_CFG_ID_4   (0x10U)

Config 4 (Config is used only by Unit Test, Scaleability level 0)

◆ SPI_CFG_ID_5

#define SPI_CFG_ID_5   (0x20U)

Config 5 (Config is used only by Unit Test for DMA

◆ SPI_CFG_ID_6

#define SPI_CFG_ID_6   (0x40U)

Config 6 (Config is used only by Unit Test for DMA.

◆ SPI_CFG_ID_7

#define SPI_CFG_ID_7   (0x80U)

Config 7 (Performance testing only, level 2, asynch, no DMA)

Typedef Documentation

◆ Spi_DataBufferType

typedef uint8 Spi_DataBufferType

Type of application data buffer elements.

◆ Spi_NumberOfDataType

typedef uint16 Spi_NumberOfDataType

Type for defining the number of data elements of the type Spi_DataBufferType to send and / or receive by Channel.

◆ Spi_ChannelType

typedef uint8 Spi_ChannelType

Specifies the identification (ID) for a Channel.

◆ Spi_JobType

typedef uint16 Spi_JobType

Specifies the identification (ID) for a Job.

◆ Spi_SequenceType

typedef uint8 Spi_SequenceType

Specifies the identification (ID) for a sequence of jobs.

◆ Spi_HWUnitType

typedef uint8 Spi_HWUnitType

Specifies the identification (ID) for a SPI Hardware micro controller peripheral (unit)

◆ Spi_CacheWbInv

typedef void(* Spi_CacheWbInv) (uint8 *BufPtr, uint16 LenByte)

Cache write-back invalidate function.

Pointer to a function that performs the cache write-back invalidate operation. This function is to be called on TX buffers before they are given to the Spi controller hardware.

◆ Spi_CacheWb

typedef void(* Spi_CacheWb) (uint8 *BufPtr, uint16 LenByte)

Cache write-back function.

Pointer to a function that performs the cache write-back operation. This function is to be called on TX buffers before they are given to the Spi controller hardware.

◆ Spi_CacheInv

typedef void(* Spi_CacheInv) (uint8 *BufPtr, uint16 LenByte)

Cache invalidate function.

Pointer to a function that performs the cache invalidate operation. This function is to be called on RX buffers after they have been retrieved from the Spi controller hardware.

Enumeration Type Documentation

◆ Spi_StatusType

This type defines a range of specific status for SPI Handler/Driver.

Enumerator
SPI_UNINIT 

The SPI Handler/Driver is not initialized or not usable

SPI_IDLE 

The SPI Handler/Driver is not currently transmitting any Job

SPI_BUSY 

The SPI Handler/Driver is performing a SPI Job (transmit)

◆ Spi_JobResultType

This type defines a range of specific Jobs status for SPI Handler/Driver.

Enumerator
SPI_JOB_OK 

The last transmission of the Job has been finished successfully

SPI_JOB_PENDING 

The SPI Handler/Driver is performing a SPI Job. The meaning of this status is equal to SPI_BUSY

SPI_JOB_FAILED 

The last transmission of the Job has failed

SPI_JOB_QUEUED 

An asynchronous transmit Job has been accepted, while actual transmission for this Job has not started yet

◆ Spi_SeqResultType

This type defines a range of specific Sequences status for SPI Handler/Driver.

Enumerator
SPI_SEQ_OK 

The last transmission of the Sequence has been finished successfully

SPI_SEQ_PENDING 

The SPI Handler/Driver is performing a SPI Sequence. The meaning of this status is equal to SPI_BUSY

SPI_SEQ_FAILED 

The last transmission of the Sequence has failed

SPI_SEQ_CANCELLED 

The last transmission of the Sequence has been canceled by user

◆ Spi_HwUnitResultType

This type defines a range of specific HW unit status for SPI Handler/Driver.

Enumerator
SPI_HW_UNIT_OK 

HW unit result is ok

SPI_HW_UNIT_PENDING 

HW unit result is pending

SPI_HW_UNIT_FAILED 

HW unit result is failed

◆ Spi_AsyncModeType

Specifies the asynchronous mechanism mode for SPI busses handled asynchronously in LEVEL 2.

Enumerator
SPI_POLLING_MODE 

The asynchronous mechanism is ensured by polling, so interrupts related to SPI busses handled asynchronously are disabled

SPI_INTERRUPT_MODE 

The asynchronous mechanism is ensured by interrupt, so interrupts related to SPI busses handled asynchronously are enabled

◆ Spi_TransferType

Word transfer order - MSB first or LSB first.

Enumerator
SPI_MSB 

MSB is transferred first. Only this is supported

SPI_LSB 

LSB is transferred first. This is not supported

◆ Spi_LevelType

Type for SPI Chip Select Polarity and Clock Idle Level.

Enumerator
SPI_LOW 

Low clock or chip select

SPI_HIGH 

High clock or chip select

◆ Spi_CsPinType

SPI Chip Select Pin.

Enumerator
SPI_CS0 

Chip select 0

SPI_CS1 

Chip select 1

SPI_CS2 

Chip select 2

SPI_CS3 

Chip select 3

◆ Spi_ClkMode

SPI Clock Mode - sets the clock polarity and phase. Note: These values are a direct register mapping. So don't change value.

Enumerator
SPI_CLK_MODE_0 

SPI Clock Phase = 0 (rising edge latch), Polarity = 0 (Active HIGH)

SPI_CLK_MODE_1 

SPI Clock Phase = 1 (falling edge latch), Polarity = 0 (Active HIGH)

SPI_CLK_MODE_2 

SPI Clock Phase = 0 (rising edge latch), Polarity = 1 (Active LOW)

SPI_CLK_MODE_3 

SPI Clock Phase = 1 (falling edge latch), Polarity = 1 (Active LOW)

◆ Spi_TxRxMode

SPI TX/RX Mode.

Note:

  1. These values are a direct register mapping. So don't change value.
  2. RX only mode doesn't make sense in master mode because to receive data the master has to generate clock, which means it should transmit. Hence this mode is not supported. The user can alternatively set the TX buffer pointer to NULL and set the default TX value (defaultTxData) to make TX data line at the desired level.
Enumerator
SPI_TX_RX_MODE_BOTH 

Both TX and RX are enabled

SPI_TX_RX_MODE_TX_ONLY 

Only TX is enabled

◆ Spi_JobPriorityType

SPI Job Priority.

Enumerator
SPI_JOB_PRIORITY_0 

Job priority 0 - low

SPI_JOB_PRIORITY_1 

Job priority 1

SPI_JOB_PRIORITY_2 

Job priority 2

SPI_JOB_PRIORITY_3 

Job priority 3 - High

◆ Spi_CsModeType

SPI Chip Select Mode.

Enumerator
SPI_SINGLE 

Chip select mode - single. Active only when transfer is on.

SPI_CONTINUOUS 

Chip select mode - continuous. Active throughout.

◆ Spi_DataDelayType

Spi_DataDelayType defines the number of interface clock cycles between CS toggling and first or last edge of MCSPI clock.

Enumerator
SPI_DATADELAY_0 

0.5 clock cycles delay

SPI_DATADELAY_1 

1.5 clock cycles delay

SPI_DATADELAY_2 

2.5 clock cycles delay

SPI_DATADELAY_3 

3.5 clock cycles delay

◆ Spi_DataLineReceiveType

Spi_DataLineReceiveType defines the lines selected for reception.

Enumerator
DATA_LINE_0_RECEPTION 

Data line 0 (SPIDAT[0]) selected for reception

DATA_LINE_1_RECEPTION 

Data line 1 (SPIDAT[1]) selected for reception

◆ Spi_DataLineTransmitType

Spi_DataLineTransmitType defines the lines selected for transmission.

Enumerator
DATA_LINE_NO_TRANSMISSION 

No transmission on data lines

DATA_LINE_0_TRANSMISSION 

Data line 0 (SPIDAT[0]) selected for transmission

DATA_LINE_1_TRANSMISSION 

Data line 1 (SPIDAT[1]) selected for transmission

DATA_LINE_BOTH_TRANSMISSION 

Data line 0 and 1 (SPIDAT[0] & SPIDAT[1]) selected for transmission

◆ Mcspi_IrqStatusType

Irq status and std return type.

Enumerator
SPI_NO_EVENT 

No event ocuurs in Overflow/Under flow

SPI_EVENT_PENDING 

Event occurs in Overflow/Under flow

SPI_STATUS_READ_FAIL 

The status reading fails

Function Documentation

◆ Spi_Init()

void Spi_Init ( const Spi_ConfigType * CfgPtr)

Service for SPI initialization.

*  Service name        : Spi_Init
*  Syntax              : void Spi_Init( const Spi_ConfigType* CfgPtr )
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x00
*  Sync/Async          : Synchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : CfgPtr - Pointer to configuration set
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : None
*  Description         : Service for SPI initialization
*  

◆ Spi_DeInit()

Std_ReturnType Spi_DeInit ( void )

Service for SPI de-initialization.

*  Service name        : Spi_DeInit
*  Syntax              : Std_ReturnType Spi_DeInit( void )
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x01
*  Sync/Async          : Synchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType
*                        E_OK: de-initialisation command has been accepted
*                        E_NOT_OK: de-initialisation command has not been
*                                  accepted
*  Description         : Service for SPI de-initialization
*  

◆ Spi_GetStatus()

Spi_StatusType Spi_GetStatus ( void )

Service returns the SPI Handler/Driver software module status.

*  Service name        : Spi_GetStatus
*  Syntax              : Spi_StatusType Spi_GetStatus( void )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x06
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Spi_StatusType - Spi_StatusType
*  Description         : Service for SPI de-initialization
*  

◆ Spi_GetJobResult()

Spi_JobResultType Spi_GetJobResult ( Spi_JobType Job)

This service returns the last transmission result of the specified Job.

*  Service name        : Spi_GetJobResult
*  Syntax              : Spi_JobResultType Spi_GetJobResult( Spi_JobType Job )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x07
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Job - Job ID. An invalid job ID will return an
*                        undefined result
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Spi_JobResultType - Spi_JobResultType
*  Description         : Service for SPI de-initialization
*  

◆ Spi_GetSequenceResult()

Spi_SeqResultType Spi_GetSequenceResult ( Spi_SequenceType Sequence)

This service returns the last transmission result of the specified Sequence.

*  Service name        : Spi_GetSequenceResult
*  Syntax              : Spi_SeqResultType Spi_GetSequenceResult(
*                                                   Spi_SequenceType Sequence )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x08
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Sequence - Sequence ID. An invalid sequence ID will
*                        return an undefined result
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Spi_SeqResultType - Spi_SeqResultType
*  Description         : This service returns the last transmission result of
*                        the specified Sequence
*  

◆ Spi_GetVersionInfo()

void Spi_GetVersionInfo ( Std_VersionInfoType * versioninfo)

This service returns the version information of this module.

*  Service name        : Spi_GetVersionInfo
*  Syntax              : void Spi_GetVersionInfo( Std_VersionInfoType*
*                                                                 versioninfo )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x09
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : versioninfo - Pointer to where to store the version
*                        information of this module
*  Parameters (out)    : None
*  Return value        : None
*  Description         : This service returns the version information of this
*                        module
*  

◆ Spi_GetHWUnitStatus()

Spi_StatusType Spi_GetHWUnitStatus ( Spi_HWUnitType HWUnit)

This service returns the status of the specified SPI Hardware microcontroller peripheral.

*  Service name        : Spi_GetHWUnitStatus
*  Syntax              : Spi_StatusType Spi_GetHWUnitStatus( Spi_HWUnitType
*                                                                      HWUnit )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x0b
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : HWUnit - SPI Hardware microcontroller peripheral
*                        unit ID.
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Spi_StatusType - Spi_StatusType
*  Description         : This service returns the status of the specified SPI
*                        Hardware microcontroller peripheral
*  

◆ Spi_WriteIB()

Std_ReturnType Spi_WriteIB ( Spi_ChannelType Channel,
const Spi_DataBufferType * DataBufferPtr )

Service for writing one or more data to an IB SPI Handler/Driver Channel specified by parameter.

*  Service name        : Spi_WriteIB
*  Syntax              : Std_ReturnType Spi_WriteIB(
*                              Spi_ChannelType Channel,
*                              const Spi_DataBufferType* DataBufferPtr )
*
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x02
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Channel - Channel ID
*                        DataBufferPtr - Pointer to source data buffer.
*                        If this pointer is null, it is assumed that the data
*                        to be transmitted is not relevant and the default
*                        transmit value of this channel will be used instead.
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType
*                        E_OK: Write command has been accepted
*                        E_NOT_OK: Write command has not been accepted
*  Description         : Service for writing one or more data to an IB SPI
*                        Handler/Driver Channel specified by parameter
*  

◆ Spi_ReadIB()

Std_ReturnType Spi_ReadIB ( Spi_ChannelType Channel,
Spi_DataBufferType * DataBufferPointer )

Service for reading synchronously one or more data from an IB SPI Handler/Driver Channel specified by parameter.

*  Service name        : Spi_ReadIB
*  Syntax              : Std_ReturnType Spi_ReadIB(
*                              Spi_ChannelType Channel,
*                              Spi_DataBufferType* DataBufferPointer )
*
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x04
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Channel - Channel ID
*  Parameters (inout)  : None
*  Parameters (out)    : DataBufferPointer - Pointer to destination data buffer.
*  Return value        : Std_ReturnType
*                        E_OK: Read command has been accepted
*                        E_NOT_OK: Read command has not been accepted
*  Description         : Service for reading synchronously one or more data
*                        from an IB SPI Handler/Driver Channel specified by
*                        parameter
*  

◆ Spi_SetupEB()

Std_ReturnType Spi_SetupEB ( Spi_ChannelType Channel,
const Spi_DataBufferType * SrcDataBufferPtr,
Spi_DataBufferType * DesDataBufferPtr,
Spi_NumberOfDataType Length )

Service to setup the buffers and the length of data for the EB SPI Handler/Driver Channel specified.

*  Service name        : Spi_SetupEB
*  Syntax              : Std_ReturnType Spi_SetupEB( Spi_ChannelType Channel,
*                                  const Spi_DataBufferType* SrcDataBufferPtr,
*                                  Spi_DataBufferType* DesDataBufferPtr,
*                                   Spi_NumberOfDataType Length )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x05
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Channel - Channel ID
*                        SrcDataBufferPtr - Pointer to source data buffer
*                        DesDataBufferPtr - Pointer to destination data buffer
*                                           in RAM.
*                        Length - Length (number of data elements) of the data
*                        to be transmitted from SrcDataBufferPtr and/or
*                        received
*                        from DesDataBufferPtr Min.: 1 Max.: Max of data
*                        specified at configuration for this channel
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType
*                        E_OK: Setup command has been accepted
*                        E_NOT_OK: Setup command has not been accepted
*  Description         : Service to setup the buffers and the length of data
*                        for the EB SPI Handler/Driver Channel specified
*  

◆ Spi_AsyncTransmit()

Std_ReturnType Spi_AsyncTransmit ( Spi_SequenceType Sequence)

Service to transmit data on the SPI bus.

*  Service name        : Spi_AsyncTransmit
*  Syntax              : Std_ReturnType Spi_AsyncTransmit( Spi_SequenceType
*                                                              Sequence )
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x03
*  Sync/Async          : Asynchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Sequence - Sequence ID
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType
*                        E_OK: Transmission command has been accepted
*                        E_NOT_OK: Transmission command has not been accepted
*  Description         : Service to transmit data on the SPI bus
*  

◆ Spi_Cancel()

void Spi_Cancel ( Spi_SequenceType Sequence)

Service cancels the specified on-going sequence transmission.

*  Service name        : Spi_Cancel
*  Syntax              : void Spi_Cancel( Spi_SequenceType Sequence )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x0c
*  Sync/Async          : Asynchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Sequence - Sequence ID
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : None
*  Description         : Service cancels the specified on-going sequence
*                        transmission
*  

◆ Spi_SyncTransmit()

Std_ReturnType Spi_SyncTransmit ( Spi_SequenceType Sequence)

Service to transmit data on the SPI bus.

*  Service name        : Spi_SyncTransmit
*  Syntax              : Std_ReturnType Spi_SyncTransmit( Spi_SequenceType
*                                                                  Sequence)
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x0A
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : Sequence - Sequence ID
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType
*                        E_OK: Transmission command has been completed
*                        E_NOT_OK: Transmission command has not been completed
*  Description         : Service to transmit data on the SPI bus
*  

◆ Spi_SetAsyncMode()

Std_ReturnType Spi_SetAsyncMode ( Spi_AsyncModeType Mode)

Service to set the asynchronous mechanism mode for SPI busses handled asynchronously.

*  Service name        : Spi_SetAsyncMode
*  Syntax              : Std_ReturnType Spi_SetAsyncMode( Spi_AsyncModeType
*                                                                      Mode )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x0D
*  Sync/Async          : Synchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : Mode - New mode required.
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType
*                        E_OK: Setting command has been done
*                        E_NOT_OK: Setting command has not been accepted
*  Description         : Service to set the asynchronous mechanism mode for
*                        SPI busses handled asynchronously.
*  

◆ Spi_MainFunction_Handling()

void Spi_MainFunction_Handling ( void )

This function polls the SPI interrupts linked to HW Units allocated to the transmission of SPI sequences to enable the evolution of transmission state machine.

*  Service name        : Spi_MainFunction_Handling
*  Syntax              : void Spi_MainFunction_Handling( void )
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x10
*  Sync/Async          : Synchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : None
*  Description         : This function polls the SPI interrupts linked to
*                        HW Units allocated to the transmission of SPI
*                        sequences to enable the evolution of transmission
*                        state machine.
*  

◆ Spi_RegisterReadback()

Std_ReturnType Spi_RegisterReadback ( Spi_HWUnitType HWUnit,
Spi_RegisterReadbackType * RegRbPtr )

This function reads the important registers of the hardware unit and returns the value in the structure.

This API should be called after Spi_Init is called. Otherwise this API will return E_NOT_OK.

This API could be used to readback the register contents after Spi_Init and then the readback value could be compared during SPI execution to check the correctness of the HW unit. Since this API is used for this purpose, the register returned are the ones which doesn't change after init based on job or channel config.

*  Service name        : Spi_RegisterReadback
*  Mode                : Supervisor Mode (Privileged Mode)
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : HWUnit - SPI Hardware microcontroller peripheral
*                        unit ID. If this is invalid, then the API will
*                        return E_NOT_OK.
*  Parameters (inout)  : RegRbPtr - Pointer to where to store the readback
*                        values. If this pointer is NULL_PTR, then the API
*                        will return E_NOT_OK.
*  Return value        : Std_ReturnType
*                        E_OK: Register read back has been done
*                        E_NOT_OK: Register read back failed
*  

◆ Spi_dataOverflowUnderflowIntrEnable()

Std_ReturnType Spi_dataOverflowUnderflowIntrEnable ( Spi_HWUnitType HWUnit,
uint32 intFlags )

This function Enable Under/Overflow Interupts of the hardware unit and returns the status.

*  Service name        : Spi_dataOverflowUnderflowIntrEnable
*  Mode                : Supervisor Mode (Privileged Mode)
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : HWUnit - SPI Hardware microcontroller peripheral
*                        unit ID. If this is invalid, then the API will
*                        return E_NOT_OK.
*                      : intFlags - Mask value of MCSPI_IRQENABLE register
*  Return value        : Std_ReturnType
*                        E_OK: Interupt Enabled
*                        E_NOT_OK: Interupt Enable failed
*  

◆ Spi_dataOverflowUnderflowIntrDisable()

Std_ReturnType Spi_dataOverflowUnderflowIntrDisable ( Spi_HWUnitType HWUnit,
uint32 intFlags )

This function Disable Under/Overflow Interupts of the hardware unit and returns the status.

*  Service name        : Spi_dataOverflowUnderflowIntrDisable
*  Mode                : Supervisor Mode (Privileged Mode)
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : HWUnit - SPI Hardware microcontroller peripheral
*                        unit ID. If this is invalid, then the API will
*                        return E_NOT_OK.
*                      : intFlags - Mask value of MCSPI_IRQSTATUS register
*  Return value        : Std_ReturnType
*                        E_OK: Interupt Disabled
*                        E_NOT_OK: Interupt Disable failed
*
*  

◆ Spi_dataOverflowUnderflowIntrGetStatus()

Mcspi_IrqStatusType Spi_dataOverflowUnderflowIntrGetStatus ( Spi_HWUnitType HWUnit,
uint32 intFlags )

This function status Under/Overflow Interupts of the hardware unit and returns the status.

*  Service name        : Spi_dataOverflowUnderflowIntrGetStatus
*  Mode                : Supervisor Mode (Privileged Mode)
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : HWUnit - SPI Hardware microcontroller peripheral
*                        unit ID. If this is invalid, then the API will
*                        return E_NOT_OK.
*                        intFlags - Mask value of MCSPI_IRQSTATUS register
*  Return value        : Mcspi_IrqStatusType
*                        SPI_NO_EVENT: No underflow event
*                        SPI_EVENT_PENDING: Underflow Event
*                        SPI_STATUS_READ_FAIL: Status read fail
*  

◆ Spi_dataOverflowUnderflowIntrStatusClear()

Std_ReturnType Spi_dataOverflowUnderflowIntrStatusClear ( Spi_HWUnitType HWUnit,
uint32 intFlags )

This function status clear Under/Overflow Interupts of the hardware unit and returns the status.

*  Service name        : Spi_dataOverflowUnderflowIntrStatusClear
*  Mode                : Supervisor Mode (Privileged Mode)
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : HWUnit - SPI Hardware microcontroller peripheral
*                        unit ID. If this is invalid, then the API will
*                        return E_NOT_OK.
*                        intFlags - Mask value of MCSPI_IRQSTATUS register
*  Return value        : Std_ReturnType
*                        E_OK: Interuptstatus cleares
*                        E_NOT_OK: Interupt status clear failed
*
*