FlexCAN_Ip.h 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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. /* implements FlexCAN_Ip.h_Artifact */
  25. #ifndef FLEXCAN_FLEXCAN_IP_H_
  26. #define FLEXCAN_FLEXCAN_IP_H_
  27. /**
  28. * @file FlexCAN_Ip.h
  29. *
  30. * @brief FlexCAN Ip Driver Header File
  31. * @details FlexCAN Ip Driver Header File contains the APIs and structures exported by FlexCAN Driver
  32. *
  33. * @addtogroup FlexCAN
  34. * @{
  35. */
  36. #ifdef __cplusplus
  37. extern "C"{
  38. #endif
  39. /*==================================================================================================
  40. * INCLUDE FILES
  41. * 1) system and project includes
  42. * 2) needed interfaces from external units
  43. * 3) internal and external interfaces from this unit
  44. ==================================================================================================*/
  45. #include "Mcal.h"
  46. #include "FlexCAN_Ip_DeviceReg.h"
  47. #include "FlexCAN_Ip_Types.h"
  48. #include "Platform_Types.h"
  49. #include "FlexCAN_Ip_Cfg.h"
  50. #include "FlexCAN_Ip_Wrapper.h"
  51. /*==================================================================================================
  52. * SOURCE FILE VERSION INFORMATION
  53. ==================================================================================================*/
  54. #define FLEXCAN_IP_VENDOR_ID_H 43
  55. #define FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H 4
  56. #define FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H 4
  57. #define FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_H 0
  58. #define FLEXCAN_IP_SW_MAJOR_VERSION_H 1
  59. #define FLEXCAN_IP_SW_MINOR_VERSION_H 0
  60. #define FLEXCAN_IP_SW_PATCH_VERSION_H 0
  61. /*==================================================================================================
  62. * FILE VERSION CHECKS
  63. ==================================================================================================*/
  64. /* Check if current file and FlexCAN_Ip_DeviceReg header file are of the same vendor */
  65. #if (FLEXCAN_IP_VENDOR_ID_H != FLEXCAN_IP_DEVICEREG_VENDOR_ID_H)
  66. #error "FlexCAN_Ip.h and FlexCAN_Ip_DeviceReg.h have different vendor ids"
  67. #endif
  68. /* Check if current file and FlexCAN_Ip_DeviceReg header file are of the same Autosar version */
  69. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H != FLEXCAN_IP_DEVICEREG_AR_RELEASE_MAJOR_VERSION_H) || \
  70. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H != FLEXCAN_IP_DEVICEREG_AR_RELEASE_MINOR_VERSION_H) || \
  71. (FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_H != FLEXCAN_IP_DEVICEREG_AR_RELEASE_REVISION_VERSION_H) \
  72. )
  73. #error "AutoSar Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_DeviceReg.h are different"
  74. #endif
  75. /* Check if current file and FlexCAN_Ip_DeviceReg header file are of the same Software version */
  76. #if ((FLEXCAN_IP_SW_MAJOR_VERSION_H != FLEXCAN_IP_DEVICEREG_SW_MAJOR_VERSION_H) || \
  77. (FLEXCAN_IP_SW_MINOR_VERSION_H != FLEXCAN_IP_DEVICEREG_SW_MINOR_VERSION_H) || \
  78. (FLEXCAN_IP_SW_PATCH_VERSION_H != FLEXCAN_IP_DEVICEREG_SW_PATCH_VERSION_H) \
  79. )
  80. #error "Software Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_DeviceReg.h are different"
  81. #endif
  82. /* Check if current file and FlexCAN_Ip_Types header file are of the same vendor */
  83. #if (FLEXCAN_IP_VENDOR_ID_H != FLEXCAN_IP_TYPES_VENDOR_ID_H)
  84. #error "FlexCAN_Ip.h and FlexCAN_Ip_Types.h have different vendor ids"
  85. #endif
  86. /* Check if current file and FlexCAN_Ip_Types header file are of the same Autosar version */
  87. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H != FLEXCAN_IP_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
  88. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H != FLEXCAN_IP_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
  89. (FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_H != FLEXCAN_IP_TYPES_AR_RELEASE_REVISION_VERSION_H) \
  90. )
  91. #error "AutoSar Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_Types.h are different"
  92. #endif
  93. /* Check if current file and FlexCAN_Ip_Types header file are of the same Software version */
  94. #if ((FLEXCAN_IP_SW_MAJOR_VERSION_H != FLEXCAN_IP_TYPES_SW_MAJOR_VERSION_H) || \
  95. (FLEXCAN_IP_SW_MINOR_VERSION_H != FLEXCAN_IP_TYPES_SW_MINOR_VERSION_H) || \
  96. (FLEXCAN_IP_SW_PATCH_VERSION_H != FLEXCAN_IP_TYPES_SW_PATCH_VERSION_H) \
  97. )
  98. #error "Software Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_Types.h are different"
  99. #endif
  100. /* Check if current file and FlexCAN_Ip_Cfg header file are of the same vendor */
  101. #if (FLEXCAN_IP_VENDOR_ID_H != FLEXCAN_IP_CFG_VENDOR_ID_H)
  102. #error "FlexCAN_Ip.h and FlexCAN_Ip_Cfg.h have different vendor ids"
  103. #endif
  104. /* Check if current file and FlexCAN_Ip_Cfg header file are of the same Autosar version */
  105. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H != FLEXCAN_IP_CFG_AR_RELEASE_MAJOR_VERSION_H) || \
  106. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H != FLEXCAN_IP_CFG_AR_RELEASE_MINOR_VERSION_H) || \
  107. (FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_H != FLEXCAN_IP_CFG_AR_RELEASE_REVISION_VERSION_H) \
  108. )
  109. #error "AutoSar Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_Cfg.h are different"
  110. #endif
  111. /* Check if current file and FlexCAN_Ip_Cfg header file are of the same Software version */
  112. #if ((FLEXCAN_IP_SW_MAJOR_VERSION_H != FLEXCAN_IP_CFG_SW_MAJOR_VERSION_H) || \
  113. (FLEXCAN_IP_SW_MINOR_VERSION_H != FLEXCAN_IP_CFG_SW_MINOR_VERSION_H) || \
  114. (FLEXCAN_IP_SW_PATCH_VERSION_H != FLEXCAN_IP_CFG_SW_PATCH_VERSION_H) \
  115. )
  116. #error "Software Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_Cfg.h are different"
  117. #endif
  118. /* Check if current file and FlexCAN_Ip_Wrapper header file are of the same vendor */
  119. #if (FLEXCAN_IP_VENDOR_ID_H != FLEXCAN_IP_WRAPPER_VENDOR_ID_H)
  120. #error "FlexCAN_Ip.h and FlexCAN_Ip_Wrapper.h have different vendor ids"
  121. #endif
  122. /* Check if current file and FlexCAN_Ip_Wrapper header file are of the same Autosar version */
  123. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H != FLEXCAN_IP_WRAPPER_AR_RELEASE_MAJOR_VERSION_H) || \
  124. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H != FLEXCAN_IP_WRAPPER_AR_RELEASE_MINOR_VERSION_H) || \
  125. (FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_H != FLEXCAN_IP_WRAPPER_AR_RELEASE_REVISION_VERSION_H) \
  126. )
  127. #error "AutoSar Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_Wrapper.h are different"
  128. #endif
  129. /* Check if current file and FlexCAN_Ip_Wrapper header file are of the same Software version */
  130. #if ((FLEXCAN_IP_SW_MAJOR_VERSION_H != FLEXCAN_IP_WRAPPER_SW_MAJOR_VERSION_H) || \
  131. (FLEXCAN_IP_SW_MINOR_VERSION_H != FLEXCAN_IP_WRAPPER_SW_MINOR_VERSION_H) || \
  132. (FLEXCAN_IP_SW_PATCH_VERSION_H != FLEXCAN_IP_WRAPPER_SW_PATCH_VERSION_H) \
  133. )
  134. #error "Software Version Numbers of FlexCAN_Ip.h and FlexCAN_Ip_Wrapper.h are different"
  135. #endif
  136. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  137. /* Check if current file and Platform_Types header file are of the same Autosar version */
  138. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H != PLATFORM_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  139. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H != PLATFORM_TYPES_AR_RELEASE_MINOR_VERSION) \
  140. )
  141. #error "AutoSar Version Numbers of FlexCAN_Ip.h and Platform_Types.h are different"
  142. #endif
  143. /* Check if current file and Mcal header file are of the same Autosar version */
  144. #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  145. (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H != MCAL_AR_RELEASE_MINOR_VERSION) \
  146. )
  147. #error "AutoSar Version Numbers of FlexCAN_Ip.h and Mcal.h are different"
  148. #endif
  149. #endif
  150. /*==================================================================================================
  151. * CONSTANTS
  152. ==================================================================================================*/
  153. /*==================================================================================================
  154. * DEFINES AND MACROS
  155. ==================================================================================================*/
  156. #define FLEXCAN_IP_MB_HANDLE_RXFIFO 0U
  157. #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
  158. #define FLEXCAN_IP_MB_ENHANCED_RXFIFO 255U
  159. #endif /* FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO */
  160. /*==================================================================================================
  161. * GLOBAL VARIABLE DECLARATIONS
  162. ==================================================================================================*/
  163. #define CAN_START_SEC_CONFIG_DATA_UNSPECIFIED
  164. #include "Can_MemMap.h"
  165. /* Calling the external Configuration symbols defined by FlexCAN_Ip_Cfg.h */
  166. FLEXCAN_IP_CONFIG_EXT
  167. #if (FLEXCAN_IP_FEATURE_HAS_PRETENDED_NETWORKING == STD_ON)
  168. FLEXCAN_IP_PN_CONFIG_EXT
  169. #endif
  170. #define CAN_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  171. #include "Can_MemMap.h"
  172. #define CAN_START_SEC_VAR_CLEARED_UNSPECIFIED
  173. #include "Can_MemMap.h"
  174. FLEXCAN_IP_STATE_EXT
  175. #define CAN_STOP_SEC_VAR_CLEARED_UNSPECIFIED
  176. #include "Can_MemMap.h"
  177. /*==================================================================================================
  178. * FUNCTION PROTOTYPES
  179. ==================================================================================================*/
  180. #define CAN_START_SEC_CODE
  181. #include "Can_MemMap.h"
  182. /**
  183. * @brief Initializes the FlexCAN peripheral.
  184. * @details This function will config FlexCAN module and will leave the module in freeze mode.
  185. * @param[in] Flexcan_Ip_u8Instance A FlexCAN instance number
  186. * @param[in\out] Flexcan_Ip_pState Pointer to the FlexCAN driver state structure.
  187. * @param[in] Flexcan_Ip_pData The FlexCAN platform configuration data
  188. * @return FLEXCAN_STATUS_SUCCESS if successfull;<br>
  189. * FLEXCAN_STATUS_ERROR if other error occurred;<br>
  190. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid;<br>
  191. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  192. * @note In case of the enable option of Remote Request Store by setting corresponding bit for FLEXCAN_IP_REM_STORE_U32
  193. * in the ctrlOptions structure member of the Flexcan platform configuration data, will disable Automatic Response Request,
  194. * in this case is not allowed use of the function FlexCAN_Ip_ConfigRemoteResponseMb
  195. */
  196. #define FlexCAN_Ip_Init(Flexcan_Ip_u8Instance, Flexcan_Ip_pState, Flexcan_Ip_pData) \
  197. Call_FlexCAN_Ip_Init(Flexcan_Ip_u8Instance, Flexcan_Ip_pState, Flexcan_Ip_pData)
  198. /**
  199. * @brief Sends a CAN frame using the specified message buffer.
  200. * @details This function configure parameters form Flexcan_Ip_DataInfoType, ID and sends data as CAN frame using a message buffer.
  201. * @param[in] instance A FlexCAN instance number
  202. * @param[in] mb_idx Index of the message buffer
  203. * @param[in] tx_info Data info
  204. * @param[in] msg_id ID of the message to transmit
  205. * @param[in] mb_data Data Bytes of the FlexCAN message.
  206. * @return FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid;<br>
  207. * FLEXCAN_STATUS_BUSY if the message buffer is used for other operation;<br>
  208. * FLEXCAN_STATUS_SUCCESS if successfull.<br>
  209. */
  210. Flexcan_Ip_StatusType FlexCAN_Ip_Send(uint8 instance,
  211. uint8 mb_idx,
  212. const Flexcan_Ip_DataInfoType * tx_info,
  213. uint32 msg_id,
  214. const uint8 * mb_data);
  215. /**
  216. * @brief Sends a CAN frame using the specified message buffer, in a blocking manner.
  217. * @details This function sends a CAN frame using a configured message buffer. The function
  218. * blocks until either the frame was sent, or the specified timeout expired.
  219. * @param[in] instance A FlexCAN instance number
  220. * @param[in] mb_idx Index of the message buffer
  221. * @param[in] tx_info Data info
  222. * @param[in] msg_id ID of the message to transmit
  223. * @param[in] mb_data Data bytes of the FlexCAN message
  224. * @param[in] timeout_ms A timeout for the transfer in milliseconds.
  225. * @return FLEXCAN_STATUS_SUCCESS if successfull;<br>
  226. * FLEXCAN_STATUS_TIMEOUT if the timeout is reached;<br>
  227. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid;<br>
  228. * FLEXCAN_STATUS_BUSY if the message buffer is used for other operation.<br>
  229. *
  230. */
  231. Flexcan_Ip_StatusType FlexCAN_Ip_SendBlocking(uint8 instance,
  232. uint8 mb_idx,
  233. const Flexcan_Ip_DataInfoType * tx_info,
  234. uint32 msg_id,
  235. const uint8 * mb_data,
  236. uint32 timeout_ms);
  237. /**
  238. * @brief Receives a CAN frame using the specified message buffer.
  239. * @details This function receives a CAN frame using a configured message buffer. The function
  240. * returns immediately.
  241. * @param[in] instance A FlexCAN instance number
  242. * @param[in] mb_idx Index of the message buffer
  243. * @param[out] data The FlexCAN receive message buffer data.
  244. * @param[in] isPolling If the message will be send using pooling(true) or interrupt(false).
  245. * @return FLEXCAN_STATUS_SUCCESS if successfull operation;<br>
  246. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid;<br>
  247. * FLEXCAN_STATUS_BUSY if the message buffer is used for other operation.<br>
  248. *
  249. */
  250. Flexcan_Ip_StatusType FlexCAN_Ip_Receive(uint8 instance,
  251. uint8 mb_idx,
  252. Flexcan_Ip_MsgBuffType * data,
  253. boolean isPolling);
  254. /**
  255. * @brief FlexCAN Rx FIFO field configuration
  256. * @details Each element in the ID filter table specifies an ID to be used as
  257. * acceptance criteria for the FIFO as follows:
  258. * - for format A: In the standard frame format, bits 10 to 0 of the ID
  259. * are used for frame identification. In the extended frame format, bits
  260. * 28 to 0 are used.
  261. * - for format B: In the standard frame format, bits 10 to 0 of the ID
  262. * are used for frame identification. In the extended frame format, only
  263. * the 14 most significant bits (28 to 15) of the ID are compared to the
  264. * 14 most significant bits (28 to 15) of the received ID.
  265. * - for format C: In both standard and extended frame formats, only the 8
  266. * most significant bits (7 to 0 for standard, 28 to 21 for extended) of
  267. * the ID are compared to the 8 most significant bits (7 to 0 for
  268. * standard, 28 to 21 for extended) of the received ID.
  269. *
  270. * @param[in] instance A FlexCAN instance number
  271. * @param[in] id_format The format of the Rx FIFO ID Filter Table Elements
  272. * @param[in] id_filter_table The ID filter table elements which contain RTR
  273. * bit, IDE bit, and Rx message ID
  274. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  275. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  276. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  277. *
  278. * @note The number of elements in the ID filter table is defined by the
  279. * following formula:
  280. * - for format A: the number of Rx FIFO ID filters
  281. * - for format B: twice the number of Rx FIFO ID filters
  282. * - for format C: four times the number of Rx FIFO ID filters
  283. * The user must provide the exact number of elements in order to avoid
  284. * any misconfiguration.
  285. * This function should be called from StopMode or FreezeMode.
  286. */
  287. #define FlexCAN_Ip_ConfigRxFifo(instance, id_format, id_filter_table) \
  288. Call_FlexCAN_Ip_ConfigRxFifo(instance, id_format, id_filter_table)
  289. #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
  290. /*!
  291. * @brief FlexCAN Enhanced Rx FIFO field configuration
  292. *
  293. * @note The number of elements in the ID filter table is defined by the
  294. * following types:
  295. * - Type 1:ID filter element with filter + mask scheme
  296. * - Type 2: ID filter element with range scheme
  297. * - Type 3: ID filter element with 2-filter scheme
  298. * The user must provide the exact number of elements in order to avoid
  299. * any misconfiguration.
  300. * This function should be called from StopMode or FreezeMode.
  301. * Each element in the ID filter table specifies an ID to be used as
  302. * acceptance criteria for the Enhanced Rx FIFO as follows:
  303. * - for type 1: In the standard frame format, bits 26 to 16 of the ID
  304. * are used for frame identification and bits 10 to 0 are used for ID mask.
  305. * In the extended frame format, bits 28 to 0 are used for frame identification and
  306. * bits 28 to 0 of next work are used for ID mask.
  307. * - for type 2: In the standard frame format, bits 26 to 16 and bits 10 to 0 of the ID
  308. * are used for frame identification. The filter scheme is based on range.
  309. * In the extended frame format, bits 28 to 0 and bits 28 to 0 of next work
  310. * are used for frame identification. The filter scheme is based on range.
  311. * - for type 3: In the standard frame format, bits 26 to 16 and bits 10 to 0 of the ID
  312. * are used for frame identification.
  313. * In the extended frame format, bits 28 to 0 and bits 28 to 0 of next work
  314. * are used for frame identification.
  315. * @param instance A FlexCAN instance number
  316. * @param id_filter_table The ID filter table elements which contain Enhanced Rx FIFO
  317. * filter type, RTR bit, IDE bit, and Rx message ID
  318. *
  319. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  320. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  321. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  322. */
  323. #define FlexCAN_Ip_ConfigEnhancedRxFifo(instance, id_filter_table) \
  324. Call_FlexCAN_Ip_ConfigEnhancedRxFifo(instance, id_filter_table)
  325. #endif /* (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON) */
  326. /**
  327. * @brief Receives a CAN frame using the message FIFO.
  328. * @details This function receives a CAN frame using the Rx FIFO.
  329. * The function returns immediately.
  330. * @param[in] instance A FlexCAN instance number
  331. * @param[out] data The FlexCAN receive message buffer data.
  332. * @return FLEXCAN_STATUS_SUCCESS if successfull operation;<br>
  333. * FLEXCAN_STATUS_ERROR if FiFO feature wasn't enable;<br>
  334. * FLEXCAN_STATUS_BUSY if the message buffer is used by other operation.<br>
  335. *
  336. */
  337. Flexcan_Ip_StatusType FlexCAN_Ip_RxFifo(uint8 instance, Flexcan_Ip_MsgBuffType * data);
  338. /*!
  339. * @brief Receives a CAN frame using the message FIFO, in a blocking manner.
  340. *
  341. * This function receives a CAN frame using the Rx FIFO or
  342. * Enhanced Rx FIFO (if available and enabled). If using Enhanced Rx FIFO, the size of
  343. * the data array will be considered the same as the configured FIFO watermark.
  344. * The function blocks until either a frame was received, or the specified timeout expired.
  345. * FlexCAN_Ip_RxFifoBlocking/FlexCAN_Ip_RxFifo must not be called in callback invocation
  346. * while FlexCAN_Ip_RxFifoBlocking is running to avoid unexpected behaviour.
  347. *
  348. * @param instance A FlexCAN instance number
  349. * @param data The FlexCAN receive message buffer data.
  350. * @param timeout A timeout for the transfer in milliseconds.
  351. * @return FLEXCAN_STATUS_SUCCESS if successful;
  352. * FLEXCAN_STATUS_BUSY if a resource is busy;
  353. * FLEXCAN_STATUS_TIMEOUT if the timeout is reached;
  354. * FLEXCAN_STATUS_ERROR if other error occurred
  355. */
  356. Flexcan_Ip_StatusType FlexCAN_Ip_RxFifoBlocking(uint8 instance, Flexcan_Ip_MsgBuffType *data, uint32 timeout);
  357. /**
  358. * @brief FlexCAN receive message buffer field configuration
  359. * @details This function will config receive parameters form Flexcan_Ip_DataInfoType and
  360. * the message Id, and can overwritte another MB status.
  361. * @param[in] instance A FlexCAN instance number
  362. * @param[in] mb_idx Index of the message buffer
  363. * @param[in] rx_info Data info
  364. * @param[in] msg_id ID of the message to transmit
  365. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  366. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid.
  367. *
  368. */
  369. Flexcan_Ip_StatusType FlexCAN_Ip_ConfigRxMb(uint8 instance,
  370. uint8 mb_idx,
  371. const Flexcan_Ip_DataInfoType * rx_info,
  372. uint32 msg_id
  373. );
  374. /**
  375. * @brief Sets the FlexCAN Rx individual mask
  376. * @details This function will set directly the mask value as is provided.
  377. * @param[in] instance A FlexCAN instance number
  378. * @param[in] mb_idx Index of the message buffer
  379. * @param[in] mask Mask value
  380. * @note This function should be called from StopMode or FreezeMode.
  381. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  382. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid.
  383. *
  384. */
  385. #define FlexCAN_Ip_SetRxIndividualMask(instance, mb_idx, mask) \
  386. Call_FlexCAN_Ip_SetRxIndividualMask(instance, mb_idx, mask)
  387. /**
  388. * @brief Sets the FlexCAN Rx MB global mask.
  389. * @details This function will set directly the mask value as is provided.
  390. * @param[in] instance A FlexCAN instance number
  391. * @param[in] mask Mask value
  392. * @note This function should be called from StopMode or FreezeMode.
  393. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  394. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  395. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  396. *
  397. */
  398. #define FlexCAN_Ip_SetRxMbGlobalMask(instance, mask) \
  399. Call_FlexCAN_Ip_SetRxMbGlobalMask(instance, mask)
  400. /**
  401. * @brief Sets the FlexCAN Rx FIFO global mask.
  402. * This mask is applied to all filters ID regardless the ID Filter format.
  403. *
  404. * @param[in] instance A FlexCAN instance number
  405. * @param[in] mask Mask Value.
  406. * @note This function should be called from StopMode or FreezeMode.
  407. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  408. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  409. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  410. */
  411. #define FlexCAN_Ip_SetRxFifoGlobalMask(instance, mask) \
  412. Call_FlexCAN_Ip_SetRxFifoGlobalMask(instance, mask)
  413. /**
  414. * @brief Check a receive event.
  415. * @details This will check if message is received and read the message buffer or RxFifo.
  416. * @param[in] instance A FlexCAN instance number
  417. * @param[in] mb_idx Index of the message buffer
  418. */
  419. void FlexCAN_Ip_MainFunctionRead(uint8 instance, uint8 mb_idx);
  420. /**
  421. * @brief Check a Transmission event.
  422. * @details This function will check a specific MB have been sent of FlexCAN module and
  423. * if was sent will reset the status of Mb and clear the status flag.
  424. * @param[in] instance A FlexCAN instance number
  425. * @param[in] mb_idx message buffer number
  426. *
  427. */
  428. void FlexCAN_Ip_MainFunctionWrite(uint8 instance, uint8 mb_idx);
  429. /**
  430. * @brief Check a bus-off event.
  431. * @details This function will check bus activity of FlexCAN module and
  432. * if a bus off event is detected will suspend the future bus activities by setting
  433. * module in stop mode.
  434. * @param[in] instance A FlexCAN instance number
  435. * @return FLEXCAN_STATUS_SUCCESS if successful busoff and set on stop;<br>
  436. * FLEXCAN_STATUS_ERROR if no busoff event detected;<br>
  437. * FLEXCAN_STATUS_TIMEOUT if fail to configure in the configured timeout value.<br>
  438. *
  439. */
  440. #define FlexCAN_Ip_MainFunctionBusOff(instance) \
  441. Call_FlexCAN_Ip_MainFunctionBusOff(instance)
  442. /**
  443. * @brief Enter FlexCAN Module in Freeze Mode.
  444. * @details This function will suspend bus activity of FlexCAN module and
  445. * set it to Freeze Mode to allow module configuration.
  446. * @param[in] instance A FlexCAN instance number
  447. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  448. * FLEXCAN_STATUS_TIMEOUT if fail to configure in the configured timeout value.<br>
  449. *
  450. */
  451. #define FlexCAN_Ip_EnterFreezeMode(instance) \
  452. Call_FlexCAN_Ip_EnterFreezeMode(instance)
  453. /**
  454. * @brief Exit FlexCAN Module from Freeze Mode.
  455. * @details This function will allow FlexCAN module to participate to the BUS activity and
  456. * restore normal opertaion of the driver.
  457. * @param[in] instance A FlexCAN instance number
  458. * @note This function should be called from FreezeMode.
  459. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  460. * FLEXCAN_STATUS_TIMEOUT if fail to configure in the configured timeout value.<br>
  461. *
  462. */
  463. #define FlexCAN_Ip_ExitFreezeMode(instance) \
  464. Call_FlexCAN_Ip_ExitFreezeMode(instance)
  465. /**
  466. * @brief DeInitilize the FlexCAN instance driver
  467. * @details This function will make future operataions of FlexCAN instance imposibile and will restore
  468. * it's state to default value as before initialization.
  469. * @param[in] instance A FlexCAN instance number
  470. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  471. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  472. *
  473. */
  474. #define FlexCAN_Ip_Deinit(instance) \
  475. Call_FlexCAN_Ip_Deinit(instance)
  476. /**
  477. * @brief Get Start Mode Status
  478. * @details Return if the instance is in Start Mode
  479. * @param[in] instance A FlexCAN instance number
  480. * @return True instance is in START Mode
  481. * False instance is not in START Mode
  482. *
  483. */
  484. #define FlexCAN_Ip_GetStartMode(instance) \
  485. Call_FlexCAN_Ip_GetStartMode(instance)
  486. /**
  487. * @brief Set the FlexCAN instance in START mode
  488. * @details Set the FlexCAN instance in START mode, allowing to participate to bus transfers.
  489. * @param[in] instance A FlexCAN instance number
  490. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  491. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  492. */
  493. #define FlexCAN_Ip_SetStartMode(instance) \
  494. Call_FlexCAN_Ip_SetStartMode(instance)
  495. /**
  496. * @brief Set the FlexCAN instance in STOP mode
  497. * @details Set the FlexCAN instance in START mode, this will prevent instance to participate to
  498. * bus transactions and disable module clocks.
  499. * @param[in] instance A FlexCAN instance number
  500. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  501. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  502. *
  503. */
  504. #define FlexCAN_Ip_SetStopMode(instance) \
  505. Call_FlexCAN_Ip_SetStopMode(instance)
  506. /**
  507. * @brief Enable\Disable listen Only Mode
  508. * @details This function will Enable or Disable listen Only Mode.
  509. * @note This function should be called from StopMode or FreezeMode.
  510. * @param[in] u8Instance A FlexCAN instance number
  511. * @param[in] listenonlystate Enable\Disable interrupt selected
  512. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  513. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  514. *
  515. */
  516. #define FlexCAN_Ip_SetListenOnlyMode(instance, listenonlystate) \
  517. Call_FlexCAN_Ip_SetListenOnlyMode(instance, listenonlystate)
  518. /**
  519. * @brief Returns whether the previous FlexCAN transfer has finished.
  520. *
  521. * When performing an async transfer, call this function to ascertain the state of the
  522. * current transfer: in progress (or busy) or complete (success).
  523. *
  524. * @param[in] instance The FlexCAN instance number.
  525. * @param[in] mb_idx The index of the message buffer.
  526. * @return FLEXCAN_STATUS_SUCCESS if successful;
  527. * FLEXCAN_STATUS_BUSY if a resource is busy;
  528. * FLEXCAN_STATUS_ERROR in case of a DMA error transfer;
  529. */
  530. Flexcan_Ip_StatusType FlexCAN_Ip_GetTransferStatus(uint8 instance,
  531. uint8 mb_idx);
  532. /**
  533. * @brief Get Error Status of FlexCAN
  534. * @details This function will return the error status from ESR1 register.
  535. * For exact mapping of errors please refere to RM(Reference Manual)
  536. * on FLEXCAN ESR1 register description.
  537. * @param[in] instance: A FlexCAN instance number
  538. * @return The errors flags stored by register ESR1
  539. */
  540. uint32 FlexCAN_Ip_GetErrorStatus(uint8 instance);
  541. /**
  542. * @brief Get Transmit error counter of FlexCAN
  543. * @details This function will return the Transmit error counter for all errors
  544. * detected in transmitted messages from ECR register.
  545. * For exact mapping of errors please refere to RM(Reference Manual)
  546. * on FLEXCAN ECR register description.
  547. * @param[in] instance: A FlexCAN instance number
  548. * @return The Transmit error counter stored by TXERRCNT in register ECR
  549. */
  550. uint8 FlexCAN_Ip_GetControllerTxErrorCounter(uint8 instance);
  551. /**
  552. * @brief Get Receive error counter of FlexCAN
  553. * @details This function will return the Receive error counter for all errors
  554. * detected in transmitted messages from ECR register.
  555. * For exact mapping of errors please refere to RM(Reference Manual)
  556. * on FLEXCAN ECR register description.
  557. * @param[in] instance: A FlexCAN instance number
  558. * @return The Receive error counter stored by RXERRCNT in register ECR
  559. */
  560. uint8 FlexCAN_Ip_GetControllerRxErrorCounter(uint8 instance);
  561. /**
  562. * @brief Clear Error Status of FlexCAN
  563. * @details This function will clear the error status from ESR1 register.
  564. * For exact mapping of errors please refere to RM(Reference Manual)
  565. * on FLEXCAN ESR1 register description.
  566. * @param[in] instance: A FlexCAN instance number
  567. * @param[in] error: errors flags to be cleared
  568. */
  569. void FlexCAN_Ip_ClearErrorStatus(uint8 instance,
  570. uint32 error);
  571. /**
  572. * @brief Set RX masking type
  573. * @details This function will set RX masking type as RX global mask or RX individual mask
  574. * @param[in] instance: A FlexCAN instance number
  575. * @param[in] type: FlexCAN Rx mask type
  576. * @note This function should be called from StopMode or FreezeMode.
  577. * @return FLEXCAN_STATUS_SUCCESS if successful<br>
  578. * FLEXCAN_STATUS_ERROR if controller is not in freeze mode<br>
  579. *
  580. */
  581. #define FlexCAN_Ip_SetRxMaskType(instance, type) \
  582. Call_FlexCAN_Ip_SetRxMaskType(instance, type)
  583. /**
  584. * @brief Set Rx14Mask filter for message buffer 14.
  585. * @details This function will set directly the mask value as is provided.
  586. * @param[in] instance: A FlexCAN instance number
  587. * @param[in] mask: The value applied for mask
  588. * @note This function should be called from StopMode or FreezeMode.
  589. * @return FLEXCAN_STATUS_SUCCESS if successful<br>
  590. * FLEXCAN_STATUS_ERROR if controller is not in freeze mode<br>
  591. *
  592. */
  593. #define FlexCAN_Ip_SetRxMb14Mask(instance, mask) \
  594. Call_FlexCAN_Ip_SetRxMb14Mask(instance, mask)
  595. /**
  596. * @brief Set Rx15Mask filter for message buffer 15.
  597. * @details This function will set directly the mask value as is provided.
  598. * @param[in] instance: A FlexCAN instance number
  599. * @param[in] mask: The value applied for mask
  600. * @note This function should be called from StopMode or FreezeMode.
  601. * @return FLEXCAN_STATUS_SUCCESS if successful<br>
  602. * FLEXCAN_STATUS_ERROR if controller is not in freeze mode<br>
  603. *
  604. */
  605. #define FlexCAN_Ip_SetRxMb15Mask(instance, mask) \
  606. Call_FlexCAN_Ip_SetRxMb15Mask(instance, mask)
  607. /**
  608. * @brief Gets the FlexCAN bit rate for standard frames or the arbitration phase of FD frames.
  609. * @note In case is used Enhanced Time Segments the PhaseSeg1 is the sum of PropSeg +1+ PhaseSeg1, and the
  610. * PropSeg will be 0;
  611. * @param[in] instance A FlexCAN instance number
  612. * @param[out] bitrate A pointer to a variable for returning the FlexCAN bit rate settings
  613. * @return true if Enhanced Time segments are used;
  614. * false if Enhanced Time segments are not used.
  615. */
  616. boolean FlexCAN_Ip_GetBitrate(uint8 instance,
  617. Flexcan_Ip_TimeSegmentType * bitrate);
  618. /**
  619. * @brief Sets the FlexCAN bit rate for standard frames or the arbitration phase of FD frames.
  620. * @details This function request the FlexCAN module to be in Stop Mode or in Freeze Mode.
  621. * @param[in] instance A FlexCAN instance number
  622. * @param[in] bitrate A pointer to the FlexCAN bit rate settings.
  623. * @param[in] enhExt The time segments used are set in Enhanced Time Seg Registers
  624. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  625. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  626. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  627. */
  628. #define FlexCAN_Ip_SetBitrate(instance, bitrate, enhExt) \
  629. Call_FlexCAN_Ip_SetBitrate(instance, bitrate, enhExt)
  630. #if (FLEXCAN_IP_FEATURE_HAS_FD == STD_ON)
  631. /*!
  632. * @brief Clears the TDC Fail flag.
  633. *
  634. * @param[in] instance A FlexCAN instance number
  635. */
  636. void FlexCAN_Ip_ClearTDCFail(uint8 u8Instance);
  637. /*!
  638. * @brief Gets the value of the TDC Fail flag.
  639. *
  640. * @param[in] instance A FlexCAN instance number
  641. * @return If true, indicates that the TDC mechanism is out of range, unable to
  642. * compensate the transceiver's loop delay and successfully compare the delayed
  643. * received bits to the transmitted ones.
  644. */
  645. boolean FlexCAN_Ip_GetTDCFail(uint8 u8Instance);
  646. /*!
  647. * @brief Gets the value of the Transceiver Delay Compensation.
  648. *
  649. * @param[in] u8Instance A FlexCAN instance number
  650. * @return The value of the transceiver loop delay measured from the transmitted
  651. * EDL to R0 transition edge to the respective received one added to the TDCOFF
  652. * value.
  653. */
  654. uint8 FlexCAN_Ip_GetTDCValue(uint8 u8Instance);
  655. /**
  656. * @brief Sets the FlexCAN bit rate for the data phase of FD frames.
  657. * @details This function request the FlexCAN module to be in Stop Mode or in Freeze Mode.
  658. * @param[in] instance A FlexCAN instance number
  659. * @param[in] bitrate A pointer to the FlexCAN bit rate settings.
  660. * @param[in] fd_enable Enable/Disable Fd Frame Feature Support
  661. * @param[in] bitRateSwitch Enable/Disable of FD Data Bitrate Switch support
  662. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  663. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  664. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  665. */
  666. #define FlexCAN_Ip_SetBitrateCbt(instance, bitrate, bitRateSwitch) \
  667. Call_FlexCAN_Ip_SetBitrateCbt(instance, bitrate, bitRateSwitch)
  668. /**
  669. * @brief Gets the FlexCAN bit rate for the data phase of FD frames (BRS enabled).
  670. * @note In case is used Enhanced Time Segments the PhaseSeg1 is the sum of PropSeg + PhaseSeg1, and the
  671. * PropSeg will be 0;
  672. * @param instance A FlexCAN instance number
  673. * @param bitrate A pointer to a variable for returning the FlexCAN bit rate settings
  674. * @return true if Enhanced Time segments are used;
  675. * false if Enhanced Time segments are not used.
  676. */
  677. boolean FlexCAN_Ip_GetBitrateFD(uint8 instance,
  678. Flexcan_Ip_TimeSegmentType * bitrate);
  679. /**
  680. * @brief This function will set how many CAN bits the Tx arbitration process start point can
  681. * be delayed from the first bit of CRC field on CAN bus.
  682. * @details This function request the FlexCAN module to be in Stop Mode or in Freeze Mode.
  683. * @param[in] instance A FlexCAN instance number
  684. * @param[in] value Tx Arbitration Start Delay value
  685. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  686. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  687. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  688. *
  689. */
  690. #define FlexCAN_Ip_SetTxArbitrationStartDelay(instance, value) \
  691. Call_FlexCAN_Ip_SetTxArbitrationStartDelay(instance, value)
  692. /**
  693. * @brief Enables/Disables the Transceiver Delay Compensation feature and sets
  694. * the Transceiver Delay Compensation Offset (offset value to be added to the
  695. * measured transceiver's loop delay in order to define the position of the
  696. * delayed comparison point when bit rate switching is active).
  697. * @details This function request the FlexCAN module to be in Stop Mode or in Freeze Mode.
  698. * @param[in] instance A FlexCAN instance number
  699. * @param[in] enable Enable/Disable Transceiver Delay Compensation
  700. * @param[in] offset Transceiver Delay Compensation Offset
  701. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  702. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  703. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  704. */
  705. #define FlexCAN_Ip_SetTDCOffset(instance, enable, offset) \
  706. Call_FlexCAN_Ip_SetTDCOffset(instance, enable, offset)
  707. #endif /* FLEXCAN_IP_FEATURE_HAS_FD == STD_ON */
  708. /**
  709. * @brief Get the Status of Message Buffer
  710. * @details This function will return True if Message Buffer Flag
  711. * is Set or False if is not set.
  712. * @param[in] instance A FlexCAN instance number
  713. * @param[in] msgBuffIdx Index of the message buffer
  714. * @return True if is set
  715. * False if is clear.
  716. *
  717. */
  718. boolean FlexCAN_Ip_GetBuffStatusFlag(uint8 instance,
  719. uint8 msgBuffIdx);
  720. /**
  721. * @brief Clear Message Buffer Status Flag
  722. * @details This function will clear the status of the message buffer
  723. * @param[in] instance A FlexCAN instance number
  724. * @param[in] msgBuffIdx Index of the message buffer
  725. *
  726. */
  727. void FlexCAN_Ip_ClearBuffStatusFlag(uint8 instance,
  728. uint8 msgBuffIdx);
  729. /**
  730. * @brief Enable all interrupts configured.
  731. * @details Enable all interrupts configured.
  732. * @param[in] u8Instance A FlexCAN instance number
  733. * @return FLEXCAN_STATUS_SUCCESS if successful<br>
  734. * FLEXCAN_STATUS_ERROR if fail to set<br>
  735. */
  736. #define FlexCAN_Ip_EnableInterrupts(u8Instance) \
  737. Call_FlexCAN_Ip_EnableInterrupts(u8Instance)
  738. /**
  739. * @brief Disable all interrupts.
  740. * @details Disable all interrupts.
  741. * @param[in] u8Instance A FlexCAN instance number
  742. * @return FLEXCAN_STATUS_SUCCESS if successful<br>
  743. * FLEXCAN_STATUS_ERROR if fail to set<br>
  744. */
  745. #define FlexCAN_Ip_DisableInterrupts(u8Instance) \
  746. Call_FlexCAN_Ip_DisableInterrupts(u8Instance)
  747. /**
  748. * @brief Enable\Disable Error or BusOff Interrupt
  749. * @details This function will set Error or BusOff interrupt, Error Fast is available only
  750. * if FD CAN support is active.
  751. * @Note This function should be called from StopMode or FreezeMode.
  752. * When an error interrupt is set and error callback function is installed,
  753. * The error callback function will be invoked with a respective event occurred and status of ESR1 register:
  754. * In the callback, if another event(got from ESR1 register) recognized(Error, Error Fast, Bus Off, Tx/Rx warning)
  755. * Then it should be cleared by FlexCAN_Ip_ClearErrorStatus with a respective mask to avoid dupplication.
  756. * @param[in] u8Instance A FlexCAN instance number
  757. * @param[in] type Interrupt Type
  758. * @param[in] enable Enable\Disable interrupt selected
  759. * @return FLEXCAN_STATUS_SUCCESS if successful;<br>
  760. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  761. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  762. *
  763. */
  764. #define FlexCAN_Ip_SetErrorInt(u8Instance, type, enable) \
  765. Call_FlexCAN_Ip_SetErrorInt(u8Instance, type, enable)
  766. /**
  767. * @brief Ends a non-blocking FlexCAN transfer early.
  768. * @details Full description
  769. * @param[in] u8Instance A FlexCAN instance number
  770. * @param[in] mb_idx The index of the message buffer
  771. * @return FLEXCAN_STATUS_SUCCESS if successful;
  772. * FLEXCAN_STATUS_NO_TRANSFER_IN_PROGRESS if no transfer was running,
  773. * FLEXCAN_STATUS_TIMEOUT if fail to configure in configured timeout value.<br>
  774. *
  775. */
  776. Flexcan_Ip_StatusType FlexCAN_Ip_AbortTransfer(uint8 u8Instance,
  777. uint8 mb_idx);
  778. /**
  779. * @brief Get the Status of Listen Only Mode
  780. * @details This function will return True if Listen Only Mode
  781. * is Enable or False if is Disable.
  782. * @param[in] instance A FlexCAN instance number
  783. * @return True if Listen Only Mode is Enable
  784. * False if Listen Only Mode is Disable.
  785. *
  786. */
  787. boolean FlexCAN_Ip_GetListenOnlyMode(uint8 instance);
  788. /**
  789. * @brief Get Stop Mode Status
  790. * @details Return if the instance is in Stop Mode
  791. * @param[in] instance A FlexCAN instance number
  792. * @return True instance is in STOP Mode
  793. * False instance is not in STOP Mode
  794. *
  795. */
  796. #define FlexCAN_Ip_GetStopMode(instance) \
  797. Call_FlexCAN_Ip_GetStopMode(instance)
  798. /*!
  799. * @brief Receives a CAN frame using the specified message buffer, in a blocking manner.
  800. *
  801. * This function receives a CAN frame using a configured message buffer. The function
  802. * blocks until either a frame was received, or the specified timeout expired.
  803. *
  804. * @param[in] instance A FlexCAN instance number
  805. * @param[in] mb_idx Index of the message buffer
  806. * @param[out] data The FlexCAN receive message buffer data.
  807. * @param[in] isPolling If the message will be send using pooling(true) or interrupt(false).
  808. * @param[in] timeout_ms A timeout for the transfer in milliseconds.
  809. * @return FLEXCAN_STATUS_SUCCESS if successfull operation;<br>
  810. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of a message buffer is invalid;<br>
  811. * FLEXCAN_STATUS_BUSY if the message buffer is used for other operation.<br>
  812. * FLEXCAN_STATUS_TIMEOUT if the timeout is reached.<br>
  813. */
  814. Flexcan_Ip_StatusType FlexCAN_Ip_ReceiveBlocking(uint8 instance,
  815. uint8 mb_idx,
  816. Flexcan_Ip_MsgBuffType * data,
  817. boolean isPolling,
  818. uint32 u32TimeoutMs);
  819. /**
  820. * @brief Configures a transmit message buffer for remote frame response.
  821. *
  822. * @Note In case of using this function as polling mode the user should call
  823. * FlexCAN_Ip_MainFunctionWrite to check it.
  824. * @Note In case of enable the option Remote Request Store by setting corresponding bit for FLEXCAN_IP_REM_STORE_U32
  825. * in the ctrlOptions structure member of the Flexcan platform configuration data from FlexCAN_Ip_Init function,
  826. * will disable Automatic Response Request feature, in this case is not allowed use of this function.
  827. *
  828. * @param[in] instance A FlexCAN instance number
  829. * @param[in] mb_idx Index of the message buffer
  830. * @param[in] tx_info Data info
  831. * @param[in] msg_id ID of the message to transmit
  832. * @param[in] mb_data Bytes of the FlexCAN message
  833. * @return FLEXCAN_STATUS_SUCCESS if successful;
  834. * FLEXCAN_STATUS_BUFF_OUT_OF_RANGE if the index of the message buffer
  835. * is invalid
  836. */
  837. Flexcan_Ip_StatusType FlexCAN_Ip_ConfigRemoteResponseMb(uint8 instance,
  838. uint8 mb_idx,
  839. const Flexcan_Ip_DataInfoType *tx_info,
  840. uint32 msg_id,
  841. const uint8 *mb_data);
  842. #if (FLEXCAN_IP_FEATURE_HAS_TS_ENABLE == STD_ON)
  843. /*!
  844. * @brief This function configure the timestamp settings.
  845. *
  846. * This function will allow to set the timestamp timer source and config the
  847. * HR Timer selected capture point for timestamp.
  848. * @note Need enable clock counter for the source selected before use HR Time Stamp.
  849. *
  850. * @param[in] instance A FlexCAN instance number
  851. * @param[in] time_stamp A timestamp configuration structure
  852. * @return FLEXCAN_STATUS_SUCCESS if successful operation;<br>
  853. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  854. * FLEXCAN_STATUS_TIMEOUT if the timeout is reached.<br>
  855. */
  856. #define FlexCAN_Ip_ConfigTimeStamp(instance, time_stamp) \
  857. Call_FlexCAN_Ip_ConfigTimeStamp(instance, time_stamp)
  858. #endif /* FLEXCAN_IP_FEATURE_HAS_TS_ENABLE == STD_ON */
  859. #if (FLEXCAN_IP_FEATURE_HAS_PRETENDED_NETWORKING == STD_ON)
  860. /*!
  861. * @brief Configures Pretended Networking settings.
  862. * @details This function will enable or disable the Pretended Network feature and configure PN the
  863. * wakeup events and filters. This function requires the FlexCAN module to be in Stop Mode or in Freeze Mode.
  864. * @note In order this feature to work, the FlexCAN module need to be in Start Mode after configuring PN
  865. * and the Protocol Clock needed to remain active during sleep mode.
  866. *
  867. * @param[in] u8Instance The FlexCAN instance number.
  868. * @param[in] bEnable Enable/Disable Pretended Networking mode.
  869. * @param[in] pPnConfig Pointer to the Pretended Networking configuration structure.
  870. * @return FLEXCAN_STATUS_SUCCESS if successful operation;<br>
  871. * FLEXCAN_STATUS_ERROR if fail to set;<br>
  872. * FLEXCAN_STATUS_TIMEOUT if the timeout is reached.<br>
  873. */
  874. #define FlexCAN_Ip_ConfigPN(u8Instance, bEnable, pPnConfig) \
  875. Call_FlexCAN_Ip_ConfigPN(u8Instance, bEnable, pPnConfig)
  876. /*!
  877. * @brief Extracts one of the frames which triggered the wake up event.
  878. *
  879. * @param[in] u8Instance The FlexCAN instance number.
  880. * @param[in] u8WmbIndex The index of the message buffer to be extracted.
  881. * @param[in] pWmb Pointer to the message buffer structure where the frame will be saved.
  882. */
  883. void FlexCAN_Ip_GetWMB(uint8 u8Instance,
  884. uint8 u8WmbIndex,
  885. Flexcan_Ip_MsgBuffType * pWmb);
  886. #endif /* FLEXCAN_IP_FEATURE_HAS_PRETENDED_NETWORKING */
  887. /*!
  888. * @brief Recover manually from bus-off if possible.
  889. * @note This function should be used when bus-off auto recovery disabled and controller is in START mode.
  890. * The function FlexCAN_Ip_GetErrorStatus can be used to check FLTCONF bits to check if bus-off state is exited or not.
  891. *
  892. * @param[in] Instance The FlexCAN instance number.
  893. * @return FLEXCAN_STATUS_SUCCESS if successful operation or the controller wasn't in bus-off.<br>
  894. * FLEXCAN_STATUS_ERROR if bus-off auto recovery enabled.<br>
  895. * FLEXCAN_STATUS_TIMEOUT if the timeout is reached.<br>
  896. */
  897. Flexcan_Ip_StatusType FlexCAN_Ip_ManualBusOffRecovery(uint8 Instance);
  898. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  899. void DMA_Can_Callback0(void);
  900. #if FLEXCAN_INSTANCE_COUNT > 1U
  901. void DMA_Can_Callback1(void);
  902. #endif
  903. #if FLEXCAN_INSTANCE_COUNT > 2U
  904. void DMA_Can_Callback2(void);
  905. #endif
  906. #if FLEXCAN_INSTANCE_COUNT > 3U
  907. void DMA_Can_Callback3(void);
  908. #endif
  909. #if FLEXCAN_INSTANCE_COUNT > 4U
  910. void DMA_Can_Callback4(void);
  911. #endif
  912. #if FLEXCAN_INSTANCE_COUNT > 5U
  913. void DMA_Can_Callback5(void);
  914. #endif
  915. #if FLEXCAN_INSTANCE_COUNT > 6U
  916. void DMA_Can_Callback6(void);
  917. #endif
  918. #if FLEXCAN_INSTANCE_COUNT > 7U
  919. void DMA_Can_Callback7(void);
  920. #endif
  921. #endif /* FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE */
  922. #define CAN_STOP_SEC_CODE
  923. #include "Can_MemMap.h"
  924. #ifdef __cplusplus
  925. }
  926. #endif
  927. /** @} */
  928. #endif /* FLEXCAN_FLEXCAN_IP_H_ */