5.8. SPI

5.8.1. Types

Base type

Type Name

Brief

enum

Spi_BufferWidthType

SPI Buffer pointer type.

enum

Spi_HwInstance

This type defines Channel Select Interface with in SPI(SPI instance)

enum

Spi_StatusType

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

enum

Spi_JobResultType

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

enum

Spi_SeqResultType

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

enum

Spi_HwUnitResultType

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

enum

Spi_AsyncModeType

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

enum

Spi_TransferType

Word transfer order - MSB first or LSB first.

enum

Spi_CsSelection

Spi Cs Selection - Chip select handling.

enum

Spi_ClkMode

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

enum

Spi_JobPriorityType

SPI Job Priority.

typedef uint8

Spi_CsLevelType

These are the possible levels a chip select.

typedef uint8

Spi_DataBufferType

Type of application data buffer elements.

typedef uint32

Spi_CsGpioType

GPIO ID type.

typedef uint32

Spi_RegisterPtrType

type for the register pointer

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 void(*)(void)

Spi_JobEndNotifyType

Typedef for job end notification function pointer.

typedef void(*)(void)

Spi_SeqEndNotifyType

Typedef for sequence end notification function pointer.

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)

typedef uint8

Spi_DataDelayType

Spi_DataDelayType defines the number of SPI serial clock cycles delay between each word in FIFO mode.

5.8.1.1. enum Spi_BufferWidthType

Enumerator

Value

Description

SPI_8BIT_BUFFER

SPI 8 bit buffer.

SPI_16BIT_BUFFER

SPI 16 bit buffer.

Brief: SPI Buffer pointer type.

5.8.1.2. enum Spi_HwInstance

Enumerator

Value

Description

SPI_UNIT_SPIA

SPIA instance.

SPI_UNIT_SPIB

SPIB instance.

SPI_UNIT_SPIC

SPIC instance.

SPI_UNIT_SPID

SPID instance.

SPI_UNIT_SPIE

SPIE instance.

Brief: This type defines Channel Select Interface with in SPI(SPI instance)

5.8.1.3. enum Spi_StatusType

Enumerator

Value

Description

SPI_UNINIT

0U

The SPI Handler/Driver is not initialized or not usable.

SPI_IDLE

1U

The SPI Handler/Driver is not currently transmitting any Job.

SPI_BUSY

2U

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

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

5.8.1.4. enum Spi_JobResultType

Enumerator

Value

Description

SPI_JOB_OK

0U

The last transmission of the Job has been finished successfully.

SPI_JOB_PENDING

1U

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

SPI_JOB_FAILED

2U

The last transmission of the Job has failed.

SPI_JOB_QUEUED

3U

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

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

5.8.1.5. enum Spi_SeqResultType

Enumerator

Value

Description

SPI_SEQ_OK

0U

The last transmission of the Sequence has been finished successfully.

SPI_SEQ_PENDING

1U

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

SPI_SEQ_FAILED

2U

The last transmission of the Sequence has failed.

SPI_SEQ_CANCELLED

3U

The last transmission of the Sequence has been canceled by user.

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

5.8.1.6. enum Spi_HwUnitResultType

Enumerator

Value

Description

SPI_HW_UNIT_OK

0U

HW unit result is ok.

SPI_HW_UNIT_PENDING

1U

HW unit result is pending.

SPI_HW_UNIT_FAILED

2U

HW unit result is failed.

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

5.8.1.7. enum Spi_AsyncModeType

Enumerator

Value

Description

SPI_POLLING_MODE

0U

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

SPI_INTERRUPT_MODE

1U

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

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

5.8.1.8. enum Spi_TransferType

Enumerator

Value

Description

SPI_MSB

0U

MSB is transferred first. Only this is supported.

SPI_LSB

1U

LSB is transferred first. This is not supported.

Brief: Word transfer order - MSB first or LSB first.

5.8.1.9. enum Spi_CsSelection

Enumerator

Value

Description

CS_VIA_GPIO

chip select is handled via general purpose IO by Spi driver

CS_VIA_PERIPHERAL_ENGINE

chip select is handled automatically by Peripheral HW engine

Brief: Spi Cs Selection - Chip select handling.

5.8.1.10. enum Spi_ClkMode

Enumerator

Value

Description

SPI_CLK_MODE_0

0x00U

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

SPI_CLK_MODE_1

0x01U

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

SPI_CLK_MODE_2

0x02U

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

SPI_CLK_MODE_3

0x03U

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

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

5.8.1.11. enum Spi_JobPriorityType

Enumerator

Value

Description

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.

Brief: SPI Job Priority.

5.8.2. Structures

Name

Brief

Spi_ChannelObjType

SPI Channel object structure.

Spi_SeqObjType

SPI Sequence object structure.

Spi_JobObjType

SPI Job object structure.

Spi_HwUnitObjType_t

SPI Hardware unit object structure.

Spi_DriverObjType

SPI driver object structure.

Spi_UtilsParams

Structure for storing node info.

Spi_UtilsNode_t

Self referential structure for double link list.

Spi_UtilsLinkListObj

