STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
Loading...
Searching...
No Matches
Spi.c File Reference

Spi Driver More...

#include "Std_Types.h"
#include "Spi.h"
#include "Spi_Arch.h"

Macros

#define Det_ReportError(ModuleId, InstanceId, ApiId, ErrorId)
 

Functions

void Spi_Init (const Spi_ConfigType *ConfigPtr)
 Spi Initialization
 
Std_ReturnType Spi_DeInit (void)
 Spi De-Initialization
 
Std_ReturnType Spi_WriteIB (Spi_ChannelType Channel, const Spi_DataBufferType *DataBufferPtr)
 Spi Write in the Internal Buffer
 
Std_ReturnType Spi_AsyncTransmit (Spi_SequenceType Sequence)
 Spi Asynchronous Transmit
 
Std_ReturnType Spi_ReadIB (Spi_ChannelType Channel, const Spi_DataBufferType *DataBufferPtr)
 Spi Read in the Internal Buffer
 
Std_ReturnType Spi_SetupEB (Spi_ChannelType Channel, const Spi_DataBufferType *SrcDataBufferPtr, Spi_DataBufferType *DesDataBufferPtr, Spi_NumberOfDataType Length)
 Spi set up external buffer
 
Spi_StatusType Spi_GetStatus (void)
 Spi get status
 
Spi_JobResultType Spi_GetJobResult (Spi_JobType Job)
 Spi get job result
 
Spi_SeqResultType Spi_GetSequenceResult (Spi_SequenceType Sequence)
 Spi get sequence result
 
void Spi_GetVersionInfo (Std_VersionInfoType *versioninfo)
 Spi get version information
 
Std_ReturnType Spi_SyncTransmit (Spi_SequenceType Sequence)
 Spi synchronous transmit
 
Spi_StatusType Spi_GetHWUnitStatus (Spi_HWUnitType HWUnit)
 Spi get Hardware microcontroller peripheral Unit Status
 
void Spi_Cancel (Spi_SequenceType Sequence)
 Spi cancel
 
Std_ReturnType Spi_SetAsyncMode (Spi_AsyncModeType Mode)
 Spi set asynchronous mode
 

Variables

SPI_STATIC Spi_HwUnit HwUnit_Spi
 Variable for the initial value of the port configuration array.
 

Detailed Description

Spi Driver

Author
Manuel Alejandro Ascencio Ysordia

The SPI module provides services to initiate transmissions with a terminal buffer and call callback functions to notify events. Additionally, you have the option of having an external buffer to have more memory capacity. This module has the possibility of several JOBs, Channels and sequences.

A Job is composed of one or several Channels with the same Chip Select (CS) .

Macro Definition Documentation

◆ Det_ReportError

#define Det_ReportError ( ModuleId,
InstanceId,
ApiId,
ErrorId )
Value:
(void)0
Parameters
ModuleIdmodule id number
InstanceIdInstance Id
ApiIdPai id
ErrorIdError code

Function Documentation

◆ Spi_AsyncTransmit()

Std_ReturnType Spi_AsyncTransmit ( Spi_SequenceType Sequence)

Spi Asynchronous Transmit

Service to transmit data on the SPI bus.

Parameters
SequenceSequence ID
Return values
E_OKTransmission command has been accepted E_NOT_OK: Transmission command has not been accepted
Requirement
SWS_Spi_00178, SWS_Spi_00046, SWS_Spi_00032

◆ Spi_Cancel()

void Spi_Cancel ( Spi_SequenceType Sequence)

Spi cancel

Service cancels the specified on-going sequence transmission.

Parameters
SequenceSequence ID
Requirement
SWS_Spi_00187

◆ Spi_DeInit()

Std_ReturnType Spi_DeInit ( void )

Spi De-Initialization

Service for SPI de-initialization.

Return values
E_OKde-initialisation command has been accepted E_NOT_OK: de-initialisation command has not been accepted
Requirement
SWS_Spi_00176, SWS_Spi_00046, SWS_Spi_00022

◆ Spi_GetHWUnitStatus()

Spi_StatusType Spi_GetHWUnitStatus ( Spi_HWUnitType HWUnit)

Spi get Hardware microcontroller peripheral Unit Status

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

Parameters
HWUnitSPI Hardware microcontroller peripheral (unit) ID.
Return values
Spi_StatusTypeSpi_StatusType
Requirement
SWS_Spi_00186, SWS_Spi_00046, SWS_Spi_00143

