MCUSW
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
 

Typedefs

typedef uint8 Spi_DataBufferType
 Type of application data buffer elements. More...
 
typedef uint16 Spi_NumberOfDataType
 Type for defining the number of data elements of the type Spi_DataBufferType to send and / or receive by Channel. More...
 
typedef uint8 Spi_ChannelType
 Specifies the identification (ID) for a Channel. More...
 
typedef uint16 Spi_JobType
 Specifies the identification (ID) for a Job. More...
 
typedef uint8 Spi_SequenceType
 Specifies the identification (ID) for a sequence of jobs. More...
 
typedef uint8 Spi_HWUnitType
 Specifies the identification (ID) for a SPI Hardware micro controller peripheral (unit) More...
 

Macros

#define SPI_MCSPI_FCLK   (48000000U)
 MCSPI functional clock input in Hz. This clock is used to generate the serial clock output after the divider. More...
 

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. More...
 
#define SPI_SW_MINOR_VERSION   (0U)
 Driver Implementation Minor Version. More...
 
#define SPI_SW_PATCH_VERSION   (1U)
 Driver Implementation Patch Version. More...
 

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. More...
 
#define SPI_AR_RELEASE_MINOR_VERSION   (3U)
 AUTOSAR Minor version specification implemented by SPI Driver. More...
 
#define SPI_AR_RELEASE_REVISION_VERSION   (1U)
 AUTOSAR Patch version specification implemented by SPI Driver. More...
 

SPI Driver ID Info

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

SPI Buffer Definition

#define SPI_IB   (0U)
 Buffer definitions IB - internal buffers. More...
 
#define SPI_EB   (1U)
 Buffer definitions EB - external buffers. Only this is supported. More...
 
#define SPI_IB_EB   (2U)
 Buffer definitions IB/EB - internal/external buffers. More...
 

SPI Error Codes

Error codes returned by SPI functions

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

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. More...
 
#define SPI_SID_DEINIT   ((uint8) 0x01U)
 Spi_DeInit() API Service ID. More...
 
#define SPI_SID_WRITE_IB   ((uint8) 0x02U)
 Spi_WriteIB() API Service ID. More...
 
#define SPI_SID_ASYNC_TRANSMIT   ((uint8) 0x03U)
 Spi_AsyncTransmit() API Service ID. More...
 
#define SPI_SID_READ_IB   ((uint8) 0x04U)
 Spi_ReadIB() API Service ID. More...
 
#define SPI_SID_SETUP_EB   ((uint8) 0x05U)
 Spi_SetupEB() API Service ID. More...
 
#define SPI_SID_GET_STATUS   ((uint8) 0x06U)
 Spi_GetStatus() API Service ID. More...
 
#define SPI_SID_GET_JOB_RESULT   ((uint8) 0x07U)
 Spi_GetJobResult() API Service ID. More...
 
#define SPI_SID_GET_SEQ_RESULT   ((uint8) 0x08U)
 Spi_GetSequenceResult() API Service ID. More...
 
#define SPI_SID_GET_VERSION_INFO   ((uint8) 0x09U)
 Spi_GetVersionInfo() API Service ID. More...
 
#define SPI_SID_SYNC_TRANSMIT   ((uint8) 0x0AU)
 Spi_SyncTransmit() API Service ID. More...
 
#define SPI_SID_GET_HW_UNIT_STATUS   ((uint8) 0x0BU)
 Spi_GetHWUnitStatus() API Service ID. More...
 
#define SPI_SID_CANCEL   ((uint8) 0x0CU)
 Spi_Cancel() API Service ID. More...
 
#define SPI_SID_SET_ASYNC_MODE   ((uint8) 0x0DU)
 Spi_SetAsyncMode() API Service ID. More...
 
#define SPI_SID_MAINFUNCTION_HANDLING   ((uint8) 0x10U)
 Spi_MainFunction_Handling() API Service ID. More...
 

SPI Config Ids

The Config Ids used for different SPI Configuration builds

#define SPI_CFG_ID_0   (0x01U)
 Config 0 (All configurations ON), Scaleability level 2) More...
 
#define SPI_CFG_ID_1   (0x02U)
 Config 1 (All configurations OFF). SPI_CFG_ID_1 is used only for compile check. More...
 
#define SPI_CFG_ID_2   (0x04U)
 Config 2 (All configurations ON except DET OFF) More...
 
#define SPI_CFG_ID_3   (0x08U)
 Config 3 (Configurator auto generated file) More...
 
#define SPI_CFG_ID_4   (0x10U)
 Config 4 (Config is used only by Unit Test, Scaleability level 0) More...
 
#define SPI_CFG_ID_5   (0x20U)
 Config 5 (Config is used only by Unit Test for DMA. More...
 
#define SPI_CFG_ID_6   (0x40U)
 Config 6 (Config is used only by Unit Test for DMA. More...
 
#define SPI_CFG_ID_7   (0x80U)
 Config 7 (Performance testing only, level 2, asynch, no DMA) More...
 

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   (0U)

Driver Implementation Minor Version.

◆ SPI_SW_PATCH_VERSION

#define SPI_SW_PATCH_VERSION   (1U)

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)