Structure to the link list object information.

Spi_ChannelConfigType

SPI Channel configuration structure.

Spi_ExternalDeviceConfigType

SPI external device specific configuration structure .

Spi_JobConfigType

SPI Job configuration structure.

Spi_SeqConfigType

SPI Sequence configuration structure.

Spi_HwUnitConfigType

SPI Hardware unit configuration structure.

Spi_ConfigType

SPI config structure.

5.8.3. Defines

Name

Brief

SPI_SID_INIT

Spi_Init() API Service ID.

SPI_SID_DEINIT

Spi_DeInit() API Service ID.

SPI_SID_WRITE_IB

Spi_WriteIB() API Service ID.

SPI_SID_ASYNC_TRANSMIT

Spi_AsyncTransmit() API Service ID.

SPI_SID_READ_IB

Spi_ReadIB() API Service ID.

SPI_SID_SETUP_EB

Spi_SetupEB() API Service ID.

SPI_SID_GET_STATUS

Spi_GetStatus() API Service ID.

SPI_SID_GET_JOB_RESULT

Spi_GetJobResult() API Service ID.

SPI_SID_GET_SEQ_RESULT

Spi_GetSequenceResult() API Service ID.

SPI_SID_GET_VERSION_INFO

Spi_GetVersionInfo() API Service ID.

SPI_SID_SYNC_TRANSMIT

Spi_SyncTransmit() API Service ID.

SPI_SID_GET_HW_UNIT_STATUS

Spi_GetHWUnitStatus() API Service ID.

SPI_SID_CANCEL

Spi_Cancel() API Service ID.

SPI_SID_SET_ASYNC_MODE

Spi_SetAsyncMode() API Service ID.

SPI_SID_MAINFUNCTION_HANDLING

Spi_MainFunction_Handling() API Service ID.

SPI_SW_MAJOR_VERSION

Driver Implementation Major Version.

SPI_SW_MINOR_VERSION

Driver Implementation Minor Version.

SPI_SW_PATCH_VERSION

Driver Implementation Patch Version.

SPI_AR_RELEASE_MAJOR_VERSION

AUTOSAR major version specification implemented by SPI Driver.

SPI_AR_RELEASE_MINOR_VERSION

AUTOSAR minor version specification implemented by SPI Driver.

SPI_AR_RELEASE_PATCH_VERSION

AUTOSAR patch version specification implemented by SPI Driver.

SPI_VENDOR_ID

Texas Instruments Vendor ID.

SPI_MODULE_ID

SPI Driver Module ID.

SPI_INSTANCE_ID

SPI Driver Instance ID.

SPI_IB

Buffer definitions IB - internal buffers.

SPI_EB

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

SPI_IB_EB

Buffer definitions IB/EB - internal/external buffers.

SPI_E_PARAM_CHANNEL

SPI Error Codes. Error codes returned by SPI functions.

SPI_E_PARAM_JOB

API service called with wrong parameter.

SPI_E_PARAM_SEQ

API service called with wrong parameter.

SPI_E_PARAM_LENGTH

API service called with wrong parameter.

SPI_E_PARAM_UNIT

API service called with wrong parameter.

SPI_E_PARAM_POINTER

APIs called with a Null Pointer.

SPI_E_UNINIT

API service used without module initialization.

SPI_E_SEQ_PENDING

Services called in a wrong sequence.

SPI_E_SEQ_IN_PROCESS

Synchronous transmission service called at wrong time.

SPI_E_ALREADY_INITIALIZED

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

5.8.4. Functions

Return type

Function Name

Brief

void

Spi_Init(const Spi_ConfigType * CfgPtr)

Spi_Init : Service for SPI initialization.

Std_ReturnType

Spi_DeInit(void )

Spi_DeInit : Service for SPI de-initialization.

Spi_StatusType

Spi_GetStatus(void )

Spi_GetStatus: Service returns the SPI Handler/Driver software module status.

Spi_JobResultType

Spi_GetJobResult(Spi_JobType Job)

Spi_GetStatus: Service is to get the result of a specified job.

Spi_SeqResultType

Spi_GetSequenceResult(Spi_SequenceType Sequence)

Spi_GetSequenceResult: Service.

void

Spi_GetVersionInfo(Std_VersionInfoType * versioninfo)

Service to get the version information of the module.

Spi_StatusType

Spi_GetHWUnitStatus(Spi_HWUnitType HWUnit)

Spi_GetHWUnitStatus: Service to get the status of the SPI hardware unit.

Std_ReturnType

Spi_WriteIB(Spi_ChannelType Channel, const Spi_DataBufferType * DataBufferPtr)

Spi_WriteIB: 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 data from internal buffers.

Std_ReturnType

Spi_AsyncTransmit(Spi_SequenceType Sequence)

Spi_AsyncTransmit: Service to transmit data on the SPI bus.

void

Spi_Cancel(Spi_SequenceType Sequence)

Spi_Cancel: this service is to cancel on going sequence.

Std_ReturnType

Spi_SyncTransmit(Spi_SequenceType Sequence)

Spi_SyncTransmit: Service to transmit data on the SPI bu.

