5.2. DIO

5.2.1. Types

Base type

Type Name

Brief

typedef uint32

Dio_ChannelType

Numeric ID of a DIO channel.

typedef uint32

Dio_PortType

Numeric ID of a DIO port.

typedef uint8

Dio_LevelType

These are the possible levels a DIO channel can have (input or output).

typedef uint32

Dio_PortLevelType

If the uC owns ports of different port widths Dio_PortLevelType inherits the size of the largest port.

5.2.2. Structures

Name

Brief

Dio_ChannelGroupType

Type definition for identifying channel groups (meaning a set of pins in one port).

5.2.3. Defines

Name

Brief

DIO_SW_MAJOR_VERSION

Driver Implementation Major Version.

DIO_SW_MINOR_VERSION

Driver Implementation Minor Version.

DIO_SW_PATCH_VERSION

Driver Implementation Patch Version.

DIO_AR_RELEASE_MAJOR_VERSION

AUTOSAR Major version specification implemented by DIO Driver.

DIO_AR_RELEASE_MINOR_VERSION

AUTOSAR Minor version specification implemented by DIO Driver.

DIO_AR_RELEASE_REVISION_VERSION

AUTOSAR Patch version specification implemented by DIO Driver.

DIO_VENDOR_ID

Texas Instruments Vendor ID.

DIO_MODULE_ID

DIO Driver Module ID.

DIO_INSTANCE_ID

DIO Driver Instance ID.

DIO_E_PARAM_INVALID_CHANNEL_ID

API service called with invalid channel ID.

DIO_E_PARAM_INVALID_PORT_ID

API service called with invalid port ID.

DIO_E_PARAM_INVALID_GROUP

API service called with invalid channel group ID.

DIO_E_PARAM_POINTER

Dio_GetVersionInfo() called with NULL_PTR as parameter.

DIO_SID_READ_CHANNEL

Dio_ReadChannel()

DIO_SID_WRITE_CHANNEL

Dio_WriteChannel()

DIO_SID_READ_PORT

Dio_ReadPort()

DIO_SID_WRITE_PORT

Dio_WritePort()

DIO_SID_READ_CHANNEL_GROUP

Dio_ReadChannelGroup()

DIO_SID_WRITE_CHANNEL_GROUP

Dio_WriteChannelGroup()

DIO_SID_FLIP_CHANNEL

Dio_FlipChannel()

DIO_SID_GET_VERSION_INFO

Dio_GetVersionInfo()

GPIO_DATA_INDEX

Index of GPIO_DATA register for a port registers set.

GPIO_TOGGLE_INDEX

Index of GPIO_TOGGLE register for a port registers set.

GPIO_CLEAR_INDEX

Index of GPIO_CLEAR register for a port registers set.

GPIO_SET_INDEX

Index of GPIO_SET register for a port registers set.

GPIO_DATA_REGS_STEP

Port Data register step size.

DIO_PORT_WIDTH

Width of GPIO register in this platform.

GPIO_PORT_A

GPIO PORT A identifier.

GPIO_PORT_B

GPIO PORT B identifier.

GPIO_PORT_C

GPIO PORT C identifier.

GPIO_PORT_D

GPIO PORT D identifier.

GPIO_PORT_E

GPIO PORT E identifier.

GPIO_PORT_F

GPIO PORT F identifier.

GPIO_PORT_G

GPIO PORT G identifier.

GPIO_PORT_H

GPIO PORT H identifier.

5.2.4. Functions

Return type

Function Name

Brief

void

Dio_GetVersionInfo(Std_VersionInfoType * Versioninfo)

Service to get the version information of the module.

Dio_LevelType

Dio_ReadChannel(Dio_ChannelType ChannelId)

Returns the value of the specified DIO channel.

void

Dio_WriteChannel(Dio_ChannelType ChannelId, Dio_LevelType Level)

Service to set a level of a channel.

Dio_PortLevelType

Dio_ReadPort(Dio_PortType PortId)

Returns the level of all channels of that port.

void

Dio_WritePort(Dio_PortType PortId, Dio_PortLevelType Level)

Service to set a value of the port.

Dio_PortLevelType

Dio_ReadChannelGroup(const Dio_ChannelGroupType * ChannelGroupIdPtr)

This Service reads a subset of the adjoining bits of a port.

void

Dio_WriteChannelGroup(const Dio_ChannelGroupType * ChannelGroupIdPtr, Dio_PortLevelType Level)

Service to set a subset of the adjoining bits of a port to a specified level.

Dio_LevelType

Dio_FlipChannel(Dio_ChannelType ChannelId)

