Can.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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. ==================================================================================================*/
  26. #ifndef CAN_H
  27. #define CAN_H
  28. /**
  29. * @file Can.h
  30. * @version 1.0.0
  31. *
  32. * @brief AUTOSAR Can - module interface.
  33. * @details API header for CAN driver.
  34. *
  35. * @addtogroup CAN_DRIVER
  36. * @{
  37. */
  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_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.
  63. * This violation is not fixed since the inclusion of <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
  64. *
  65. * @section Can_h_REF_2
  66. * Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
  67. * Declaration is reserved for future feature.
  68. *
  69. * @section Can_h_REF_3
  70. * Violates MISRA 2012 Advisory Rule 4.9, A function should be used in preference to a function-like macro where they are interchangeable.
  71. * Function like macro are used to reduce code complexity
  72. *
  73. * @section Can_h_REF_4
  74. * Violates MISRA 2012 Advisory Rule 2.3, A project should not contain unused type declarations.
  75. * The declarations are used depend on user configuration.
  76. *
  77. * @section Can_h_REF_5
  78. * Violates MISRA 2012 Advisory Rule 8.9, An object should be defined at block scope if identifier only appears in a single function.
  79. * These objects are used when Precompile is supported.
  80. *
  81. * @section Can_h_REF_6
  82. * Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor
  83. * directives or comments.
  84. */
  85. /*
  86. (CAN043) The file Can.h contains the declaration of the Can module API.
  87. (CAN037) The file Can.h only contains 'extern' declarations of constants, global data, type definitions and services
  88. that are specified in the Can module SWS.
  89. */
  90. /**
  91. *
  92. */
  93. /*==================================================================================================
  94. * INCLUDE FILES
  95. * 1) system and project includes
  96. * 2) needed interfaces from external units
  97. * 3) internal and external interfaces from this unit
  98. ==================================================================================================*/
  99. /**
  100. *
  101. */
  102. #include "ComStackTypes.h"
  103. #include "Soc_Ips.h"
  104. #include "Can_Flexcan_Types.h"
  105. #include "Can_Ipw_Types.h"
  106. /*==================================================================================================
  107. * SOURCE FILE VERSION INFORMATION
  108. ==================================================================================================*/
  109. /*
  110. Internal micro-dependent versioning. Check of AUTOSAR & Vendor specification version.
  111. */
  112. /**
  113. * @{
  114. *
  115. */
  116. #define CAN_VENDOR_ID 43
  117. /* @violates @ref Can_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
  118. #define CAN_MODULE_ID 80
  119. #define CAN_AR_RELEASE_MAJOR_VERSION 4
  120. #define CAN_AR_RELEASE_MINOR_VERSION 4
  121. #define CAN_AR_RELEASE_REVISION_VERSION 0
  122. #define CAN_SW_MAJOR_VERSION 1
  123. #define CAN_SW_MINOR_VERSION 0
  124. #define CAN_SW_PATCH_VERSION 0
  125. /**@}*/
  126. /*==================================================================================================
  127. * FILE VERSION CHECKS
  128. ==================================================================================================*/
  129. /* Check if current file and Can_Ipw_Types header file are of the same vendor */
  130. #if (CAN_VENDOR_ID != CAN_IPW_TYPES_VENDOR_ID_H)
  131. #error "Can.h and Can_Ipw_Types.h have different vendor ids"
  132. #endif
  133. /* Check if current file and Can_Ipw_Types header file are of the same Autosar version */
  134. #if ((CAN_AR_RELEASE_MAJOR_VERSION != CAN_IPW_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
  135. (CAN_AR_RELEASE_MINOR_VERSION != CAN_IPW_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
  136. (CAN_AR_RELEASE_REVISION_VERSION != CAN_IPW_TYPES_AR_RELEASE_REVISION_VERSION_H) \
  137. )
  138. #error "AutoSar Version Numbers of Can.h and Can_Ipw_Types.h are different"
  139. #endif
  140. /* Check if current file and Can_Ipw_Types header file are of the same software version */
  141. #if ((CAN_SW_MAJOR_VERSION != CAN_IPW_TYPES_SW_MAJOR_VERSION_H) || \
  142. (CAN_SW_MINOR_VERSION != CAN_IPW_TYPES_SW_MINOR_VERSION_H) || \
  143. (CAN_SW_PATCH_VERSION != CAN_IPW_TYPES_SW_PATCH_VERSION_H) \
  144. )
  145. #error "Software Version Numbers of Can.h and Can_Ipw_Types.h are different"
  146. #endif
  147. /* Check if current file and Can_Flexcan_Types header file are of the same vendor */
  148. #if (CAN_VENDOR_ID != CAN_FLEXCAN_TYPES_VENDOR_ID_H)
  149. #error "Can.h and Can_Flexcan_Types.h have different vendor ids"
  150. #endif
  151. /* Check if current file and Can_Flexcan_Types header file are of the same Autosar version */
  152. #if ((CAN_AR_RELEASE_MAJOR_VERSION != CAN_FLEXCAN_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
  153. (CAN_AR_RELEASE_MINOR_VERSION != CAN_FLEXCAN_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
  154. (CAN_AR_RELEASE_REVISION_VERSION != CAN_FLEXCAN_TYPES_AR_RELEASE_REVISION_VERSION_H) \
  155. )
  156. #error "AutoSar Version Numbers of Can.h and Can_Flexcan_Types.h are different"
  157. #endif
  158. /* Check if current file and Can_Ipw_Types header file are of the same software version */
  159. #if ((CAN_SW_MAJOR_VERSION != CAN_FLEXCAN_TYPES_SW_MAJOR_VERSION_H) || \
  160. (CAN_SW_MINOR_VERSION != CAN_FLEXCAN_TYPES_SW_MINOR_VERSION_H) || \
  161. (CAN_SW_PATCH_VERSION != CAN_FLEXCAN_TYPES_SW_PATCH_VERSION_H) \
  162. )
  163. #error "Software Version Numbers of Can.h and Can_Flexcan_Types.h are different"
  164. #endif
  165. /* Check if current file and CAN configuration header file are of the same software version */
  166. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  167. #if ((CAN_AR_RELEASE_MAJOR_VERSION != SOC_IPS_AR_RELEASE_MAJOR_VERSION) || \
  168. (CAN_AR_RELEASE_MINOR_VERSION != SOC_IPS_AR_RELEASE_MINOR_VERSION) \
  169. )
  170. #error "Software Version Numbers of Can.h and Soc_Ips.h are different"
  171. #endif
  172. /* Check if current file and ComStackTypes header file are of the same Autosar version */
  173. #if ((CAN_AR_RELEASE_MAJOR_VERSION != COMTYPE_AR_RELEASE_MAJOR_VERSION) || \
  174. (CAN_AR_RELEASE_MINOR_VERSION != COMTYPE_AR_RELEASE_MINOR_VERSION) \
  175. )
  176. #error "AutoSar Version Numbers of Can.h and ComStackTypes.h are different"
  177. #endif
  178. #endif
  179. /*==================================================================================================
  180. * CONSTANTS
  181. ==================================================================================================*/
  182. /*==================================================================================================
  183. * DEFINES AND MACROS
  184. ==================================================================================================*/
  185. /*==================================================================================================
  186. * ENUMS
  187. ==================================================================================================*/
  188. #if (CAN_DEV_ERROR_DETECT == STD_ON)
  189. /**
  190. * @brief Can_StatusType
  191. * @details CAN Driver status used for checking and preventing double driver intialization.
  192. * CAN_UNINIT = The CAN controller is not initialized. The CAN Controller is not participating on the CAN bus.
  193. * All registers belonging to the CAN module are in reset state, CAN interrupts are disabled.
  194. * CAN_READY = Controller has initialized: static variables, including flags;
  195. * Common setting for the complete CAN HW unit; CAN controller specific settings for each CAN controller.
  196. *
  197. */
  198. typedef enum
  199. {
  200. CAN_UNINIT = 0U, /**< @brief Driver not initialized */
  201. CAN_READY /**< @brief Driver ready */
  202. }Can_DriverStatusType;
  203. #endif /* CAN_DEV_ERROR_DETECT == STD_ON */
  204. /*==================================================================================================
  205. * STRUCTURES AND OTHER TYPEDEFS
  206. ==================================================================================================*/
  207. /** @brief Can Configuration */
  208. typedef struct
  209. {
  210. /** @brief Configuration Core ID */
  211. const uint32 Can_u32CoreID;
  212. /** @brief The first Hth after Hrh consecutive */
  213. const Can_HwHandleType Can_uHthFirstIndex;
  214. /** @brief Mapping Controller ID to Controller hardware offset */
  215. const uint8 * Can_pCtrlOffsetToCtrlIDMap;
  216. /** @brief Mapping Controller ID to Hardware Object ID */
  217. const uint8 * Can_pHwObjIDToCtrlIDMap;
  218. /** @brief Pointer to Can Hardware Object Config */
  219. const Can_HwObjectConfigType * Can_pHwObjectConfig;
  220. #if (CAN_PUBLIC_ICOM_SUPPORT == STD_ON)
  221. /** @brief The size of Can Pn Configs */
  222. const uint8 u8NumCanIcomConfigs;
  223. /** brief Pointer point to Can Pn Configs */
  224. const Can_IcomConfigsType * pCanIcomConfigs;
  225. #endif /* (!!CAN##!!_##PUBLIC_ICOM_SUPPORT == STD_ON) */
  226. /** @brief Pointer to Can Controller Config */
  227. const Can_ControllerConfigType * const * Can_ppController;
  228. }Can_ConfigType;
  229. /*==================================================================================================
  230. * GLOBAL VARIABLE DECLARATIONS
  231. ==================================================================================================*/
  232. #define CAN_START_SEC_CONFIG_DATA_UNSPECIFIED
  233. /* @violates @ref Can_h_REF_1 MISRA 2012 Required Directive 4.10 */
  234. #include "Can_MemMap.h"
  235. CAN_CONFIG_EXT
  236. #define CAN_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  237. /* @violates @ref Can_h_REF_1 MISRA 2012 Required Directive 4.10 */
  238. /* @violates @ref Can_h_REF_6 MISRA 2012 Advisory Rule 20.1 */
  239. #include "Can_MemMap.h"
  240. /*==================================================================================================
  241. * FUNCTION PROTOTYPES
  242. ==================================================================================================*/
  243. #define CAN_START_SEC_CODE
  244. /* @violates @ref Can_h_REF_1 MISRA 2012 Required Directive 4.10 */
  245. /* @violates @ref Can_h_REF_6 MISRA 2012 Advisory Rule 20.1 */
  246. #include "Can_MemMap.h"
  247. #if (CAN_VERSION_INFO_API == STD_ON)
  248. /**
  249. * @brief Returns the version information of this module. SID is 0x07
  250. * @details This routine is called by:
  251. * - CanIf or an upper layer according to Autosar requirements.
  252. *
  253. * @param[in] versioninfo A pointer to location to store version info
  254. * Must be omitted if the function does not have parameters.
  255. *
  256. * @return void
  257. *
  258. *
  259. * @pre The CAN_VERSION_INFO_API define must be configured on.
  260. * @post The version information is return if the parameter versionInfo is not a null pointer.
  261. *
  262. *
  263. */
  264. void Can_GetVersionInfo(Std_VersionInfoType * versioninfo);
  265. #endif /* CAN_VERSION_INFO_API == STD_ON */
  266. /**
  267. * @brief Initialize the CAN driver. SID is 0x00.
  268. * @details Initialize all the controllers.
  269. * The CAN module shall be initialized by Can_Init(<&Can_Configuration>) service call during the start-up.
  270. * This routine is called by:
  271. * - CanIf or an upper layer according to Autosar requirements.
  272. *
  273. * @param[in] Config Pointer to driver configuration.
  274. *
  275. * @return void
  276. *
  277. *
  278. * @pre Can_Init shall be called at most once during runtime.
  279. * @post Can_Init shall initialize all the controllers and set the driver in READY state.
  280. *
  281. */
  282. void Can_Init(const Can_ConfigType * Config);
  283. /**
  284. * @brief De-initialize the CAN driver. SID is 0x10.
  285. * @details De-initialize all the controllers.
  286. * The CAN module shall be de-initialized by Can_DeInit() service call during the start-up.
  287. * This routine is called by:
  288. * - CanIf or an upper layer according to Autosar requirements.
  289. *
  290. * @param[in] None
  291. *
  292. * @return void
  293. *
  294. *
  295. * @pre Before controller de-initalization, the driver must be initialized and the controllers must be not in Start state.
  296. * @post Can_DeInit shall de-initialize all the controllers and set the driver in UNINIT state.
  297. *
  298. */
  299. void Can_DeInit(void);
  300. #if (CAN_SET_BAUDRATE_API == STD_ON)
  301. /**
  302. * @brief This function set baudrate
  303. * @details This routine is called by an upper layer.
  304. *
  305. * @param[in] Controller controller ID
  306. * @param[in] BaudRateConfigID baudrateID selection
  307. *
  308. * @return Std_ReturnType Result of the transition.
  309. * @retval E_OK Switch baudrate operation was ok.
  310. * @retval E_NOT_OK Switch baudrate operation was not ok.
  311. *
  312. * @pre Driver must be initialized.
  313. */
  314. Std_ReturnType Can_SetBaudrate
  315. (
  316. uint8 Controller,
  317. uint16 BaudRateConfigID
  318. );
  319. #endif /* CAN_SET_BAUDRATE_API == STD_ON */
  320. /**
  321. * @brief Put the controller into a required state. SID is 0x03.
  322. * @details Switch the controller from one state to another.
  323. * This routine is called by:
  324. * - CanIf or an upper layer according to Autosar requirements.
  325. *
  326. * @param[in] Controller - Can controller for which the status shall be changed - based on configuration order list (CanControllerId).
  327. * @param[in] Transition - Possible transitions (CAN_CS_STOPPED , CAN_CS_STARTED , CAN_CS_SLEEP)
  328. * @return Std_ReturnType Result of the transition.
  329. * @retval E_OK request accepted.
  330. * @retval E_NOT_OK request not accepted, a development error occurred.
  331. *
  332. *
  333. * @pre Before changing the controller state the driver must be initialized.
  334. * @post After the transition to the new state the interrupts required for that state must be enebaled.
  335. *
  336. *
  337. */
  338. Std_ReturnType Can_SetControllerMode(uint8 Controller, Can_ControllerStateType Transition);
  339. #if (CAN_LISTEN_ONLY_MODE == STD_ON)
  340. /**
  341. * @brief Enable or disable Listen Only Mode. SID is 0x32.
  342. * @details Enable or disable Listen Only Mode.
  343. * @param[in] Controller - Controller in which ListenOnlyMode will be enabled/disabled.
  344. * @param[in] State - Enable or Disable the feature (NORMAL_MODE , LISTEN_ONLY_MODE)
  345. * @return Std_ReturnType Result of the transition.
  346. * @retval E_OK request accepted.
  347. * @retval E_NOT_OK request not accepted, a development error occurred.
  348. *
  349. * @pre
  350. * @post
  351. *
  352. *
  353. */
  354. Std_ReturnType Can_ListenOnlyMode(uint8 Controller, Can_ListenOnlyType State);
  355. #endif /* (CAN_LISTEN_ONLY_MODE == STD_ON) */
  356. /**
  357. * @brief Disable INTs. SID is 0x04.
  358. * @details Switch OFF the controller's interrupts.
  359. * This routine is called by:
  360. * - CanIf or an upper layer according to Autosar requirements.
  361. *
  362. * @param[in] Controller Can controller for which interrupts shall be disabled - based on configuration order list (CanControllerId).
  363. *
  364. * @return void
  365. *
  366. *
  367. * @pre Driver must be initalzied before changing the interrupts state (en or dis).
  368. * @post Controller must not respond to any interrupt assertion.
  369. *
  370. *
  371. */
  372. void Can_DisableControllerInterrupts(uint8 Controller);
  373. /**
  374. * @brief Enable INTs. SID is 0x05.
  375. * @details Switch ON the controller's interrupts.
  376. * This routine is called by:
  377. * - CanIf or an upper layer according to Autosar requirements.
  378. *
  379. * @param[in] Controller Can controller for which interrupts shall be disabled - based on configuration order list (CanControllerId).
  380. *
  381. * @return void
  382. *
  383. *
  384. * @pre Driver must be initalzied before changing the interrupts state (en or dis).
  385. * @post Controller must respond to interrupt assertion.
  386. *
  387. */
  388. void Can_EnableControllerInterrupts(uint8 Controller);
  389. #if (CAN_CHECK_WAKEUP_API == STD_ON)
  390. Std_ReturnType Can_CheckWakeup(uint8 Controller);
  391. #endif
  392. /**
  393. * @brief Obtains the error state of the CAN controller.. SID is 0x11
  394. * @details This routine is called by:
  395. * - CanIf or an upper layer according to Autosar requirements.
  396. *
  397. * @param[in] ControllerId: Abstracted CanIf ControllerId which is assigned to a CAN controller, which is requested for ErrorState.
  398. *
  399. * @param[out] ErrorStatePtr: Pointer to a memory location, where the error state of the CAN controller will be stored.
  400. *
  401. * @return Std_ReturnType Result of the transition.
  402. * @retval E_OK : Error state request has been accepted.
  403. * @retval E_NOT_OK : Error state request has not been accepted.
  404. *
  405. * @pre
  406. * @post
  407. *
  408. *
  409. */
  410. Std_ReturnType Can_GetControllerErrorState
  411. (
  412. uint8 ControllerId,
  413. Can_ErrorStateType * ErrorStatePtr
  414. );
  415. /**
  416. * @brief Reports about the current status of the requested CAN controller. SID is 0x12
  417. * @details This routine is called by:
  418. * - CanIf or an upper layer according to Autosar requirements.
  419. *
  420. * @param[in] Controller: CAN controller for which the status shall be requested.
  421. *
  422. * @param[out] ControllerModePtr: Pointer to a memory location, where the current mode of the CAN controller will be stored.
  423. *
  424. * @return Std_ReturnType Result of the transition.
  425. * @retval E_OK : Controller mode request has been accepted.
  426. * @retval E_NOT_OK : Controller mode request has not been accepted.
  427. *
  428. * @pre
  429. * @post
  430. *
  431. *
  432. */
  433. Std_ReturnType Can_GetControllerMode
  434. (
  435. uint8 Controller,
  436. Can_ControllerStateType * ControllerModePtr
  437. );
  438. /**
  439. * @brief Return the Rx error counter for a CAN controller
  440. * @details Return the Rx error counter for a CAN controller. This value might not be
  441. * available for all CAN controller, in which case E_NOT_OK would be returned.
  442. * Please note that the value of the counter might not be correct at the moment
  443. * the API returns it, because the Rx counter is handled asynchronously in hardware.
  444. * Applications should not trust this value for any assumption about the current bus state.
  445. *
  446. * @param[in] ControllerId: CAN controller, whose current Rx error counter shall be acquired.
  447. * @param[out] RxErrorCounterPtr: Pointer to a memory location, where the current Rx error
  448. * counter of the CAN controller will be stored.
  449. *
  450. * @return Std_ReturnType Result of the transition.
  451. * @retval E_OK: Rx error counter available.
  452. * @retval E_NOT_OK: Wrong ControllerId, or Rx error counter not available.
  453. *
  454. * @pre
  455. * @post
  456. *
  457. */
  458. Std_ReturnType Can_GetControllerRxErrorCounter
  459. (
  460. uint8 ControllerId,
  461. uint8 * RxErrorCounterPtr
  462. );
  463. /**
  464. * @brief Return the Tx error counter for a CAN controller
  465. * @details Return the Tx error counter for a CAN controller. This value might not be
  466. * available for all CAN controller, in which case E_NOT_OK would be returned.
  467. * Please note that the value of the counter might not be correct at the moment
  468. * the API returns it, because the Tx counter is handled asynchronously in hardware.
  469. * Applications should not trust this value for any assumption about the current bus state.
  470. *
  471. * @param[in] ControllerId: CAN controller, whose current Tx error counter shall be acquired.
  472. * @param[out] TxErrorCounterPtr: Pointer to a memory location, where the current Tx error
  473. * counter of the CAN controller will be stored.
  474. *
  475. * @return Std_ReturnType Result of the transition.
  476. * @retval E_OK: Tx error counter available.
  477. * @retval E_NOT_OK: Wrong ControllerId, or Tx error counter not available.
  478. *
  479. * @pre
  480. * @post
  481. *
  482. */
  483. Std_ReturnType Can_GetControllerTxErrorCounter
  484. (
  485. uint8 ControllerId,
  486. uint8 * TxErrorCounterPtr
  487. );
  488. /**
  489. * @brief Transmit information on CAN bus. SID is 0x06.
  490. * @details Can_Write checks if hardware transmit object that is identified by the HTH is free.
  491. * Can_Write checks if another Can_Write is ongoing for the same HTH.
  492. * a) hardware transmit object is free:
  493. * The mutex for that HTH is set to 'signaled' the ID, DLC and SDU are put in a format appropriate for
  494. * the hardware (if necessary) and copied in the appropriate hardware registers or buffers.
  495. * All necessary control operations to initiate the transmit are done.
  496. * The mutex for that HTH is released. The function returns with E_OK.
  497. * b) hardware transmit object is busy with another transmit request.
  498. * The function returns with CAN_BUSY.
  499. * c) A preemptive call of Can_Write has been issued, that could not be handled reentrant (i.e. a call with the same HTH).
  500. * The function returns with CAN_BUSY the function is non blocking
  501. * d) The hardware transmit object is busy with another transmit request for an L-PDU that has lower priority than that for the current request
  502. * The transmission of the previous L-PDU is cancelled (asynchronously).
  503. * The function returns with CAN_BUSY.
  504. * This routine is called by:
  505. * - CanIf or an upper layer according to Autosar requirements.
  506. *
  507. * @param[in] Hth Information which HW-transmit handle shall be used for transmit.
  508. * Implicitly this is also the information about the controller to use because the Hth numbers are unique inside one hardware unit.
  509. * @param[in] PduInfo Pointer to SDU user memory, DLC and Identifier.
  510. * @return Std_ReturnType Result of the write operation.
  511. * @retval E_OK Write command has been accepted.
  512. * @retval E_NOT_OK Development error occured.
  513. * @retval CAN_BUSY No of TX hardware buffer available or preemtive call of Can_Write() that can't be implemented reentrant.
  514. *
  515. *
  516. * @pre Driver must be initialized and MB must be configured for Tx.
  517. * @post The data can be transmitted or rejected because of another data with a higher priority.
  518. *
  519. *
  520. */
  521. Std_ReturnType Can_Write
  522. (
  523. Can_HwHandleType Hth,
  524. const Can_PduType * PduInfo
  525. );
  526. #if (CAN_ABORT_MB_API == STD_ON)
  527. /**
  528. * @brief Process a message buffer abort
  529. * @details This function write a abort code (b'1001) to MBCS[CODE] field of the MB.
  530. * This routine is called by:
  531. * - CanIf or an upper layer according to Autosar requirements.
  532. *
  533. * @param[in] Hth - HW-transmit handler
  534. *
  535. *
  536. * @pre Driver must be initialized and the current MB transmission should be ready for transmit.
  537. *
  538. *
  539. * @note Not AUTOSAR required. This is user implementation.
  540. */
  541. void Can_AbortMb(Can_HwHandleType Hth);
  542. #endif /* CAN_ABORT_MB_API == STD_ON */
  543. #if (CAN_DUAL_CLOCK_MODE == STD_ON)
  544. /**
  545. * @brief Function switch between two prescaler that was configured when Clock Source value to driver changed to another one.
  546. * @details Function sets all controllers' prescaller based on input parameter.
  547. *
  548. * @param[in] eClkMode - prescaler setting (NORMAL or ALTERNATE)
  549. *
  550. * @pre Can_Init must be called before, all controllers must be in STOPPED.
  551. *
  552. */
  553. void Can_SetClockMode(Can_ClockModeType eClkMode);
  554. #endif
  555. #if (CAN_PUBLIC_ICOM_SUPPORT == STD_ON)
  556. /**
  557. * @brief Set controller into Pretended Networking mode with the ConfigurationID valid.
  558. * @details This function is API which support the Pretended Networking featrue. After this function is called,
  559. * it will configure for controller with information in the configurationIDs (corresponding with ID valid )
  560. *
  561. * @param[in] Controller CAN controller for which the init shall be done. Based on configuration order list (CanControllerId).
  562. * @param[in] ConfigurationId the ID of CanIcomConfig
  563. *
  564. * @return Std_ReturnType
  565. * @retval E_OK PNET is Enabled/disabled successfully.
  566. * @retval E_NOT_OK PNET is not Enabled/disabled successfully.
  567. *
  568. * @pre Driver must be initialized
  569. *
  570. * @note In order to activate PNET (ConfigurationId != 0) the controller must be in START mode.
  571. * @implements Can_SetIcomConfiguration_Activity
  572. */
  573. Std_ReturnType Can_SetIcomConfiguration(uint8 Controller, IcomConfigIdType ConfigurationId);
  574. #endif /* (CAN_PUBLIC_ICOM_SUPPORT == STD_ON) */
  575. #define CAN_STOP_SEC_CODE
  576. /* @violates @ref Can_h_REF_1 MISRA 2012 Required Directive 4.10 */
  577. /* @violates @ref Can_h_REF_6 MISRA 2012 Advisory Rule 20.1 */
  578. #include "Can_MemMap.h"
  579. #ifdef __cplusplus
  580. }
  581. #endif
  582. /** @} */
  583. #endif /* CAN_H */