1 /*
2  * Copyright 2021-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #ifndef OSIF_TIMER_SYSTEM_INTERNAL_GENERICTIMER
7 #define OSIF_TIMER_SYSTEM_INTERNAL_GENERICTIMER
8 
9 #ifdef __cplusplus
10 extern "C"{
11 #endif
12 
13 /*==================================================================================================
14 *                                          INCLUDE FILES
15 * 1) system and project includes
16 * 2) needed interfaces from external units
17 * 3) internal and external interfaces from this unit
18 ==================================================================================================*/
19 #include "OsIf_Cfg.h"
20 
21 /*==================================================================================================
22 *                                 SOURCE FILE VERSION INFORMATION
23 ==================================================================================================*/
24 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_VENDOR_ID                    43
25 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_AR_RELEASE_MAJOR_VERSION     4
26 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_AR_RELEASE_MINOR_VERSION     7
27 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_AR_RELEASE_REVISION_VERSION  0
28 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_SW_MAJOR_VERSION             1
29 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_SW_MINOR_VERSION             0
30 #define OSIF_TIMER_SYS_INTER_GENERICTIMER_SW_PATCH_VERSION             0
31 
32 /*==================================================================================================
33 *                                       FILE VERSION CHECKS
34 ==================================================================================================*/
35 /* Check if OsIf_Timer_System_Internal_GenericTimer.h file and OsIf_Cfg.h file are of the same vendor */
36 #if (OSIF_TIMER_SYS_INTER_GENERICTIMER_VENDOR_ID != OSIF_CFG_VENDOR_ID)
37     #error "OsIf_Timer_System_Internal_GenericTimer.h and OsIf_Cfg.h have different vendor ids"
38 #endif
39 /* Check if OsIf_Timer_System_Internal_GenericTimer.h file and OsIf_Cfg.h file are of the same Autosar version */
40 #if ((OSIF_TIMER_SYS_INTER_GENERICTIMER_AR_RELEASE_MAJOR_VERSION    != OSIF_CFG_AR_RELEASE_MAJOR_VERSION) || \
41      (OSIF_TIMER_SYS_INTER_GENERICTIMER_AR_RELEASE_MINOR_VERSION    != OSIF_CFG_AR_RELEASE_MINOR_VERSION) || \
42      (OSIF_TIMER_SYS_INTER_GENERICTIMER_AR_RELEASE_REVISION_VERSION != OSIF_CFG_AR_RELEASE_REVISION_VERSION))
43     #error "AUTOSAR Version Numbers of OsIf_Timer_System_Internal_GenericTimer.h and OsIf_Cfg.h are different"
44 #endif
45 /* Check if OsIf_Timer_System_Internal_GenericTimer.h file and OsIf_Cfg.h file are of the same Software version */
46 #if ((OSIF_TIMER_SYS_INTER_GENERICTIMER_SW_MAJOR_VERSION != OSIF_CFG_SW_MAJOR_VERSION) || \
47      (OSIF_TIMER_SYS_INTER_GENERICTIMER_SW_MINOR_VERSION != OSIF_CFG_SW_MINOR_VERSION) || \
48      (OSIF_TIMER_SYS_INTER_GENERICTIMER_SW_PATCH_VERSION != OSIF_CFG_SW_PATCH_VERSION) \
49     )
50     #error "Software Version Numbers of OsIf_Timer_System_Internal_GenericTimer.h and OsIf_Cfg.h are different"
51 #endif
52 
53 /*==================================================================================================
54 *                                            CONSTANTS
55 ==================================================================================================*/
56 
57 /*==================================================================================================
58 *                                       DEFINES AND MACROS
59 ==================================================================================================*/
60 
61 /*==================================================================================================
62 *                                              ENUMS
63 ==================================================================================================*/
64 
65 /*==================================================================================================
66 *                                  STRUCTURES AND OTHER TYPEDEFS
67 ==================================================================================================*/
68 
69 /*==================================================================================================
70 *                                  GLOBAL VARIABLE DECLARATIONS
71 ==================================================================================================*/
72 
73 /*==================================================================================================
74 *                                       FUNCTION PROTOTYPES
75 ==================================================================================================*/
76 #if defined(OSIF_USE_GENERICTIMER)
77 #if (OSIF_USE_GENERICTIMER == STD_ON)
78 
79 #define BASENXP_START_SEC_CODE
80 #include "BaseNXP_MemMap.h"
81 /*!
82  * @brief Initialize SysTick timer
83  *
84  * This function initializes SysTick timer
85  *
86  * @param[in] SystemCounterFreq     System counter's frequency
87  * @return void
88  */
89 void OsIf_Timer_System_Internal_Init(uint32 SystemCounterFreq);
90 
91 /*!
92  * @brief Get current counter value of SysTick timer
93  *
94  * This function gets current counter value of SysTick timer
95  *
96  * @param[in] void
97  * @return current counter value
98  */
99 uint32 OsIf_Timer_System_Internal_GetCounter(void);
100 
101 /*!
102  * @brief Get elapsed time
103  *
104  * This function gets elapsed time
105  *
106  * @param[in] CurrentRef - pointer to old counter value
107  * @return elapsed time
108  */
109 uint32 OsIf_Timer_System_Internal_GetElapsed(uint32 * const CurrentRef);
110 
111 #define BASENXP_STOP_SEC_CODE
112 #include "BaseNXP_MemMap.h"
113 
114 #endif /* (OSIF_USE_GENERICTIMER == STD_ON) */
115 #endif /* defined(OSIF_USE_GENERICTIMER) */
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif /* OSIF_TIMER_SYSTEM_INTERNAL_GENERICTIMER */
122