Std_ReturnType

Spi_SetAsyncMode(Spi_AsyncModeType Mode)

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

void

Spi_MainFunction_Handling(void )

Spi_MainFunction_Handling: This function shall polls the SPI interrupts linked to HW Units.

void

Spi_ResetDrvObj(Spi_DriverObjType * drvObj)

function to reset driver object

void

Spi_CopyConfig(Spi_DriverObjType * drvObj, const Spi_ConfigType * cfgPtr)

function to copy configuration into driver obj

void

Spi_HwUnitInit(Spi_HwUnitObjType * hwUnitObj)

function to initialize SPI hardware unit

void

Spi_HwUnitDeInit(Spi_HwUnitObjType * hwUnitObj)

function to de-initialize SPI hardware unit

Spi_HwUnitObjType *

Spi_GetHwUnitObj(Spi_HWUnitType HWUnit)

function to get hardware unit object based on HW unit ID

void

Spi_DisableInterrupt(uint32 baseAddr, boolean isFifoEnabled)

function to disable all the interrupts

void

Spi_EnableInterrupt(uint32 baseAddr, boolean isFifoEnabled)

function to enable interrupts

Std_ReturnType

Spi_StartSeqAsync(Spi_SeqObjType * seqObj)

private function to start Asynchronous transmission

Std_ReturnType

Spi_StartSeqSync(Spi_SeqObjType * seqObj)

private function to start synchronous transmission

void

Spi_ProcessRxEvent(Spi_HWUnitType hwUnitId)

process receive interrupt(RXINT/INT)

void

Spi_ProcessChCompletion(Spi_HwUnitObjType * hwUnitObj, Spi_JobResultType jobResult)

process channel completion

void

Spi_ConfigGpioChipSelect(const Spi_JobObjType * jobObj, boolean enable)

function to Enable or Disable chip-select when it is a GPIO

uint32

Spi_GetHwUnitBaseAddr(Spi_HWUnitType HwUnitId)

function to get HW unit base address

void

Spi_CancelSequence(Spi_SeqObjType * seqObj)

function to cancel ongoing sequence

void

Spi_PrivIntlBufWrite8(Spi_ChannelObjType * ChObj, const Spi_DataBufferType * DataBufferPtr)

function to write into internal buffer in 8 bits

void

Spi_PrivIntlBufWrite16(Spi_ChannelObjType * ChObj, const Spi_DataBufferType * DataBufferPtr)

function to write into internal buffer in 16 bits

void

Spi_PrivReadIB(Spi_ChannelObjType * ChObj, const Spi_DataBufferType * DataBufferPtr)

function to read from internal buffer

Spi_StatusType

Spi_PrivGetHWStatus(const Spi_HwUnitObjType * hwUnitObj)

function to get HW Status

void

Spi_PrivProcessTxEvent(uint32 baseAddr, Spi_ChannelObjType * chObj, uint16 txIntrStatus)

This function process transfer interrupt(TXINT)

void

Spi_PrivJobCopyConfig(Spi_DriverObjType * drvObj, const Spi_ConfigType * cfgPtr)

function to copy configuration into Job obj

void

Spi_PrivSeqCopyConfig(Spi_DriverObjType * drvObj, const Spi_ConfigType * cfgPtr)

function to copy configuration into Sequence obj

void

Spi_PrivChannelCopyConfig(Spi_DriverObjType * drvObj, const Spi_ConfigType * cfgPtr)

function to copy configuration into Channel obj

void

Spi_PrivHWUnitCopyConfig(Spi_DriverObjType * drvObj, const Spi_ConfigType * cfgPtr)

function to copy configuration into HWUnit obj

void

Spi_PrivExtDevCopyConfig(Spi_DriverObjType * drvObj, const Spi_ConfigType * cfgPtr)

function to copy configuration into External Device obj

__inline const uint8 *

Spi_FifoWrite8(uint32 baseAddr, uint32 wordSize, const uint8 * bufPtr, uint32 transferLength, uint16 curTxWords)

function to write into Register in 8 bits

__inline const uint16 *

Spi_FifoWrite16(uint32 baseAddr, uint32 wordSize, const uint16 * bufPtr, uint32 transferLength, uint16 curTxWords)

function to write into Register in 16 bits

__inline uint8 *

Spi_FifoRead8(uint32 baseAddr, uint8 * bufPtr, uint32 numWordsToRead, uint16 dataWidthBitMask, uint16 curRxWords)

function to read from Register to bufPtr in 8 bits

__inline uint16 *

Spi_FifoRead16(uint32 baseAddr, uint16 * bufPtr, uint32 numWordsToRead, uint16 dataWidthBitMask, uint16 curRxWords)

function to read from Register to bufPtr in 16 bits

__inline void

Spi_FifoWriteDefault(uint32 baseAddr, uint32 wordSize, uint16 defaultTxData, uint32 transferLength)

function to write Default data into Register

__inline void

Spi_FifoReadDiscard(uint32 baseAddr, uint32 transferLength)

function to read from Register and discard

__inline void

