FlexCAN_Ip_VS_0_PBcfg.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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_PBcfg.c
  26. *
  27. * @addtogroup FlexCAN
  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 "FlexCAN_Ip_Types.h"
  40. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  41. #include "Dma_Ip.h"
  42. #endif
  43. #include "USER_CONFIG.h"
  44. /*==================================================================================================
  45. * SOURCE FILE VERSION INFORMATION
  46. ==================================================================================================*/
  47. #define FLEXCAN_IP_VENDOR_ID_VS_0_PBCFG_C 43
  48. #define FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_C 4
  49. #define FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_C 4
  50. #define FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_VS_0_PBCFG_C 0
  51. #define FLEXCAN_IP_SW_MAJOR_VERSION_VS_0_PBCFG_C 1
  52. #define FLEXCAN_IP_SW_MINOR_VERSION_VS_0_PBCFG_C 0
  53. #define FLEXCAN_IP_SW_PATCH_VERSION_VS_0_PBCFG_C 0
  54. /*==================================================================================================
  55. * FILE VERSION CHECKS
  56. ==================================================================================================*/
  57. /* Check if current file and FlexCAN_Ip_Types header file are of the same vendor */
  58. #if (FLEXCAN_IP_VENDOR_ID_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_VENDOR_ID_H)
  59. #error "FlexCAN_Ip_VS_0_PBcfg.c and FlexCAN_Ip_Types.h have different vendor ids"
  60. #endif
  61. /* Check if current file and FlexCAN_Ip_Types header file are of the same Autosar version */
  62. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
  63. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
  64. (FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_AR_RELEASE_REVISION_VERSION_H) \
  65. )
  66. #error "AutoSar Version Numbers of FlexCAN_Ip_VS_0_PBcfg.c and FlexCAN_Ip_Types.h are different"
  67. #endif
  68. /* Check if current file and FlexCAN_Ip_Types header file are of the same Software version */
  69. #if ((FLEXCAN_IP_SW_MAJOR_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_SW_MAJOR_VERSION_H) || \
  70. (FLEXCAN_IP_SW_MINOR_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_SW_MINOR_VERSION_H) || \
  71. (FLEXCAN_IP_SW_PATCH_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_SW_PATCH_VERSION_H) \
  72. )
  73. #error "Software Version Numbers of FlexCAN_Ip_VS_0_PBcfg.c and FlexCAN_Ip_Types.h are different"
  74. #endif
  75. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  76. /* Checks against current file and Dma_Ip.h */
  77. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  78. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_C != DMA_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  79. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_C != DMA_IP_AR_RELEASE_MINOR_VERSION_H) \
  80. )
  81. #error "AUTOSAR Version Numbers of FlexCAN_Ip_VS_0_PBcfg.c and Dma_Ip.h are different"
  82. #endif
  83. #endif
  84. #endif
  85. /*==================================================================================================
  86. * GLOBAL FUNCTION PROTOTYPES
  87. ==================================================================================================*/
  88. #define CAN_START_SEC_CODE
  89. #include "Can_MemMap.h"
  90. extern void Can_CommonIrqCallback(uint8 u8Instance, Flexcan_Ip_EventType event, uint32 u32buffIdx, const Flexcan_Ip_StateType *driverState);
  91. extern void Can_ErrorIrqCallback(uint8 u8Instance, Flexcan_Ip_EventType event, uint32 u32ErrStatus, const Flexcan_Ip_StateType *driverState);
  92. #define CAN_STOP_SEC_CODE
  93. #include "Can_MemMap.h"
  94. /*==================================================================================================
  95. * GLOBAL VARIABLE DECLARATIONS
  96. ==================================================================================================*/
  97. /*==================================================================================================
  98. * GLOBAL CONSTANTS
  99. ==================================================================================================*/
  100. #define CAN_START_SEC_CONFIG_DATA_UNSPECIFIED
  101. #include "Can_MemMap.h"
  102. const Flexcan_Ip_ConfigType Flexcan_aCtrlConfigPB_VS_0[3U]=
  103. {
  104. /* Can Hardware Channel FLEXCAN_0 */
  105. {
  106. /* Number Of Message Buffer used .max_num_mb */
  107. (uint8)18U,
  108. /*Can Hw filter count* .num_id_filters */
  109. (Flexcan_Ip_RxFifoIdFilterNumType)((8U >> 3U) - 1U),
  110. /* Legacy FIFO ENABLED .is_rx_fifo_needed */
  111. (boolean)TRUE,
  112. #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
  113. /* The number of standard ID filter elements */
  114. 0U,
  115. /* The number of extended ID filter elements */
  116. 0U,
  117. /* The number of enhanced Rx FIFO watermark */
  118. -1U,
  119. /* The Enhanced Rx FIFO feature is enabled or not. */
  120. (boolean)FALSE,
  121. #endif
  122. /* Loopback enabled .flexcanMode */
  123. FLEXCAN_NORMAL_MODE,
  124. /* Controller Options .ctrlOptions */
  125. (uint32)( FLEXCAN_IP_BUSOFF_RECOVERY_U32 |FLEXCAN_IP_EACEN_U32),
  126. /* Can FD RamBlock specified .payload */
  127. {
  128. FLEXCAN_PAYLOAD_SIZE_8
  129. },
  130. /* Can FD enabled .fd_enable */
  131. (boolean)FALSE,
  132. #if (FLEXCAN_IP_FEATURE_HAS_PE_CLKSRC_SELECT == STD_ON)
  133. /* Can PE clock selected .is_pe_clock */
  134. (boolean)TRUE,
  135. #endif
  136. /* Cbt support .extCbtEnable */
  137. (boolean)FALSE,
  138. /* BRS for FD .bitRateSwitch */
  139. (boolean)FALSE,
  140. /* Values for normal baudrate .bitrate */
  141. {
  142. #if (defined CAN0_BAUDRATE)
  143. #if (CAN0_BAUDRATE == CAN_BAUDRATE_500K)
  144. (uint8)4U,
  145. (uint8)4U,
  146. (uint8)4U,
  147. (uint16)5,
  148. (uint8)3U
  149. #elif (CAN0_BAUDRATE == CAN_BAUDRATE_250K)
  150. (uint8)2U,
  151. (uint8)5U,
  152. (uint8)5U,
  153. (uint16)11,
  154. (uint8)3U
  155. #else
  156. #error "please define the baudrate of can0 (BAUDRATE_500K or BAUDRATE_250K)"
  157. #endif
  158. #else
  159. #error "please define the CAN0_BAUDRATE"
  160. #endif
  161. },
  162. /* Values for CBT baudrate .bitrate_cbt */
  163. {
  164. #if (defined CAN0_BAUDRATE)
  165. #if (CAN0_BAUDRATE == CAN_BAUDRATE_500K)
  166. (uint8)4U,
  167. (uint8)4U,
  168. (uint8)4U,
  169. (uint16)5U,
  170. (uint8)3U
  171. #elif (CAN0_BAUDRATE == CAN_BAUDRATE_250K)
  172. (uint8)2U,
  173. (uint8)5U,
  174. (uint8)5U,
  175. (uint16)11U,
  176. (uint8)3U
  177. #else
  178. #error "please define the baudrate of can0 (BAUDRATE_500K or BAUDRATE_250K)"
  179. #endif
  180. #else
  181. #error "please define the baudrate of can0"
  182. #endif
  183. },
  184. /* Fifo Transfer Type .transfer_type */
  185. FLEXCAN_RXFIFO_USING_POLLING,
  186. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  187. /* DMA channel number used for transfers. */
  188. (uint8)0U,
  189. #endif
  190. /* Controller Callback .Callback */
  191. Can_CommonIrqCallback,
  192. /* Error Callback .ErrorCallback */
  193. Can_ErrorIrqCallback
  194. },
  195. /* Can Hardware Channel FLEXCAN_1 */
  196. {
  197. /* Number Of Message Buffer used .max_num_mb */
  198. (uint8)18U,
  199. /*Can Hw filter count* .num_id_filters */
  200. (Flexcan_Ip_RxFifoIdFilterNumType)((8U >> 3U) - 1U),
  201. /* Legacy FIFO ENABLED .is_rx_fifo_needed */
  202. (boolean)TRUE,
  203. #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
  204. /* The number of standard ID filter elements */
  205. 0U,
  206. /* The number of extended ID filter elements */
  207. 0U,
  208. /* The number of enhanced Rx FIFO watermark */
  209. -1U,
  210. /* The Enhanced Rx FIFO feature is enabled or not. */
  211. (boolean)FALSE,
  212. #endif
  213. /* Loopback enabled .flexcanMode */
  214. FLEXCAN_NORMAL_MODE,
  215. /* Controller Options .ctrlOptions */
  216. (uint32)( FLEXCAN_IP_BUSOFF_RECOVERY_U32 |FLEXCAN_IP_EACEN_U32),
  217. /* Can FD RamBlock specified .payload */
  218. {
  219. FLEXCAN_PAYLOAD_SIZE_8
  220. },
  221. /* Can FD enabled .fd_enable */
  222. (boolean)FALSE,
  223. #if (FLEXCAN_IP_FEATURE_HAS_PE_CLKSRC_SELECT == STD_ON)
  224. /* Can PE clock selected .is_pe_clock */
  225. (boolean)TRUE,
  226. #endif
  227. /* Cbt support .extCbtEnable */
  228. (boolean)FALSE,
  229. /* BRS for FD .bitRateSwitch */
  230. (boolean)FALSE,
  231. /* Values for normal baudrate .bitrate */
  232. {
  233. #if (defined CAN1_BAUDRATE)
  234. #if (CAN1_BAUDRATE == CAN_BAUDRATE_500K)
  235. (uint8)4U,
  236. (uint8)4U,
  237. (uint8)4U,
  238. (uint16)5,
  239. (uint8)3U
  240. #elif (CAN1_BAUDRATE == CAN_BAUDRATE_250K)
  241. (uint8)2U,
  242. (uint8)5U,
  243. (uint8)5U,
  244. (uint16)11,
  245. (uint8)3U
  246. #else
  247. #error "please define the baudrate of can1 (BAUDRATE_500K or BAUDRATE_250K)"
  248. #endif
  249. #else
  250. #error "please define the CAN0_BAUDRATE"
  251. #endif
  252. },
  253. /* Values for CBT baudrate .bitrate_cbt */
  254. {
  255. #if (defined CAN1_BAUDRATE)
  256. #if (CAN1_BAUDRATE == CAN_BAUDRATE_500K)
  257. (uint8)4U,
  258. (uint8)4U,
  259. (uint8)4U,
  260. (uint16)5U,
  261. (uint8)3U
  262. #elif (CAN1_BAUDRATE == CAN_BAUDRATE_250K)
  263. (uint8)2U,
  264. (uint8)5U,
  265. (uint8)5U,
  266. (uint16)11U,
  267. (uint8)3U
  268. #else
  269. #error "please define the baudrate of can1 (BAUDRATE_500K or BAUDRATE_250K)"
  270. #endif
  271. #else
  272. #error "please define the baudrate of can1"
  273. #endif
  274. },
  275. /* Fifo Transfer Type .transfer_type */
  276. FLEXCAN_RXFIFO_USING_POLLING,
  277. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  278. /* DMA channel number used for transfers. */
  279. (uint8)0U,
  280. #endif
  281. /* Controller Callback .Callback */
  282. NULL_PTR,
  283. /* Error Callback .ErrorCallback */
  284. Can_ErrorIrqCallback
  285. },
  286. /* Can Hardware Channel FLEXCAN_2 */
  287. {
  288. /* Number Of Message Buffer used .max_num_mb */
  289. (uint8)15U,
  290. /*Can Hw filter count* .num_id_filters */
  291. (Flexcan_Ip_RxFifoIdFilterNumType)((8U >> 3U) - 1U),
  292. /* Legacy FIFO ENABLED .is_rx_fifo_needed */
  293. (boolean)TRUE,
  294. #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
  295. /* The number of standard ID filter elements */
  296. 0U,
  297. /* The number of extended ID filter elements */
  298. 0U,
  299. /* The number of enhanced Rx FIFO watermark */
  300. -1U,
  301. /* The Enhanced Rx FIFO feature is enabled or not. */
  302. (boolean)FALSE,
  303. #endif
  304. /* Loopback enabled .flexcanMode */
  305. FLEXCAN_NORMAL_MODE,
  306. /* Controller Options .ctrlOptions */
  307. (uint32)( FLEXCAN_IP_BUSOFF_RECOVERY_U32 |FLEXCAN_IP_EACEN_U32),
  308. /* Can FD RamBlock specified .payload */
  309. {
  310. FLEXCAN_PAYLOAD_SIZE_8
  311. },
  312. /* Can FD enabled .fd_enable */
  313. (boolean)FALSE,
  314. #if (FLEXCAN_IP_FEATURE_HAS_PE_CLKSRC_SELECT == STD_ON)
  315. /* Can PE clock selected .is_pe_clock */
  316. (boolean)TRUE,
  317. #endif
  318. /* Cbt support .extCbtEnable */
  319. (boolean)FALSE,
  320. /* BRS for FD .bitRateSwitch */
  321. (boolean)FALSE,
  322. /* Values for normal baudrate .bitrate */
  323. {
  324. #if (defined CAN2_BAUDRATE)
  325. #if (CAN2_BAUDRATE == CAN_BAUDRATE_500K)
  326. (uint8)4U,
  327. (uint8)4U,
  328. (uint8)4U,
  329. (uint16)5,
  330. (uint8)3U
  331. #elif (CAN2_BAUDRATE == CAN_BAUDRATE_250K)
  332. (uint8)2U,
  333. (uint8)5U,
  334. (uint8)5U,
  335. (uint16)11,
  336. (uint8)3U
  337. #else
  338. #error "please define the baudrate of can2 (BAUDRATE_500K or BAUDRATE_250K)"
  339. #endif
  340. #else
  341. #error "please define the CAN2_BAUDRATE"
  342. #endif
  343. },
  344. /* Values for CBT baudrate .bitrate_cbt */
  345. {
  346. #if (defined CAN2_BAUDRATE)
  347. #if (CAN2_BAUDRATE == CAN_BAUDRATE_500K)
  348. (uint8)4U,
  349. (uint8)4U,
  350. (uint8)4U,
  351. (uint16)5U,
  352. (uint8)3U
  353. #elif (CAN2_BAUDRATE == CAN_BAUDRATE_250K)
  354. (uint8)2U,
  355. (uint8)5U,
  356. (uint8)5U,
  357. (uint16)11U,
  358. (uint8)3U
  359. #else
  360. #error "please define the baudrate of can2 (BAUDRATE_500K or BAUDRATE_250K)"
  361. #endif
  362. #else
  363. #error "please define the baudrate of can2"
  364. #endif
  365. },
  366. /* Fifo Transfer Type .transfer_type */
  367. FLEXCAN_RXFIFO_USING_POLLING,
  368. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  369. /* DMA channel number used for transfers. */
  370. (uint8)0U,
  371. #endif
  372. /* Controller Callback .Callback */
  373. NULL_PTR,
  374. /* Error Callback .ErrorCallback */
  375. Can_ErrorIrqCallback
  376. }
  377. };
  378. /* PN array configuration */
  379. const Flexcan_Ip_PnConfigType Flexcan_aPnConfigPB_VS_0[1U]=
  380. {
  381. {
  382. /* Wakeup timeout enable .bWakeUpTimeout */
  383. (boolean)FALSE,
  384. /* Wakeup on mactch enable .bWakeUpMatch */
  385. (boolean)TRUE,
  386. /* The number of matches needed before generating an wake up event .u16numMatches */
  387. (uint16)1U,
  388. /* Defines a timeout value that generates an wake up event if wakeUpTimeout is true .u16matchTimeout */
  389. (uint16)0,
  390. /* Defines the filtering scheme used .eFilterComb */
  391. FLEXCAN_FILTER_ID_NTIMES,
  392. /* The configuration of the first ID filter .idFilter1 */
  393. {
  394. /* Specifies if the ID is standard or extended .bExtendedId */
  395. (boolean)TRUE,
  396. /* Specifies if the frame is standard or remote .bRemoteFrame */
  397. (boolean)FALSE,
  398. /* Specifies the ID value .u32Id */
  399. (uint32)0U
  400. },
  401. /* The configuration of the first ID filter .idFilter2 */
  402. {
  403. /* Specifies if the ID is standard or extended .bExtendedId */
  404. (boolean)TRUE,
  405. /* Specifies if the frame is standard or remote .bRemoteFrame */
  406. (boolean)TRUE,
  407. /* Specifies the ID value .u32Id */
  408. (boolean)0U,
  409. },
  410. /* Defines the ID filtering scheme .eIdFilterType */
  411. FLEXCAN_FILTER_MATCH_GEQ,
  412. /* Defines the payload filtering scheme. .ePayloadFilterType */
  413. FLEXCAN_FILTER_MATCH_EXACT,
  414. /* The configuration of the payload filter .payloadFilter */
  415. {
  416. (uint8)0U,
  417. (uint8)0U,
  418. {0U},
  419. {0U}
  420. }
  421. }
  422. };
  423. #define CAN_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  424. #include "Can_MemMap.h"
  425. #ifdef __cplusplus
  426. }
  427. #endif
  428. /** @} */