Port.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : PORT_CI
  5. * Dependencies : none
  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. #ifndef PORT_H
  25. #define PORT_H
  26. /**
  27. * @file Port.h
  28. *
  29. * @implements Port.h_Artifact
  30. * @brief Autosar Port driver header file
  31. * @details Port driver header file containg exported fucntions and macros
  32. *
  33. * @defgroup Port_HLD Port HLD
  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 "StandardTypes.h"
  46. #include "Port_Cfg.h"
  47. #include "Port_Ipw.h"
  48. #include "Mcal.h"
  49. /*=================================================================================================
  50. * SOURCE FILE VERSION INFORMATION
  51. =================================================================================================*/
  52. /**
  53. * @brief Parameters that shall be published within the Port driver header file and also in the
  54. * module's description file
  55. */
  56. #define PORT_VENDOR_ID_H 43
  57. #define PORT_MODULE_ID 124
  58. #define PORT_AR_RELEASE_MAJOR_VERSION_H 4
  59. #define PORT_AR_RELEASE_MINOR_VERSION_H 4
  60. #define PORT_AR_RELEASE_REVISION_VERSION_H 0
  61. #define PORT_SW_MAJOR_VERSION_H 1
  62. #define PORT_SW_MINOR_VERSION_H 0
  63. #define PORT_SW_PATCH_VERSION_H 0
  64. /*=================================================================================================
  65. * FILE VERSION CHECKS
  66. =================================================================================================*/
  67. /* Check if the files Port.h and Port_Cfg.h are of the same vendor */
  68. #if (PORT_VENDOR_ID_H != PORT_VENDOR_ID_CFG_H)
  69. #error "Port.h and Port_Cfg.h have different vendor ids"
  70. #endif
  71. /* Check if the files Port.h and Port_Cfg.h are of the same Autosar version */
  72. #if ((PORT_AR_RELEASE_MAJOR_VERSION_H != PORT_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
  73. (PORT_AR_RELEASE_MINOR_VERSION_H != PORT_AR_RELEASE_MINOR_VERSION_CFG_H) || \
  74. (PORT_AR_RELEASE_REVISION_VERSION_H != PORT_AR_RELEASE_REVISION_VERSION_CFG_H) \
  75. )
  76. #error "AutoSar Version Numbers of Port.h and Port_Cfg.h are different"
  77. #endif
  78. /* Check if the files Port.h and Port_Cfg.h are of the same software version */
  79. #if ((PORT_SW_MAJOR_VERSION_H != PORT_SW_MAJOR_VERSION_CFG_H) || \
  80. (PORT_SW_MINOR_VERSION_H != PORT_SW_MINOR_VERSION_CFG_H) || \
  81. (PORT_SW_PATCH_VERSION_H != PORT_SW_PATCH_VERSION_CFG_H) \
  82. )
  83. #error "Software Version Numbers of Port.h and Port_Cfg.h are different"
  84. #endif
  85. /* Check if the files Port.h and Port_Ipw.h are of the same vendor */
  86. #if (PORT_VENDOR_ID_H != PORT_VENDOR_ID_IPW_H)
  87. #error "Port.h and Port_Ipw.h have different vendor ids"
  88. #endif
  89. /* Check if the files Port.h and Port_Ipw.h are of the same Autosar version */
  90. #if ((PORT_AR_RELEASE_MAJOR_VERSION_H != PORT_AR_RELEASE_MAJOR_VERSION_IPW_H) || \
  91. (PORT_AR_RELEASE_MINOR_VERSION_H != PORT_AR_RELEASE_MINOR_VERSION_IPW_H) || \
  92. (PORT_AR_RELEASE_REVISION_VERSION_H != PORT_AR_RELEASE_REVISION_VERSION_IPW_H) \
  93. )
  94. #error "AutoSar Version Numbers of Port.h and Port_Ipw.h are different"
  95. #endif
  96. /* Check if the files Port.h and Port_Ipw.h are of the same Software version */
  97. #if ((PORT_SW_MAJOR_VERSION_H != PORT_SW_MAJOR_VERSION_IPW_H) || \
  98. (PORT_SW_MINOR_VERSION_H != PORT_SW_MINOR_VERSION_IPW_H) || \
  99. (PORT_SW_PATCH_VERSION_H != PORT_SW_PATCH_VERSION_IPW_H) \
  100. )
  101. #error "Software Version Numbers of Port.h and Port_Ipw.h are different"
  102. #endif
  103. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  104. /* Check if the files Port.h and StandardTypes.h are of the same version */
  105. #if ((PORT_AR_RELEASE_MAJOR_VERSION_H != STD_AR_RELEASE_MAJOR_VERSION) || \
  106. (PORT_AR_RELEASE_MINOR_VERSION_H != STD_AR_RELEASE_MINOR_VERSION) \
  107. )
  108. #error "AutoSar Version Numbers of Port.h and StandardTypes.h are different"
  109. #endif
  110. /* Check if the files Port.h and Mcal.h are of the same version */
  111. #if ((PORT_AR_RELEASE_MAJOR_VERSION_H != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  112. (PORT_AR_RELEASE_MINOR_VERSION_H != MCAL_AR_RELEASE_MINOR_VERSION) \
  113. )
  114. #error "AutoSar Version Numbers of Port.h and Mcal.h are different"
  115. #endif
  116. #endif
  117. /*=================================================================================================
  118. * CONSTANTS
  119. =================================================================================================*/
  120. /**
  121. * @brief The PORT module is not properly configured
  122. *
  123. * @api
  124. */
  125. #define PORT_E_PARAM_CONFIG ((uint8)0xF0)
  126. /* Instance IDs */
  127. /**
  128. * @brief Instance ID of port driver.
  129. *
  130. */
  131. #define PORT_INSTANCE_ID ((uint8)0x0)
  132. /* Service IDs */
  133. /*
  134. * @brief Service ID of port driver.
  135. */
  136. /**
  137. * @brief API service ID for PORT Init function.
  138. * @details Parameters used when raising an error/exception.
  139. *
  140. * @api
  141. *
  142. */
  143. #define PORT_INIT_ID ((uint8)0x00)
  144. /**
  145. * @brief API service ID for PORT set pin direction function.
  146. * @details Parameters used when raising an error/exception.
  147. *
  148. * @api
  149. *
  150. */
  151. #define PORT_SETPINDIRECTION_ID ((uint8)0x01)
  152. /**
  153. * @brief API service ID for PORT refresh pin direction function.
  154. * @details Parameters used when raising an error/exception.
  155. *
  156. * @api
  157. *
  158. */
  159. #define PORT_REFRESHPINDIRECTION_ID ((uint8)0x02)
  160. /**
  161. * @brief API service ID for PORT get version info function.
  162. * @details Parameters used when raising an error/exception.
  163. *
  164. * @api
  165. *
  166. */
  167. #define PORT_GETVERSIONINFO_ID ((uint8)0x03)
  168. /**
  169. * @brief API service ID for PORT set pin mode.
  170. * @details Parameters used when raising an error/exception.
  171. *
  172. * @api
  173. *
  174. */
  175. #define PORT_SETPINMODE_ID ((uint8)0x04)
  176. /**
  177. * @brief API service ID for PORT set as unused pin.
  178. * @details Parameters used when raising an error/exception.
  179. */
  180. #define PORT_SETASUNUSEDPIN_ID ((uint8)0x05)
  181. /**
  182. * @brief API service ID for PORT set as used pin.
  183. * @details Parameters used when raising an error/exception.
  184. */
  185. #define PORT_SETASUSEDPIN_ID ((uint8)0x06)
  186. /**
  187. * @brief API service ID for PORT reset pin mode.
  188. * @details Parameters used when raising an error/exception.
  189. *
  190. * @api
  191. *
  192. */
  193. #define PORT_RESETPINMODE_ID ((uint8)0x07)
  194. #ifdef PORT_SET_2_PINS_DIRECTION_API
  195. #if (STD_ON == PORT_SET_2_PINS_DIRECTION_API)
  196. /**
  197. * @brief API service ID for PORT set 2 pins direction function.
  198. * @details Parameters used when raising an error/exception.
  199. *
  200. * @api
  201. *
  202. */
  203. #define PORT_SET2PINSDIRECTION_ID ((uint8)0x08)
  204. #endif /* (STD_ON == PORT_SET_2_PINS_DIRECTION_API) */
  205. #endif
  206. /* Errors IDs */
  207. /**
  208. * @brief Error ID of port driver.
  209. * @details The following errors and exception are detectable by the PORT driver
  210. * if development error detection is enabled.
  211. *
  212. */
  213. /**
  214. * @brief Invalid Port Pin ID requested.
  215. * @details Det Error value, returned by Port_SetPinDirection and Port_PinMode
  216. * if an wrong PortPin ID is passed.
  217. *
  218. * @implements Port_ErrorCodes_define
  219. */
  220. #define PORT_E_PARAM_PIN ((uint8)0x0A)
  221. /**
  222. * @brief Port Pin Direction not configured as changeable.
  223. * @details Det Error value, returned by Port_SetPinDirection
  224. * if the passed PortPin have unchangeable direction.
  225. *
  226. * @implements Port_ErrorCodes_define
  227. */
  228. #define PORT_E_DIRECTION_UNCHANGEABLE ((uint8)0x0B)
  229. /**
  230. * @brief API Port_Init() service called with wrong parameter.
  231. * @details Det Error value, returned by Port_Init function
  232. * if Port_Init is called with wrong parameter.
  233. *
  234. * @implements Port_ErrorCodes_define
  235. */
  236. #define PORT_E_INIT_FAILED ((uint8)0x0C)
  237. /**
  238. * @brief API Port_SetPinMode() service called when mode is invalid.
  239. * @details Det Error value, returned by Port_SetPinMode function
  240. * if the passed PortPinMode is invalid.
  241. *
  242. * @implements Port_ErrorCodes_define
  243. */
  244. #define PORT_E_PARAM_INVALID_MODE ((uint8)0x0D)
  245. /**
  246. * @brief API Port_SetPinMode() service called when mode is unchangeable.
  247. * @details Det Error value, returned by Port_SetPinMode function
  248. * if the passed PortPin have a unchangeable Mode.
  249. *
  250. * @implements Port_ErrorCodes_define
  251. */
  252. #define PORT_E_MODE_UNCHANGEABLE ((uint8)0x0E)
  253. /**
  254. * @brief API service called without module initialization.
  255. * @details Det Error value, returned by a function if API service called
  256. * prior to module initialization.
  257. *
  258. * @implements Port_ErrorCodes_define
  259. */
  260. #define PORT_E_UNINIT ((uint8)0x0F)
  261. /**
  262. * @brief API service called with NULL Pointer Parameter.
  263. * @details Det Error value, returned by Port_GetVersionInfo function
  264. * if API is called with NULL Pointer Parameter.
  265. *
  266. * @implements Port_ErrorCodes_define
  267. */
  268. #define PORT_E_PARAM_POINTER ((uint8)0x10)
  269. /*=================================================================================================
  270. * DEFINES AND MACROS
  271. =================================================================================================*/
  272. /*=================================================================================================
  273. * ENUMS
  274. =================================================================================================*/
  275. /*=================================================================================================
  276. * STRUCTURES AND OTHER TYPEDEFS
  277. =================================================================================================*/
  278. /*=================================================================================================
  279. * GLOBAL VARIABLE DECLARATIONS
  280. =================================================================================================*/
  281. #define PORT_START_SEC_CONFIG_DATA_UNSPECIFIED
  282. #include "Port_MemMap.h"
  283. PORT_CONFIG_EXT
  284. #define PORT_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  285. #include "Port_MemMap.h"
  286. /*=================================================================================================
  287. * FUNCTION PROTOTYPES
  288. =================================================================================================*/
  289. /* Allocate defined section for PORT code */
  290. #define PORT_START_SEC_CODE
  291. #include "Port_MemMap.h"
  292. /*!
  293. * @brief Port driver initialization function
  294. *
  295. * @details Function used for initializing the port driver and
  296. * for initializing the configured pins.
  297. *
  298. *
  299. * @param[in] Port_ConfigType * ConfigPtr Pointer to configuration (NULL_PTR if only one variant is used)
  300. *
  301. * @return void
  302. *
  303. *
  304. **/
  305. void Port_Init
  306. (
  307. const Port_ConfigType * ConfigPtr
  308. );
  309. #if (STD_ON == PORT_SET_PIN_DIRECTION_API)
  310. /*!
  311. * @brief Port_SetPinDirection
  312. *
  313. * @details Function used for changing the pin direction at runtime
  314. *
  315. *
  316. * @param[in]Pin pin id of the pin that needs to change the direction
  317. * @param[in]Direction new desired direction IN OUT IN_OUT
  318. *
  319. * @return void
  320. **/
  321. void Port_SetPinDirection
  322. (
  323. Port_PinType Pin,
  324. Port_PinDirectionType Direction
  325. );
  326. #endif /* (STD_ON == PORT_SET_PIN_DIRECTION_API) */
  327. #ifdef PORT_SET_2_PINS_DIRECTION_API
  328. #if (STD_ON == PORT_SET_2_PINS_DIRECTION_API)
  329. /**
  330. * @brief Sets the direction of 2 pins.
  331. * @details The function @p Port_Set2PinsDirection() will set the port pins direction
  332. * during runtime.
  333. * @pre @p Port_Init() must have been called first. In order to change the
  334. * pin direction the PortPinDirectionChangeable flag must have been set
  335. * to @p TRUE for both pins.
  336. *
  337. * @param[in] Pin1 Pin 1 ID number.
  338. * @param[in] Pin2 Pin 2 ID number.
  339. * @param[in] Direction Port Pin direction.
  340. *
  341. * Port_Set2PinsDirection_Activity
  342. * @api
  343. */
  344. void Port_Set2PinsDirection
  345. (
  346. Port_PinType Pin1,
  347. Port_PinType Pin2,
  348. Port_PinDirectionType Direction
  349. );
  350. #endif /*(STD_ON == PORT_SET_2_PINS_DIRECTION_API) */
  351. #endif
  352. #if (STD_ON == PORT_SET_PIN_MODE_API)
  353. /*!
  354. * @brief Port_SetPinMode
  355. *
  356. * @details Function used to change the pin mode at runtime.
  357. *
  358. * @param[in]Pin pin id of the pin that needs to change the direction
  359. * @param[in]Mode new mode
  360. *
  361. * @return void
  362. *
  363. *
  364. **/
  365. void Port_SetPinMode
  366. (
  367. Port_PinType Pin,
  368. Port_PinModeType Mode
  369. );
  370. #endif /* (STD_ON == PORT_SET_PIN_MODE_API) */
  371. #if (STD_ON == PORT_VERSION_INFO_API)
  372. /*!
  373. * @brief Port_GetVersionInfo
  374. *
  375. * @details Function used to read the driver version information
  376. *
  377. *
  378. * @param[in] versioninfo pointer to structure that will contain the version information
  379. *
  380. * @return void
  381. *
  382. *
  383. **/
  384. void Port_GetVersionInfo
  385. (
  386. Std_VersionInfoType * versioninfo
  387. );
  388. #endif /* (STD_ON == PORT_VERSION_INFO_API) */
  389. /*!
  390. * @brief Port_RefreshPortDirection
  391. *
  392. * @details function used to reset the direction of the pin
  393. *
  394. * @return void
  395. **/
  396. void Port_RefreshPortDirection(void);
  397. #ifdef PORT_SET_AS_UNUSED_PIN_API
  398. #if (STD_ON == PORT_SET_AS_UNUSED_PIN_API)
  399. /*!
  400. * @brief Port_SetAsUnusedPin
  401. *
  402. * @details configures the referenced pin with all the properties specified in the NotUsedPortPin container.
  403. *
  404. * @return void
  405. **/
  406. void Port_SetAsUnusedPin
  407. (
  408. Port_PinType Pin
  409. );
  410. /*!
  411. * @brief Port_SetAsUsedPin
  412. *
  413. * @details configures the referenced pin with all the properties that where set during the Port_Init operation.
  414. *
  415. * @return void
  416. **/
  417. void Port_SetAsUsedPin
  418. (
  419. Port_PinType Pin
  420. );
  421. #endif /* (STD_ON == PORT_SET_AS_UNUSED_PIN_API) */
  422. #endif
  423. #ifdef PORT_RESET_PIN_MODE_API
  424. #if (STD_ON == PORT_RESET_PIN_MODE_API)
  425. /*!
  426. * @brief Port_ResetPinMode
  427. *
  428. * @details reverts the port pin mode of the referenced pin to the value that was set by Port_Init operation.
  429. *
  430. * @return void
  431. **/
  432. void Port_ResetPinMode
  433. (
  434. Port_PinType Pin
  435. );
  436. #endif /* (STD_ON == PORT_RESET_PIN_MODE_API) */
  437. #endif
  438. #define PORT_STOP_SEC_CODE
  439. #include "Port_MemMap.h"
  440. #ifdef __cplusplus
  441. }
  442. #endif
  443. /** @} */
  444. #endif /* PORT_H */