Spi_ReadRxBufferNonFifo(Spi_ChannelObjType * chObj, uint32 baseAddr)

function to read from Register to Channel Object

__inline void

Spi_WriteTxBufferNonFifo(Spi_ChannelObjType * chObj, uint32 baseAddr)

function to write into Register from Channel Object

__inline void

Spi_ClearPIPEINTFlag(uint32 intNum)

function to clear PIPE interrupt

uint16

Spi_RegMFReadRaw16(uint32 addr, uint16 mask, uint16 shift)

This function reads a 16 bit register, masks specific set of bits and the left shifted value.

void

Spi_RegMFWriteRaw16(uint32 addr, uint16 mask, uint16 shift, uint16 value)

This function writes a 16 bit register masking specific set of bits and the left shifted value.

uint16

Spi_RegReadRaw16(uint32 addr)

This function reads a 16 bit register.

void

Spi_RegWriteRaw16(uint32 addr, uint16 value)

This function writes a 16 bit register.

void

Spi_RegBitSet16(uint32 addr, uint16 mask)

This function sets one of the bit in 16 bit register.

void

Spi_RegBitClear16(uint32 addr, uint16 mask)

This function clears one of the bit in 16 bit register.

void

Spi_UtilsInitLinkList(Spi_UtilsLinkListObj * llobj)

function to Initialize linked list

void

Spi_UtilsDeInitLinkList(Spi_UtilsLinkListObj * llobj)

function to De-Initialize linked list

void

Spi_UtilsLinkNodePri(Spi_UtilsLinkListObj * llobj, Spi_UtilsNode * node, const Spi_UtilsParams * params, uint8 currSeqId)

Links a node to the linked list. The memory to the node object should be allocated by the caller. This is used for link list with priority.

void

Spi_UtilsUnLinkNodePri(Spi_UtilsLinkListObj * llobj, Spi_UtilsNode * node)

Unlinks the node from the list. Used for the priority link lists.

void

Spi_UtilsInitNodeObject(Spi_UtilsNode * node)

Initialize the node object with default value.

Spi_UtilsNode *

Spi_UtilsGetHeadNode(const Spi_UtilsLinkListObj * llobj)

Returns the reference to the head node. This does not remove the node from the head.

5.8.4.1. function Spi_Init

void Spi_Init(
    const Spi_ConfigType * CfgPtr
)

Brief: Spi_Init : Service for SPI initialization.

This service initializes all the configured Spi channels, jobs, sequences and SPI instances This will set the state of SPI driver to Initialized.

Parameters:

  • CfgPtr - Pointer to configuration set

Returns:

  • None

Return: None

Precondition: CfgPtr shall be null in Pre-Compile variant, Link-Time variant and shall not be NULL in Post-Build variant

Postcondition: None

5.8.4.2. function Spi_DeInit

Std_ReturnType Spi_DeInit(
    void 
)

Brief: Spi_DeInit : Service for SPI de-initialization.

This service de-initializes all the configured Spi channels, jobs, sequences and SPI instances This will set the state of SPI driver to Un-Initialized.

Returns:

  • E_OK de-initialisation command has been accepted

  • E_NOT_OK de-initialisation command has not been accepted

Return: returns whether the de-init command is accepted or not.

Precondition: None

Postcondition: None

5.8.4.3. function Spi_GetStatus

Spi_StatusType Spi_GetStatus(
    void 
)

Brief: Spi_GetStatus: Service returns the SPI Handler/Driver software module status.

Service returns the SPI Handler/Driver software module status.

Returns:

  • 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)

Return: returns SPI driver status

Precondition: None

Postcondition: None

5.8.4.4. function Spi_GetJobResult

Spi_JobResultType Spi_GetJobResult(
    Spi_JobType Job
)

Brief: Spi_GetStatus: Service is to get the result of a specified job.

Service is to get the result of a specified job(queued, pending, failed, success)

Parameters:

  • Job job Id

Returns:

  • 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.

  • 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

Return: returns the status of a job

Precondition: None

Postcondition: None

5.8.4.5. function Spi_GetSequenceResult

Spi_SeqResultType Spi_GetSequenceResult(
    Spi_SequenceType Sequence
)

Brief: Spi_GetSequenceResult: Service.

Service is to return the status of a specified sequence

Parameters:

  • Sequence sequence ID

Returns:

  • 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

Return: returns the status of a sequence

Precondition: None

Postcondition: None

5.8.4.6. function Spi_GetVersionInfo

void Spi_GetVersionInfo(
    Std_VersionInfoType * versioninfo
)

Brief: Service to get the version information of the module.

This service writes the version information of this module into the data structure referenced by the parameter. If this parameter references NULL_PTR, a development error is reported to Det. This service is only available if the pre-compile configuration parameter SPI_VERSION_INFO_API is enabled.

Parameters:

  • Versioninfo structure that contains the version information parameters.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.7. function Spi_GetHWUnitStatus

Spi_StatusType Spi_GetHWUnitStatus(
    Spi_HWUnitType HWUnit
)

Brief: Spi_GetHWUnitStatus: Service to get the status of the SPI hardware unit.

