Wdg_Ipw.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : Wdog,Ewm
  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
  26. *
  27. * @addtogroup Wdg
  28. * @{
  29. */
  30. /*==================================================================================================
  31. * INCLUDE FILES
  32. * 1) system and project includes
  33. * 2) needed interfaces from external units
  34. * 3) internal and external interfaces from this unit
  35. ==================================================================================================*/
  36. #include "Wdg_Ipw.h"
  37. #include "Det.h"
  38. /*==================================================================================================
  39. * SOURCE FILE VERSION INFORMATION
  40. ==================================================================================================*/
  41. #define WDG_IPW_VENDOR_ID_C 43
  42. #define WDG_IPW_AR_RELEASE_MAJOR_VERSION_C 4
  43. #define WDG_IPW_AR_RELEASE_MINOR_VERSION_C 4
  44. #define WDG_IPW_AR_RELEASE_REVISION_VERSION_C 0
  45. #define WDG_IPW_SW_MAJOR_VERSION_C 1
  46. #define WDG_IPW_SW_MINOR_VERSION_C 0
  47. #define WDG_IPW_SW_PATCH_VERSION_C 0
  48. /*==================================================================================================
  49. * FILE VERSION CHECKS
  50. ==================================================================================================*/
  51. /* Check if current file and Wdg_Ipw header file are of the same vendor */
  52. #if (WDG_IPW_VENDOR_ID_C != WDG_IPW_VENDOR_ID)
  53. #error "Wdg_Ipw.c and Wdg_Ipw.h have different vendor ids"
  54. #endif
  55. #if ((WDG_IPW_AR_RELEASE_MAJOR_VERSION_C != WDG_IPW_AR_RELEASE_MAJOR_VERSION) || \
  56. (WDG_IPW_AR_RELEASE_MINOR_VERSION_C != WDG_IPW_AR_RELEASE_MINOR_VERSION) || \
  57. (WDG_IPW_AR_RELEASE_REVISION_VERSION_C != WDG_IPW_AR_RELEASE_REVISION_VERSION))
  58. #error "AutoSar Version Numbers of Wdg_Ipw.c and Wdg_Ipw.h are different"
  59. #endif
  60. #if ((WDG_IPW_SW_MAJOR_VERSION_C != WDG_IPW_SW_MAJOR_VERSION) || \
  61. (WDG_IPW_SW_MINOR_VERSION_C != WDG_IPW_SW_MINOR_VERSION) || \
  62. (WDG_IPW_SW_PATCH_VERSION_C != WDG_IPW_SW_PATCH_VERSION))
  63. #error "Software Version Numbers of Wdg_Ipw.c and Wdg_Ipw.h are different"
  64. #endif
  65. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  66. /* Check if current file and Det header file are of the same Autosar version */
  67. #if ((WDG_IPW_AR_RELEASE_MAJOR_VERSION_C != DET_AR_RELEASE_MAJOR_VERSION) || \
  68. (WDG_IPW_AR_RELEASE_MINOR_VERSION_C != DET_AR_RELEASE_MINOR_VERSION))
  69. #error "AutoSar Version Numbers of Wdg_Ipw.c and Det.h are different"
  70. #endif
  71. #endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */
  72. /*==================================================================================================
  73. * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  74. ==================================================================================================*/
  75. /*==================================================================================================
  76. * LOCAL MACROS
  77. ==================================================================================================*/
  78. /*==================================================================================================
  79. * LOCAL CONSTANTS
  80. ==================================================================================================*/
  81. /*==================================================================================================
  82. * LOCAL VARIABLES
  83. ==================================================================================================*/
  84. #define WDG_START_SEC_VAR_INIT_UNSPECIFIED
  85. #include "Wdg_MemMap.h"
  86. static Wdg_Ipw_IpType aeWdg_Ipw_Ip[2] = {WDG_IPW_UNINIT_IP, WDG_IPW_UNINIT_IP};
  87. #define WDG_STOP_SEC_VAR_INIT_UNSPECIFIED
  88. #include "Wdg_MemMap.h"
  89. /*==================================================================================================
  90. * GLOBAL CONSTANTS
  91. ==================================================================================================*/
  92. /*==================================================================================================
  93. * GLOBAL VARIABLES
  94. ==================================================================================================*/
  95. /*==================================================================================================
  96. * LOCAL FUNCTION PROTOTYPES
  97. ==================================================================================================*/
  98. /*==================================================================================================
  99. * LOCAL FUNCTIONS
  100. ==================================================================================================*/
  101. /*==================================================================================================
  102. * GLOBAL FUNCTIONS
  103. ==================================================================================================*/
  104. #ifdef WDG_ROM
  105. #if (WDG_ROM == 1U)
  106. #define WDG_START_SEC_CODE
  107. #endif
  108. #else
  109. #if (WDG_RAM == 0U)
  110. #define WDG_START_SEC_RAMCODE
  111. #endif
  112. #endif
  113. #include "Wdg_MemMap.h"
  114. Std_ReturnType Wdg_Ipw_Init(Wdg_Ipw_InstanceType Wdg_Instance, const Wdg_Ipw_ConfigType * const pIpwConfig)
  115. {
  116. Std_ReturnType ret = (Std_ReturnType) E_OK;
  117. #if(WDOG_IP_USED == STD_ON)
  118. Wdog_Ip_StatusType retIp = WDOG_IP_STATUS_SUCCESS;
  119. #endif /*(WDOG_IP_USED == STD_ON)*/
  120. aeWdg_Ipw_Ip[Wdg_Instance] = pIpwConfig->eWdgIp;
  121. switch (pIpwConfig->eWdgIp)
  122. {
  123. #if(WDOG_IP_USED == STD_ON)
  124. case WDG_IPW_WDOG_IP:
  125. retIp = Wdog_Ip_Init((uint8)Wdg_Instance, pIpwConfig->pWdogConfig);
  126. if (retIp != WDOG_IP_STATUS_SUCCESS)
  127. {
  128. if(retIp == WDOG_IP_STATUS_TIMEOUT)
  129. {
  130. /* Raise a runtime det for Osif timeout expired*/
  131. (void)Det_ReportRuntimeError((uint16)WDG_IPW_MODULE_ID, (uint8)Wdg_Instance, (uint8)WDG_IPW_INIT_ID, (uint8)WDG_IPW_E_PARAM_TIMEOUT);
  132. }
  133. ret = (Std_ReturnType) E_NOT_OK;
  134. }
  135. break;
  136. #endif /*(WDOG_IP_USED == STD_ON)*/
  137. #if(EWM_IP_USED == STD_ON)
  138. case WDG_IPW_EWM_IP:
  139. (void)Wdg_Instance;
  140. if (Ewm_Ip_Init((uint8)0, pIpwConfig->pEwmConfig) != EWM_IP_STATUS_SUCCESS)
  141. {
  142. ret = (Std_ReturnType) E_NOT_OK;
  143. }
  144. break;
  145. #endif /*(EWM_IP_USED == STD_ON)*/
  146. default:
  147. ret = (Std_ReturnType) E_NOT_OK;
  148. break;
  149. }
  150. return ret;
  151. }
  152. Std_ReturnType Wdg_Ipw_SetMode(Wdg_Ipw_InstanceType Wdg_Instance, const Wdg_Ipw_ConfigType * const pIpwConfig)
  153. {
  154. Std_ReturnType ret = (Std_ReturnType) E_OK;
  155. #if(WDOG_IP_USED == STD_ON)
  156. Wdog_Ip_StatusType retIp = WDOG_IP_STATUS_SUCCESS;
  157. #endif /*(WDOG_IP_USED == STD_ON)*/
  158. aeWdg_Ipw_Ip[Wdg_Instance] = pIpwConfig->eWdgIp;
  159. switch (aeWdg_Ipw_Ip[Wdg_Instance])
  160. {
  161. #if(WDOG_IP_USED == STD_ON)
  162. case WDG_IPW_WDOG_IP:
  163. retIp = Wdog_Ip_Config((uint8)Wdg_Instance, pIpwConfig->pWdogConfig);
  164. if (retIp != WDOG_IP_STATUS_SUCCESS)
  165. {
  166. if(retIp == WDOG_IP_STATUS_TIMEOUT)
  167. {
  168. /* Raise a runtime det for Osif timeout expired*/
  169. (void)Det_ReportRuntimeError((uint16)WDG_IPW_MODULE_ID, (uint8)Wdg_Instance, (uint8)WDG_IPW_SETMODE_ID, (uint8)WDG_IPW_E_PARAM_TIMEOUT);
  170. }
  171. ret = (Std_ReturnType) E_NOT_OK;
  172. }
  173. break;
  174. #endif /*(WDOG_IP_USED == STD_ON)*/
  175. #if(EWM_IP_USED == STD_ON)
  176. case WDG_IPW_EWM_IP:
  177. (void)pIpwConfig;
  178. ret = (Std_ReturnType) E_NOT_OK;
  179. break;
  180. #endif /*(EWM_IP_USED == STD_ON)*/
  181. default:
  182. ret = (Std_ReturnType) E_NOT_OK;
  183. break;
  184. }
  185. return ret;
  186. }
  187. Std_ReturnType Wdg_Ipw_StartTimer(Wdg_Ipw_InstanceType Wdg_Instance)
  188. {
  189. Std_ReturnType ret = (Std_ReturnType) E_OK;
  190. #if(WDOG_IP_USED == STD_ON)
  191. Wdog_Ip_StatusType retIp = WDOG_IP_STATUS_SUCCESS;
  192. #endif /*(WDOG_IP_USED == STD_ON)*/
  193. switch (aeWdg_Ipw_Ip[Wdg_Instance])
  194. {
  195. #if(WDOG_IP_USED == STD_ON)
  196. case WDG_IPW_WDOG_IP:
  197. retIp = Wdog_Ip_StartTimer((uint8)Wdg_Instance);
  198. if (retIp != WDOG_IP_STATUS_SUCCESS)
  199. {
  200. if(retIp == WDOG_IP_STATUS_TIMEOUT)
  201. {
  202. /* Raise a runtime det for Osif timeout expired*/
  203. (void)Det_ReportRuntimeError((uint16)WDG_IPW_MODULE_ID, (uint8)Wdg_Instance, (uint8)WDG_IPW_SETMODE_ID, (uint8)WDG_IPW_E_PARAM_TIMEOUT);
  204. }
  205. ret = (Std_ReturnType) E_NOT_OK;
  206. }
  207. break;
  208. #endif /*(WDOG_IP_USED == STD_ON)*/
  209. #if(EWM_IP_USED == STD_ON)
  210. case WDG_IPW_EWM_IP:
  211. ret = (Std_ReturnType) E_NOT_OK;
  212. break;
  213. #endif /*(EWM_IP_USED == STD_ON)*/
  214. default:
  215. ret = (Std_ReturnType) E_NOT_OK;
  216. break;
  217. }
  218. return ret;
  219. }
  220. #if (WDG_IPW_DEINIT == STD_ON)
  221. Std_ReturnType Wdg_Ipw_StopTimer(Wdg_Ipw_InstanceType Wdg_Instance)
  222. {
  223. Std_ReturnType ret = (Std_ReturnType) E_OK;
  224. #if(WDOG_IP_USED == STD_ON)
  225. Wdog_Ip_StatusType retIp = WDOG_IP_STATUS_SUCCESS;
  226. #endif /*(WDOG_IP_USED == STD_ON)*/
  227. switch (aeWdg_Ipw_Ip[Wdg_Instance])
  228. {
  229. #if(WDOG_IP_USED == STD_ON)
  230. case WDG_IPW_WDOG_IP:
  231. retIp = Wdog_Ip_StopTimer((uint8)Wdg_Instance);
  232. if (retIp != WDOG_IP_STATUS_SUCCESS)
  233. {
  234. if(retIp == WDOG_IP_STATUS_TIMEOUT)
  235. {
  236. /* Raise a runtime det for Osif timeout expired*/
  237. (void)Det_ReportRuntimeError((uint16)WDG_IPW_MODULE_ID, (uint8)Wdg_Instance, (uint8)WDG_IPW_SETMODE_ID, (uint8)WDG_IPW_E_PARAM_TIMEOUT);
  238. }
  239. ret = (Std_ReturnType) E_NOT_OK;
  240. }
  241. break;
  242. #endif /*(WDOG_IP_USED == STD_ON)*/
  243. #if(EWM_IP_USED == STD_ON)
  244. case WDG_IPW_EWM_IP:
  245. ret = (Std_ReturnType) E_NOT_OK;
  246. break;
  247. #endif /*(EWM_IP_USED == STD_ON)*/
  248. default:
  249. ret = (Std_ReturnType) E_NOT_OK;
  250. break;
  251. }
  252. return ret;
  253. }
  254. #endif
  255. void Wdg_Ipw_Service(Wdg_Ipw_InstanceType Wdg_Instance)
  256. {
  257. switch (aeWdg_Ipw_Ip[Wdg_Instance])
  258. {
  259. #if(WDOG_IP_USED == STD_ON)
  260. case WDG_IPW_WDOG_IP:
  261. Wdog_Ip_Service((uint8)Wdg_Instance);
  262. break;
  263. #endif /*(WDOG_IP_USED == STD_ON)*/
  264. #if(EWM_IP_USED == STD_ON)
  265. case WDG_IPW_EWM_IP:
  266. (void)Wdg_Instance;
  267. Ewm_Ip_Service((uint8)0);
  268. break;
  269. #endif /*(EWM_IP_USED == STD_ON)*/
  270. default:
  271. /* do nothing*/
  272. break;
  273. }
  274. }
  275. #ifdef WDG_ROM
  276. #if (WDG_ROM == 1U)
  277. #define WDG_STOP_SEC_CODE
  278. #endif
  279. #else
  280. #if (WDG_RAM == 0U)
  281. #define WDG_STOP_SEC_RAMCODE
  282. #endif
  283. #endif
  284. #include "Wdg_MemMap.h"
  285. /** @} */