Can_Ipw.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /**
  2. * @file Can_Ipw.h
  3. * @version 1.0.0
  4. *
  5. * @brief AUTOSAR Can - module interface
  6. * @details Main header file - can include different IPV models.
  7. *
  8. * @addtogroup CAN_DRIVER
  9. * @{
  10. */
  11. /*==================================================================================================
  12. * Project : RTD AUTOSAR 4.4
  13. * Platform : CORTEXM
  14. * Peripheral : FLEXCAN
  15. * Dependencies :
  16. *
  17. * Autosar Version : 4.4.0
  18. * Autosar Revision : ASR_REL_4_4_REV_0000
  19. * Autosar Conf.Variant :
  20. * SW Version : 1.0.0
  21. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  22. *
  23. * (c) Copyright 2020-2021 NXP Semiconductors
  24. * All Rights Reserved.
  25. *
  26. * NXP Confidential. This software is owned or controlled by NXP and may only be
  27. * used strictly in accordance with the applicable license terms. By expressly
  28. * accepting such terms or by downloading, installing, activating and/or otherwise
  29. * using the software, you are agreeing that you have read, and that you agree to
  30. * comply with and are bound by, such license terms. If you do not agree to be
  31. * bound by the applicable license terms, then you may not retain, install,
  32. * activate or otherwise use the software.
  33. ==================================================================================================*/
  34. /*==================================================================================================
  35. ==================================================================================================*/
  36. #ifndef CAN_IPW_H
  37. #define CAN_IPW_H
  38. #ifdef __cplusplus
  39. extern "C"{
  40. #endif
  41. /*
  42. * @page misra_violations MISRA-C:2012 violations
  43. *
  44. * @section [global]
  45. * Violates MISRA 2012 Required Rule 5.1, External identifiers shall be distinct.
  46. * The used compilers use more than 31 chars for identifiers.
  47. *
  48. * @section [global]
  49. * Violates MISRA 2012 Required Rule 5.2, Identifiers declared in the same scope and name space shall be distinct.
  50. * The used compilers use more than 31 chars for identifiers.
  51. *
  52. * @section [global]
  53. * Violates MISRA 2012 Required Rule 5.4, Macro identifiers shall be distinct.
  54. * The used compilers use more than 31 chars for identifiers.
  55. *
  56. * @section [global]
  57. * Violates MISRA 2012 Required Rule 5.5, Identifiers shall be distinct from macro names.
  58. * The used compilers use more than 31 chars for identifiers.
  59. *
  60. * @section Can_Ipw_h_REF_1
  61. * Violates MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents
  62. * of a header file being included more than once. This comes from the order of includes in the .c file
  63. * and from include dependencies. As a safe approach, any file must include all its dependencies.
  64. * Header files are already protected against double inclusions. The inclusion of Can_Memmap.h is as
  65. * per AUTOSAR requirement (SWS_MemMap_00003)
  66. *
  67. */
  68. /*==================================================================================================
  69. * INCLUDE FILES
  70. * 1) system and project includes
  71. * 2) needed interfaces from external units
  72. * 3) internal and external interfaces from this unit
  73. ==================================================================================================*/
  74. #include "FlexCAN_Ip.h"
  75. #include "Can_Flexcan_Types.h"
  76. #include "Can_Ipw_Cfg.h"
  77. /*==================================================================================================
  78. * SOURCE FILE VERSION INFORMATION
  79. ==================================================================================================*/
  80. /**
  81. * @{
  82. *
  83. */
  84. #define CAN_IPW_VENDOR_ID_H 43
  85. #define CAN_IPW_MODULE_ID 80
  86. #define CAN_IPW_AR_RELEASE_MAJOR_VERSION_H 4
  87. #define CAN_IPW_AR_RELEASE_MINOR_VERSION_H 4
  88. #define CAN_IPW_AR_RELEASE_REVISION_VERSION_H 0
  89. #define CAN_IPW_SW_MAJOR_VERSION_H 1
  90. #define CAN_IPW_SW_MINOR_VERSION_H 0
  91. #define CAN_IPW_SW_PATCH_VERSION_H 0
  92. /**@}*/
  93. /*==================================================================================================
  94. * FILE VERSION CHECKS
  95. ==================================================================================================*/
  96. /* Check if current file and FlexCAN_Ip header file are of the same vendor */
  97. #if (CAN_IPW_VENDOR_ID_H != FLEXCAN_IP_VENDOR_ID_H)
  98. #error "Can_Ipw.h and FlexCAN_Ip.h have different vendor ids"
  99. #endif
  100. /* Check if current file and FlexCAN_Ip header file are of the same Autosar version */
  101. #if ((CAN_IPW_AR_RELEASE_MAJOR_VERSION_H != FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  102. (CAN_IPW_AR_RELEASE_MINOR_VERSION_H != FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_H) || \
  103. (CAN_IPW_AR_RELEASE_REVISION_VERSION_H != FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_H))
  104. #error "AutoSar Version Numbers of Can_Ipw.h and FlexCAN_Ip.h are different"
  105. #endif
  106. /* Check if current file and FlexCAN_Ip header file are of the same Software version */
  107. #if ((CAN_IPW_SW_MAJOR_VERSION_H != FLEXCAN_IP_SW_MAJOR_VERSION_H) || \
  108. (CAN_IPW_SW_MINOR_VERSION_H != FLEXCAN_IP_SW_MINOR_VERSION_H) || \
  109. (CAN_IPW_SW_PATCH_VERSION_H != FLEXCAN_IP_SW_PATCH_VERSION_H))
  110. #error "Software Version Numbers of Can_Ipw.h and FlexCAN_Ip.h are different"
  111. #endif
  112. /* Check if current file and Can_Ipw_Cfg header file are of the same vendor */
  113. #if (CAN_IPW_VENDOR_ID_H != CAN_IPW_CFG_VENDOR_ID)
  114. #error "Can_Ipw.h and Can_Ipw_Cfg.h have different vendor ids"
  115. #endif
  116. /* Check if current file and Can_Ipw_Cfg header file are of the same Autosar version */
  117. #if ((CAN_IPW_AR_RELEASE_MAJOR_VERSION_H != CAN_IPW_CFG_AR_RELEASE_MAJOR_VERSION) || \
  118. (CAN_IPW_AR_RELEASE_MINOR_VERSION_H != CAN_IPW_CFG_AR_RELEASE_MINOR_VERSION) || \
  119. (CAN_IPW_AR_RELEASE_REVISION_VERSION_H != CAN_IPW_CFG_AR_RELEASE_REVISION_VERSION))
  120. #error "AutoSar Version Numbers of Can_Ipw.h and Can_Ipw_Cfg.h are different"
  121. #endif
  122. /* Check if current file and Can_Ipw_Cfg header file are of the same Software version */
  123. #if ((CAN_IPW_SW_MAJOR_VERSION_H != CAN_IPW_CFG_SW_MAJOR_VERSION) || \
  124. (CAN_IPW_SW_MINOR_VERSION_H != CAN_IPW_CFG_SW_MINOR_VERSION) || \
  125. (CAN_IPW_SW_PATCH_VERSION_H != CAN_IPW_CFG_SW_PATCH_VERSION))
  126. #error "Software Version Numbers of Can_Ipw.h and Can_Ipw_Cfg.h are different"
  127. #endif
  128. /* Check if current file and Can_Flexcan_Types header file are of the same vendor */
  129. #if (CAN_IPW_VENDOR_ID_H != CAN_FLEXCAN_TYPES_VENDOR_ID_H)
  130. #error "Can_Ipw.h and Can_Flexcan_Types.h have different vendor ids"
  131. #endif
  132. /* Check if current file and Can_Flexcan_Types header file are of the same Autosar version */
  133. #if ((CAN_IPW_AR_RELEASE_MAJOR_VERSION_H != CAN_FLEXCAN_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
  134. (CAN_IPW_AR_RELEASE_MINOR_VERSION_H != CAN_FLEXCAN_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
  135. (CAN_IPW_AR_RELEASE_REVISION_VERSION_H != CAN_FLEXCAN_TYPES_AR_RELEASE_REVISION_VERSION_H))
  136. #error "AutoSar Version Numbers of Can_Ipw.h and Can_Flexcan_Types.h are different"
  137. #endif
  138. /* Check if current file and Can_Flexcan_Types header file are of the same Software version */
  139. #if ((CAN_IPW_SW_MAJOR_VERSION_H != CAN_FLEXCAN_TYPES_SW_MAJOR_VERSION_H) || \
  140. (CAN_IPW_SW_MINOR_VERSION_H != CAN_FLEXCAN_TYPES_SW_MINOR_VERSION_H) || \
  141. (CAN_IPW_SW_PATCH_VERSION_H != CAN_FLEXCAN_TYPES_SW_PATCH_VERSION_H))
  142. #error "Software Version Numbers of Can_Ipw.h and Can_Flexcan_Types.h are different"
  143. #endif
  144. /*==================================================================================================
  145. * CONSTANTS
  146. ==================================================================================================*/
  147. /*==================================================================================================
  148. * DEFINES AND MACROS
  149. ==================================================================================================*/
  150. /* @violates @ref Can_Flexcan_h_REF_2 MISRA 2012 Advisory Rule 4.9 */
  151. #define Call_Can_FlexCan_Init(instance, status, Can_pControllerConfig) FlexCAN_Ip_Init(instance, status, Can_pControllerConfig)
  152. /*==================================================================================================
  153. * ENUMS
  154. ==================================================================================================*/
  155. /*==================================================================================================
  156. * STRUCTURES AND OTHER TYPEDEFS
  157. ==================================================================================================*/
  158. /*==================================================================================================
  159. * GLOBAL VARIABLE DECLARATIONS
  160. ==================================================================================================*/
  161. /*==================================================================================================
  162. * FUNCTION PROTOTYPES
  163. ==================================================================================================*/
  164. #define CAN_START_SEC_CODE
  165. /* @violates @ref Can_Ipw_h_REF_1 MISRA 2012 Required Directive 4.10. */
  166. #include "Can_MemMap.h"
  167. /* Initialize Controller */
  168. Std_ReturnType Can_Ipw_Init(const Can_ControllerConfigType * Can_pControllerConfig);
  169. /* Initialize Rx Fifo or MBs for reception ready */
  170. Std_ReturnType Can_Ipw_InitRx(const Can_ControllerConfigType * Can_pController);
  171. /* De-Initialize Controller */
  172. void Can_Ipw_DeInit(const Can_ControllerConfigType * Can_pControllerConfig);
  173. #if (CAN_SET_BAUDRATE_API == STD_ON)
  174. /* Set Baud Rate of Controller */
  175. Std_ReturnType Can_Ipw_SetBaudrate
  176. (
  177. const Can_ControllerConfigType * Can_pControllerConfig,
  178. uint16 BaudRateConfigID
  179. );
  180. #endif
  181. /* Set Controller to participate the CAN network */
  182. Std_ReturnType Can_Ipw_SetControllerToStartMode(const Can_ControllerConfigType * Can_pControllerConfig);
  183. /* Set Controller to stop participating the CAN network */
  184. Std_ReturnType Can_Ipw_SetControllerToStopMode(const Can_ControllerConfigType * Can_pControllerConfig);
  185. /* Disable Can Controller Interrupt */
  186. void Can_Ipw_DisableControllerInterrupts(const Can_ControllerConfigType * Can_pControllerConfig);
  187. /* Enable Can Controller Interrupt */
  188. void Can_Ipw_EnableControllerInterrupts(const Can_ControllerConfigType * Can_pControllerConfig);
  189. /* Get Controller Error State */
  190. uint8 Can_Ipw_GetControllerErrorState(const Can_ControllerConfigType * Can_pControllerConfig);
  191. /* Get Controller Rx Error Counter */
  192. uint8 Can_Ipw_GetControllerRxErrorCounter(const Can_ControllerConfigType * Can_pControllerConfig);
  193. /* Get Controller Tx Error Counter */
  194. uint8 Can_Ipw_GetControllerTxErrorCounter(const Can_ControllerConfigType * Can_pControllerConfig);
  195. #if (CAN_LISTEN_ONLY_MODE == STD_ON)
  196. /* Enable or disable Listen Only Mode */
  197. Std_ReturnType Can_Ipw_ListenOnlyMode(const Can_ControllerConfigType * Can_pControllerConfig, const Can_ListenOnlyType State);
  198. #endif /* (CAN_LISTEN_ONLY_MODE == STD_ON) */
  199. /* Write Pduinfo to Hw Buffer and request transmission */
  200. Std_ReturnType Can_Ipw_Write
  201. (
  202. const Can_ControllerConfigType * Can_pControllerConfig,
  203. const Can_HwObjectConfigType * Can_pHwObjectConfig,
  204. const Can_PduType * PduInfo
  205. );
  206. #if (CAN_ABORT_MB_API == STD_ON)
  207. /* Cancel of a pending CAN transmission */
  208. void Can_Ipw_AbortMb
  209. (
  210. const Can_ControllerConfigType * Can_pControllerConfig,
  211. const Can_HwObjectConfigType * Can_pHwObjectConfig
  212. );
  213. #endif
  214. #if (CAN_DUAL_CLOCK_MODE == STD_ON)
  215. /* Switch to another clock by changing controller's prescaler */
  216. void Can_Ipw_SetClockMode
  217. (
  218. const Can_ControllerConfigType * Can_pControllerConfig,
  219. uint16 Can_u16BaudrateID,
  220. Can_ClockModeType Can_eClkMode
  221. );
  222. #endif
  223. /* Polling Tx Confirmation */
  224. void Can_Ipw_MainFunction_Write
  225. (
  226. const Can_ControllerConfigType * Can_pControllerConfig,
  227. const Can_HwObjectConfigType * Can_pHwObjectConfig
  228. );
  229. /* Polling Rx Indication */
  230. void Can_Ipw_MainFunction_Read
  231. (
  232. const Can_ControllerConfigType * Can_pControllerConfig,
  233. const Can_HwObjectConfigType * Can_pHwObjectConfig
  234. );
  235. /* Polling Bus Off */
  236. void Can_Ipw_MainFunction_BusOff(const Can_ControllerConfigType * Can_pControllerConfig);
  237. /* Polling Controller Mode Transitions */
  238. void Can_Ipw_MainFunction_Mode
  239. (
  240. const Can_ControllerConfigType * Can_pControllerConfig,
  241. Can_ControllerStateType * Can_pControllerState
  242. );
  243. #if (CAN_MB_INTERRUPT_SUPPORT == STD_ON)
  244. /* Process Tx Interrupt */
  245. void Can_Ipw_ProcessTxMesgBuffer
  246. (
  247. const Can_ControllerConfigType * Can_pControllerConfig,
  248. const Can_HwObjectConfigType * Can_pHwObjectConfig,
  249. uint8 u8MbIdx
  250. );
  251. /* Process Rx Interrupt */
  252. void Can_Ipw_ProcessRxMesgBuffer
  253. (
  254. const Can_ControllerConfigType * Can_pControllerConfig,
  255. const Can_HwObjectConfigType * Can_pHwObjectConfig,
  256. uint8 u8MbIdx
  257. );
  258. #if (CAN_ENHANCED_FIFO_ENABLED == STD_ON)
  259. /* Process Rx Enhance FIFO Interrupt */
  260. void Can_Ipw_ProcessRxEnhance
  261. (
  262. const Can_ControllerConfigType * Can_pControllerConfig,
  263. const Can_HwObjectConfigType * Can_pHwObjectConfig,
  264. uint8 u8Event
  265. );
  266. #endif
  267. #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
  268. void Can_Ipw_ProcessRxLegacyDma
  269. (
  270. const Can_ControllerConfigType * Can_pControllerConfig,
  271. const Can_HwObjectConfigType * Can_pHwObjectConfig,
  272. uint8 u8Event
  273. );
  274. #endif
  275. #endif
  276. #if (CAN_PUBLIC_ICOM_SUPPORT == STD_ON)
  277. Std_ReturnType Can_Ipw_DeactivateIcomConfiguration(const Can_ControllerConfigType * Can_pControllerConfig);
  278. Std_ReturnType Can_Ipw_SetIcomConfiguration(const Can_ControllerConfigType * Can_pControllerConfig, const Can_IcomConfigsType * pIcomConfig);
  279. void Can_Ipw_ProcessPN(const Can_ControllerConfigType * Can_pControllerConfig, const Can_IcomConfigsType * pIcomConfig);
  280. #endif /* (CAN_PUBLIC_ICOM_SUPPORT == STD_ON) */
  281. #define CAN_STOP_SEC_CODE
  282. /* @violates @ref Can_Ipw_h_REF_1 MISRA 2012 Required Directive 4.10. */
  283. #include "Can_MemMap.h"
  284. #ifdef __cplusplus
  285. }
  286. #endif
  287. #endif /*TEMPLATE_H*/
  288. /** @} */