This service returns the status of the specified SPI Hardware micro-controller peripheral.

Parameters:

  • HWUnit SPI Hardware micro-controller peripheral (unit) ID.

Returns:

  • SPI_UNINIT The SPI HW unit is not initialized or not usable

  • SPI_IDLE : The SPI HW unit is not currently transmitting any Job

  • SPI_BUSY : The SPI HW unit is performing a SPI Job (transmit)

Return: returns the status of the specified SPI HW unit

Precondition: None

Postcondition: None

5.8.4.8. function Spi_WriteIB

Std_ReturnType Spi_WriteIB(
    Spi_ChannelType Channel,
    const Spi_DataBufferType * DataBufferPtr
)

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

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

Parameters:

  • 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

Returns:

  • E_OK write command has been accepted

  • E_NOT_OK write command has not been accepted

Return: returns whether command has been accepted or rejected

Precondition: None

Postcondition: None

5.8.4.9. function Spi_ReadIB

Std_ReturnType Spi_ReadIB(
    Spi_ChannelType Channel,
    Spi_DataBufferType * DataBufferPointer
)

Brief: Service for reading data from internal buffers.

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

Parameters:

  • Channel Channel ID

  • DataBufferPointer Pointer to destination data buffer in RAM

Returns:

  • E_OK read command has been accepted

  • E_NOT_OK read command has not been accepted

Return: returns whether command has been accepted or rejected

Precondition: None

Postcondition: None

5.8.4.10. function Spi_AsyncTransmit

Std_ReturnType Spi_AsyncTransmit(
    Spi_SequenceType Sequence
)

Brief: Spi_AsyncTransmit: Service to transmit data on the SPI bus.

Service is to transmit data on SPI bus if the sequence is valid and not pending

Parameters:

  • Sequence Sequence ID

Returns:

  • E_OK read command has been accepted

  • E_NOT_OK read command has not been accepted

Return: returns whether command has been accepted or rejected

Precondition: None

Postcondition: None

5.8.4.11. function Spi_Cancel

void Spi_Cancel(
    Spi_SequenceType Sequence
)

Brief: Spi_Cancel: this service is to cancel on going sequence.

Service cancels the specified on-going sequence transmission.

Parameters:

  • Sequence Sequence ID

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.12. function Spi_SyncTransmit

Std_ReturnType Spi_SyncTransmit(
    Spi_SequenceType Sequence
)

Brief: Spi_SyncTransmit: Service to transmit data on the SPI bu.

Service is to transmit data on SPI bus synchronously

Parameters:

  • Sequence Sequence ID

Returns:

  • E_OK read command has been accepted

  • E_NOT_OK read command has not been accepted

Return: returns whether command has been accepted or rejected

Precondition: None

Postcondition: None

5.8.4.13. function Spi_SetAsyncMode

Std_ReturnType Spi_SetAsyncMode(
    Spi_AsyncModeType Mode
)

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

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

Parameters:

  • Mode New mode required

Returns:

  • E_OK read command has been accepted

  • E_NOT_OK read command has not been accepted

Return: returns whether command has been accepted or rejected

Precondition: None

Postcondition: None

5.8.4.14. function Spi_MainFunction_Handling

void Spi_MainFunction_Handling(
    void 
)

Brief: Spi_MainFunction_Handling: This function shall polls the SPI interrupts linked to HW Units.

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

Returns:

  • E_OK read command has been accepted

  • E_NOT_OK read command has not been accepted

Return: returns whether command has been accepted or rejected

Precondition: None

Postcondition: None

5.8.4.15. function Spi_ResetDrvObj

void Spi_ResetDrvObj(
    Spi_DriverObjType * drvObj
)

Brief: function to reset driver object

function to reset driver object

Parameters:

  • drvObj pointer to driver object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.16. function Spi_CopyConfig

void Spi_CopyConfig(
    Spi_DriverObjType * drvObj,
    const Spi_ConfigType * cfgPtr
)

Brief: function to copy configuration into driver obj

function to copy driver object

Parameters:

  • drvObj pointer to driver object

  • cfgPtr pointer to configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.17. function Spi_HwUnitInit

void Spi_HwUnitInit(
    Spi_HwUnitObjType * hwUnitObj
)

Brief: function to initialize SPI hardware unit

function to initialize SPI hardware unit

Parameters:

  • hwUnitObj pointer to hardware unit object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.18. function Spi_HwUnitDeInit

void Spi_HwUnitDeInit(
    Spi_HwUnitObjType * hwUnitObj
)

Brief: function to de-initialize SPI hardware unit

function to de-initialize SPI hardware unit

Parameters:

  • hwUnitObj pointer to hardware unit object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.19. function Spi_GetHwUnitObj

Spi_HwUnitObjType * Spi_GetHwUnitObj(
    Spi_HWUnitType HWUnit
)

Brief: function to get hardware unit object based on HW unit ID

function to get hardware unit object based on HW unit ID

Parameters:

  • HWUnit Hw unit ID

Returns:

  • Spi_HwUnitObjType pointer to HW unit object

Return: return found hardware unit object based on HW unit ID