Service to flip the value of a DIO channel.

Std_ReturnType

Dio_IsChannelValid(Dio_ChannelType ChannelId)

Checks if the channel ID is valid.

Std_ReturnType

Dio_IsChannelGroupValid(const Dio_ChannelGroupType * ChannelGroupIdPtr)

Checks if the channel group is valid.

Dio_LevelType

Dio_PinReadPriv(Dio_ChannelType channelId)

Reads the value present on the specified pin.

void

Dio_PinWritePriv(Dio_ChannelType channelId, Dio_LevelType channelVal)

Writes a value to the specified pin.

void

Dio_WritePortDataPriv(Dio_PortType portId, Dio_PortLevelType portValue)

Writes a value to the specified port.

void

Dio_WriteChannelGroupPriv(const Dio_ChannelGroupType * ChannelGroupIdPtr, Dio_PortLevelType PortValue)

Writes a subset of the adjoining bits of a port to a specified level.

void

Dio_ReadPortDataPriv(Dio_PortType PortId, Dio_PortLevelType * PortValue)

Reads the data on the specified port.

void

Dio_PinFlipVal(Dio_ChannelType ChannelId)

Toggles the present value of the specified channel.

5.2.4.1. function Dio_GetVersionInfo

void Dio_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 DIO_VERSION_INFO_API is enabled.

Parameters:

  • Versioninfo

  • Versioninfo structure that contains the version information parameters.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.2. function Dio_ReadChannel

Dio_LevelType Dio_ReadChannel(
    Dio_ChannelType ChannelId
)

Brief: Returns the value of the specified DIO channel.

This service is to read from a specified DIO channel. If the channel specified is not valid, a development error is reported to Det. The value for the DIO channel is read and returned.

Parameters:

  • ChannelId specifies the ID of the general-purpose digital input/output pin.

Returns:

  • STD_HIGH logic level 1

  • STD_LOW logic level 0

Return: Returns the logic level(value) on a specified DIO pin of type Dio_LevelType.

Precondition: None

Postcondition: None

5.2.4.3. function Dio_WriteChannel

void Dio_WriteChannel(
    Dio_ChannelType ChannelId,
    Dio_LevelType Level
)

Brief: Service to set a level of a channel.

This service is to set a specified level of a particular DIO channel. If the channel specified is not valid, a development error is reported to Det. The value is written to the specified DIO channel.

Parameters:

  • ChannelId specifies the ID of the general-purpose digital input/output pin.

  • Level specifies the value to be written to the channel. Value can be STD_HIGH or STD_LOW.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.4. function Dio_ReadPort

Dio_PortLevelType Dio_ReadPort(
    Dio_PortType PortId
)

Brief: Returns the level of all channels of that port.

This service reads the value of a DIO port. If the port is not enabled, a development error is reported to Det. The value of the port of which the ID is specified is read and returned.

Parameters:

  • PortId specifies the ID of the grouped Input/Output channels.

Returns:

  • Value of type Dio_PortLevelType

Return: level of all the channels of the specified port

Precondition: None

Postcondition: None

5.2.4.5. function Dio_WritePort

void Dio_WritePort(
    Dio_PortType PortId,
    Dio_PortLevelType Level
)

Brief: Service to set a value of the port.

This service sets a specified value of a DIO port. If the port is not enabled, a development error is reported to Det. The value is written to the specified DIO port.

Parameters:

  • PortId specifies the ID of the grouped Input/Output channels.

  • Level Value consisting of level of all the channels of the specified port.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.6. function Dio_ReadChannelGroup

Dio_PortLevelType Dio_ReadChannelGroup(
    const Dio_ChannelGroupType * ChannelGroupIdPtr
)

Brief: This Service reads a subset of the adjoining bits of a port.

This service reads the value of the subset of the bits of a port. If this parameter references NULL_PTR, a development error is reported to Det. The value of the level of the channel group is read and returned.

Parameters:

  • ChannelGroupIdPtr for referencing channel group structures.

Returns:

  • value of type Dio_PortLevelType

Return: levels of the specified channel group.

Precondition: None

Postcondition: None

5.2.4.7. function Dio_WriteChannelGroup

void Dio_WriteChannelGroup(
    const Dio_ChannelGroupType * ChannelGroupIdPtr,
    Dio_PortLevelType Level
)

Brief: Service to set a subset of the adjoining bits of a port to a specified level.

This service writes the specified value to a subset of the bits of a port. If this parameter references NULL_PTR, a development error is reported to Det. The information of the channel group is in the referenced channel group structure.The data is then written to the port.

