123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- /*==================================================================================================
- * Project : RTD AUTOSAR 4.4
- * Platform : CORTEXM
- * Peripheral : DMA,CACHE,TRGMUX,FLEXIO
- * 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 Trgmux_Ip.c
- *
- * @version 1.0.0
- *
- * @brief AUTOSAR Mcl - Trgmux Ip driver source file.
- * @details
- *
- * @addtogroup TRGMUX_IP_DRIVER TRGMUX IP Driver
- * @{
- */
- /*==================================================================================================
- * INCLUDE FILES
- * 1) system and project includes
- * 2) needed interfaces from external units
- * 3) internal and external interfaces from this unit
- ==================================================================================================*/
- #include "Trgmux_Ip.h"
- #include "Trgmux_Ip_HwAcc.h"
- #include "SchM_Mcl.h"
- #if (TRGMUX_IP_IS_AVAILABLE == STD_ON)
- /*==================================================================================================
- SOURCE FILE VERSION INFORMATION
- ==================================================================================================*/
- #define TRGMUX_IP_VENDOR_ID_C 43
- #define TRGMUX_IP_AR_RELEASE_MAJOR_VERSION_C 4
- #define TRGMUX_IP_AR_RELEASE_MINOR_VERSION_C 4
- #define TRGMUX_IP_AR_RELEASE_REVISION_VERSION_C 0
- #define TRGMUX_IP_SW_MAJOR_VERSION_C 1
- #define TRGMUX_IP_SW_MINOR_VERSION_C 0
- #define TRGMUX_IP_SW_PATCH_VERSION_C 0
- /**
- * @page misra_violations MISRA-C:2012 violations
- */
- /*==================================================================================================
- FILE VERSION CHECKS
- ==================================================================================================*/
- /* Check if Trgmux_Ip.c file and Trgmux_Ip.h file are of the same vendor */
- #if (TRGMUX_IP_VENDOR_ID_C != TRGMUX_IP_VENDOR_ID_H)
- #error "Trgmux_Ip.c and Trgmux_Ip.h have different vendor ids"
- #endif
- /* Check if Trgmux_Ip.c file and Trgmux_Ip.h file are of the same Autosar version */
- #if ((TRGMUX_IP_AR_RELEASE_MAJOR_VERSION_C != TRGMUX_IP_AR_RELEASE_MAJOR_VERSION_H) || \
- (TRGMUX_IP_AR_RELEASE_MINOR_VERSION_C != TRGMUX_IP_AR_RELEASE_MINOR_VERSION_H) || \
- (TRGMUX_IP_AR_RELEASE_REVISION_VERSION_C != TRGMUX_IP_AR_RELEASE_REVISION_VERSION_H) \
- )
- #error "AutoSar Version Numbers of Trgmux_Ip.c and Trgmux_Ip.h are different"
- #endif
- /* Check if Trgmux_Ip.c file and Trgmux_Ip.h file are of the same Software version */
- #if ((TRGMUX_IP_SW_MAJOR_VERSION_C != TRGMUX_IP_SW_MAJOR_VERSION_H) || \
- (TRGMUX_IP_SW_MINOR_VERSION_C != TRGMUX_IP_SW_MINOR_VERSION_H) || \
- (TRGMUX_IP_SW_PATCH_VERSION_C != TRGMUX_IP_SW_PATCH_VERSION_H) \
- )
- #error "Software Version Numbers of Trgmux_Ip.c and Trgmux_Ip.h are different"
- #endif
- /* Check if Trgmux_Ip.c file and Trgmux_Ip_HwAcc.h file are of the same vendor */
- #if (TRGMUX_IP_VENDOR_ID_C != TRGMUX_IP_HWACC_VENDOR_ID_H)
- #error "Trgmux_Ip.c and Trgmux_Ip_HwAcc.h have different vendor ids"
- #endif
- /* Check if Trgmux_Ip.c file and Trgmux_Ip_HwAcc.h file are of the same Autosar version */
- #if ((TRGMUX_IP_AR_RELEASE_MAJOR_VERSION_C != TRGMUX_IP_HWACC_AR_RELEASE_MAJOR_VERSION_H) || \
- (TRGMUX_IP_AR_RELEASE_MINOR_VERSION_C != TRGMUX_IP_HWACC_AR_RELEASE_MINOR_VERSION_H) || \
- (TRGMUX_IP_AR_RELEASE_REVISION_VERSION_C != TRGMUX_IP_HWACC_AR_RELEASE_REVISION_VERSION_H) \
- )
- #error "AutoSar Version Numbers of Trgmux_Ip.c and Trgmux_Ip_HwAcc.h are different"
- #endif
- /* Check if Trgmux_Ip.c file and Trgmux_Ip_HwAcc.h file are of the same Software version */
- #if ((TRGMUX_IP_SW_MAJOR_VERSION_C != TRGMUX_IP_HWACC_SW_MAJOR_VERSION_H) || \
- (TRGMUX_IP_SW_MINOR_VERSION_C != TRGMUX_IP_HWACC_SW_MINOR_VERSION_H) || \
- (TRGMUX_IP_SW_PATCH_VERSION_C != TRGMUX_IP_HWACC_SW_PATCH_VERSION_H) \
- )
- #error "Software Version Numbers of Trgmux_Ip.c and Trgmux_Ip_HwAcc.h are different"
- #endif
- #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
- /* Check if Trgmux_Ip.c file and SchM_Mcl header file are of the same Autosar version */
- #if ((TRGMUX_IP_AR_RELEASE_MAJOR_VERSION_C != SCHM_MCL_AR_RELEASE_MAJOR_VERSION) || \
- (TRGMUX_IP_AR_RELEASE_MINOR_VERSION_C != SCHM_MCL_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Trgmux_Ip.c and SchM_Mcl.h are different"
- #endif
- #endif
- /*==================================================================================================
- * GLOBAL VARIABLES
- ==================================================================================================*/
- #define MCL_START_SEC_CONFIG_DATA_UNSPECIFIED
- /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
- #include "Mcl_MemMap.h"
- static TRGMUX_Type * const g_paxTrgmuxBaseArray[TRGMUX_INSTANCE_COUNT] = IP_TRGMUX_BASE_PTRS;
- #define MCL_STOP_SEC_CONFIG_DATA_UNSPECIFIED
- /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
- #include "Mcl_MemMap.h"
- #define MCL_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
- /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
- #include "Mcl_MemMap.h"
- /* Pointer to the TRGMUX Initialization Configuration. Based on this configuration pointer,
- the TRGMUX Driver obtains all information for the Logic Triggers and corresponding
- Triggers Configurations.
- The Pointer is loaded when Trgmux_Ip_Init() is called. */
- static const Trgmux_Ip_InitType * g_pxTrgmuxInit;
- #define MCL_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
- /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
- #include "Mcl_MemMap.h"
- /*==================================================================================================
- * GLOBAL FUNCTIONS
- ==================================================================================================*/
- #define MCL_START_SEC_CODE
- /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
- #include "Mcl_MemMap.h"
- /*==================================================================================================
- * LOCAL MACROS
- ==================================================================================================*/
- #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
- #if (STD_ON == TRGMUX_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
- #define Trgmux_Ip_HwAcc_Init(pTrgmux) \
- (OsIf_Trusted_Call_Return1param((uint32)hwAcc_Init, pTrgmux))
- #define Trgmux_Ip_HwAcc_SetInputForOutput(pTrgmux, Input, Output) \
- (OsIf_Trusted_Call3params(hwAcc_SetInputForOutput, pTrgmux, Input, Output))
- #define Trgmux_Ip_HwAcc_SetLockForOutput(pTrgmux, Output) \
- (OsIf_Trusted_Call2params(hwAcc_SetLockForOutput, pTrgmux, Output))
- #define Trgmux_Ip_HwAcc_GetLockForOutput(pTrgmux, Output) \
- (OsIf_Trusted_Call_Return2param((uint32)hwAcc_GetLockForOutput, pTrgmux, Output))
- #else
- #define Trgmux_Ip_HwAcc_Init(pTrgmux) \
- (hwAcc_Init(pTrgmux))
- #define Trgmux_Ip_HwAcc_SetInputForOutput(pTrgmux, Input, Output) \
- (hwAcc_SetInputForOutput(pTrgmux, Input, Output))
- #define Trgmux_Ip_HwAcc_SetLockForOutput(pTrgmux, Output) \
- (hwAcc_SetLockForOutput(pTrgmux, Output))
- #define Trgmux_Ip_HwAcc_GetLockForOutput(pTrgmux, Output) \
- (hwAcc_GetLockForOutput(pTrgmux, Output))
- #endif /* STD_ON == TRGMUX_IP_USER_MODE_SUPPORT_IS_AVAILABLE */
- #else
- #define Trgmux_Ip_HwAcc_Init(pTrgmux) \
- (hwAcc_Init(pTrgmux))
- #define Trgmux_Ip_HwAcc_SetInputForOutput(pTrgmux, Input, Output) \
- (hwAcc_SetInputForOutput(pTrgmux, Input, Output))
- #define Trgmux_Ip_HwAcc_SetLockForOutput(pTrgmux, Output) \
- (hwAcc_SetLockForOutput(pTrgmux, Output))
- #define Trgmux_Ip_HwAcc_GetLockForOutput(pTrgmux, Output) \
- (hwAcc_GetLockForOutput(pTrgmux, Output))
- #endif /* MCAL_ENABLE_USER_MODE_SUPPORT */
- Trgmux_Ip_StatusType Trgmux_Ip_Init(const Trgmux_Ip_InitType * const pxTrgmuxInit)
- {
- TRGMUX_Type * LocTrgmuxBase;
- uint32 LocTriggerIdx;
- uint32 LocInput;
- uint32 LocOutput;
- uint8 LocInst;
- boolean LocLock;
- Trgmux_Ip_StatusType Status = TRGMUX_IP_STATUS_SUCCESS;
- TRGMUX_IP_DEV_ASSERT(NULL_PTR != pxTrgmuxInit);
- /* Clear register */
- LocTrgmuxBase = g_paxTrgmuxBaseArray[TRGMUX_IP_HW_INST_0];
- /* Enter exclusive area to protect TRGMUXn */
- SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_19();
- #ifdef MCAL_ENABLE_USER_MODE_SUPPORT
- #if (STD_ON == TRGMUX_IP_USER_MODE_SUPPORT_IS_AVAILABLE)
- if((Std_ReturnType)TRGMUX_IP_STATUS_SUCCESS != Trgmux_Ip_HwAcc_Init(LocTrgmuxBase))
- #else
- if(TRGMUX_IP_STATUS_SUCCESS != Trgmux_Ip_HwAcc_Init(LocTrgmuxBase))
- #endif
- #else
- if(TRGMUX_IP_STATUS_SUCCESS != Trgmux_Ip_HwAcc_Init(LocTrgmuxBase))
- #endif
- {
- Status = TRGMUX_IP_STATUS_LOCKED;
- }
- else
- {
- /* Do nothing */
- }
- if(TRGMUX_IP_STATUS_LOCKED != Status)
- {
- /* Set register with configured value */
- for(LocTriggerIdx = 0U; LocTriggerIdx < TRGMUX_IP_NOF_CFG_LOGIC_TRIGGERS; LocTriggerIdx++)
- {
- LocInst = pxTrgmuxInit->paxLogicTrigger[LocTriggerIdx]->HwInstId;
- LocOutput = pxTrgmuxInit->paxLogicTrigger[LocTriggerIdx]->Output;
- LocInput = pxTrgmuxInit->paxLogicTrigger[LocTriggerIdx]->Input;
- LocTrgmuxBase = g_paxTrgmuxBaseArray[LocInst];
- Trgmux_Ip_HwAcc_SetInputForOutput(LocTrgmuxBase, LocInput, LocOutput);
- }
- /* Set register lock */
- for(LocTriggerIdx = 0U; LocTriggerIdx < TRGMUX_IP_NOF_CFG_LOGIC_TRIGGERS; LocTriggerIdx++)
- {
- LocLock = pxTrgmuxInit->paxLogicTrigger[LocTriggerIdx]->Lock;
- if(TRUE == LocLock)
- {
- LocOutput = pxTrgmuxInit->paxLogicTrigger[LocTriggerIdx]->Output;
- Trgmux_Ip_HwAcc_SetLockForOutput(LocTrgmuxBase, LocOutput);
- }
- }
- /* Exit exclusive area to protect TRGMUXn */
- SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_19();
- g_pxTrgmuxInit = pxTrgmuxInit;
- }
- else
- {
- /* Do nothing*/
- }
- return Status;
- }
- Trgmux_Ip_StatusType Trgmux_Ip_SetInput(const uint32 LogicTrigger, const uint32 Input)
- {
- uint32 LocHwInst = g_pxTrgmuxInit->paxLogicTrigger[LogicTrigger]->HwInstId;
- uint32 LocOutput = g_pxTrgmuxInit->paxLogicTrigger[LogicTrigger]->Output;
- TRGMUX_Type * LocTrgmuxBase = g_paxTrgmuxBaseArray[LocHwInst];
- Trgmux_Ip_StatusType Status = TRGMUX_IP_STATUS_SUCCESS;
- if(FALSE != Trgmux_Ip_HwAcc_GetLockForOutput(LocTrgmuxBase, LocOutput))
- {
- Status = TRGMUX_IP_STATUS_LOCKED;
- }
- if(TRGMUX_IP_STATUS_LOCKED != Status)
- {
- /* Enter exclusive area to protect TRGMUXn */
- SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_20();
- Trgmux_Ip_HwAcc_SetInputForOutput(LocTrgmuxBase, Input, LocOutput);
- /* Exit exclusive area to protect TRGMUXn */
- SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_20();
- }
- else
- {
- /* Do nothing */
- }
- return Status;
- }
- Trgmux_Ip_StatusType Trgmux_Ip_SetLock(const uint32 LogicTrigger)
- {
- uint32 LocHwInst = g_pxTrgmuxInit->paxLogicTrigger[LogicTrigger]->HwInstId;
- uint32 LocOutput = g_pxTrgmuxInit->paxLogicTrigger[LogicTrigger]->Output;
- TRGMUX_Type * LocTrgmuxBase = g_paxTrgmuxBaseArray[LocHwInst];
- Trgmux_Ip_StatusType Status = TRGMUX_IP_STATUS_SUCCESS;
- if(FALSE != Trgmux_Ip_HwAcc_GetLockForOutput(LocTrgmuxBase, LocOutput))
- {
- Status = TRGMUX_IP_STATUS_LOCKED;
- }
- if(TRGMUX_IP_STATUS_LOCKED != Status)
- {
- /* Enter exclusive area to protect TRGMUXn */
- SchM_Enter_Mcl_MCL_EXCLUSIVE_AREA_21();
- Trgmux_Ip_HwAcc_SetLockForOutput(LocTrgmuxBase, LocOutput);
- /* Exit exclusive area to protect TRGMUXn */
- SchM_Exit_Mcl_MCL_EXCLUSIVE_AREA_21();
- }
- else
- {
- /*Do nothing*/
- }
- return Status;
- }
- #define MCL_STOP_SEC_CODE
- /* @violates @ref Mcl_Dma_h_REF_1 MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
- #include "Mcl_MemMap.h"
- #endif /* TRGMUX_IP_IS_AVAILABLE */
- /** @} */
- /*==================================================================================================
- * END OF FILE
- ==================================================================================================*/
|