Precondition: None

Postcondition: None

5.8.4.20. function Spi_DisableInterrupt

void Spi_DisableInterrupt(
    uint32 baseAddr,
    boolean isFifoEnabled
)

Brief: function to disable all the interrupts

function to disable all the interrupts

Parameters:

  • baseAddr HW unit base address

  • isFifoEnabled FIFO enhancement mode enabled or disabled

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.21. function Spi_EnableInterrupt

void Spi_EnableInterrupt(
    uint32 baseAddr,
    boolean isFifoEnabled
)

Brief: function to enable interrupts

function to enable interrupts

Parameters:

  • baseAddr HW unit base address

  • isFifoEnabled FIFO enhancement mode enabled or disabled

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.22. function Spi_StartSeqAsync

Std_ReturnType Spi_StartSeqAsync(
    Spi_SeqObjType * seqObj
)

Brief: private function to start Asynchronous transmission

private function to start Asynchronous transmission

Parameters:

  • seqObj pointer to sequence object

Returns:

  • E_OK sequence transfer start in async mode is success

  • E_NOT_OK sequence transfer start in async mode failed

Return: returns the status of the async transfer start

Precondition: None

Postcondition: None

5.8.4.23. function Spi_StartSeqSync

Std_ReturnType Spi_StartSeqSync(
    Spi_SeqObjType * seqObj
)

Brief: private function to start synchronous transmission

private function to start synchronous transmission

Parameters:

  • seqObj pointer to sequence object

Returns:

  • E_OK sequence transfer start in sync mode is success

  • E_NOT_OK sequence transfer start in sync mode failed

Return: returns the status of the async transfer start

Precondition: None

Postcondition: None

5.8.4.24. function Spi_ProcessRxEvent

void Spi_ProcessRxEvent(
    Spi_HWUnitType hwUnitId
)

Brief: process receive interrupt(RXINT/INT)

function to process receive interrupt

Parameters:

  • HwUnitId Id of Hardware Unit

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.25. function Spi_ProcessChCompletion

void Spi_ProcessChCompletion(
    Spi_HwUnitObjType * hwUnitObj,
    Spi_JobResultType jobResult
)

Brief: process channel completion

function to process operations after channel transfer is done

Parameters:

  • hwUnitObj pointer to HW unit object

  • jobResult result of channel completion

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.26. function Spi_ConfigGpioChipSelect

void Spi_ConfigGpioChipSelect(
    const Spi_JobObjType * jobObj,
    boolean enable
)

Brief: function to Enable or Disable chip-select when it is a GPIO

function to Enable or disable chip-select what it is a GPIO

Parameters:

  • jobObj pointer to Job object

  • enable enable or disable flag

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.27. function Spi_GetHwUnitBaseAddr

uint32 Spi_GetHwUnitBaseAddr(
    Spi_HWUnitType HwUnitId
)

Brief: function to get HW unit base address

function to get HW unit base address

Parameters:

  • hwUnitId HWUnit Id

Returns:

  • base address of the hardware unit

Return: uint32

Precondition: None

Postcondition: None

5.8.4.28. function Spi_CancelSequence

void Spi_CancelSequence(
    Spi_SeqObjType * seqObj
)

Brief: function to cancel ongoing sequence

function to cancel ongoing sequence

Parameters:

  • seqObj pointer to Sequence object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.29. function Spi_PrivIntlBufWrite8

void Spi_PrivIntlBufWrite8(
    Spi_ChannelObjType * ChObj,
    const Spi_DataBufferType * DataBufferPtr
)

Brief: function to write into internal buffer in 8 bits

function to write into internal buffer

Parameters:

  • DataBufferPtr pointer to Data Buffer

  • ChObj pointer to Channel object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.30. function Spi_PrivIntlBufWrite16

void Spi_PrivIntlBufWrite16(
    Spi_ChannelObjType * ChObj,
    const Spi_DataBufferType * DataBufferPtr
)

Brief: function to write into internal buffer in 16 bits

function to write into internal buffer

Parameters:

  • DataBufferPtr pointer to Data Buffer

  • ChObj pointer to Channel object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.31. function Spi_PrivReadIB

void Spi_PrivReadIB(
    Spi_ChannelObjType * ChObj,
    const Spi_DataBufferType * DataBufferPtr
)

Brief: function to read from internal buffer

function to read from internal buffer

Parameters:

  • ChObj pointer to Channel object

  • DataBufferPtr pointer to Data Buffer

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.32. function Spi_PrivGetHWStatus

Spi_StatusType Spi_PrivGetHWStatus(
    const Spi_HwUnitObjType * hwUnitObj
)

Brief: function to get HW Status

function to get HW unit Status

Parameters:

  • hwUnitObj pointer to HWUnit object

Returns:

  • 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)

Return: Status of HWUnit

Precondition: None

Postcondition: None

5.8.4.33. function Spi_PrivProcessTxEvent

void Spi_PrivProcessTxEvent(
    uint32 baseAddr,
    Spi_ChannelObjType * chObj,
    uint16 txIntrStatus
)

