123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919 |
- /*==================================================================================================
- * Project : RTD AUTOSAR 4.4
- * Platform : CORTEXM
- * Peripheral : GPIO
- * Dependencies : none
- *
- * Autosar Version : 4.4.0
- * Autosar Revision : ASR_REL_4_4_REV_0000
- * Autosar Conf.Variant :
- * SW Version : 1.0.0
- * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
- *
- * (c) Copyright 2020-2021 NXP Semiconductors
- * All Rights Reserved.
- *
- * NXP Confidential. This software is owned or controlled by NXP and may only be
- * used strictly in accordance with the applicable license terms. By expressly
- * accepting such terms or by downloading, installing, activating and/or otherwise
- * using the software, you are agreeing that you have read, and that you agree to
- * comply with and are bound by, such license terms. If you do not agree to be
- * bound by the applicable license terms, then you may not retain, install,
- * activate or otherwise use the software.
- ==================================================================================================*/
- /**
- * @file Dio.c
- * @implements Dio.c_Artifact
- *
- * @addtogroup DIO_HLD
- * @{
- */
- #ifdef __cplusplus
- extern "C"{
- #endif
- /*=================================================================================================
- * INCLUDE FILES
- * 1) system and project includes
- * 2) needed interfaces from external units
- * 3) internal and external interfaces from this unit
- =================================================================================================*/
- #include "Dio.h"
- #include "Dio_Ipw.h"
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- #include "Det.h"
- #endif
- /*=================================================================================================
- * SOURCE FILE VERSION INFORMATION
- =================================================================================================*/
- #define DIO_VENDOR_ID_C 43
- #define DIO_AR_RELEASE_MAJOR_VERSION_C 4
- #define DIO_AR_RELEASE_MINOR_VERSION_C 4
- #define DIO_AR_RELEASE_REVISION_VERSION_C 0
- #define DIO_SW_MAJOR_VERSION_C 1
- #define DIO_SW_MINOR_VERSION_C 0
- #define DIO_SW_PATCH_VERSION_C 0
- /*=================================================================================================
- * FILE VERSION CHECKS
- =================================================================================================*/
- /* Check if current file and DET header file are of the same version.*/
- #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- #if ((DIO_AR_RELEASE_MAJOR_VERSION_C != DET_AR_RELEASE_MAJOR_VERSION) || \
- (DIO_AR_RELEASE_MINOR_VERSION_C != DET_AR_RELEASE_MINOR_VERSION) \
- )
- #error "AutoSar Version Numbers of Dio.c and Det.h are different"
- #endif
- #endif
- #endif
- /* Check if current file and DIO header file are of the same vendor.*/
- #if (DIO_VENDOR_ID_C != DIO_VENDOR_ID)
- #error "Dio.c and Dio.h have different vendor ids"
- #endif
- /* Check if current file and DIO header file are of the same Autosar version.*/
- #if ((DIO_AR_RELEASE_MAJOR_VERSION_C != DIO_AR_RELEASE_MAJOR_VERSION) || \
- (DIO_AR_RELEASE_MINOR_VERSION_C != DIO_AR_RELEASE_MINOR_VERSION) || \
- (DIO_AR_RELEASE_REVISION_VERSION_C != DIO_AR_RELEASE_REVISION_VERSION) \
- )
- #error "AutoSar Version Numbers of Dio.c and Dio.h are different"
- #endif
- /* Check if current file and DIO header file are of the same Software version.*/
- #if ((DIO_SW_MAJOR_VERSION_C != DIO_SW_MAJOR_VERSION) || \
- (DIO_SW_MINOR_VERSION_C != DIO_SW_MINOR_VERSION) || \
- (DIO_SW_PATCH_VERSION_C != DIO_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Dio.c and Dio.h are different"
- #endif
- /* Dio_Ipw.h version check start */
- #if ((DIO_AR_RELEASE_MAJOR_VERSION_C != DIO_AR_RELEASE_MAJOR_VERSION_IPW_H) || \
- (DIO_AR_RELEASE_MINOR_VERSION_C != DIO_AR_RELEASE_MINOR_VERSION_IPW_H) || \
- (DIO_AR_RELEASE_REVISION_VERSION_C != DIO_AR_RELEASE_REVISION_VERSION_IPW_H)\
- )
- #error "AUTOSAR Version Numbers of Dio.c and Dio_Ipw.h are different"
- #endif
- #if ((DIO_SW_MAJOR_VERSION_C != DIO_SW_MAJOR_VERSION_IPW_H) || \
- (DIO_SW_MINOR_VERSION_C != DIO_SW_MINOR_VERSION_IPW_H) || \
- (DIO_SW_PATCH_VERSION_C != DIO_SW_PATCH_VERSION_IPW_H) \
- )
- #error "Software Version Numbers of Dio.c and Dio_Ipw.h are different"
- #endif
- #if (DIO_VENDOR_ID_C != DIO_VENDOR_ID_IPW_H)
- #error "VENDOR ID for Dio.c and Dio_Ipw.h is different"
- #endif
- /* Dio_Ipw.h version check end */
- /*=================================================================================================
- * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
- =================================================================================================*/
- /*=================================================================================================
- * LOCAL MACROS
- =================================================================================================*/
- #if (STD_ON == DIO_MULTICORE_ENABLED)
- #define Dio_GetCoreID() OsIf_GetCoreID()
- #else
- #define Dio_GetCoreID() ((uint32)0UL)
- #endif
- /*=================================================================================================
- * LOCAL CONSTANTS
- =================================================================================================*/
- /*=================================================================================================
- * LOCAL VARIABLES
- =================================================================================================*/
- #if (defined(DIO_PRECOMPILE_SUPPORT) || defined(DIO_LINKTIME_SUPPORT))
- #define DIO_START_SEC_CONFIG_DATA_UNSPECIFIED
- #include "Dio_MemMap.h"
- /* Local Variable for storing the generated Dio configuration */
- extern const Dio_ConfigType Dio_ConfigPC;
- #define DIO_STOP_SEC_CONFIG_DATA_UNSPECIFIED
- #include "Dio_MemMap.h"
- #endif /* (defined(DIO_PRECOMPILE_SUPPORT) || defined(DIO_LINKTIME_SUPPORT)) */
- /*=================================================================================================
- * GLOBAL CONSTANTS
- =================================================================================================*/
- /*=================================================================================================
- * GLOBAL VARIABLES
- =================================================================================================*/
- /*=================================================================================================
- * LOCAL FUNCTION PROTOTYPES
- =================================================================================================*/
- #define DIO_START_SEC_CODE
- #include "Dio_MemMap.h"
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- static inline Std_ReturnType Dio_ValidateChannelLevel
- (
- Dio_LevelType Level
- );
- static inline Std_ReturnType Dio_ValidateChannelForWrite
- (
- Dio_ChannelType ChannelId,
- uint8 u8ServiceId
- );
- static inline Std_ReturnType Dio_ValidateChannelForRead
- (
- Dio_ChannelType ChannelId,
- uint8 u8ServiceId
- );
- static inline Std_ReturnType Dio_ValidatePortForWrite
- (
- Dio_PortType PortId,
- uint8 u8ServiceId
- );
- static inline Std_ReturnType Dio_ValidatePortForRead
- (
- Dio_PortType PortId,
- uint8 u8ServiceId
- );
- static inline Std_ReturnType Dio_ValidateChannelGroupForWrite
- (
- const Dio_ChannelGroupType * pChannelGroup,
- uint8 u8ServiceId
- );
- static inline Std_ReturnType Dio_ValidateChannelGroupForRead
- (
- const Dio_ChannelGroupType * pChannelGroup,
- uint8 u8ServiceId
- );
- #endif /* (STD_ON == DIO_DEV_ERROR_DETECT) */
- /*=================================================================================================
- * LOCAL FUNCTIONS
- =================================================================================================*/
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- /**
- * @brief DIO channel level validation.
- * @details Checks if the specified channel level is valid (either STD_HIGH or STD_LOW).
- *
- * @param[in] Level channel level parameter to be checked
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidateChannelLevel_Activity
- */
- static inline Std_ReturnType Dio_ValidateChannelLevel
- (
- Dio_LevelType Level
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- if (((Dio_LevelType)STD_HIGH == Level) || ((Dio_LevelType)STD_LOW == Level))
- {
- Valid = (Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, DIO_WRITECHANNEL_ID, DIO_E_PARAM_LEVEL);
- }
- return Valid;
- }
- #endif
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- /**
- * @brief DIO channel availability check.
- * @details Checks if the specified channel is implemented in the current platform package.
- *
- * @param[in] ChannelId Identifier of the channel to be checked.
- * u8ServiceId The service id of the caller function
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidateChannelForWrite_Activity
- */
- static inline Std_ReturnType Dio_ValidateChannelForWrite
- (
- Dio_ChannelType ChannelId,
- uint8 u8ServiceId
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- uint8 CoreId = (uint8)Dio_GetCoreID();
- if ((((Dio_ChannelType)(ChannelId) <= DIO_NUM_CHANNELS_U16)) &&
- ((Dio_PortLevelType)0 != (Dio_aAvailablePinsForWrite[DIO_PORTID_EXTRACT(ChannelId)] &
- (DIO_CHECK_CHANNEL_VALIDITY((uint16)ChannelId))
- )
- )
- )
- {
- if ((uint32)1 == ((Dio_ConfigPC.pau32Dio_ChannelToPartitionMap[ChannelId] & ((uint32)1 << CoreId)) >> CoreId))
- {
- Valid = (Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_CONFIG);
- }
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_INVALID_CHANNEL_ID);
- }
- return Valid;
- }
- /**
- * @brief DIO channel availability check.
- * @details Checks if the specified channel is implemented in the current platform package.
- *
- * @param[in] ChannelId Identifier of the channel to be checked.
- * u8ServiceId The service id of the caller function
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidateChannelForRead_Activity
- */
- static inline Std_ReturnType Dio_ValidateChannelForRead
- (
- Dio_ChannelType ChannelId,
- uint8 u8ServiceId
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- uint8 CoreId = (uint8)Dio_GetCoreID();
- /* Check if that channel ID is available for read */
- if ((((Dio_ChannelType)(ChannelId) <= DIO_NUM_CHANNELS_U16)) &&
- ((Dio_PortLevelType)0 != (Dio_aAvailablePinsForRead[DIO_PORTID_EXTRACT(ChannelId)] &
- (DIO_CHECK_CHANNEL_VALIDITY((uint16)ChannelId))
- )
- )
- )
- {
- /* Check if port was assigned to the current coreID */
- if ((uint32)1 == ((Dio_ConfigPC.pau32Dio_ChannelToPartitionMap[ChannelId] & ((uint32)1 << CoreId)) >> CoreId))
- {
- Valid = (Std_ReturnType)E_OK;
- }
- else
- {
- /* Raise Det error when invalid serviceID */
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_CONFIG);
- }
- }
- else
- {
- /* Raise Det error when invalid channel ID */
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_INVALID_CHANNEL_ID);
- }
- return Valid;
- }
- #endif
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- /**
- * @brief DIO port availability check.
- * @details Checks if the specified port is implemented in the current platform package.
- *
- * @param[in] PortId Identifier of the port to be checked.
- * u8ServiceId The service id of the caller function
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidatePortForWrite_Activity
- */
- static inline Std_ReturnType Dio_ValidatePortForWrite
- (
- Dio_PortType PortId,
- uint8 u8ServiceId
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- uint8 CoreId = (uint8)Dio_GetCoreID();
- if (((uint8)(PortId) < DIO_NUM_PORTS_U16) &&
- (Dio_aAvailablePinsForWrite[(uint8)(PortId)] != DIO_NO_AVAILABLE_CHANNELS_U16)
- )
- {
- if ((uint32)1 == ((Dio_ConfigPC.pau32Dio_PortToPartitionMap[PortId] & ((uint32)1 << CoreId)) >> CoreId))
- {
- Valid = ( Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_CONFIG);
- }
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_INVALID_PORT_ID);
- }
- return Valid;
- }
- /**
- * @brief DIO port availability check.
- * @details Checks if the specified port is implemented in the current platform package.
- *
- * @param[in] PortId Identifier of the port to be checked.
- * u8ServiceId The service id of the caller function
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidatePortForRead_Activity
- */
- static inline Std_ReturnType Dio_ValidatePortForRead
- (
- Dio_PortType PortId,
- uint8 u8ServiceId
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- uint8 CoreId = (uint8)Dio_GetCoreID();
- /* Check input parameters are available for read */
- if (((uint8)(PortId) < DIO_NUM_PORTS_U16) &&
- (Dio_aAvailablePinsForRead[(uint8)(PortId)] != DIO_NO_AVAILABLE_CHANNELS_U16)
- )
- {
- /* Check if Port was assigned to the current coreID */
- if ((uint32)1 == ((Dio_ConfigPC.pau32Dio_PortToPartitionMap[PortId] & ((uint32)1 << CoreId)) >> CoreId))
- {
- Valid = ( Std_ReturnType)E_OK;
- }
- else
- {
- /* Raise Det error when invalid serviceID */
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_CONFIG);
- }
- }
- else
- {
- /* Raise Det error when invalid port ID */
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_INVALID_PORT_ID);
- }
- return Valid;
- }
- #endif
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- /**
- * @brief DIO channel group validity check.
- * @details Checks if the parameter matches one of the channel group pointers in
- * the configuration.
- *
- * @param[in] pChannelGroup The channel group to be validated.
- * u8ServiceId The service id of the caller function
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidateChannelGroupForWrite_Activity
- */
- static inline Std_ReturnType Dio_ValidateChannelGroupForWrite
- (
- const Dio_ChannelGroupType * pChannelGroup,
- uint8 u8ServiceId
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- /* Compiler_Warning: Pointer to channel group is converted to unsigned long in order for it to
- be compared with the boundaries of the channel group list. */
- if ((((pointerSizeType)(pChannelGroup)) >= ((pointerSizeType)Dio_ConfigPC.pChannelGroupList)) && \
- (((pointerSizeType)(pChannelGroup)) <= (pointerSizeType)(&Dio_ConfigPC.pChannelGroupList[Dio_ConfigPC.u8NumChannelGroups - 1U])) && \
- ((uint8)(pChannelGroup->port) < DIO_NUM_PORTS_U16) && \
- (Dio_aAvailablePinsForWrite[(uint8)(pChannelGroup->port)] != DIO_NO_AVAILABLE_CHANNELS_U16) && \
- ((uint8)(pChannelGroup->u8offset) <= DIO_MAX_VALID_OFFSET_U8)
- )
- {
- Valid = (Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_INVALID_GROUP_ID);
- }
- return Valid;
- }
- /**
- * @brief DIO channel group validity check.
- * @details Checks if the parameter matches one of the channel group pointers in
- * the configuration.
- *
- * @param[in] pChannelGroup The channel group to be validated.
- * u8ServiceId The service id of the caller function
- *
- * @return Std_ReturnType
- *
- * @api
- *
- * @implements Dio_ValidateChannelGroupForRead_Activity
- */
- static inline Std_ReturnType Dio_ValidateChannelGroupForRead
- (
- const Dio_ChannelGroupType * pChannelGroup,
- uint8 u8ServiceId
- )
- {
- Std_ReturnType Valid = (Std_ReturnType)E_NOT_OK;
- /* Compiler_Warning: Pointer to channel group is converted to unsigned long in order for it to
- be compared with the boundaries of the channel group list. */
- if ((((pointerSizeType)(pChannelGroup)) >= ((pointerSizeType)Dio_ConfigPC.pChannelGroupList)) && \
- (((pointerSizeType)(pChannelGroup)) <= (pointerSizeType)(&Dio_ConfigPC.pChannelGroupList[Dio_ConfigPC.u8NumChannelGroups - 1U])) && \
- ((uint8)(pChannelGroup->port) < DIO_NUM_PORTS_U16) && \
- (Dio_aAvailablePinsForRead[(uint8)(pChannelGroup->port)] != DIO_NO_AVAILABLE_CHANNELS_U16) && \
- ((uint8)(pChannelGroup->u8offset) <= DIO_MAX_VALID_OFFSET_U8)
- )
- {
- Valid = (Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, u8ServiceId, DIO_E_PARAM_INVALID_GROUP_ID);
- }
- return Valid;
- }
- #endif
- /*=================================================================================================
- * GLOBAL FUNCTIONS
- =================================================================================================*/
- /*================================================================================================*/
- #if (STD_ON == DIO_VERSION_INFO_API)
- /*================================================================================================*/
- /**
- * @brief Service to get the version information of this module.
- * @details The @p Dio_GetVersionInfo() function shall return the version
- * information of this module. The version information includes:
- * - Module Id.
- * - Vendor Id.
- * - Vendor specific version numbers.
- * .
- *
- * @param[in,out] VersionInfo Pointer to where to store the version
- * information of this module.
- *
- * @pre This function can be used only if @p DIO_VERSION_INFO_API
- * has been enabled.
- *
- * @implements Dio_GetVersionInfo_Activity
- */
- void Dio_GetVersionInfo
- (
- Std_VersionInfoType * VersionInfo
- )
- {
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- if (NULL_PTR == VersionInfo)
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, DIO_GETVERSIONINFO_ID, DIO_E_PARAM_POINTER);
- }
- else
- #endif /* (STD_ON == DIO_DEV_ERROR_DETECT) */
- {
- VersionInfo->vendorID = (uint16)DIO_VENDOR_ID;
- VersionInfo->moduleID = (uint16)DIO_MODULE_ID;
- VersionInfo->sw_major_version = (uint8)DIO_SW_MAJOR_VERSION;
- VersionInfo->sw_minor_version = (uint8)DIO_SW_MINOR_VERSION;
- VersionInfo->sw_patch_version = (uint8)DIO_SW_PATCH_VERSION;
- }
- }
- #endif /* (STD_ON == DIO_DEV_ERROR_DETECT) */
- /*================================================================================================*/
- /**
- * @brief Returns the value of the specified DIO channel.
- * @details This function returns the value of the specified DIO channel.
- *
- * @param[in] ChannelId Specifies the required channel id.
- *
- * @return Returns the level of the corresponding pin as
- * @p STD_HIGH or @p STD_LOW.
- * @retval STD_HIGH The logical level of the corresponding pin is 1.
- * @retval STD_LOW The logical level of the corresponding Pin is 0.
- *
- * @implements Dio_ReadChannel_Activity
- */
- Dio_LevelType Dio_ReadChannel
- (
- Dio_ChannelType ChannelId
- )
- {
- Dio_LevelType ChannelLevel = (Dio_LevelType)STD_LOW;
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- Std_ReturnType Valid = Dio_ValidateChannelForRead(ChannelId, DIO_READCHANNEL_ID);
- if ((Std_ReturnType)E_OK == Valid)
- {
- #endif
- ChannelLevel = Dio_Ipw_ReadChannel(ChannelId);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- }
- #endif
- return ChannelLevel;
- }
- /*================================================================================================*/
- /**
- * @brief Sets the level of a channel.
- * @details If the specified channel is configured as an output channel,
- * this function shall set the specified level on the
- * specified channel. If the specified channel is configured
- * as an input channel, this function shall have no influence
- * on the physical output and on the result of the next read
- * service.
- *
- * @param[in] ChannelId Specifies the required channel id.
- * @param[in] Level Specifies the channel desired level.
- *
- * @implements Dio_WriteChannel_Activity
- */
- void Dio_WriteChannel
- (
- Dio_ChannelType ChannelId,
- Dio_LevelType Level
- )
- {
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- Std_ReturnType Valid = Dio_ValidateChannelForWrite(ChannelId, DIO_WRITECHANNEL_ID);
- if ((Std_ReturnType) E_OK == Valid)
- {
- Valid = Dio_ValidateChannelLevel(Level);
- if ((Std_ReturnType) E_OK == Valid)
- {
- #endif
- Dio_Ipw_WriteChannel(ChannelId, Level);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- }
- }
- #endif
- }
- #if (STD_ON == DIO_FLIP_CHANNEL_API)
- /*================================================================================================*/
- /**
- * @brief Inverts the level of a channel.
- * @details If the specified channel is configured as an output channel,
- * this function shall invert the level of the specified
- * channel. If the specified channel is configured as an
- * input channel, this function shall have no influence
- * on the physical output and on the result of the next
- * read service.
- *
- * @param[in] ChannelId Specifies the required channel id.
- *
- * @return Returns the level of the corresponding pin as
- * @p STD_HIGH or @p STD_LOW.
- * @retval STD_HIGH The logical level of the corresponding pin is 1.
- * @retval STD_LOW The logical level of the corresponding Pin is 0.
- *
- * @pre This function can be used only if @p DIO_FLIP_CHANNEL_API
- * has been enabled.
- *
- * @implements Dio_FlipChannel_Activity
- */
- Dio_LevelType Dio_FlipChannel
- (
- Dio_ChannelType ChannelId
- )
- {
- Dio_LevelType ChannelLevel = (Dio_LevelType)STD_LOW;
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- Std_ReturnType Valid = Dio_ValidateChannelForWrite(ChannelId, DIO_FLIPCHANNEL_ID);
- if ((Std_ReturnType)E_OK == Valid)
- {
- #endif
- ChannelLevel = Dio_Ipw_FlipChannel(ChannelId);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- }
- #endif
- return ChannelLevel;
- }
- #endif /* (STD_ON == DIO_FLIP_CHANNEL_API) */
- /*================================================================================================*/
- /**
- * @brief Returns the level of all channels of specified port.
- * @details This function will return the level of all channels
- * belonging to the specified port.
- *
- * @param[in] PortId Specifies the required port id.
- *
- * @return Levels of all channels of specified port.
- *
- * @implements Dio_ReadPort_Activity
- */
- Dio_PortLevelType Dio_ReadPort
- (
- Dio_PortType PortId
- )
- {
- Dio_PortLevelType PortLevel = (Dio_PortLevelType)STD_LOW;
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- Std_ReturnType Valid = Dio_ValidatePortForRead(PortId, DIO_READPORT_ID);
- if ((Std_ReturnType) E_OK == Valid)
- {
- #endif
- PortLevel = Dio_Ipw_ReadPort(PortId);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- }
- #endif
- return PortLevel;
- }
- /*================================================================================================*/
- /**
- * @brief Sets the value of a port.
- * @details This function will set the specified value on the specified
- * port.
- *
- * @param[in] PortId Specifies the required port id.
- * @param[in] Level Specifies the required levels for the port pins.
- *
- * @implements Dio_WritePort_Activity
- */
- void Dio_WritePort
- (
- Dio_PortType PortId,
- Dio_PortLevelType Level
- )
- {
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- Std_ReturnType Valid = Dio_ValidatePortForWrite(PortId, DIO_WRITEPORT_ID);
- if ((Std_ReturnType)E_OK == Valid)
- {
- #endif
- Dio_Ipw_WritePort(PortId, Level);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- }
- #endif
- }
- /*================================================================================================*/
- /**
- * @brief This service reads a subset of the adjoining bits of a port.
- * @details This function will read a subset of adjoining bits of a
- * port (channel group).
- *
- * @param[in] ChannelGroupIdPtr Pointer to the channel group.
- *
- * @return The channel group levels.
- *
- * @implements Dio_ReadChannelGroup_Activity
- */
- Dio_PortLevelType Dio_ReadChannelGroup
- (
- const Dio_ChannelGroupType * ChannelGroupIdPtr
- )
- {
- Dio_PortLevelType PortLevel = (Dio_PortLevelType)STD_LOW;
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- uint8 GroupAlocated = 0;
- uint8 GroupIndex = 0;
- uint8 CoreId;
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- Std_ReturnType Valid;
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- CoreId = (uint8)Dio_GetCoreID();
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- Valid = Dio_ValidateChannelGroupForRead(ChannelGroupIdPtr, DIO_READCHANNELGROUP_ID);
- if ((Std_ReturnType)E_OK == Valid)
- {
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- for(GroupIndex = 0; GroupIndex < Dio_ConfigPC.u8NumChannelGroups; GroupIndex++)
- {
- if(au32ChannelGroupsListForEachPartition[CoreId][GroupIndex] == ChannelGroupIdPtr)
- {
- GroupAlocated = 1;
- }
- }
- if ((uint8)1 == GroupAlocated)
- {
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- #endif /* DIO_DEV_ERROR_DETECT */
- PortLevel = Dio_Ipw_ReadChannelGroup(ChannelGroupIdPtr);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, DIO_READCHANNELGROUP_ID, DIO_E_PARAM_CONFIG);
- }
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- }
- #endif /* DIO_DEV_ERROR_DETECT */
- return PortLevel;
- }
- /*================================================================================================*/
- /**
- * @brief Sets a subset of the adjoining bits of a port to the
- * specified levels.
- * @details This function will set a subset of adjoining bits of a port
- * (channel group) to the specified levels without changing
- * the remaining channels of the port and channels that
- * are configured as input.
- * This function will do the masking of the channels and will
- * do the shifting so that the values written by the function
- * are aligned to the LSB.
- *
- * @param[in] ChannelGroupIdPtr Pointer to the channel group.
- * @param[in] Level Desired levels for the channel group.
- *
- * @implements Dio_WriteChannelGroup_Activity
- */
- void Dio_WriteChannelGroup
- (
- const Dio_ChannelGroupType * ChannelGroupIdPtr,
- Dio_PortLevelType Level
- )
- {
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- uint8 GroupAlocated = 0;
- uint8 GroupIndex = 0;
- uint8 CoreId;
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- Std_ReturnType Valid;
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- CoreId = (uint8)Dio_GetCoreID();
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- Valid = Dio_ValidateChannelGroupForWrite(ChannelGroupIdPtr, DIO_WRITECHANNELGROUP_ID);
- if ((Std_ReturnType)E_OK == Valid)
- {
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- for(GroupIndex = 0; GroupIndex < Dio_ConfigPC.u8NumChannelGroups; GroupIndex++)
- {
- if(au32ChannelGroupsListForEachPartition[CoreId][GroupIndex] == ChannelGroupIdPtr)
- {
- GroupAlocated = 1;
- }
- }
- if ((uint8)1 == GroupAlocated)
- {
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- #endif /* DIO_DEV_ERROR_DETECT */
- Dio_Ipw_WriteChannelGroup(ChannelGroupIdPtr, Level);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- #ifdef DIO_CHANNEL_GROUPS_AVAILABLE
- }
- else
- {
- (void)Det_ReportError((uint16)DIO_MODULE_ID, DIO_INSTANCE_ID, DIO_WRITECHANNELGROUP_ID, DIO_E_PARAM_CONFIG);
- }
- #endif /* DIO_CHANNEL_GROUPS_AVAILABLE */
- }
- #endif /* DIO_DEV_ERROR_DETECT */
- }
- #if (STD_ON == DIO_MASKEDWRITEPORT_API)
- /*================================================================================================*/
- /**
- * @brief DIO Mask write port using mask.
- * @details Writes a DIO port with masked value.
- *
- * @param[in] PortId Specifies the required port id.
- * @param[in] Level Specifies the required levels for the port pins.
- * @param[in] Mask Specifies the Mask value of the port.
- *
- * @pre This function can be used only if @p DIO_MASKEDWRITEPORT_API
- * has been enabled.
- *
- * @implements Dio_MaskedWritePort_Activity
- */
- void Dio_MaskedWritePort
- (
- Dio_PortType PortId,
- Dio_PortLevelType Level,
- Dio_PortLevelType Mask
- )
- {
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- Std_ReturnType Valid = Dio_ValidatePortForWrite(PortId, DIO_MASKEDWRITEPORT_ID);
- if ((Std_ReturnType)E_OK == Valid)
- {
- #endif
- Dio_Ipw_MaskedWritePort(PortId, Level, Mask);
- #if (STD_ON == DIO_DEV_ERROR_DETECT)
- }
- #endif
- }
- #endif /* (STD_ON == DIO_MASKEDWRITEPORT_API) */
- #define DIO_STOP_SEC_CODE
- #include "Dio_MemMap.h"
- #ifdef __cplusplus
- }
- #endif
- /** @} */
|