Parameters:

  • ChannelGroupIdPtr for referencing channel group structures.

  • Level Value consisting of levels of the specified channel group.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.8. function Dio_FlipChannel

Dio_LevelType Dio_FlipChannel(
    Dio_ChannelType ChannelId
)

Brief: Service to flip the value of a DIO channel.

This service is to change the value of the corresponding DIO channel.If the channel specified is not valid, a development error is reported to Det. The value of the specified channel is flipped.This service is only available if the pre-compile configuration parameter DIO_FLIP_CHANNEL_API is enabled.

Parameters:

  • ChannelId specifies the ID of the general-purpose digital input/output pin.

Returns:

  • STD_HIGH logic level 1 STD_LOW: logic level 0

Return: Value consisting of level of the specified channel after flip of type Dio_LevelType.

Precondition: None

Postcondition: None

5.2.4.9. function Dio_IsChannelValid

Std_ReturnType Dio_IsChannelValid(
    Dio_ChannelType ChannelId
)

Brief: Checks if the channel ID is valid.

Checks if the channel_id passed to the API is valid or not by calculating the Port of the Channel and checking if the port is enabled.

Parameters:

  • ChannelId specifies the ID of the general-purpose digital

Returns:

  • value E_OK: ChannelId is valid. E_NOT_OK: ChannelId is Invalid.

Return: This function returns Std_ReturnType

Precondition: None

Postcondition: None

5.2.4.10. function Dio_IsChannelGroupValid

Std_ReturnType Dio_IsChannelGroupValid(
    const Dio_ChannelGroupType * ChannelGroupIdPtr
)

Brief: Checks if the channel group is valid.

Checks if the channelgroup_id_ptr passed to the API is valid or not by comparing it with the structure pointers of the current configuration.

Parameters:

  • ChannelGroupIdPtr for referencing channel group structures.

Returns:

  • E_OK ChannelGroupIdPtr is valid. E_NOT_OK: ChannelGroupIdPtr is Invalid.

Return: This function returns Std_ReturnType

Precondition: None

Postcondition: None

5.2.4.11. function Dio_PinReadPriv

Dio_LevelType Dio_PinReadPriv(
    Dio_ChannelType channelId
)

Brief: Reads the value present on the specified pin.

The value at the specified channel is read, as specified by channelId and returned

Parameters:

  • channelId is the identifying number of the pin.

Returns:

  • STD_HIGH logic level 1 STD_LOW: logic level 0

Return: Returns the logic level(value) on a specified DIO pin of type Dio_LevelType.

Precondition: None

Postcondition: None

5.2.4.12. function Dio_PinWritePriv

void Dio_PinWritePriv(
    Dio_ChannelType channelId,
    Dio_LevelType channelVal
)

Brief: Writes a value to the specified pin.

Writes the corresponding bit values to the pin specified by channelId. Writing to a channel configured as an input pin has no effect.

Parameters:

  • channelId is the identifying number of the pin.

  • channelVal is the value to write to the channel.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.13. function Dio_WritePortDataPriv

void Dio_WritePortDataPriv(
    Dio_PortType portId,
    Dio_PortLevelType portValue
)

Brief: Writes a value to the specified port.

This function writes the value port_value to the port specified by the portId parameter.

Parameters:

  • portId is the DIO port being accessed.

  • portValue is the value to write to the port.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.14. function Dio_WriteChannelGroupPriv

void Dio_WriteChannelGroupPriv(
    const Dio_ChannelGroupType * ChannelGroupIdPtr,
    Dio_PortLevelType PortValue
)

Brief: Writes a subset of the adjoining bits of a port to a specified level.

This function compute the port value based on the received level, group mask and offset. Then write the computed port value to the specified port based on the portId received in channelGroupPtr.

Parameters:

  • ChannelGroupIdPtr for referencing channel group structures.

  • PortValue is the value to write to the port.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.15. function Dio_ReadPortDataPriv

void Dio_ReadPortDataPriv(
    Dio_PortType PortId,
    Dio_PortLevelType * PortValue
)

Brief: Reads the data on the specified port.

The value at the specified port is read, as specified by PortId and writes into the PortValue parameter.

Parameters:

  • PortId is the DIO port being accessed.

  • PortValue stores the value of the corresponding port being referred.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None

5.2.4.16. function Dio_PinFlipVal

void Dio_PinFlipVal(
    Dio_ChannelType ChannelId
)

Brief: Toggles the present value of the specified channel.

Toggles the corresponding bit values to the pin specified by ChannelId.

Parameters:

  • ChannelId is the identifying number of the pin.

Returns:

  • None

Return: None

Precondition: None

Postcondition: None