Brief: This function process transfer interrupt(TXINT)

function to process transfer interrupt(TXINT)

Parameters:

  • baseAddr Base Address of HWUnit

  • ChObj pointer to Channel object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.34. function Spi_PrivJobCopyConfig

void Spi_PrivJobCopyConfig(
    Spi_DriverObjType * drvObj,
    const Spi_ConfigType * cfgPtr
)

Brief: function to copy configuration into Job obj

function to reset Job object

Parameters:

  • drvObj pointer to driver object

  • cfgPtr pointer to configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.35. function Spi_PrivSeqCopyConfig

void Spi_PrivSeqCopyConfig(
    Spi_DriverObjType * drvObj,
    const Spi_ConfigType * cfgPtr
)

Brief: function to copy configuration into Sequence obj

function to reset Sequence object

Parameters:

  • drvObj pointer to driver object

  • cfgPtr pointer to configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.36. function Spi_PrivChannelCopyConfig

void Spi_PrivChannelCopyConfig(
    Spi_DriverObjType * drvObj,
    const Spi_ConfigType * cfgPtr
)

Brief: function to copy configuration into Channel obj

function to reset Channel object

Parameters:

  • drvObj pointer to driver object

  • cfgPtr pointer to configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.37. function Spi_PrivHWUnitCopyConfig

void Spi_PrivHWUnitCopyConfig(
    Spi_DriverObjType * drvObj,
    const Spi_ConfigType * cfgPtr
)

Brief: function to copy configuration into HWUnit obj

function to reset HWUnit object

Parameters:

  • drvObj pointer to driver object

  • cfgPtr pointer to configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.38. function Spi_PrivExtDevCopyConfig

void Spi_PrivExtDevCopyConfig(
    Spi_DriverObjType * drvObj,
    const Spi_ConfigType * cfgPtr
)

Brief: function to copy configuration into External Device obj

function to reset External Device object

Parameters:

  • drvObj pointer to driver object

  • cfgPtr pointer to configuration

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.39. function Spi_FifoWrite8

static __inline const uint8 * Spi_FifoWrite8(
    uint32 baseAddr,
    uint32 wordSize,
    const uint8 * bufPtr,
    uint32 transferLength,
    uint16 curTxWords
)

Brief: function to write into Register in 8 bits

function to write into Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • wordSize : No.of bits to be shifted while writing into register

  • transferLength : no.of bytes to transfer

  • curTxWords : index of transmitted words in bufPtr

  • bufPtr pointer to Data Buffer

Returns:

  • pointer to bufPtr

Return: pointer to bufPtr

Precondition: None

Postcondition: None

5.8.4.40. function Spi_FifoWrite16

static __inline const uint16 * Spi_FifoWrite16(
    uint32 baseAddr,
    uint32 wordSize,
    const uint16 * bufPtr,
    uint32 transferLength,
    uint16 curTxWords
)

Brief: function to write into Register in 16 bits

function to write into Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • wordSize : No.of bits to be shifted while writing into register

  • transferLength : no.of bytes to transfer

  • curTxWords : index of transmitted words in bufPtr

  • bufPtr pointer to Data Buffer

Returns:

  • pointer to bufPtr

Return: pointer to bufPtr

Postcondition: None

5.8.4.41. function Spi_FifoRead8

static __inline uint8 * Spi_FifoRead8(
    uint32 baseAddr,
    uint8 * bufPtr,
    uint32 numWordsToRead,
    uint16 dataWidthBitMask,
    uint16 curRxWords
)

Brief: function to read from Register to bufPtr in 8 bits

function to read from Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • numWordsToRead : no.of bytes to transfer

  • dataWidthBitMask : Clear unused bits

  • curRxWords : index of received words in bufPtr

  • bufPtr pointer to Data Buffer

Returns:

  • pointer to bufPtr

Return: pointer to bufPtr

Precondition: None

Postcondition: None

5.8.4.42. function Spi_FifoRead16

static __inline uint16 * Spi_FifoRead16(
    uint32 baseAddr,
    uint16 * bufPtr,
    uint32 numWordsToRead,
    uint16 dataWidthBitMask,
    uint16 curRxWords
)

Brief: function to read from Register to bufPtr in 16 bits

function to read from Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • numWordsToRead : no.of bytes to transfer

  • dataWidthBitMask : Clear unused bits

  • curRxWords : index of received words in bufPtr

  • bufPtr pointer to Data Buffer

Returns:

  • pointer to bufPtr

Return: pointer to bufPtr

Precondition: None

Postcondition: None

5.8.4.43. function Spi_FifoWriteDefault

static __inline void Spi_FifoWriteDefault(
    uint32 baseAddr,
    uint32 wordSize,
    uint16 defaultTxData,
    uint32 transferLength
)

Brief: function to write Default data into Register

function to write default data into Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • wordSize : No.of bits to be shifted while writing into register

  • transferLength : no.of bytes to transfer

  • defaultTxData : Default data transmitted into register

Returns:

  • pointer to bufPtr

Return: pointer to bufPtr

Precondition: None

Postcondition: None

5.8.4.44. function Spi_FifoReadDiscard

