AUTOSAR_SWS_DIODriver
Specification of DIO Driver
Introduction and functional overview
This specification specifies the functionality, API and the configuration of the AUTOSAR Basic Software module DIO Driver.
This specification is applicable to drivers only for on chip DIO pins and ports.
The DIO Driver provides services for reading and writing to / from
- DIO Channels (Pins)
- DIO Ports
- DIO Channel Groups
The behaviour of those services is synchronous.
This module works on pins and ports which are 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 diagram below identifies the DIO Driver functions, and the structure of the PORT Driver and DIO Driver within the MCAL software layer.
Acronyms and abbreviations that have a local scope are not contained in the AUTOSAR glossary. These must appear in a local glossary.
Deliverables of AUTOSAR
[1] Layered Software Architecture
- AUTOSAR_EXP_LayeredSoftwareArchitecture
[2] List of Basic Software Modules
- AUTOSAR_TR_BSWModuleList
[3] General Requirements on SPAL
- AUTOSAR_SRS_SPALGeneral
[4] General Requirements on Basic Software Modules
- AUTOSAR_SRS_BSWGeneral
[5] Specification of ECU Configuration
- AUTOSAR_TPS_ECUConfiguration
[6] Specification of PORT Driver
- AUTOSAR_SWS_PortDriver
[7] Specification of Standard Types
- AUTOSAR_SWS_StandardTypes
[8] AUTOSAR Basic Software Module Description Template
- AUTOSAR_TPS_BSWModuleDescriptionTemplate
[9] General Specification of Basic Software Modules
- AUTOSAR_SWS_BSWGeneral
Related specification
AUTOSAR provides a General Specification on Basic Software modules [7] (SWS BSW General), which is also valid for DIO Driver.
Thus, the specification SWS BSW General shall be considered as additional and required specification for DIO Driver.
Dependencies to other modules
Port Driver Module
Many ports and port pins are assigned by the PORT Driver Module to various functionalities as for example:
- General purpose I/O
- ADC
- SPI
- PWM
[SWS_Dio_00061]
[ ]
- The Dio module shall not provide APIs for overall configuration and initialization of the port structure which is used in the Dio module. These actions are done by the PORT Driver Module.
[SWS_Dio_00063]
[ ]
- The Dio module shall adapt its configuration and usage to the microcontroller and ECU.
[SWS_Dio_00102]
[ ]
- The Dio module's user shall only use the Dio functions after the Port Driver has been initialized. Otherwise the Dio module will exhibit undefined behavior.
Default Error Tracer
[SWS_Dio_00194]
[ ]
- Dio.c shall include Det.h if detection of development error (DET) is enabled.
Requirements traceability
This chapter refers to input requirements specified in the SRS documents (Software Requirements Specifications) that are applicable for this software module.
The table below lists links to specification items of the DIO driver SWS document, that satisfy the input requirements. Only functional requirements are referenced.
General Behaviour
Background & Rationale
The DIO Driver abstracts the access to the microcontroller's hardware pins. Furthermore, it allows the grouping of those pins.
Requirements
The Dio SWS shall define functions allowing
- Port
- Channel
- Channel-group
based read and write access to the internal general purpose I/O ports.
[SWS_Dio_00051]
[SRS_Dio_12003]
[SRS_Dio_12004]
[SRS_Dio_12005]
[SRS_Dio_12006]
[SRS_Dio_12007]
[SRS_Dio_12008]
- The Dio module shall not buffer data when providing read and write services. The Dio SWS shall define synchronous read/write services.
[SWS_Dio_00005]
[SRS_Dio_12424]
- The Dio module's read and write services shall ensure for all services, that the data is consistent (Interruptible read-modify-write sequences are not allowed).
[SWS_Dio_00089]
[SRS_Dio_12003]
[SRS_Dio_12004]
[SRS_Dio_12005]
[SRS_Dio_12006]
[SRS_Dio_12007]
[SRS_Dio_12008]
- Values used by the DIO Driver for the software level of Channels are either STD_HIGH or STD_LOW.
[SWS_Dio_00128]
[SRS_Dio_12005]
[SRS_Dio_12008]
- A general-purpose digital IO pin represents a DIO channel.
[SWS_Dio_00127]
[SRS_Dio_12005]
[SRS_Dio_12008]
- The Port module shall configure a DIO channel as input or output [SWS_Dio_00001 and SWS_Dio_00002].
[SWS_Dio_00053]
[ ]
- In the DIO Driver, it shall be possible to group several DIO channels by hardware (typically controlled by one hardware register) to represent a DIO port.
Note:
The single DIO channel levels inside a DIO port represent a bit in the DIO port value, depending on their position inside the port.
[SWS_Dio_00056]
[SRS_Dio_12004]
[SRS_Dio_12007]
- A channel group is a formal logical combination of several adjoining DIO channels within a DIO port.
- The Dio SWS shall define functions to modify the levels of output channels individually, for a port or for a channel group.
- The Dio SWS shall define functions to read the level of input and output (see SWS_Dio_00083) channels individually, for a port or for a channel group.
[SWS_Dio_00060]
[ ]
- All read and write functions of the Dio module shall be re-entrant. Reason: The DIO Driver may be accessed by different upper layer handlers or drivers. These upper layer modules may access the driver concurrently.
[SWS_Dio_00026]
[SRS_Dio_12355]
- The configuration process for Dio module shall provide symbolic names for each configured DIO channel, port and group.
Initialization
Background & Rationale
Initialization of the hardware is done by the PORT Driver.
Requirements
[SWS_Dio_00001]
[SRS_BSW_00344]
[SRS_SPAL_12064]
[SRS_SPAL_12461]
[SRS_SPAL_12462]
[SRS_SPAL_12463]
- The Dio module shall not provide an interface for initialization of the hardware. The Port Driver performs this.
Runtime reconfiguration
Background & Rationale
Runtime reconfiguration is provided by the PORT Driver.
Requirements
[SWS_Dio_00002]
[SRS_BSW_00344]
[SRS_SPAL_12064]
[SRS_SPAL_12461]
[SRS_SPAL_12462]
[SRS_SPAL_12463]
- The PORT driver shall provide the reconfiguration of the port pin direction during runtime.
DIO write service
Background & Rationale
The DIO Driver provides services to transfer data to the microcontroller's pins.
Requirements
[SWS_Dio_00064]
[SRS_Dio_12352]
- The Dio module's write functions shall work on input and output channels.
[SWS_Dio_00070]
[SRS_Dio_12352]
- If a Dio write function is used on an input channel, it shall have no effect on the physical output level.
[SWS_Dio_00109]
[ ]
- If supported by hardware, the Dio module shall set/clear the output data latch of an input channel so that the required level is output from the pin when the port driver configures the pin as a DIO output pin.
[SWS_Dio_00119]
[SRS_SPAL_12448]
- If development errors are enabled and an error occurred, the Dio module's write functions shall NOT process the write command.
DIO channel write service
[SWS_Dio_00006]
[SRS_Dio_12005]
- The Dio_WriteChannel function shall set the level of a single DIO channel to STD_HIGH or STD_LOW.
DIO port write service
[SWS_Dio_00007]
[SRS_Dio_12003]
- The Dio_WritePort function shall simultaneously set the levels of all output channels. A bit value '0' sets the corresponding channel to physical STD_LOW, a bit value '1' sets the corresponding channel to physical STD_HIGH.
[SWS_Dio_00004]
[SRS_Dio_12003]
- The Dio_WritePort function shall ensure that the functionality of the input channels of that port is not affected.
DIO channel group write service
[SWS_Dio_00008]
[SRS_Dio_12004]
- The Dio_WriteChannelGroup function shall simultaneously set an adjoining subset of DIO channels (channel group). A bit value '0' sets the corresponding channel to physical STD_LOW, a bit value '1' sets the corresponding channel to physical STD_HIGH.
DIO masked port write service
[SWS_Dio_00200]
[SRS_Dio_12003]
- The Dio_MaskedWritePort function shall simultaneously set the levels of the selected output channels. Mask argument specifies which bits are selected: a bit value '0' means the corresponding channel is not selected, a bit value '1' means the corresponding channel is selected. Level argument specifies the physical levels: a bit value '0' sets the corresponding channel to physical STD_LOW, a bit value '1' sets the corresponding channel to physical STD_HIGH.
[SWS_Dio_00201]
[SRS_Dio_12003]
- The Dio_MaskedWritePort function shall ensure that the functionality of the input channels of that port is not affected.
DIO Read Service
Background & Rationale
The DIO Driver provides services to transfer data from the microcontroller's pins.
Requirements
[SWS_Dio_00012]
[SRS_Dio_12352]
- The Dio module's read functions shall work on input and output channels.
DIO channel read Service
[SWS_Dio_00011]
[SRS_Dio_12008]
- The Dio_ReadChannel function shall read the level of a single DIO channel.
DIO port read service
[SWS_Dio_00013]
[SRS_Dio_12006]
- The Dio_ReadPort function shall read the levels of all channels of one port. A bit value '0' indicates that the corresponding channel is physical STD_LOW, a bit value '1' indicates that the corresponding channel is physical STD_HIGH.
DIO channel group read service
[SWS_Dio_00014]
[SRS_Dio_12007]
- The Dio_ReadChannelGroup function shall read the levels of a DIO channel group. A bit value '0' indicates that the corresponding channel is physical STD_LOW, a bit value '1' indicates that the corresponding channel is physical STD_HIGH.
DIO readback of output pins
[SWS_Dio_00083]
[SRS_Dio_12352]
- If the microcontroller supports the direct read-back of a pin value, the Dio module's read functions shall provide the real pin level, when they are used on a channel which is configured as an output channel.
[SWS_Dio_00084]
[SRS_Dio_12352]
- If the microcontroller does not support the direct read-back of a pin value, the Dio module's read functions shall provide the value of the output register, when they are used on a channel which is configured as an output channel.
Error classification
Section 7.2 "Error Handling" of the document "General Specification of Basic Software Modules" describes the error handling of the Basic Software in detail. Above all, it constitutes a classification scheme consisting of five error types which may occur in BSW modules. Based on this foundation, the following section specifies particular errors arranged in the respective subsections below.
Development Errors
[SWS_Dio_91001]
[ ]
API specification
Imported types
In this chapter all types included from the following modules are listed:
[SWS_Dio_00131]
[ ]
Type definitions
[SWS_Dio_00103]
[ ]
- The port width within the types defined for the DIO Driver shall be the size of the largest port on the MCU which may be accessed by the DIO Driver.
Dio_ChannelType
[SWS_Dio_00182]
[ ]
[SWS_Dio_00015]
[ ]
- Parameters of type Dio_ChannelType contain the numeric ID of a DIO channel.
[SWS_Dio_00180]
[ ]
- The mapping of the ID is implementation specific but not configurable.
[SWS_Dio_00017]
[SRS_SPAL_12263]
[SRS_Dio_12355]
- For parameter values of type Dio_ChannelType, the Dio's user shall use the symbolic names provided by the configuration description. Furthermore, [SWS_Dio_00103] applies to the type Dio_ChannelType.
Dio_PortType
[SWS_Dio_00183]
[ ]
[SWS_Dio_00018]
[ ]
- Parameters of type Dio_PortType contain the numeric ID of a DIO port.
[SWS_Dio_00181]
[ ]
- The mapping of ID is implementation specific but not configurable.
[SWS_Dio_00020]
[SRS_SPAL_12263]
[SRS_Dio_12355]
- For parameter values of type Dio_PortType, the user shall use the symbolic names provided by the configuration description. Furthermore, [SWS_Dio_00103] applies to the type Dio_PortType.
Dio_ChannelGroupType
[SWS_Dio_00184]
[ ]
[SWS_Dio_00021]
[ ]
- Dio_ChannelGroupType is the type for the definition of a channel group, which consists of several adjoining channels within a port.
[SWS_Dio_00022]
[SRS_SPAL_12263]
[SRS_Dio_12355]
- For parameter values of type Dio_ChannelGroupType, the user shall use the symbolic names provided by the configuration description. Furthermore, SWS_Dio_00056 applies to the type Dio_ChannelGroupType.
Dio_LevelType
[SWS_Dio_00185]
[ ]
[SWS_Dio_00023]
[ ]
- Dio_LevelType is the type for the possible levels that a DIO channel can have (input or output).
Dio_PortLevelType
[SWS_Dio_00186]
[ ]
[SWS_Dio_00024]
[ ]
- Dio_PortLevelType is the type for the value of a DIO port. Furthermore, SWS_Dio_00103 applies to the type Dio_PortLevelType.
Function definitions
This is a list of functions provided for upper layer modules.
Dio_ReadChannel
[SWS_Dio_00133]
[ ]
[SWS_Dio_00027]
[SRS_Dio_12008]
- The Dio_ReadChannel function shall return the value of the specified DIO channel. Regarding the return value of the Dio_ReadChannel function, the requirements [SWS_Dio_00083] and [SWS_Dio_00084] are applicable. Furthermore, the requirements [SWS_Dio_00005] and [SWS_Dio_00026] are applicable to the Dio_ReadChannel function.
[SWS_Dio_00074]
[SRS_BSW_00323]
[SRS_SPAL_12448]
- If development error detection is enabled, the services Dio_ReadChannel, Dio_WriteChannel and Dio_FlipChannel shall check the "ChannelId" parameter to be valid within the current configuration. If the "ChannelId" parameter is invalid, the functions shall report the error code DIO_E_PARAM_INVALID_CHANNEL_ID to the DET.
Dio_WriteChannel
[SWS_Dio_00134]
[ ]
[SWS_Dio_00028]
[SRS_Dio_12005]
- If the specified channel is configured as an output channel, the Dio_WriteChannel function shall set the specified Level for the specified channel.
[SWS_Dio_00029]
[SRS_Dio_12005]
- If the specified channel is configured as an input channel, the Dio_WriteChannel function shall have no influence on the physical output.
[SWS_Dio_00079]
[SRS_Dio_12005]
- If the specified channel is configured as an input channel, the Dio_WriteChannel function shall have no influence on the result of the next ReadService. Furthermore, the requirements [SWS_Dio_00005], [SWS_Dio_00119] and [SWS_Dio_00026] are applicable to the Dio_WriteChannel function.
Dio_ReadPort
[SWS_Dio_00135]
[ ]
[SWS_Dio_00031]
[SRS_Dio_12006]
- The Dio_ReadPort function shall return the level of all channels of that port.
[SWS_Dio_00104]
[ ]
- When reading a port which is smaller than the Dio_PortLevelType using the Dio_ReadPort function (see [SWS_Dio_00103]), the function shall set the bits corresponding to undefined port pins to 0. Furthermore, the requirements [SWS_Dio_00005] and [SWS_Dio_00026] are applicable to the Dio_ReadPort function.
[SWS_Dio_00075]
[SRS_BSW_00323]
[SRS_SPAL_12448]
- If development error detection is enabled, the functions Dio_ReadPort, Dio_WritePort and Dio_MaskedWritePort shall check the "PortId" parameter to be valid within the current configuration. If the "PortId" parameter is invalid, the functions shall report the error code DIO_E_PARAM_INVALID_PORT_ID to the DET.
Dio_WritePort
[SWS_Dio_00136]
[ ]
[SWS_Dio_00034]
[SRS_Dio_12003]
- The Dio_WritePort function shall set the specified value for the specified port.
[SWS_Dio_00035]
[SRS_Dio_12003]
- When the Dio_WritePort function is called, DIO Channels that are configured as input shall remain unchanged.
[SWS_Dio_00105]
[ ]
- When writing a port which is smaller than the Dio_PortLevelType using the Dio_WritePort function (see [SWS_Dio_00103]), the function shall ignore the MSB.
[SWS_Dio_00108]
[ ]
- The Dio_WritePort function shall have no effect on channels within this port which are configured as input channels. Furthermore, the requirements [SWS_Dio_00005], [SWS_Dio_00119] and [SWS_Dio_00026] are applicable to the Dio_WritePort function.
Dio_ReadChannelGroup
[SWS_Dio_00137]
[ ]
[SWS_Dio_00037]
[SRS_Dio_12007]
- The Dio_ReadChannelGroup function shall read a subset of the adjoining bits of a port (channel group).
[SWS_Dio_00092]
[SRS_Dio_12007]
- The Dio_ReadChannelGroup function shall do the masking of the channel group.
[SWS_Dio_00093]
[SRS_Dio_12007]
- The Dio_ReadChannelGroup function shall do the shifting so that the values read by the function are aligned to the LSB. Furthermore, the requirements [SWS_Dio_00005], [SWS_Dio_00056], [SWS_Dio_00083], [SWS_Dio_00084] and [SWS_Dio_00026] are applicable to the Dio_ReadChannelGroup function.
[SWS_Dio_00114]
[SRS_BSW_00323]
[SRS_SPAL_12448]
- If development error detection is enabled, the functions Dio_ReadChannelGroup and Dio_WriteChannelGroup shall check the "ChannelGroupIdPtr" parameter to be valid within the current configuration. If the "ChannelGroupIdPtr" parameter is invalid, the functions shall report the error code DIO_E_PARAM_INVALID_GROUP to the DET.
Dio_WriteChannelGroup
[SWS_Dio_00138]
[ ]
[SWS_Dio_00039]
[SRS_Dio_12004]
- The Dio_WriteChannelGroup function shall set a subset of the adjoining bits of a port (channel group) to a specified level.
[SWS_Dio_00040]
[SRS_Dio_12004]
- The Dio_WriteChannelGroup shall not change the remaining channels of the port and channels which are configured as input.
[SWS_Dio_00090]
[SRS_Dio_12004]
- The Dio_WriteChannelGroup function shall do the masking of the channel group.
[SWS_Dio_00091]
[SRS_Dio_12004]
- The function Dio_WriteChannelGroup shall do the shifting so that the values written by the function are aligned to the LSB. Furthermore, the requirements [SWS_Dio_00005], [SWS_Dio_00056], [SWS_Dio_00119] and [SWS_Dio_00026] are applicable for the Dio_WriteChannelGroup function.
Dio_GetVersionInfo
[SWS_Dio_00139]
[SRS_BSW_00411]
[SWS_Dio_00189]
[ ]
- If DET is enabled for the DIO Driver module, the function Dio_GetVersionInfo shall raise DIO_E_PARAM_POINTER, if the argument is NULL pointer and return without any action. See also Chapter 11.
Dio_FlipChannel
[SWS_Dio_00190]
[ ]
[SWS_Dio_00191]
[ ]
- If the specified channel is configured as an output channel, the Dio_FlipChannel function shall read level of the channel (requirements [SWS_Dio_00083] & [SWS_Dio_00084] are applicable) and invert it, then write the inverted level to the channel. The return value shall be the inverted level of the specified channel.
[SWS_Dio_00192]
[ ]
- If the specified channel is configured as an input channel, the Dio_FlipChannel function shall have no influence on the physical output. The return value shall be the level of the specified channel.
[SWS_Dio_00193]
[ ]
- If the specified channel is configured as an input channel, the Dio_FlipChannel function shall have no influence on the result of the next ReadService. Furthermore, the requirements [SWS_Dio_00005], [SWS_Dio_00119] and [SWS_Dio_00026] are applicable to the Dio_FlipChannel function. See also Chapter 11.
Dio_MaskedWritePort
[SWS_Dio_00300]
[ ]
[SWS_Dio_00202]
[SRS_Dio_12003]
- The Dio_MaskedWritePort function shall set the specified value for the channels in the specified port if the corresponding bit in Mask is '1'.
[SWS_Dio_00203]
[SRS_Dio_12003]
- When the Dio_MaskedWritePort function is called, DIO Channels that are configured as input shall remain unchanged.
[SWS_Dio_00204]
[ ]
- When writing a port which is smaller than the Dio_PortLevelType using the Dio_MaskedWritePort function (see [SWS_Dio_00103]), the function shall ignore the MSB.
Call-back notifications
This chapter lists all functions provided by the Dio module to lower layers.
The Dio module does not provide any callback notifications. Callbacks related to the functionality of the Dio module are implemented in another module (ICU Driver and/or complex drivers).
Scheduled functions
This chapter lists all functions called directly by the Basic Software Module Scheduler.
The Dio module has no scheduled functions.
Expected Interfaces
This chapter lists all functions the Dio module requires from other modules.
Optional Interfaces
This chapter defines all interfaces which are required to fulfill an optional functionality of the module.
[SWS_Dio_00140]
[ ]
Sequence diagrams
The diagrams below show the sequences when calling the Dio_ReadChannel() and Dio_WriteChannel() service, they show normal operation mode. Since all other services which are defined in chapter 9.3 have exactly the same synchronous behavior concerning, there are intentionally no further sequence diagrams in this document.
Read a value from a digital I/O
This chapter defines configuration parameters and their clustering into containers.
Containers and configuration parameters
The following chapters summarize all configuration parameters. The detailed meanings of the parameters describe Chapters 8 and Chapter 9.
[SWS_Dio_00205]
[ ]
- The DIO module shall reject configurations with partition mappings which are not supported by the implementation.
Variants
[SWS_Dio_00129]
[ ]
- At least one of the following variants has to be supported by implementation: - VARIANT-PRE-COMPILE - VARIANT-LINK-TIME
DioGeneral
DioPort
[SWS_Dio_00206]
[ ]
- The ECUC partitions referenced by DioPortEcucPartitionRef shall be a subset of the ECUC partitions referenced by DioEcucPartitionRef.
[SWS_Dio_00209]
[ ]
- If DioEcucPartitionRef references one or more ECUC partitions, DioPortEcucPartitionRef shall have a multiplicity of greater than zero and reference one or several of these ECUC partitions as well.
DioChannel
[SWS_Dio_00207]
[ ]
- The ECUC partitions referenced by DioChannelEcucPartitionRef shall be a subset of the ECUC partitions referenced by DioPortEcucPartitionRef.
[SWS_Dio_00210]
[ ]
- If DioEcucPartitionRef references one or more ECUC partitions, DioChannelEcucPartitionRef shall have a multiplicity of greater than zero and reference one or several of these ECUC partitions as well.
DioChannelGroup
[SWS_Dio_00208]
[ ]
- The ECUC partitions referenced by DioChannelGroupEcucPartitionRef shall be a subset of the ECUC partitions referenced by DioPortEcucPartitionRef.
[SWS_Dio_00211]
[ ]
- If DioPortEcucPartitionRef references one or more ECUC partitions, DioChannelGroupEcucPartitionRef shall have a multiplicity of greater than zero and reference one or several of these ECUC partitions as well.
评论
发表评论