FlexCAN_Ip_Irq.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : FLEXCAN
  5. * Dependencies :
  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 FlexCAN_Ip_Irq.c
  26. *
  27. * @brief FlexCAN Interrupts
  28. *
  29. * @addtogroup FlexCAN
  30. * @{
  31. */
  32. /*==================================================================================================
  33. * INCLUDE FILES
  34. * 1) system and project includes
  35. * 2) needed interfaces from external units
  36. * 3) internal and external interfaces from this unit
  37. ==================================================================================================*/
  38. #include "FlexCAN_Ip_Irq.h"
  39. #include "FlexCAN_Ip_HwAccess.h"
  40. /*==================================================================================================
  41. * SOURCE FILE VERSION INFORMATION
  42. ==================================================================================================*/
  43. #define FLEXCAN_IP_IRQ_VENDOR_ID_C 43
  44. #define FLEXCAN_IP_IRQ_AR_RELEASE_MAJOR_VERSION_C 4
  45. #define FLEXCAN_IP_IRQ_AR_RELEASE_MINOR_VERSION_C 4
  46. #define FLEXCAN_IP_IRQ_AR_RELEASE_REVISION_VERSION_C 0
  47. #define FLEXCAN_IP_IRQ_SW_MAJOR_VERSION_C 1
  48. #define FLEXCAN_IP_IRQ_SW_MINOR_VERSION_C 0
  49. #define FLEXCAN_IP_IRQ_SW_PATCH_VERSION_C 0
  50. /*==================================================================================================
  51. * FILE VERSION CHECKS
  52. ==================================================================================================*/
  53. /* Check if current file and FlexCAN_Ip_Irq header file are of the same vendor */
  54. #if (FLEXCAN_IP_IRQ_VENDOR_ID_C != FLEXCAN_IP_IRQ_VENDOR_ID_H)
  55. #error "FlexCAN_Ip_Irq.c and FlexCAN_Ip_Irq.h have different vendor ids"
  56. #endif
  57. /* Check if current file and FlexCAN_Ip_Irq header file are of the same Autosar version */
  58. #if ((FLEXCAN_IP_IRQ_AR_RELEASE_MAJOR_VERSION_C != FLEXCAN_IP_IRQ_AR_RELEASE_MAJOR_VERSION_H) || \
  59. (FLEXCAN_IP_IRQ_AR_RELEASE_MINOR_VERSION_C != FLEXCAN_IP_IRQ_AR_RELEASE_MINOR_VERSION_H) || \
  60. (FLEXCAN_IP_IRQ_AR_RELEASE_REVISION_VERSION_C != FLEXCAN_IP_IRQ_AR_RELEASE_REVISION_VERSION_H))
  61. #error "AutoSar Version Numbers of FlexCAN_Ip_Irq.c and FlexCAN_Ip_Irq.h are different"
  62. #endif
  63. /* Check if current file and FlexCAN_Ip_Irq header file are of the same Software version */
  64. #if ((FLEXCAN_IP_IRQ_SW_MAJOR_VERSION_C != FLEXCAN_IP_IRQ_SW_MAJOR_VERSION_H) || \
  65. (FLEXCAN_IP_IRQ_SW_MINOR_VERSION_C != FLEXCAN_IP_IRQ_SW_MINOR_VERSION_H) || \
  66. (FLEXCAN_IP_IRQ_SW_PATCH_VERSION_C != FLEXCAN_IP_IRQ_SW_PATCH_VERSION_H))
  67. #error "Software Version Numbers of FlexCAN_Ip_Irq.c and FlexCAN_Ip_Irq.h are different"
  68. #endif
  69. /* Check if current file and FlexCAN_Ip_HwAccess header file are of the same vendor */
  70. #if (FLEXCAN_IP_IRQ_VENDOR_ID_C != FLEXCAN_IP_HWACCESS_VENDOR_ID_H)
  71. #error "FlexCAN_Ip_Irq.c and FlexCAN_Ip_HwAccess.h have different vendor ids"
  72. #endif
  73. /* Check if current file and FlexCAN_Ip_HwAccess header file are of the same Autosar version */
  74. #if ((FLEXCAN_IP_IRQ_AR_RELEASE_MAJOR_VERSION_C != FLEXCAN_IP_HWACCESS_AR_RELEASE_MAJOR_VERSION_H) || \
  75. (FLEXCAN_IP_IRQ_AR_RELEASE_MINOR_VERSION_C != FLEXCAN_IP_HWACCESS_AR_RELEASE_MINOR_VERSION_H) || \
  76. (FLEXCAN_IP_IRQ_AR_RELEASE_REVISION_VERSION_C != FLEXCAN_IP_HWACCESS_AR_RELEASE_REVISION_VERSION_H))
  77. #error "AutoSar Version Numbers of FlexCAN_Ip_Irq.c and FlexCAN_Ip_HwAccess.h are different"
  78. #endif
  79. /* Check if current file and FlexCAN_Ip_HwAccess header file are of the same Software version */
  80. #if ((FLEXCAN_IP_IRQ_SW_MAJOR_VERSION_C != FLEXCAN_IP_HWACCESS_SW_MAJOR_VERSION_H) || \
  81. (FLEXCAN_IP_IRQ_SW_MINOR_VERSION_C != FLEXCAN_IP_HWACCESS_SW_MINOR_VERSION_H) || \
  82. (FLEXCAN_IP_IRQ_SW_PATCH_VERSION_C != FLEXCAN_IP_HWACCESS_SW_PATCH_VERSION_H))
  83. #error "Software Version Numbers of FlexCAN_Ip_Irq.c and FlexCAN_Ip_HwAccess.h are different"
  84. #endif
  85. /*==================================================================================================
  86. * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
  87. ==================================================================================================*/
  88. /*==================================================================================================
  89. * LOCAL MACROS
  90. ==================================================================================================*/
  91. /*==================================================================================================
  92. * LOCAL CONSTANTS
  93. ==================================================================================================*/
  94. /*==================================================================================================
  95. * GLOBAL CONSTANTS
  96. ==================================================================================================*/
  97. /*==================================================================================================
  98. * GLOBAL VARIABLES
  99. ==================================================================================================*/
  100. /*==================================================================================================
  101. * FUNCTION PROTOTYPES
  102. ==================================================================================================*/
  103. #define CAN_START_SEC_CODE
  104. #include "Can_MemMap.h"
  105. #if (defined(S32K118) || defined(S32K116))
  106. ISR(CAN0_ORED_IRQHandler);
  107. ISR(CAN0_ORED_0_31_MB_IRQHandler);
  108. #else
  109. ISR(CAN0_ORED_IRQHandler);
  110. ISR(CAN0_Error_IRQHandler);
  111. #if (FLEXCAN_IP_FEATURE_HAS_PRETENDED_NETWORKING == STD_ON)
  112. ISR(CAN0_Wake_Up_IRQHandler);
  113. #endif
  114. ISR(CAN0_ORED_0_15_MB_IRQHandler);
  115. ISR(CAN0_ORED_16_31_MB_IRQHandler);
  116. #endif
  117. #if (defined(S32K142W) || defined(S32K144W))
  118. ISR(CAN0_ORED_32_47_MB_IRQHandler);
  119. ISR(CAN0_ORED_48_63_MB_IRQHandler);
  120. #endif /* (defined(S32K142W) || defined(S32K144W)) */
  121. #if (FLEXCAN_INSTANCE_COUNT > 1U)
  122. ISR(CAN1_ORED_IRQHandler);
  123. ISR(CAN1_Error_IRQHandler);
  124. ISR(CAN1_ORED_0_15_MB_IRQHandler);
  125. ISR(CAN1_ORED_16_31_MB_IRQHandler);
  126. #if (defined(S32K142W) || defined(S32K144W))
  127. ISR(CAN1_ORED_32_47_MB_IRQHandler);
  128. ISR(CAN1_ORED_48_63_MB_IRQHandler);
  129. #endif /* (defined(S32K142W) || defined(S32K144W)) */
  130. #endif /* (FLEXCAN_INSTANCE_COUNT > 1U) */
  131. #if (FLEXCAN_INSTANCE_COUNT > 2U)
  132. ISR(CAN2_ORED_IRQHandler);
  133. ISR(CAN2_Error_IRQHandler);
  134. ISR(CAN2_ORED_0_15_MB_IRQHandler);
  135. #if defined(S32K148)
  136. ISR(CAN2_ORED_16_31_MB_IRQHandler);
  137. #endif
  138. #endif /* (FLEXCAN_INSTANCE_COUNT > 2U) */
  139. /*==================================================================================================
  140. * GLOBAL FUNCTIONS
  141. ==================================================================================================*/
  142. #if (defined(S32K118) || defined(S32K116))
  143. /* Implementation of CAN0 IRQ handler for interrupts indicating a successful
  144. transmission or reception for Message Buffers 0-31. Used for K11x derivatives.*/
  145. ISR(CAN0_ORED_0_31_MB_IRQHandler)
  146. {
  147. FlexCAN_IRQHandler(0U, 0U, 31U);
  148. }
  149. /* Implementation of CAN0 handler named in startup code for processing of Errors and Bus Off reporting. */
  150. ISR(CAN0_ORED_IRQHandler)
  151. {
  152. FlexCAN_Busoff_Error_IRQHandler(0U);
  153. }
  154. #else
  155. /* Implementation of CAN0 handler named in startup code for processing of Tx\Rx Warning and Bus Off reporting. */
  156. ISR(CAN0_ORED_IRQHandler)
  157. {
  158. FlexCAN_BusOff_IRQHandler(0U);
  159. EXIT_INTERRUPT();
  160. }
  161. /* Implementation of CAN0 handler named in startup code for processing of Errors reporting. */
  162. ISR(CAN0_Error_IRQHandler)
  163. {
  164. FlexCAN_Error_IRQHandler(0U);
  165. EXIT_INTERRUPT();
  166. }
  167. #if (FLEXCAN_IP_FEATURE_HAS_PRETENDED_NETWORKING == STD_ON)
  168. ISR(CAN0_Wake_Up_IRQHandler)
  169. {
  170. FlexCAN_WakeUp_IRQHandler(0U);
  171. EXIT_INTERRUPT();
  172. }
  173. #endif
  174. /* Implementation of CAN0 IRQ handler for interrupts indicating a successful
  175. transmission or reception for Message Buffers 0-15. */
  176. ISR(CAN0_ORED_0_15_MB_IRQHandler)
  177. {
  178. FlexCAN_IRQHandler(0U, 0U, 15U);
  179. EXIT_INTERRUPT();
  180. }
  181. /* Implementation of CAN0 IRQ handler for interrupts indicating a successful
  182. transmission or reception for Message Buffers 16-31. */
  183. ISR(CAN0_ORED_16_31_MB_IRQHandler)
  184. {
  185. FlexCAN_IRQHandler(0U, 16U, 31U);
  186. EXIT_INTERRUPT();
  187. }
  188. #endif /* (defined(S32K118) || defined(S32K116)) */
  189. #if (defined(S32K142W) || defined(S32K144W))
  190. /* Implementation of CAN0 IRQ handler for interrupts indicating a successful
  191. transmission or reception for Message Buffers 32-47. */
  192. ISR(CAN0_ORED_32_47_MB_IRQHandler)
  193. {
  194. FlexCAN_IRQHandler(0U, 32U, 47U);
  195. EXIT_INTERRUPT();
  196. }
  197. /* Implementation of CAN0 IRQ handler for interrupts indicating a successful
  198. transmission or reception for Message Buffers 48-63. */
  199. ISR(CAN0_ORED_48_63_MB_IRQHandler)
  200. {
  201. FlexCAN_IRQHandler(0U, 48U, 63U);
  202. EXIT_INTERRUPT();
  203. }
  204. #endif
  205. #if (FLEXCAN_INSTANCE_COUNT > 1U)
  206. /* Implementation of CAN1 handler named in startup code for processing of Tx\Rx Warning and Bus Off reporting. */
  207. ISR(CAN1_ORED_IRQHandler)
  208. {
  209. FlexCAN_BusOff_IRQHandler(1U);
  210. EXIT_INTERRUPT();
  211. }
  212. /* Implementation of CAN1 handler named in startup code for processing of Errors reporting. */
  213. ISR(CAN1_Error_IRQHandler)
  214. {
  215. FlexCAN_Error_IRQHandler(1U);
  216. EXIT_INTERRUPT();
  217. }
  218. /* Implementation of CAN1 IRQ handler for interrupts indicating a successful
  219. transmission or reception for Message Buffers 0-15. */
  220. ISR(CAN1_ORED_0_15_MB_IRQHandler)
  221. {
  222. FlexCAN_IRQHandler(1U, 0U, 15U);
  223. EXIT_INTERRUPT();
  224. }
  225. /* Implementation of CAN1 IRQ handler for interrupts indicating a successful
  226. transmission or reception for Message Buffers 16-31. */
  227. ISR(CAN1_ORED_16_31_MB_IRQHandler)
  228. {
  229. FlexCAN_IRQHandler(1U, 16U, 31U);
  230. EXIT_INTERRUPT();
  231. }
  232. #if (defined(S32K142W) || defined(S32K144W))
  233. /* Implementation of CAN1 IRQ handler for interrupts indicating a successful
  234. transmission or reception for Message Buffers 32-47. */
  235. ISR(CAN1_ORED_32_47_MB_IRQHandler)
  236. {
  237. FlexCAN_IRQHandler(1U, 32U, 47U);
  238. EXIT_INTERRUPT();
  239. }
  240. /* Implementation of CAN1 IRQ handler for interrupts indicating a successful
  241. transmission or reception for Message Buffers 48-63. */
  242. ISR(CAN1_ORED_48_63_MB_IRQHandler)
  243. {
  244. FlexCAN_IRQHandler(1U, 48U, 63U);
  245. EXIT_INTERRUPT();
  246. }
  247. #endif /* #if (defined(S32K142W) || defined(S32K144W)) */
  248. #endif /* (FLEXCAN_INSTANCE_COUNT > 1U) */
  249. #if (FLEXCAN_INSTANCE_COUNT > 2U)
  250. /* Implementation of CAN2 handler named in startup code for processing of Errors and Bus Off reporting. */
  251. ISR(CAN2_ORED_IRQHandler)
  252. {
  253. FlexCAN_BusOff_IRQHandler(2U);
  254. EXIT_INTERRUPT();
  255. }
  256. /* Implementation of CAN1 handler named in startup code for processing of Errors reporting. */
  257. ISR(CAN2_Error_IRQHandler)
  258. {
  259. FlexCAN_Error_IRQHandler(2U);
  260. EXIT_INTERRUPT();
  261. }
  262. /* Implementation of CAN2 IRQ handler for interrupts indicating a successful
  263. transmission or reception for Message Buffers 0-15. */
  264. ISR(CAN2_ORED_0_15_MB_IRQHandler)
  265. {
  266. FlexCAN_IRQHandler(2U, 0U, 15U);
  267. EXIT_INTERRUPT();
  268. }
  269. #if defined(S32K148)
  270. /* Implementation of CAN2 IRQ handler for interrupts indicating a successful
  271. transmission or reception for Message Buffers 16-31. */
  272. ISR(CAN2_ORED_16_31_MB_IRQHandler)
  273. {
  274. FlexCAN_IRQHandler(2U, 16U, 31U);
  275. EXIT_INTERRUPT();
  276. }
  277. #endif
  278. #endif /* (FLEXCAN_INSTANCE_COUNT > 2U) */
  279. #define CAN_STOP_SEC_CODE
  280. #include "Can_MemMap.h"
  281. /** @} */