◆ Spi_GetJobResult()

Spi_JobResultType Spi_GetJobResult ( Spi_JobType Job)

Spi get job result

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

Parameters
JobJob ID. An invalid job ID will return an undefined result
Return values
Spi_JobResultTypeSpi_JobResultType
Requirement
SWS_Spi_00182, SWS_Spi_00046, SWS_Spi_00032

◆ Spi_GetSequenceResult()

Spi_SeqResultType Spi_GetSequenceResult ( Spi_SequenceType Sequence)

Spi get sequence result

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

Parameters
SequenceSequence ID. An invalid sequence ID will return an undefined result
Return values
Spi_SeqResultTypeSpi_SeqResultType
Requirement
SWS_Spi_00183, SWS_Spi_00046, SWS_Spi_00032

◆ Spi_GetStatus()

Spi_StatusType Spi_GetStatus ( void )

Spi get status

Service returns the SPI Handler/Driver software module status.

Return values
Spi_StatusTypeSpi_StatusType
Requirement
SWS_Spi_00181

◆ Spi_GetVersionInfo()

void Spi_GetVersionInfo ( Std_VersionInfoType * versioninfo)

Spi get version information

This service returns the version information of this module.

Parameters
versioninfoPointer to where to store the version information of this module
Requirement
SWS_Spi_00184, SWS_Spi_00371

◆ Spi_Init()

void Spi_Init ( const Spi_ConfigType * ConfigPtr)

Spi Initialization

Service for SPI initialization.

Parameters
ConfigPtrPointer to configuration set
Requirement
SWS_Spi_00175, SWS_Spi_00233, SWS_Spi_00015

◆ Spi_ReadIB()

Std_ReturnType Spi_ReadIB ( Spi_ChannelType Channel,
const Spi_DataBufferType * DataBufferPtr )

Spi Read in the Internal Buffer

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

Parameters
ChannelChannel ID
DataBufferPtrPointer to destination data buffer in RAM
Return values
E_OKread command has been accepted E_NOT_OK: read command has not been accepted
Requirement
SWS_Spi_00179, SWS_Spi_00046, SWS_Spi_00031, SWS_Spi_00371

◆ Spi_SetAsyncMode()

Std_ReturnType Spi_SetAsyncMode ( Spi_AsyncModeType Mode)

Spi set asynchronous mode

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

Parameters
ModeNew mode required.
Return values
E_OKSetting command has been done E_NOT_OK: setting command has not been accepted
Requirement
SWS_Spi_00188

◆ Spi_SetupEB()

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

Spi set up external buffer

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

Parameters
ChannelChannel ID
SrcDataBufferPtrPointer to source data buffer
LengthLength (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
DesDataBufferPtrPointer to destination data buffer in RAM
Return values
E_OKSetup command has been accepted E_NOT_OK: Setup command has not been accepted
Requirement
SWS_Spi_00180, SWS_Spi_00046, SWS_Spi_00031, SWS_Spi_00371,SWS_Spi_00060

◆ Spi_SyncTransmit()

Std_ReturnType Spi_SyncTransmit ( Spi_SequenceType Sequence)

Spi synchronous transmit

Service to transmit data on the SPI bus.

Parameters
SequenceSequence ID
Return values
E_OKTransmission has been successful E_NOT_OK: Transmission failed
Requirement
SWS_Spi_00185, SWS_Spi_00046, SWS_Spi_00032

◆ Spi_WriteIB()

Std_ReturnType Spi_WriteIB ( Spi_ChannelType Channel,
const Spi_DataBufferType * DataBufferPtr )

Spi Write in the Internal Buffer

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

Parameters
ChannelChannel ID
DataBufferPtrPointer 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.
Return values
E_OKwrite command has been accepted E_NOT_OK: write command has not been accepted
Requirement
SWS_Spi_00177, SWS_Spi_00046, SWS_Spi_00031, SWS_Spi_00371

Variable Documentation

◆ HwUnit_Spi

SPI_STATIC Spi_HwUnit HwUnit_Spi
Initial value:
=
{
.Config = NULL_PTR,
.HwUnitState = SPI_UNINIT,
}
@ SPI_UNINIT
Definition Spi_Types.h:74
#define NULL_PTR
null pointer definition
Definition Std_Types.h:165

Variable for the initial value of the port configuration array.