123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- #ifdef __cplusplus
- extern "C"{
- #endif
- #include "StandardTypes.h"
- #include "Port_Ci_Icu_Ip.h"
- #include "OsIf.h"
- #if(PORT_CI_ICU_IP_DEV_ERROR_DETECT == STD_ON)
- #include "Devassert.h"
- #endif
- #if (STD_ON == PORT_CI_ICU_IP_ENABLE_USER_MODE_SUPPORT)
- #define USER_MODE_REG_PROT_ENABLED (PORT_CI_ICU_IP_ENABLE_USER_MODE_SUPPORT)
- #include "RegLockMacros.h"
- #endif
- #define PORT_CI_ICU_IP_VENDOR_ID_C 43
- #define PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION_C 4
- #define PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION_C 4
- #define PORT_CI_ICU_IP_AR_RELEASE_REVISION_VERSION_C 0
- #define PORT_CI_ICU_IP_SW_MAJOR_VERSION_C 1
- #define PORT_CI_ICU_IP_SW_MINOR_VERSION_C 0
- #define PORT_CI_ICU_IP_SW_PATCH_VERSION_C 0
- #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
-
- #if ((PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION_C != STD_AR_RELEASE_MAJOR_VERSION) || \
- (PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION_C != STD_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Port_Ci_Icu_Ip.c and StandardTypes.h are different"
- #endif
- #if (STD_ON == PORT_CI_ICU_IP_ENABLE_USER_MODE_SUPPORT)
-
- #if ((PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION_C != REGLOCKMACROS_AR_RELEASE_MAJOR_VERSION) || \
- (PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION_C != REGLOCKMACROS_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Port_Ci_Icu_Ip.c and RegLockMacros.h are different"
- #endif
- #endif
-
-
- #if ((PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION_C != OSIF_AR_RELEASE_MAJOR_VERSION) || \
- (PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION_C != OSIF_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Port_Ci_Icu_Ip.c and OsIf.h are different"
- #endif
- #if(PORT_CI_ICU_IP_DEV_ERROR_DETECT == STD_ON)
-
- #if ((PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION_C != DEVASSERT_AR_RELEASE_MAJOR_VERSION) || \
- (PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION_C != DEVASSERT_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Port_Ci_Icu_Ip.c and Devassert.h are different"
- #endif
- #endif
- #endif
- #if (PORT_CI_ICU_IP_VENDOR_ID_C != PORT_CI_ICU_IP_VENDOR_ID)
- #error "Port_Ci_Icu_Ip.c and Port_Ci_Icu_Ip.h have different vendor IDs"
- #endif
- #if ((PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION_C != PORT_CI_ICU_IP_AR_RELEASE_MAJOR_VERSION) || \
- (PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION_C != PORT_CI_ICU_IP_AR_RELEASE_MINOR_VERSION) || \
- (PORT_CI_ICU_IP_AR_RELEASE_REVISION_VERSION_C != PORT_CI_ICU_IP_AR_RELEASE_REVISION_VERSION))
- #error "AutoSar Version Numbers of Port_Ci_Icu_Ip.c and Port_Ci_Icu_Ip.h are different"
- #endif
- #if ((PORT_CI_ICU_IP_SW_MAJOR_VERSION_C != PORT_CI_ICU_IP_SW_MAJOR_VERSION) || \
- (PORT_CI_ICU_IP_SW_MINOR_VERSION_C != PORT_CI_ICU_IP_SW_MINOR_VERSION) || \
- (PORT_CI_ICU_IP_SW_PATCH_VERSION_C != PORT_CI_ICU_IP_SW_PATCH_VERSION))
- #error "Software Version Numbers of Port_Ci_Icu_Ip.c and Port_Ci_Icu_Ip.h are different"
- #endif
- #define ICU_START_SEC_CONST_UNSPECIFIED
- #include "Icu_MemMap.h"
- PORT_Type * const s_Port_Ci_Base[] = IP_PORT_BASE_PTRS;
- #define ICU_STOP_SEC_CONST_UNSPECIFIED
- #include "Icu_MemMap.h"
- #define ICU_START_SEC_VAR_CLEARED_8
- #include "Icu_MemMap.h"
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) || (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- static uint8 Port_Ci_Icu_Ip_aChActivationMode[PORT_PCR_COUNT];
- #endif
- #define ICU_STOP_SEC_VAR_CLEARED_8
- #include "Icu_MemMap.h"
- #define ICU_START_SEC_VAR_CLEARED_UNSPECIFIED
- #include "Icu_MemMap.h"
- Port_Ci_Icu_Ip_State Port_Ci_Icu_Ip_u32ChState[PORT_INSTANCE_COUNT][PORT_PCR_COUNT];
- #define ICU_STOP_SEC_VAR_CLEARED_UNSPECIFIED
- #include "Icu_MemMap.h"
- #define ICU_START_SEC_CODE
- #include "Icu_MemMap.h"
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) ||(PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- void Port_Ci_Icu_Ip_EnableInterrupt(uint8 instance, uint8 hwChannel)
- {
- uint32 u32pinMask = (uint32)((uint32)1U << (uint32)hwChannel);
-
- if (Port_Ci_Icu_Ip_aChActivationMode[hwChannel] == ICU_PORT_CI_CH_FALLING_EDGE_U8)
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~ICU_PORT_CI_PCR_IREE_U32;
- s_Port_Ci_Base[instance]->PCR[hwChannel] |= ICU_PORT_CI_PCR_IFEE_U32;
- }
- else if (Port_Ci_Icu_Ip_aChActivationMode[hwChannel] == ICU_PORT_CI_CH_RISING_EDGE_U8)
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~ICU_PORT_CI_PCR_IFEE_U32;
- s_Port_Ci_Base[instance]->PCR[hwChannel] |= ICU_PORT_CI_PCR_IREE_U32;
- }
- else
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] |= (ICU_PORT_CI_PCR_IREE_U32 | ICU_PORT_CI_PCR_IFEE_U32);
- }
-
-
- s_Port_Ci_Base[instance]->ISFR |= u32pinMask;
- }
- #endif
- void Port_Ci_Icu_Ip_DisableInterrupt(uint8 instance, uint8 hwChannel)
- {
- uint32 u32pinMask = (uint32)((uint32)1U << (uint32)hwChannel);
-
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~PORT_PCR_IRQC_MASK;
-
-
- s_Port_Ci_Base[instance]->ISFR |= u32pinMask;
- }
- Port_Ci_Icu_Ip_StatusType Port_Ci_Icu_Ip_Init (uint8 instance, const Port_Ci_Icu_Ip_ConfigType * userConfig)
- {
-
- uint8 nCounter;
- uint8 hwChannel;
- for (nCounter=0U; nCounter < userConfig->nNumChannels; nCounter++)
- {
-
- hwChannel = (uint8)((*userConfig->pChannelsConfig)[nCounter].pinId);
-
- Port_Ci_Icu_Ip_DisableInterrupt(instance, hwChannel);
-
- Port_Ci_Icu_Ip_SetActivationCondition
- (
- instance, hwChannel,
- (Port_Ci_Icu_Ip_EdgeType)((*userConfig->pChannelsConfig)[nCounter].nDefaultStartEdge)
- );
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].chInit = TRUE;
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].callback = (*userConfig->pChannelsConfig)[nCounter].callback;
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].callbackParam = (*userConfig->pChannelsConfig)[nCounter].callbackParam;
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].PortCiChannelNotification = (*userConfig->pChannelsConfig)[nCounter].PortCiChannelNotification;
- }
- return PORT_CI_IP_STATUS_SUCCESS;
- }
- #if (STD_ON == PORT_CI_ICU_IP_DEINIT_API)
- Port_Ci_Icu_Ip_StatusType Port_Ci_Icu_Ip_DeInit(uint8 instance)
- {
-
- uint8 hwChannel;
- uint32 u32pinMask;
- for (hwChannel=0U; hwChannel < PORT_PCR_COUNT; hwChannel++)
- {
-
- u32pinMask = (uint32)((uint32)1U << (uint32)hwChannel);
-
-
- Port_Ci_Icu_Ip_DisableInterrupt(instance, hwChannel);
-
-
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~PORT_PCR_IRQC_MASK;
-
-
- s_Port_Ci_Base[instance]->DFER &= ~u32pinMask;
-
-
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].chInit = FALSE;
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].callback = NULL_PTR;
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].callbackParam = 0U;
- Port_Ci_Icu_Ip_u32ChState[instance][hwChannel].PortCiChannelNotification = NULL_PTR;
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) || (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- Port_Ci_Icu_Ip_aChActivationMode[hwChannel] = ICU_PORT_CI_CH_NEITHER_EDGE_U8;
- #endif
- }
- return PORT_CI_IP_STATUS_SUCCESS;
- }
- #endif
- #if (PORT_CI_ICU_IP_SET_MODE_API == STD_ON)
- void Port_Ci_Icu_Ip_SetSleepMode(uint8 instance, uint8 hwChannel)
- {
-
- Port_Ci_Icu_Ip_DisableInterrupt(instance, hwChannel);
- }
- void Port_Ci_Icu_Ip_SetNormalMode(uint8 instance, uint8 hwChannel)
- {
-
- Port_Ci_Icu_Ip_EnableInterrupt(instance, hwChannel);
- }
- #endif
- void Port_Ci_Icu_Ip_SetActivationCondition(uint8 instance, uint8 hwChannel, Port_Ci_Icu_Ip_EdgeType activation)
- {
- switch (activation)
- {
- case PORT_CI_ICU_RISING_EDGE:
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~ICU_PORT_CI_PCR_IFEE_U32;
- s_Port_Ci_Base[instance]->PCR[hwChannel] |= ICU_PORT_CI_PCR_IREE_U32;
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) || (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- Port_Ci_Icu_Ip_aChActivationMode[hwChannel] = ICU_PORT_CI_CH_RISING_EDGE_U8;
- #endif
- }
- break;
- case PORT_CI_ICU_FALLING_EDGE:
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~ICU_PORT_CI_PCR_IREE_U32;
- s_Port_Ci_Base[instance]->PCR[hwChannel] |= ICU_PORT_CI_PCR_IFEE_U32;
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) || (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- Port_Ci_Icu_Ip_aChActivationMode[hwChannel] = ICU_PORT_CI_CH_FALLING_EDGE_U8;
- #endif
- }
- break;
- case PORT_CI_ICU_BOTH_EDGES:
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] |= ICU_PORT_CI_PCR_IEEE_U32;
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) || (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- Port_Ci_Icu_Ip_aChActivationMode[hwChannel] = ICU_PORT_CI_CH_EITHER_EDGE_U8;
- #endif
- }
- break;
-
- default:
- {
- s_Port_Ci_Base[instance]->PCR[hwChannel] &= ~(ICU_PORT_CI_PCR_IREE_U32|ICU_PORT_CI_PCR_IFEE_U32);
- #if ((PORT_CI_ICU_IP_SET_MODE_API == STD_ON) || (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON))
- Port_Ci_Icu_Ip_aChActivationMode[hwChannel] = ICU_PORT_CI_CH_NEITHER_EDGE_U8;
- #endif
- }
- break;
-
- }
- }
- #if (PORT_CI_ICU_IP_EDGE_DETECT_API == STD_ON)
- void Port_Ci_Icu_Ip_EnableEdgeDetection(uint8 instance, uint8 hwChannel)
- {
-
- Port_Ci_Icu_Ip_EnableInterrupt(instance, hwChannel);
- }
- void Port_Ci_Icu_Ip_DisableDetection(uint8 instance, uint8 hwChannel)
- {
-
- Port_Ci_Icu_Ip_DisableInterrupt(instance, hwChannel);
- }
- #endif
- #if (PORT_CI_ICU_IP_GET_INPUT_STATE_API == STD_ON)
- boolean Port_Ci_Icu_Ip_GetInputState(uint8 instance, uint8 hwChannel)
- {
- boolean bStatus = FALSE;
- uint32 u32pinMask = (uint32)((uint32)1U << (uint32)hwChannel);
-
-
- if (0x0U != (s_Port_Ci_Base[instance]->ISFR & u32pinMask) )
- {
-
- s_Port_Ci_Base[instance]->ISFR |= u32pinMask;
-
- bStatus = TRUE;
- }
- return bStatus;
- }
- #endif
- #define ICU_STOP_SEC_CODE
- #include "Icu_MemMap.h"
- #ifdef __cplusplus
- }
- #endif
|