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

Spi Driver More...

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

Functions

void Spi_Arch_Init (Spi_HwUnit *HwUnit, const Spi_ConfigType *Config)
 Spi Initialization
 
Std_ReturnType Spi_Arch_DeInit (Spi_HwUnit *HwUnit)
 Spi De-Initialization
 
Std_ReturnType Spi_Arch_WriteIB (Spi_HwUnit *HwUnit, Spi_ChannelType Channel, const Spi_DataBufferType *DataBufferPtr)
 Spi Write in the Internal Buffer
 
Std_ReturnType Spi_Arch_AsyncTransmit (Spi_HwUnit *HwUnit, Spi_SequenceType Sequence)
 Spi Asynchronous Transmit
 
Std_ReturnType Spi_Arch_ReadIB (Spi_HwUnit *HwUnit, Spi_ChannelType Channel, const Spi_DataBufferType *DataBufferPtr)
 Spi Read in the Internal Buffer
 
Std_ReturnType Spi_Arch_SetupEB (Spi_HwUnit *HwUnit, Spi_ChannelType Channel, const Spi_DataBufferType *SrcDataBufferPtr, Spi_DataBufferType *DesDataBufferPtr, Spi_NumberOfDataType Length)
 Spi set up external buffer
 
Spi_StatusType Spi_Arch_GetStatus (Spi_HwUnit *HwUnit)
 Spi get status
 
Spi_JobResultType Spi_Arch_GetJobResult (Spi_HwUnit *HwUnit, Spi_JobType Job)
 Spi get job result
 
Spi_SeqResultType Spi_Arch_GetSequenceResult (Spi_HwUnit *HwUnit, Spi_SequenceType Sequence)
 Spi get sequence result
 
void Spi_Arch_GetVersionInfo (Spi_HwUnit *HwUnit, Std_VersionInfoType *versioninfo)
 Spi get version information
 
Std_ReturnType Spi_Arch_SyncTransmit (Spi_HwUnit *HwUnit, Spi_SequenceType Sequence)
 Spi synchronous transmit
 
Spi_StatusType Spi_Arch_GetHWUnitStatus (Spi_HwUnit *HwUnit, Spi_HWUnitType HWUnit)
 Spi get Hardware microcontroller peripheral Unit Status
 
void Spi_Arch_Cancel (Spi_HwUnit *HwUnit, Spi_SequenceType Sequence)
 Spi cancel
 
Std_ReturnType Spi_Arch_SetAsyncMode (Spi_HwUnit *HwUnit, Spi_AsyncModeType Mode)
 Spi set asynchronous mode
 

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

Function Documentation

◆ Spi_Arch_AsyncTransmit()

Std_ReturnType Spi_Arch_AsyncTransmit ( Spi_HwUnit * HwUnit,
Spi_SequenceType Sequence )

Spi Asynchronous Transmit

Service to transmit data on the SPI bus.

Parameters
HwUnitPointer to the hardware unit configuration
SequenceSequence ID
Return values
E_OKTransmission command has been accepted E_NOT_OK: Transmission command has not been accepted

◆ Spi_Arch_Cancel()

void Spi_Arch_Cancel ( Spi_HwUnit * HwUnit,
Spi_SequenceType Sequence )

Spi cancel

Service cancels the specified on-going sequence transmission.

Parameters
HwUnitPointer to the hardware unit configuration
SequenceSequence ID

◆ Spi_Arch_DeInit()

Std_ReturnType Spi_Arch_DeInit ( Spi_HwUnit * HwUnit)

Spi De-Initialization

Service for SPI de-initialization.

Parameters
HwUnitPointer to the hardware unit configuration
Return values
E_OKde-initialisation command has been accepted E_NOT_OK: de-initialisation command has not been accepted

◆ Spi_Arch_GetHWUnitStatus()

Spi_StatusType Spi_Arch_GetHWUnitStatus ( Spi_HwUnit * HwUnit,
Spi_HWUnitType HWUnit )

Spi get Hardware microcontroller peripheral Unit Status

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

Parameters
HwUnitPointer to the hardware unit configuration
HWUnitSPI Hardware microcontroller peripheral (unit) ID.
Return values
Spi_StatusTypeSpi_StatusType

◆ Spi_Arch_GetJobResult()

Spi_JobResultType Spi_Arch_GetJobResult ( Spi_HwUnit * HwUnit,
Spi_JobType Job )

Spi get job result

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

Parameters
HwUnitPointer to the hardware unit configuration
JobJob ID. An invalid job ID will return an undefined result
Return values
Spi_JobResultTypeSpi_JobResultType

◆ Spi_Arch_GetSequenceResult()

Spi_SeqResultType Spi_Arch_GetSequenceResult ( Spi_HwUnit * HwUnit,
Spi_SequenceType Sequence )

Spi get sequence result

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

Parameters
HwUnitPointer to the hardware unit configuration
SequenceSequence ID. An invalid sequence ID will return an undefined result
Return values
Spi_SeqResultTypeSpi_SeqResultType

◆ Spi_Arch_GetStatus()

Spi_StatusType Spi_Arch_GetStatus ( Spi_HwUnit * HwUnit)

Spi get status

Service returns the SPI Handler/Driver software module status.

Parameters
HwUnitPointer to the hardware unit configuration
Return values
Spi_StatusTypeSpi_StatusType

◆ Spi_Arch_GetVersionInfo()

void Spi_Arch_GetVersionInfo ( Spi_HwUnit * HwUnit,
Std_VersionInfoType * versioninfo )

Spi get version information

This service returns the version information of this module.

Parameters
HwUnitPointer to the hardware unit configuration
versioninfoPointer to where to store the version information of this module

◆ Spi_Arch_Init()

void Spi_Arch_Init ( Spi_HwUnit * HwUnit,
const Spi_ConfigType * Config )

Spi Initialization

Service for SPI initialization.

Parameters
HwUnitPointer to the hardware unit configuration
ConfigPointer to configuration set

◆ Spi_Arch_ReadIB()

Std_ReturnType Spi_Arch_ReadIB ( Spi_HwUnit * HwUnit,
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
HwUnitPointer to the hardware unit configuration
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

◆ Spi_Arch_SetAsyncMode()

Std_ReturnType Spi_Arch_SetAsyncMode ( Spi_HwUnit * HwUnit,
Spi_AsyncModeType Mode )

Spi set asynchronous mode

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

Parameters
HwUnitPointer to the hardware unit configuration
ModeNew mode required.
Return values
E_OKSetting command has been done E_NOT_OK: setting command has not been accepted

◆ Spi_Arch_SetupEB()

Std_ReturnType Spi_Arch_SetupEB ( Spi_HwUnit * HwUnit,
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
HwUnitPointer to the hardware unit configuration
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

◆ Spi_Arch_SyncTransmit()

Std_ReturnType Spi_Arch_SyncTransmit ( Spi_HwUnit * HwUnit,
Spi_SequenceType Sequence )

Spi synchronous transmit

Service to transmit data on the SPI bus.

Parameters
HwUnitPointer to the hardware unit configuration
SequenceSequence ID
Return values
E_OKTransmission has been successful E_NOT_OK: Transmission failed

◆ Spi_Arch_WriteIB()

Std_ReturnType Spi_Arch_WriteIB ( Spi_HwUnit * HwUnit,
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
HwUnitPointer to the hardware unit configuration
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