123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- /*==================================================================================================
- * Project : RTD AUTOSAR 4.4
- * Platform : CORTEXM
- * Peripheral : S32K14X
- * 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
- *
- * @addtogroup osif_drv
- * @{
- */
- #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 "OsIf.h"
- #include "OsIf_Cfg.h"
- #include "OsIf_Cfg_TypesDef.h"
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- /* Defines the Hw Timer functions to be implemented in OS-specific environments */
- #include "OsIf_Timer_System.h"
- #endif /* (OSIF_USE_SYSTEM_TIMER == STD_ON) */
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- /* API functions to be implemented by user */
- #include "OsIf_Timer_Custom.h"
- #endif /* (OSIF_USE_CUSTOM_TIMER == STD_ON) */
- /*==================================================================================================
- * SOURCE FILE VERSION INFORMATION
- ==================================================================================================*/
- #define OSIF_TIMER_VENDOR_ID_C 43
- #define OSIF_TIMER_AR_RELEASE_MAJOR_VERSION_C 4
- #define OSIF_TIMER_AR_RELEASE_MINOR_VERSION_C 4
- #define OSIF_TIMER_AR_RELEASE_REVISION_VERSION_C 0
- #define OSIF_TIMER_SW_MAJOR_VERSION_C 1
- #define OSIF_TIMER_SW_MINOR_VERSION_C 0
- #define OSIF_TIMER_SW_PATCH_VERSION_C 0
- /*==================================================================================================
- * FILE VERSION CHECKS
- ==================================================================================================*/
- /* Checks against OsIf.h */
- #if (OSIF_TIMER_VENDOR_ID_C != OSIF_VENDOR_ID)
- #error "OsIf_Timer.c and OsIf.h have different vendor ids"
- #endif
- #if ((OSIF_TIMER_AR_RELEASE_MAJOR_VERSION_C != OSIF_AR_RELEASE_MAJOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_MINOR_VERSION_C != OSIF_AR_RELEASE_MINOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_REVISION_VERSION_C != OSIF_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of OsIf_Timer.c and OsIf.h are different"
- #endif
- #if ((OSIF_TIMER_SW_MAJOR_VERSION_C != OSIF_SW_MAJOR_VERSION) || \
- (OSIF_TIMER_SW_MINOR_VERSION_C != OSIF_SW_MINOR_VERSION) || \
- (OSIF_TIMER_SW_PATCH_VERSION_C != OSIF_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of OsIf_Timer.c and OsIf.h are different"
- #endif
- /* Checks against OsIf_Cfg.h */
- #if (OSIF_TIMER_VENDOR_ID_C != OSIF_CFG_VENDOR_ID)
- #error "OsIf_Timer.c and OsIf_Cfg.h have different vendor ids"
- #endif
- #if ((OSIF_TIMER_AR_RELEASE_MAJOR_VERSION_C != OSIF_CFG_AR_RELEASE_MAJOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_MINOR_VERSION_C != OSIF_CFG_AR_RELEASE_MINOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_REVISION_VERSION_C != OSIF_CFG_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of OsIf_Timer.c and OsIf_Cfg.h are different"
- #endif
- #if ((OSIF_TIMER_SW_MAJOR_VERSION_C != OSIF_CFG_SW_MAJOR_VERSION) || \
- (OSIF_TIMER_SW_MINOR_VERSION_C != OSIF_CFG_SW_MINOR_VERSION) || \
- (OSIF_TIMER_SW_PATCH_VERSION_C != OSIF_CFG_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of OsIf_Timer.c and OsIf_Cfg.h are different"
- #endif
- /* Checks against OsIf_Cfg_TypesDef.h */
- #if (OSIF_TIMER_VENDOR_ID_C != OSIF_CFG_TYPESDEF_VENDOR_ID)
- #error "OsIf_Timer.c and OsIf_Cfg_TypesDef.h have different vendor ids"
- #endif
- #if ((OSIF_TIMER_AR_RELEASE_MAJOR_VERSION_C != OSIF_CFG_TYPESDEF_AR_RELEASE_MAJOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_MINOR_VERSION_C != OSIF_CFG_TYPESDEF_AR_RELEASE_MINOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_REVISION_VERSION_C != OSIF_CFG_TYPESDEF_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of OsIf_Timer_System.c and OsIf_Cfg_TypesDef.h are different"
- #endif
- #if ((OSIF_TIMER_SW_MAJOR_VERSION_C != OSIF_CFG_TYPESDEF_SW_MAJOR_VERSION) || \
- (OSIF_TIMER_SW_MINOR_VERSION_C != OSIF_CFG_TYPESDEF_SW_MINOR_VERSION) || \
- (OSIF_TIMER_SW_PATCH_VERSION_C != OSIF_CFG_TYPESDEF_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of OsIf_Timer.c and OsIf_Cfg_TypesDef.h are different"
- #endif
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- /* Checks against OsIf_Timer_System.h */
- #if (OSIF_TIMER_VENDOR_ID_C != OSIF_TIMER_SYSTEM_VENDOR_ID)
- #error "OsIf_Timer.c and OsIf_Timer_System.h have different vendor ids"
- #endif
- #if ((OSIF_TIMER_AR_RELEASE_MAJOR_VERSION_C != OSIF_TIMER_SYSTEM_AR_RELEASE_MAJOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_MINOR_VERSION_C != OSIF_TIMER_SYSTEM_AR_RELEASE_MINOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_REVISION_VERSION_C != OSIF_TIMER_SYSTEM_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of OsIf_Timer.c and OsIf_Timer_System.h are different"
- #endif
- #if ((OSIF_TIMER_SW_MAJOR_VERSION_C != OSIF_TIMER_SYSTEM_SW_MAJOR_VERSION) || \
- (OSIF_TIMER_SW_MINOR_VERSION_C != OSIF_TIMER_SYSTEM_SW_MINOR_VERSION) || \
- (OSIF_TIMER_SW_PATCH_VERSION_C != OSIF_TIMER_SYSTEM_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of OsIf_Timer.c and OsIf_Timer_System.h are different"
- #endif
- #endif /* (OSIF_USE_SYSTEM_TIMER == STD_ON) */
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- /* Checks against OsIf_Timer_Custom.h */
- #if (OSIF_TIMER_VENDOR_ID_C != OSIF_TIMER_CUSTOM_VENDOR_ID)
- #error "OsIf_Timer.c and OsIf_Timer_Custom.h have different vendor ids"
- #endif
- #if ((OSIF_TIMER_AR_RELEASE_MAJOR_VERSION_C != OSIF_TIMER_CUSTOM_AR_RELEASE_MAJOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_MINOR_VERSION_C != OSIF_TIMER_CUSTOM_AR_RELEASE_MINOR_VERSION) || \
- (OSIF_TIMER_AR_RELEASE_REVISION_VERSION_C != OSIF_TIMER_CUSTOM_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of OsIf_Timer.c and OsIf_Timer_Custom.h are different"
- #endif
- #if ((OSIF_TIMER_SW_MAJOR_VERSION_C != OSIF_TIMER_CUSTOM_SW_MAJOR_VERSION) || \
- (OSIF_TIMER_SW_MINOR_VERSION_C != OSIF_TIMER_CUSTOM_SW_MINOR_VERSION) || \
- (OSIF_TIMER_SW_PATCH_VERSION_C != OSIF_TIMER_CUSTOM_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of OsIf_Timer.c and OsIf_Timer_Custom.h are different"
- #endif
- #endif /* (OSIF_USE_CUSTOM_TIMER == STD_ON) */
- /*==================================================================================================
- * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL MACROS
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL VARIABLES
- ==================================================================================================*/
- /*==================================================================================================
- * GLOBAL CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- * GLOBAL VARIABLES
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL FUNCTION PROTOTYPES
- ==================================================================================================*/
- #define BASE_START_SEC_CODE
- #include "Base_MemMap.h"
- static inline uint32 OsIf_Timer_Dummy_GetCounter(void);
- static inline uint32 OsIf_Timer_Dummy_GetElapsed(const uint32 * const CurrentRef);
- static inline void OsIf_Timer_Dummy_SetTimerFrequency(uint32 Freq);
- static inline uint32 OsIf_Timer_Dummy_MicrosToTicks(uint32 Micros);
- #define BASE_STOP_SEC_CODE
- #include "Base_MemMap.h"
- /*==================================================================================================
- * LOCAL FUNCTIONS
- ==================================================================================================*/
- #define BASE_START_SEC_CODE
- #include "Base_MemMap.h"
- static inline uint32 OsIf_Timer_Dummy_GetCounter(void)
- {
- return 0u;
- }
- static inline uint32 OsIf_Timer_Dummy_GetElapsed(const uint32 * const CurrentRef)
- {
- (void)CurrentRef;
- return 1u;
- }
- static inline void OsIf_Timer_Dummy_SetTimerFrequency(uint32 Freq)
- {
- (void)Freq;
- }
- static inline uint32 OsIf_Timer_Dummy_MicrosToTicks(uint32 Micros)
- {
- return Micros;
- }
- #define BASE_STOP_SEC_CODE
- #include "Base_MemMap.h"
- /*==================================================================================================
- * GLOBAL FUNCTIONS
- ==================================================================================================*/
- #define BASE_START_SEC_CODE
- #include "Base_MemMap.h"
- /* @implements OsIf_Init_Activity */
- void OsIf_Init(const void* Config)
- {
- #if (STD_ON == OSIF_DEV_ERROR_DETECT)
- if (Config != NULL_PTR)
- {
- #if defined(USING_OS_AUTOSAROS)
- (void)Det_ReportError(OSIF_MODULE_ID, OSIF_DRIVER_INSTANCE, OSIF_SID_INIT, OSIF_E_INIT_FAILED);
- #else
- OSIF_DEV_ASSERT(FALSE);
- #endif
- }
- #else
- (void)Config;
- #endif
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- OsIf_Timer_System_Init();
- #endif
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- OsIf_Timer_Custom_Init();
- #endif
- }
- /* @implements OsIf_GetCounter_Activity */
- uint32 OsIf_GetCounter(OsIf_CounterType SelectedCounter)
- {
- uint32 Value = 0u;
- switch (SelectedCounter){
- case OSIF_COUNTER_DUMMY:
- Value = OsIf_Timer_Dummy_GetCounter();
- break;
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- case OSIF_COUNTER_SYSTEM:
- Value = OsIf_Timer_System_GetCounter();
- break;
- #endif
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- case OSIF_COUNTER_CUSTOM:
- Value = OsIf_Timer_Custom_GetCounter();
- break;
- #endif
- default: /* impossible */ break;
- }
- return Value;
- }
- /* @implements OsIf_GetElapsed_Activity */
- uint32 OsIf_GetElapsed(uint32 * const CurrentRef, OsIf_CounterType SelectedCounter)
- {
- uint32 Value = 0u;
- switch (SelectedCounter){
- case OSIF_COUNTER_DUMMY:
- Value = OsIf_Timer_Dummy_GetElapsed(CurrentRef);
- break;
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- case OSIF_COUNTER_SYSTEM:
- Value = OsIf_Timer_System_GetElapsed(CurrentRef);
- break;
- #endif
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- case OSIF_COUNTER_CUSTOM:
- Value = OsIf_Timer_Custom_GetElapsed(CurrentRef);
- break;
- #endif
- default: /* impossible */ break;
- }
- return Value;
- }
- /* @implements OsIf_SetTimerFrequency_Activity */
- void OsIf_SetTimerFrequency(uint32 Freq, OsIf_CounterType SelectedCounter)
- {
- switch (SelectedCounter){
- case OSIF_COUNTER_DUMMY:
- OsIf_Timer_Dummy_SetTimerFrequency(Freq);
- break;
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- case OSIF_COUNTER_SYSTEM:
- OsIf_Timer_System_SetTimerFrequency(Freq);
- break;
- #endif
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- case OSIF_COUNTER_CUSTOM:
- OsIf_Timer_Custom_SetTimerFrequency(Freq);
- break;
- #endif
- default: /* impossible */ break;
- }
- }
- /* @implements OsIf_MicrosToTicks_Activity */
- uint32 OsIf_MicrosToTicks(uint32 Micros, OsIf_CounterType SelectedCounter)
- {
- uint32 Value = 0u;
- switch (SelectedCounter){
- case OSIF_COUNTER_DUMMY:
- Value = OsIf_Timer_Dummy_MicrosToTicks(Micros);
- break;
- #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
- case OSIF_COUNTER_SYSTEM:
- Value = OsIf_Timer_System_MicrosToTicks(Micros);
- break;
- #endif
- #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
- case OSIF_COUNTER_CUSTOM:
- Value = OsIf_Timer_Custom_MicrosToTicks(Micros);
- break;
- #endif
- default: /* impossible */ break;
- }
- return Value;
- }
- #define BASE_STOP_SEC_CODE
- #include "Base_MemMap.h"
- #ifdef __cplusplus
- }
- #endif
- /** @} */
|