static __inline void Spi_FifoReadDiscard(
    uint32 baseAddr,
    uint32 transferLength
)

Brief: function to read from Register and discard

function to read from Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • transferLength : no.of bytes to read

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.45. function Spi_ReadRxBufferNonFifo

static __inline void Spi_ReadRxBufferNonFifo(
    Spi_ChannelObjType * chObj,
    uint32 baseAddr
)

Brief: function to read from Register to Channel Object

function to read from Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • chObj pointer to Channel Object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.46. function Spi_WriteTxBufferNonFifo

static __inline void Spi_WriteTxBufferNonFifo(
    Spi_ChannelObjType * chObj,
    uint32 baseAddr
)

Brief: function to write into Register from Channel Object

function to write into Register

Parameters:

  • baseAddr : BaseAddress of HWUnit

  • chObj pointer to Channel Object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.47. function Spi_ClearPIPEINTFlag

static __inline void Spi_ClearPIPEINTFlag(
    uint32 intNum
)

Brief: function to clear PIPE interrupt

function to write into Register

Parameters:

  • intNum : Interrupt vector number

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.48. function Spi_RegMFReadRaw16

static inline uint16 Spi_RegMFReadRaw16(
    uint32 addr,
    uint16 mask,
    uint16 shift
)

Brief: This function reads a 16 bit register, masks specific set of bits and the left shifted value.

Parameters:

  • addr Address of the memory mapped hardware register.

  • mask Mask for the bit field.

  • shift Bit field shift from LSB.

Returns:

  • Value of the type uint16.

Return: Bit-field value (absolute value - shifted to LSB position).

Precondition: None

Postcondition: None

5.8.4.49. function Spi_RegMFWriteRaw16

static inline void Spi_RegMFWriteRaw16(
    uint32 addr,
    uint16 mask,
    uint16 shift,
    uint16 value
)

Brief: This function writes a 16 bit register masking specific set of bits and the left shifted value.

Parameters:

  • addr Address of the memory mapped hardware register.

  • mask Mask for the bit field.

  • shift Bit field shift from LSB.

  • value Value to write in the memory mapped hardware register.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.50. function Spi_RegReadRaw16

static inline uint16 Spi_RegReadRaw16(
    uint32 addr
)

Brief: This function reads a 16 bit register.

Parameters:

  • addr Address of the memory mapped hardware register.

Returns:

  • Value of the type uint16.

Return: Bit-field value (absolute value - shifted to LSB position).

Precondition: None

Postcondition: None

5.8.4.51. function Spi_RegWriteRaw16

static inline void Spi_RegWriteRaw16(
    uint32 addr,
    uint16 value
)

Brief: This function writes a 16 bit register.

Parameters:

  • addr Address of the memory mapped hardware register.

  • value Value to write in the 16-bit register.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.52. function Spi_RegBitSet16

static inline void Spi_RegBitSet16(
    uint32 addr,
    uint16 mask
)

Brief: This function sets one of the bit in 16 bit register.

Parameters:

  • addr Address of the memory mapped hardware register.

  • mask mask of the bit to set.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.53. function Spi_RegBitClear16

static inline void Spi_RegBitClear16(
    uint32 addr,
    uint16 mask
)

Brief: This function clears one of the bit in 16 bit register.

Parameters:

  • addr Address of the memory mapped hardware register.

  • mask mask of the bit to clear.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.56. function Spi_UtilsLinkNodePri

void Spi_UtilsLinkNodePri(
    Spi_UtilsLinkListObj * llobj,
    Spi_UtilsNode * node,
    const Spi_UtilsParams * params,
    uint8 currSeqId
)

Brief: Links a node to the linked list. The memory to the node object should be allocated by the caller. This is used for link list with priority.

Parameters:

  • llobj Link list object.

  • node Node object pointer used for linking.

  • data Data pointer to add to node.

  • params Pointer to node params containing info like data pointer, priority, seqId, seqInterruptible.

  • currSeqId Current sequence ID in progress for the HW unit.

  • llobj Link list object.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.57. function Spi_UtilsUnLinkNodePri

void Spi_UtilsUnLinkNodePri(
    Spi_UtilsLinkListObj * llobj,
    Spi_UtilsNode * node
)

Brief: Unlinks the node from the list. Used for the priority link lists.

Parameters:

  • llobj pointer to linklist Object

  • node pointer to a node in linklist

  • llobj pointer to linklist Object

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.58. function Spi_UtilsInitNodeObject

void Spi_UtilsInitNodeObject(
    Spi_UtilsNode * node
)

Brief: Initialize the node object with default value.

Parameters:

  • node pointer to a node in linklist

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.8.4.59. function Spi_UtilsGetHeadNode

Spi_UtilsNode * Spi_UtilsGetHeadNode(
    const Spi_UtilsLinkListObj * llobj
)

Brief: Returns the reference to the head node. This does not remove the node from the head.

Parameters:

  • llobj Link list object.

  • llobj Link list object

Returns:

  • pointer to a node in linklist

Return: Returns the reference to the head node

Precondition: None

Postcondition: None