Det_stub.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 Det_stub.c
  26. *
  27. * @addtogroup DET_MODULE
  28. * @{
  29. */
  30. #ifdef __cplusplus
  31. extern "C"{
  32. #endif
  33. /*==================================================================================================
  34. * INCLUDE FILES
  35. * 1) system and project includes
  36. * 2) needed interfaces from external units
  37. * 3) internal and external interfaces from this unit
  38. ==================================================================================================*/
  39. #include "Mcal.h"
  40. #include "OsIf.h"
  41. #include "Det_stub.h"
  42. /*==================================================================================================
  43. * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  44. ==================================================================================================*/
  45. /*==================================================================================================
  46. * LOCAL MACROS
  47. ==================================================================================================*/
  48. /*==================================================================================================
  49. * LOCAL CONSTANTS
  50. ==================================================================================================*/
  51. /*==================================================================================================
  52. * LOCAL VARIABLES
  53. ==================================================================================================*/
  54. /*==================================================================================================
  55. * GLOBAL CONSTANTS
  56. ==================================================================================================*/
  57. /*==================================================================================================
  58. * GLOBAL VARIABLES
  59. ==================================================================================================*/
  60. /*==================================================================================================
  61. * LOCAL FUNCTION PROTOTYPES
  62. ==================================================================================================*/
  63. /*==================================================================================================
  64. * LOCAL FUNCTIONS
  65. ==================================================================================================*/
  66. /*==================================================================================================
  67. * GLOBAL FUNCTIONS
  68. ==================================================================================================*/
  69. #define DET_START_SEC_CODE
  70. #include "Det_MemMap.h"
  71. /*================================================================================================*/
  72. /**
  73. * @brief Tests if an expected error has been reported to DET
  74. * @details Tests if an expected error has been reported to DET
  75. *
  76. * @param[in] ModuleId - ID of the module reporting the error
  77. * @param[in] InstanceId - ID of the Instance reporting the error
  78. * @param[in] APIId - ID of the API where the error has been generated from
  79. * @param[in] ErrorId - Error Code
  80. * @return boolean - true in case expected error has been found
  81. *
  82. */
  83. boolean Det_TestLastReportError(uint16 ModuleId, uint8 InstanceId, uint8 ApiId, uint8 ErrorId) {
  84. boolean result = FALSE;
  85. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  86. result = (Det_ModuleId[u32CoreId] == ModuleId) && (Det_InstanceId[u32CoreId] == InstanceId) &&
  87. (Det_ApiId[u32CoreId] == ApiId) && (Det_ErrorId[u32CoreId] == ErrorId);
  88. Det_ModuleId[u32CoreId] = 0;
  89. Det_InstanceId[u32CoreId] = 0;
  90. Det_ApiId[u32CoreId] = 0;
  91. Det_ErrorId[u32CoreId] = 0;
  92. return result;
  93. }
  94. /*================================================================================================*/
  95. /**
  96. * @brief Tests if an expected error has been reported to DET
  97. * @details Tests if an expected error has been reported to DET
  98. *
  99. * @param[in] ModuleId - ID of the module reporting the error
  100. * @param[in] InstanceId - ID of the Instance reporting the error
  101. * @param[in] APIId - ID of the API where the error has been generated from
  102. * @param[in] ErrorId - Error Code
  103. * @return boolean - true in case expected error has been found
  104. *
  105. */
  106. boolean Det_TestLastReportRuntimeError(uint16 ModuleId, uint8 InstanceId, uint8 ApiId, uint8 ErrorId) {
  107. boolean result = FALSE;
  108. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  109. result = (Det_RuntimeModuleId[u32CoreId] == ModuleId) && (Det_RuntimeInstanceId[u32CoreId] == InstanceId) &&
  110. (Det_RuntimeApiId[u32CoreId] == ApiId) && (Det_RuntimeErrorId[u32CoreId] == ErrorId);
  111. Det_RuntimeModuleId[u32CoreId] = 0;
  112. Det_RuntimeInstanceId[u32CoreId] = 0;
  113. Det_RuntimeApiId[u32CoreId] = 0;
  114. Det_RuntimeErrorId[u32CoreId] = 0;
  115. return result;
  116. }
  117. /*================================================================================================*/
  118. /**
  119. * @brief Tests if an expected error has been reported to DET
  120. * @details Tests if an expected error has been reported to DET
  121. *
  122. * @param[in] ModuleId - ID of the module reporting the error
  123. * @param[in] InstanceId - ID of the Instance reporting the error
  124. * @param[in] APIId - ID of the API where the error has been generated from
  125. * @param[in] ErrorId - Error Code
  126. * @return boolean - true in case expected error has been found
  127. *
  128. */
  129. boolean Det_TestLastReportTransientFault(uint16 ModuleId, uint8 InstanceId, uint8 ApiId, uint8 FaultId) {
  130. boolean result = FALSE;
  131. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  132. result = (Det_TransientModuleId[u32CoreId] == ModuleId) && (Det_TransientInstanceId[u32CoreId] == InstanceId) &&
  133. (Det_TransientApiId[u32CoreId] == ApiId) && (Det_TransientFaultId[u32CoreId] == FaultId);
  134. Det_TransientModuleId[u32CoreId] = 0;
  135. Det_TransientInstanceId[u32CoreId] = 0;
  136. Det_TransientApiId[u32CoreId] = 0;
  137. Det_TransientFaultId[u32CoreId] = 0;
  138. return result;
  139. }
  140. /*================================================================================================*/
  141. /**
  142. * @brief Tests if an error has been reported to DET
  143. * @details Tests if an error has been reported to DET
  144. *
  145. * @return boolean - true in case of NO error has been reported to DET
  146. *
  147. */
  148. boolean Det_TestNoError(void) {
  149. boolean result = FALSE;
  150. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  151. result = Det_ModuleId[u32CoreId] || Det_InstanceId[u32CoreId] || Det_ApiId[u32CoreId] || Det_ErrorId[u32CoreId];
  152. Det_ModuleId[u32CoreId] = 0;
  153. Det_InstanceId[u32CoreId] = 0;
  154. Det_ApiId[u32CoreId] = 0;
  155. Det_ErrorId[u32CoreId] = 0;
  156. return !result;
  157. }
  158. /*================================================================================================*/
  159. /**
  160. * @brief Tests if an runtime error has been reported to DET
  161. * @details Tests if an runtime error has been reported to DET
  162. *
  163. * @return boolean - true in case of NO error has been reported to DET
  164. *
  165. */
  166. boolean Det_TestNoRuntimeError(void) {
  167. boolean result = FALSE;
  168. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  169. result = Det_RuntimeModuleId[u32CoreId] || Det_RuntimeInstanceId[u32CoreId] || Det_RuntimeApiId[u32CoreId] || Det_RuntimeErrorId[u32CoreId];
  170. Det_RuntimeModuleId[u32CoreId] = 0;
  171. Det_RuntimeInstanceId[u32CoreId] = 0;
  172. Det_RuntimeApiId[u32CoreId] = 0;
  173. Det_RuntimeErrorId[u32CoreId] = 0;
  174. return !result;
  175. }
  176. /*================================================================================================*/
  177. /**
  178. * @brief Tests if an transient error has been reported to DET
  179. * @details Tests if an transient error has been reported to DET
  180. *
  181. * @return boolean - true in case of NO error has been reported to DET
  182. *
  183. */
  184. boolean Det_TestNoTransientFault(void) {
  185. boolean result = FALSE;
  186. uint32 u32CoreId = (uint32)OsIf_GetCoreID();
  187. result = Det_TransientModuleId[u32CoreId] || Det_TransientInstanceId[u32CoreId] || Det_TransientApiId[u32CoreId] || Det_TransientFaultId[u32CoreId];
  188. Det_TransientModuleId[u32CoreId] = 0;
  189. Det_TransientInstanceId[u32CoreId] = 0;
  190. Det_TransientApiId[u32CoreId] = 0;
  191. Det_TransientFaultId[u32CoreId] = 0;
  192. return !result;
  193. }
  194. #define DET_STOP_SEC_CODE
  195. #include "Det_MemMap.h"
  196. #ifdef __cplusplus
  197. }
  198. #endif
  199. /** @} */