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

Dio driver configuration. More...

#include "Std_Types.h"
#include "Dio.h"
#include "Dio_Arch.h"

Macros

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

Functions

Dio_LevelType Dio_ReadChannel (Dio_ChannelType ChannelId)
 Read Channel.
 
void Dio_WriteChannel (Dio_ChannelType ChannelId, Dio_LevelType Level)
 Write Channel.
 
Dio_LevelType Dio_FlipChannel (Dio_ChannelType ChannelId)
 Flip Channel.
 
Dio_PortLevelType Dio_ReadPort (Dio_PortType PortId)
 Read Port.
 
void Dio_WritePort (Dio_PortType PortId, Dio_PortLevelType Level)
 Write Port.
 
Dio_PortLevelType Dio_ReadChannelGroup (const Dio_ChannelGroupType *ChannelGroupIdPtr)
 Read Channel Group.
 
void Dio_WriteChannelGroup (const Dio_ChannelGroupType *ChannelGroupIdPtr, Dio_PortLevelType Level)
 Write Channel Group.
 
void Dio_GetVersionInfo (Std_VersionInfoType *versioninfo)
 Get Version Info.
 
void Dio_MaskedWritePort (Dio_PortType PortId, Dio_PortLevelType Level, Dio_PortLevelType Mask)
 Masked Write Port.
 

Detailed Description

Dio driver configuration.

This is the file for the Dio driver, it provides functions for accessing the hardware pins of the microcontroller. It also allows the grouping of those pins.

The DIO driver provides services for reading and writing to/from: DIO Channels (Pins) DIO Ports DIO Channel Groups

This module operates on pins and ports configured by the PORT driver for this purpose. For this reason, there is no configuration and initialization of this port structure in the DIO driver.

The DIO driver provides the following functions: The Dio controller will define functions to modify the output channel levels individually, for a port or for a channel group. The Dio driver will define functions to read the level of the input and output channels individually, for a port or for a group of channels.

Note
Dio module will use the definitions that have been created during the configuration process in the Dio_Cfg.h file.

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
Requirement
SWS_Dio_00194

Function Documentation

◆ Dio_FlipChannel()

Dio_LevelType Dio_FlipChannel ( Dio_ChannelType ChannelId)

Flip Channel.

This function is used when the specified channel is configured as output channel, the Dio_FlipChannel function will read the channel level and invert it, then write the inverted level to the channel. The return value will be the inverted level of the specified channel.

Parameters
ChannelIdID of DIO channel.
Return values
Returnsthe level of a channel after flipping the level.
Requirement
SWS_Dio_00190, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00083, SWS_Dio_00084, SWS_Dio_00074

◆ Dio_GetVersionInfo()

void Dio_GetVersionInfo ( Std_VersionInfoType * versioninfo)

Get Version Info.

This function is used to define DIO driver version information.

Parameters
versioninfoPointer to where to store the version information of this module.
Requirement
SWS_Dio_00139, SWS_Dio_00189

◆ Dio_MaskedWritePort()

void Dio_MaskedWritePort ( Dio_PortType PortId,
Dio_PortLevelType Level,
Dio_PortLevelType Mask )

Masked Write Port.

This function will set the specified value for the channels on the specified port if the corresponding bit in Mask is '1'.

Parameters
PortIdID of DIO Port.
LevelValue to be written.
MaskChannels to be masked in the port.
Requirement
SWS_Dio_00300, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00075

◆ Dio_ReadChannel()

Dio_LevelType Dio_ReadChannel ( Dio_ChannelType ChannelId)

Read Channel.

The function will return the value of the specified DIO channel, taking the MSB bit as the port and the LSB bit as the pin.

Parameters
ChannelIdID of DIO channel.
Return values
Returnsthe value of the specified DIO channel.
Requirement
SWS_Dio_00133, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00011, SWS_Dio_00012,SWS_Dio_00074

◆ Dio_ReadChannelGroup()

Dio_PortLevelType Dio_ReadChannelGroup ( const Dio_ChannelGroupType * ChannelGroupIdPtr)

Read Channel Group.

This function will read a subset of the contiguous bits of a port (channel group). It will also perform masking of the channel group and the function will perform the offset so that the values read by the function are aligned with the LSB.

Parameters
ChannelGroupIdPtrPointer to ChannelGroup.
Return values
Returnsthe level of a subset of the adjacent bits of a port (channel group).
Requirement
SWS_Dio_00137, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00014, SWS_Dio_00012, SWS_Dio_00114

◆ Dio_ReadPort()

Dio_PortLevelType Dio_ReadPort ( Dio_PortType PortId)

Read Port.

The function will return the level of all channels on that port, taking the MSB bit as the port and the LSB bit as the pin.

Parameters
PortIdID of DIO Port.
Return values
Returnsthe level of all channels on that port.
Requirement
SWS_Dio_00135, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00013, SWS_Dio_00012, SWS_Dio_00075

◆ Dio_WriteChannel()

void Dio_WriteChannel ( Dio_ChannelType ChannelId,
Dio_LevelType Level )

Write Channel.

This function will write the specified Level to the output if the specified channel is configured as output channel, in this case the function will set the specified Level for the specified channel. Taking the MSB bit as the port and the LSB bit as the pin.

Parameters
ChannelIdID of DIO channel.
LevelValue to be written.
Requirement
SWS_Dio_00134, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00006, SWS_Dio_00119, SWS_Dio_00074

◆ Dio_WriteChannelGroup()

void Dio_WriteChannelGroup ( const Dio_ChannelGroupType * ChannelGroupIdPtr,
Dio_PortLevelType Level )

Write Channel Group.

This function will set a subset of the adjacent bits of a port (channel group) to a specified level. The function will not change the remaining channels of the port or the channels configured as input. Also this function will perform the masking of the channel group and in addition the function will perform the shift so that the values written by the function are aligned with the LSB.

Parameters
ChannelGroupIdPtrPointer to ChannelGroup.
LevelValue to be written.
Requirement
SWS_Dio_00138, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00008, SWS_Dio_00114

◆ Dio_WritePort()

void Dio_WritePort ( Dio_PortType PortId,
Dio_PortLevelType Level )

Write Port.

This function is used to set the value specified by the Level parameter for the port specified in the parameters.

Parameters
PortIdID of DIO Port.
LevelValue to be written.
Requirement
SWS_Dio_00136, SWS_Dio_00051, SWS_Dio_00089, SWS_Dio_00004, SWS_Dio_00075