1 /*
2  * Copyright 2021-2024 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #ifndef OSIF_TIMER_SYSTEM_H
7 #define OSIF_TIMER_SYSTEM_H
8 
9 /**
10 *   @file
11 *
12 *   @addtogroup osif_drv
13 *   @{
14 */
15 
16 #ifdef __cplusplus
17 extern "C"{
18 #endif
19 
20 /*==================================================================================================
21 *                                          INCLUDE FILES
22 * 1) system and project includes
23 * 2) needed interfaces from external units
24 * 3) internal and external interfaces from this unit
25 ==================================================================================================*/
26 #include "Std_Types.h"
27 
28 /*==================================================================================================
29 *                                 SOURCE FILE VERSION INFORMATION
30 ==================================================================================================*/
31 #define OSIF_TIMER_SYSTEM_VENDOR_ID                    43
32 #define OSIF_TIMER_SYSTEM_AR_RELEASE_MAJOR_VERSION     4
33 #define OSIF_TIMER_SYSTEM_AR_RELEASE_MINOR_VERSION     7
34 #define OSIF_TIMER_SYSTEM_AR_RELEASE_REVISION_VERSION  0
35 #define OSIF_TIMER_SYSTEM_SW_MAJOR_VERSION             2
36 #define OSIF_TIMER_SYSTEM_SW_MINOR_VERSION             0
37 #define OSIF_TIMER_SYSTEM_SW_PATCH_VERSION             0
38 
39 /*==================================================================================================
40 *                                       FILE VERSION CHECKS
41 ==================================================================================================*/
42 /* Checks against Std_Types.h */
43 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
44     #if ((OSIF_TIMER_SYSTEM_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
45          (OSIF_TIMER_SYSTEM_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION))
46         #error "AutoSar Version Numbers of OsIf_Timer_System.h and Std_Types.h are different"
47     #endif
48 #endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */
49 
50 /*==================================================================================================
51 *                                            CONSTANTS
52 ==================================================================================================*/
53 
54 /*==================================================================================================
55 *                                       DEFINES AND MACROS
56 ==================================================================================================*/
57 
58 /*==================================================================================================
59 *                                              ENUMS
60 ==================================================================================================*/
61 
62 /*==================================================================================================
63 *                                  STRUCTURES AND OTHER TYPEDEFS
64 ==================================================================================================*/
65 
66 /*==================================================================================================
67 *                                  GLOBAL VARIABLE DECLARATIONS
68 ==================================================================================================*/
69 
70 /*==================================================================================================
71 *                                       FUNCTION PROTOTYPES
72 ==================================================================================================*/
73 #define BASENXP_START_SEC_CODE
74 #include "BaseNXP_MemMap.h"
75 /*!
76  * @brief Initialize the system timer.
77  *
78  * This function initialize the system timer.
79  */
80 void OsIf_Timer_System_Init(void);
81 
82 /*!
83  * @brief Get counter value from system timer.
84  *
85  * This function get counter value from system timer.
86  *
87  * @return Counter value
88  */
89 uint32 OsIf_Timer_System_GetCounter(void);
90 
91 /*!
92  * @brief Get elapsed value from system timer.
93  *
94  * This function get elapsed value from system timer.
95  *
96  * @param[in] CurrentRef The pointer to current reference point
97  * @return Elapsed value
98  */
99 uint32 OsIf_Timer_System_GetElapsed(uint32 * const CurrentRef);
100 
101 /*!
102  * @brief Set system timer frequency.
103  *
104  * This function set system timer frequency.
105  *
106  * @param[in] Freq Frequency value
107  */
108 void OsIf_Timer_System_SetTimerFrequency(uint32 Freq);
109 
110 /*!
111  * @brief Convert micro second to ticks based on system timer frequency.
112  *
113  * This function Convert micro second to ticks based on system timer frequency.
114  *
115  * @param[in] Micros Micro second
116  * @return Ticks
117  */
118 uint32 OsIf_Timer_System_MicrosToTicks(uint32 Micros);
119 
120 #define BASENXP_STOP_SEC_CODE
121 #include "BaseNXP_MemMap.h"
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 /** @} */
128 
129 #endif /* OSIF_TIMER_SYSTEM_H */
130