Power_Ip_Private.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral :
  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. /**
  25. * @file Power_Ip_Private.c
  26. * @version 1.0.0
  27. *
  28. * @brief
  29. * @brief POWER driver implementations.
  30. * @details POWER driver implementations.
  31. *
  32. * @addtogroup POWER_DRIVER Power Ip Driver
  33. * @{
  34. */
  35. #ifdef __cplusplus
  36. extern "C"{
  37. #endif
  38. /*==================================================================================================
  39. * INCLUDE FILES
  40. * 1) system and project includes
  41. * 2) needed interfaces from external units
  42. * 3) internal and external interfaces from this unit
  43. ==================================================================================================*/
  44. #include "Power_Ip.h"
  45. #include "Power_Ip_Private.h"
  46. #include "OsIf.h"
  47. /*==================================================================================================
  48. SOURCE FILE VERSION INFORMATION
  49. ==================================================================================================*/
  50. #define POWER_IP_PRIVATE_VENDOR_ID_C 43
  51. #define POWER_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION_C 4
  52. #define POWER_IP_PRIVATE_AR_RELEASE_MINOR_VERSION_C 4
  53. #define POWER_IP_PRIVATE_AR_RELEASE_REVISION_VERSION_C 0
  54. #define POWER_IP_PRIVATE_SW_MAJOR_VERSION_C 1
  55. #define POWER_IP_PRIVATE_SW_MINOR_VERSION_C 0
  56. #define POWER_IP_PRIVATE_SW_PATCH_VERSION_C 0
  57. /*==================================================================================================
  58. * FILE VERSION CHECKS
  59. ==================================================================================================*/
  60. /* Check if current file and OsIf header file are of the same version */
  61. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  62. #if ((POWER_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION_C != OSIF_AR_RELEASE_MAJOR_VERSION) || \
  63. (POWER_IP_PRIVATE_AR_RELEASE_MINOR_VERSION_C != OSIF_AR_RELEASE_MINOR_VERSION) \
  64. )
  65. #error "AutoSar Version Numbers of Power_Ip_Private.c and OsIf.h are different"
  66. #endif
  67. #endif
  68. /* Check if current file and Power_Ip header file are of the same Autosar version */
  69. #if (POWER_IP_PRIVATE_VENDOR_ID_C != POWER_IP_VENDOR_ID)
  70. #error "Power_Ip_Private.c and Power_Ip.h have different vendor ids"
  71. #endif
  72. /* Check if current file and Power_Ip header file are of the same Autosar version */
  73. #if ((POWER_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION_C != POWER_IP_AR_RELEASE_MAJOR_VERSION) || \
  74. (POWER_IP_PRIVATE_AR_RELEASE_MINOR_VERSION_C != POWER_IP_AR_RELEASE_MINOR_VERSION) || \
  75. (POWER_IP_PRIVATE_AR_RELEASE_REVISION_VERSION_C != POWER_IP_AR_RELEASE_REVISION_VERSION) \
  76. )
  77. #error "AutoSar Version Numbers of Power_Ip_Private.c and Power_Ip.h are different"
  78. #endif
  79. /* Check if current file and Power_Ip header file are of the same Software version */
  80. #if ((POWER_IP_PRIVATE_SW_MAJOR_VERSION_C != POWER_IP_SW_MAJOR_VERSION) || \
  81. (POWER_IP_PRIVATE_SW_MINOR_VERSION_C != POWER_IP_SW_MINOR_VERSION) || \
  82. (POWER_IP_PRIVATE_SW_PATCH_VERSION_C != POWER_IP_SW_PATCH_VERSION) \
  83. )
  84. #error "Software Version Numbers of Power_Ip_Private.c and Power_Ip.h are different"
  85. #endif
  86. /* Check if current file and Power_Ip_Private header file are of the same Autosar version */
  87. #if (POWER_IP_PRIVATE_VENDOR_ID_C != POWER_IP_PRIVATE_VENDOR_ID)
  88. #error "Power_Ip_Private.c and Power_Ip_Private.h have different vendor ids"
  89. #endif
  90. /* Check if current file and Power_Ip_Private header file are of the same Autosar version */
  91. #if ((POWER_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION_C != POWER_IP_PRIVATE_AR_RELEASE_MAJOR_VERSION) || \
  92. (POWER_IP_PRIVATE_AR_RELEASE_MINOR_VERSION_C != POWER_IP_PRIVATE_AR_RELEASE_MINOR_VERSION) || \
  93. (POWER_IP_PRIVATE_AR_RELEASE_REVISION_VERSION_C != POWER_IP_PRIVATE_AR_RELEASE_REVISION_VERSION) \
  94. )
  95. #error "AutoSar Version Numbers of Power_Ip_Private.c and Power_Ip_Private.h are different"
  96. #endif
  97. /* Check if current file and Power_Ip_Private header file are of the same Software version */
  98. #if ((POWER_IP_PRIVATE_SW_MAJOR_VERSION_C != POWER_IP_PRIVATE_SW_MAJOR_VERSION) || \
  99. (POWER_IP_PRIVATE_SW_MINOR_VERSION_C != POWER_IP_PRIVATE_SW_MINOR_VERSION) || \
  100. (POWER_IP_PRIVATE_SW_PATCH_VERSION_C != POWER_IP_PRIVATE_SW_PATCH_VERSION) \
  101. )
  102. #error "Software Version Numbers of Power_Ip_Private.c and Power_Ip_Private.h are different"
  103. #endif
  104. /*==================================================================================================
  105. LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  106. ==================================================================================================*/
  107. /*==================================================================================================
  108. LOCAL MACROS
  109. ==================================================================================================*/
  110. /*==================================================================================================
  111. LOCAL CONSTANTS
  112. ==================================================================================================*/
  113. /*==================================================================================================
  114. LOCAL VARIABLES
  115. ==================================================================================================*/
  116. /*==================================================================================================
  117. GLOBAL CONSTANTS
  118. ==================================================================================================*/
  119. /*==================================================================================================
  120. GLOBAL VARIABLES
  121. ==================================================================================================*/
  122. /*==================================================================================================
  123. LOCAL FUNCTION PROTOTYPES
  124. ==================================================================================================*/
  125. #define MCU_START_SEC_CODE
  126. #include "Mcu_MemMap.h"
  127. /*==================================================================================================
  128. LOCAL FUNCTIONS
  129. ==================================================================================================*/
  130. /*==================================================================================================
  131. GLOBAL FUNCTIONS
  132. ==================================================================================================*/
  133. void ReportPowerErrors(Power_Ip_PowerReportErrorType error, uint8 u8ErrorCode)
  134. {
  135. powerReportErrorsCallback(error, u8ErrorCode);
  136. }
  137. void ReportPowerErrorsEmptyCallback(Power_Ip_PowerReportErrorType error, uint8 u8ErrorCode)
  138. {
  139. /* No implementation */
  140. (void)error;
  141. (void)u8ErrorCode;
  142. }
  143. /*FUNCTION**********************************************************************
  144. *
  145. * Function Name : PowerStartTimeout
  146. * Description : Checks for timeout condition
  147. *
  148. *END**************************************************************************/
  149. void PowerStartTimeout(uint32 *startTimeOut,
  150. uint32 *elapsedTimeOut,
  151. uint32 *timeoutTicksOut,
  152. uint32 timeoutUs)
  153. {
  154. *startTimeOut = OsIf_GetCounter(POWER_TIMEOUT_TYPE);
  155. *elapsedTimeOut = 0U;
  156. *timeoutTicksOut = OsIf_MicrosToTicks(timeoutUs, POWER_TIMEOUT_TYPE);
  157. }
  158. /*FUNCTION**********************************************************************
  159. *
  160. * Function Name : PowerTimeoutExpired
  161. * Description : Checks for timeout expiration condition
  162. *
  163. *END**************************************************************************/
  164. boolean PowerTimeoutExpired(uint32 *startTimeInOut,
  165. uint32 *elapsedTimeInOut,
  166. uint32 TimeoutTicks)
  167. {
  168. *elapsedTimeInOut += OsIf_GetElapsed(startTimeInOut, POWER_TIMEOUT_TYPE);
  169. return ((*elapsedTimeInOut >= TimeoutTicks)? TRUE : FALSE);
  170. }
  171. #define MCU_STOP_SEC_CODE
  172. #include "Mcu_MemMap.h"
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. /** @} */