1 /* 2 * Copyright 2021-2022 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #ifndef OSIF_H 7 #define OSIF_H 8 9 /** 10 * @file 11 * 12 * @addtogroup osif_drv 13 * @{ 14 */ 15 16 #ifdef __cplusplus 17 extern "C"{ 18 #endif 19 20 21 /*================================================================================================== 22 * INCLUDE FILES 23 * 1) system and project includes 24 * 2) needed interfaces from external units 25 * 3) internal and external interfaces from this unit 26 ==================================================================================================*/ 27 #include "OsIf_Internal.h" 28 #include "OsIf_Cfg.h" 29 30 /*================================================================================================== 31 * SOURCE FILE VERSION INFORMATION 32 ==================================================================================================*/ 33 #define OSIF_VENDOR_ID 43 34 #define OSIF_AR_RELEASE_MAJOR_VERSION 4 35 #define OSIF_AR_RELEASE_MINOR_VERSION 7 36 #define OSIF_AR_RELEASE_REVISION_VERSION 0 37 #define OSIF_SW_MAJOR_VERSION 0 38 #define OSIF_SW_MINOR_VERSION 9 39 #define OSIF_SW_PATCH_VERSION 0 40 41 /*================================================================================================== 42 * FILE VERSION CHECKS 43 ==================================================================================================*/ 44 /* Checks against OsIf_Internal.h */ 45 #if (OSIF_VENDOR_ID != OSIF_INTERNAL_VENDOR_ID) 46 #error "OsIf.h and OsIf_Internal.h have different vendor ids" 47 #endif 48 #if ((OSIF_AR_RELEASE_MAJOR_VERSION != OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION) || \ 49 (OSIF_AR_RELEASE_MINOR_VERSION != OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION) || \ 50 (OSIF_AR_RELEASE_REVISION_VERSION != OSIF_INTERNAL_AR_RELEASE_REVISION_VERSION)) 51 #error "AUTOSAR Version Numbers of OsIf.h and OsIf_Internal.h are different" 52 #endif 53 #if ((OSIF_SW_MAJOR_VERSION != OSIF_INTERNAL_SW_MAJOR_VERSION) || \ 54 (OSIF_SW_MINOR_VERSION != OSIF_INTERNAL_SW_MINOR_VERSION) || \ 55 (OSIF_SW_PATCH_VERSION != OSIF_INTERNAL_SW_PATCH_VERSION) \ 56 ) 57 #error "Software Version Numbers of OsIf.h and OsIf_Internal.h are different" 58 #endif 59 60 /* Checks against OsIf_Cfg.h */ 61 #if (OSIF_VENDOR_ID != OSIF_CFG_VENDOR_ID) 62 #error "OsIf.h and OsIf_Cfg.h have different vendor ids" 63 #endif 64 #if ((OSIF_AR_RELEASE_MAJOR_VERSION != OSIF_CFG_AR_RELEASE_MAJOR_VERSION) || \ 65 (OSIF_AR_RELEASE_MINOR_VERSION != OSIF_CFG_AR_RELEASE_MINOR_VERSION) || \ 66 (OSIF_AR_RELEASE_REVISION_VERSION != OSIF_CFG_AR_RELEASE_REVISION_VERSION)) 67 #error "AUTOSAR Version Numbers of OsIf.h and OsIf_Cfg.h are different" 68 #endif 69 #if ((OSIF_SW_MAJOR_VERSION != OSIF_CFG_SW_MAJOR_VERSION) || \ 70 (OSIF_SW_MINOR_VERSION != OSIF_CFG_SW_MINOR_VERSION) || \ 71 (OSIF_SW_PATCH_VERSION != OSIF_CFG_SW_PATCH_VERSION) \ 72 ) 73 #error "Software Version Numbers of OsIf.h and OsIf_Cfg.h are different" 74 #endif 75 76 /*================================================================================================== 77 * CONSTANTS 78 ==================================================================================================*/ 79 80 /*================================================================================================== 81 * DEFINES AND MACROS 82 ==================================================================================================*/ 83 84 /*================================================================================================== 85 * ENUMS 86 ==================================================================================================*/ 87 /*! 88 * @brief OsIf Counter type 89 * 90 * Counter type. 91 * 92 */ 93 typedef enum 94 { 95 OSIF_COUNTER_DUMMY, /**< dummy counter */ 96 #if (OSIF_USE_SYSTEM_TIMER == STD_ON) 97 OSIF_COUNTER_SYSTEM, /**< system counter */ 98 #endif /* (OSIF_USE_SYSTEM_TIMER == STD_ON) */ 99 #if (OSIF_USE_CUSTOM_TIMER == STD_ON) 100 OSIF_COUNTER_CUSTOM /**< custom counter */ 101 #endif /* (OSIF_USE_CUSTOM_TIMER == STD_ON) */ 102 } OsIf_CounterType; 103 104 /*================================================================================================== 105 * STRUCTURES AND OTHER TYPEDEFS 106 ==================================================================================================*/ 107 108 /*================================================================================================== 109 * GLOBAL VARIABLE DECLARATIONS 110 ==================================================================================================*/ 111 112 /*================================================================================================== 113 * FUNCTION PROTOTYPES 114 ==================================================================================================*/ 115 #define BASENXP_START_SEC_CODE 116 #include "BaseNXP_MemMap.h" 117 118 /*! 119 * @brief Initialize OsIf 120 * 121 * This function initializes the OsIf module and should be called during startup, before every 122 * other intialization other than Mcu. 123 * 124 */ 125 void OsIf_Init(const void* Config); 126 127 /*! 128 * @brief Get the current value counter 129 * 130 * This function returns the current value of the counter. 131 * 132 * @param[in] SelectedCounter the type of counter to use 133 * @return the current value of the counter 134 */ 135 uint32 OsIf_GetCounter(OsIf_CounterType SelectedCounter); 136 137 /*! 138 * @brief Get the elapsed value from a reference point 139 * 140 * This function returns the delta time in ticks compared to a reference, and updates the reference. 141 * 142 * @param[inout] CurrentRef reference counter value, updated to current counter value 143 * @param[in] SelectedCounter the type of counter to use 144 * @return the elapsed time 145 */ 146 uint32 OsIf_GetElapsed(uint32 * const CurrentRef, OsIf_CounterType SelectedCounter); 147 148 /*! 149 * @brief Set a new frequency used for time conversion (microseconds to ticks) 150 * 151 * This function stores a new timer frequency used for time conversion computations 152 * 153 * @param[in] Freq the new frequency 154 * @param[in] SelectedCounter the type of counter to use 155 */ 156 void OsIf_SetTimerFrequency(uint32 Freq, OsIf_CounterType SelectedCounter); 157 158 /*! 159 * @brief Convert microseconds to ticks 160 * 161 * This function converts a value from microsecond units to ticks units. 162 * 163 * @param[in] Micros microseconds value 164 * @param[in] SelectedCounter the type of counter to use 165 * @return the equivalent value in ticks 166 */ 167 uint32 OsIf_MicrosToTicks(uint32 Micros, OsIf_CounterType SelectedCounter); 168 169 #define BASENXP_STOP_SEC_CODE 170 #include "BaseNXP_MemMap.h" 171 172 #ifdef __cplusplus 173 } 174 #endif 175 176 /** @} */ 177 178 #endif /* OSIF_H */ 179