OsIf.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : S32K14X
  5. * Dependencies : none
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. #ifndef OSIF_H
  25. #define OSIF_H
  26. /**
  27. * @file
  28. *
  29. * @addtogroup osif_drv
  30. * @{
  31. */
  32. #ifdef __cplusplus
  33. extern "C"{
  34. #endif
  35. /*==================================================================================================
  36. * INCLUDE FILES
  37. * 1) system and project includes
  38. * 2) needed interfaces from external units
  39. * 3) internal and external interfaces from this unit
  40. ==================================================================================================*/
  41. #include "OsIf_Internal.h"
  42. #include "OsIf_Cfg.h"
  43. /*==================================================================================================
  44. * SOURCE FILE VERSION INFORMATION
  45. ==================================================================================================*/
  46. #define OSIF_VENDOR_ID 43
  47. #define OSIF_AR_RELEASE_MAJOR_VERSION 4
  48. #define OSIF_AR_RELEASE_MINOR_VERSION 4
  49. #define OSIF_AR_RELEASE_REVISION_VERSION 0
  50. #define OSIF_SW_MAJOR_VERSION 1
  51. #define OSIF_SW_MINOR_VERSION 0
  52. #define OSIF_SW_PATCH_VERSION 0
  53. /*==================================================================================================
  54. * FILE VERSION CHECKS
  55. ==================================================================================================*/
  56. /* Checks against OsIf_Internal.h */
  57. #if (OSIF_VENDOR_ID != OSIF_INTERNAL_VENDOR_ID)
  58. #error "OsIf.h and OsIf_Internal.h have different vendor ids"
  59. #endif
  60. #if ((OSIF_AR_RELEASE_MAJOR_VERSION != OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION) || \
  61. (OSIF_AR_RELEASE_MINOR_VERSION != OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION) || \
  62. (OSIF_AR_RELEASE_REVISION_VERSION != OSIF_INTERNAL_AR_RELEASE_REVISION_VERSION))
  63. #error "AUTOSAR Version Numbers of OsIf.h and OsIf_Internal.h are different"
  64. #endif
  65. #if ((OSIF_SW_MAJOR_VERSION != OSIF_INTERNAL_SW_MAJOR_VERSION) || \
  66. (OSIF_SW_MINOR_VERSION != OSIF_INTERNAL_SW_MINOR_VERSION) || \
  67. (OSIF_SW_PATCH_VERSION != OSIF_INTERNAL_SW_PATCH_VERSION) \
  68. )
  69. #error "Software Version Numbers of OsIf.h and OsIf_Internal.h are different"
  70. #endif
  71. /* Checks against OsIf_Cfg.h */
  72. #if (OSIF_VENDOR_ID != OSIF_CFG_VENDOR_ID)
  73. #error "OsIf.h and OsIf_Cfg.h have different vendor ids"
  74. #endif
  75. #if ((OSIF_AR_RELEASE_MAJOR_VERSION != OSIF_CFG_AR_RELEASE_MAJOR_VERSION) || \
  76. (OSIF_AR_RELEASE_MINOR_VERSION != OSIF_CFG_AR_RELEASE_MINOR_VERSION) || \
  77. (OSIF_AR_RELEASE_REVISION_VERSION != OSIF_CFG_AR_RELEASE_REVISION_VERSION))
  78. #error "AUTOSAR Version Numbers of OsIf.h and OsIf_Cfg.h are different"
  79. #endif
  80. #if ((OSIF_SW_MAJOR_VERSION != OSIF_CFG_SW_MAJOR_VERSION) || \
  81. (OSIF_SW_MINOR_VERSION != OSIF_CFG_SW_MINOR_VERSION) || \
  82. (OSIF_SW_PATCH_VERSION != OSIF_CFG_SW_PATCH_VERSION) \
  83. )
  84. #error "Software Version Numbers of OsIf.h and OsIf_Cfg.h are different"
  85. #endif
  86. /*==================================================================================================
  87. * CONSTANTS
  88. ==================================================================================================*/
  89. /*==================================================================================================
  90. * DEFINES AND MACROS
  91. ==================================================================================================*/
  92. /*==================================================================================================
  93. * ENUMS
  94. ==================================================================================================*/
  95. /*!
  96. * @brief OsIf Counter type
  97. *
  98. * Counter type.
  99. *
  100. */
  101. typedef enum
  102. {
  103. OSIF_COUNTER_DUMMY, /**< dummy counter */
  104. #if (OSIF_USE_SYSTEM_TIMER == STD_ON)
  105. OSIF_COUNTER_SYSTEM, /**< system counter */
  106. #endif /* (OSIF_USE_SYSTEM_TIMER == STD_ON) */
  107. #if (OSIF_USE_CUSTOM_TIMER == STD_ON)
  108. OSIF_COUNTER_CUSTOM /**< custom counter */
  109. #endif /* (OSIF_USE_CUSTOM_TIMER == STD_ON) */
  110. } OsIf_CounterType;
  111. /*==================================================================================================
  112. * STRUCTURES AND OTHER TYPEDEFS
  113. ==================================================================================================*/
  114. /*==================================================================================================
  115. * GLOBAL VARIABLE DECLARATIONS
  116. ==================================================================================================*/
  117. /*==================================================================================================
  118. * FUNCTION PROTOTYPES
  119. ==================================================================================================*/
  120. #define BASE_START_SEC_CODE
  121. #include "Base_MemMap.h"
  122. /*!
  123. * @brief Initialize OsIf
  124. *
  125. * This function initializes the OsIf module and should be called during startup, before every
  126. * other intialization other than Mcu.
  127. *
  128. */
  129. void OsIf_Init(const void* Config);
  130. /*!
  131. * @brief Get the current value counter
  132. *
  133. * This function returns the current value of the counter.
  134. *
  135. * @param[in] SelectedCounter the type of counter to use
  136. * @return the current value of the counter
  137. */
  138. uint32 OsIf_GetCounter(OsIf_CounterType SelectedCounter);
  139. /*!
  140. * @brief Get the elapsed value from a reference point
  141. *
  142. * This function returns the delta time in ticks compared to a reference, and updates the reference.
  143. *
  144. * @param[inout] CurrentRef reference counter value, updated to current counter value
  145. * @param[in] SelectedCounter the type of counter to use
  146. * @return the elapsed time
  147. */
  148. uint32 OsIf_GetElapsed(uint32 * const CurrentRef, OsIf_CounterType SelectedCounter);
  149. /*!
  150. * @brief Set a new frequency used for time conversion (microseconds to ticks)
  151. *
  152. * This function stores a new timer frequency used for time conversion computations
  153. *
  154. * @param[in] Freq the new frequency
  155. * @param[in] SelectedCounter the type of counter to use
  156. */
  157. void OsIf_SetTimerFrequency(uint32 Freq, OsIf_CounterType SelectedCounter);
  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. #define BASE_STOP_SEC_CODE
  169. #include "Base_MemMap.h"
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. /** @} */
  174. #endif /* OSIF_H */