Dio.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : GPIO
  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 DIO_H
  25. #define DIO_H
  26. /**
  27. * @file Dio.h
  28. * @implements Dio.h_Artifact
  29. *
  30. * @defgroup DIO_HLD Dio HLD
  31. * @{
  32. */
  33. #ifdef __cplusplus
  34. extern "C"{
  35. #endif
  36. /*=================================================================================================
  37. * INCLUDE FILES
  38. * 1) system and project includes
  39. * 2) needed interfaces from external units
  40. * 3) internal and external interfaces from this unit
  41. =================================================================================================*/
  42. #include "StandardTypes.h"
  43. #include "Mcal.h"
  44. #include "Dio_Cfg.h"
  45. /*=================================================================================================
  46. * SOURCE FILE VERSION INFORMATION
  47. =================================================================================================*/
  48. #define DIO_VENDOR_ID 43
  49. #define DIO_MODULE_ID 120
  50. #define DIO_AR_RELEASE_MAJOR_VERSION 4
  51. #define DIO_AR_RELEASE_MINOR_VERSION 4
  52. #define DIO_AR_RELEASE_REVISION_VERSION 0
  53. #define DIO_SW_MAJOR_VERSION 1
  54. #define DIO_SW_MINOR_VERSION 0
  55. #define DIO_SW_PATCH_VERSION 0
  56. /*=================================================================================================
  57. * FILE VERSION CHECKS
  58. =================================================================================================*/
  59. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  60. /* Check if header file and StandardTypes.h file are of the same Autosar version */
  61. #if ((DIO_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
  62. (DIO_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION) \
  63. )
  64. #error "AutoSar Version Numbers of Dio.h and StandardTypes.h are different"
  65. #endif
  66. /* Check if source file and Mcal.h header file are of the same Autosar version */
  67. #if ((DIO_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  68. (DIO_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION) \
  69. )
  70. #error "AutoSar Version Numbers of Dio.h and Mcal.h are different"
  71. #endif
  72. #endif
  73. /* Check if Dio header file and Dio configuration header file are of the same vendor */
  74. #if (DIO_VENDOR_ID != DIO_VENDOR_ID_CFG_H)
  75. #error "Dio.h and Dio_Cfg.h have different vendor ids"
  76. #endif
  77. /* Check if Dio header file and Dio configuration header file are of the same Autosar version */
  78. #if ((DIO_AR_RELEASE_MAJOR_VERSION != DIO_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
  79. (DIO_AR_RELEASE_MINOR_VERSION != DIO_AR_RELEASE_MINOR_VERSION_CFG_H) || \
  80. (DIO_AR_RELEASE_REVISION_VERSION != DIO_AR_RELEASE_REVISION_VERSION_CFG_H) \
  81. )
  82. #error "AutoSar Version Numbers of Dio.h and Dio_Cfg.h are different"
  83. #endif
  84. /* Check if Dio source file and Dio configuration header file are of the same Software version */
  85. #if ((DIO_SW_MAJOR_VERSION != DIO_SW_MAJOR_VERSION_CFG_H) || \
  86. (DIO_SW_MINOR_VERSION != DIO_SW_MINOR_VERSION_CFG_H) || \
  87. (DIO_SW_PATCH_VERSION != DIO_SW_PATCH_VERSION_CFG_H) \
  88. )
  89. #error "Software Version Numbers of Dio.h and Dio_Cfg.h are different"
  90. #endif
  91. /*=================================================================================================
  92. * CONSTANTS
  93. =================================================================================================*/
  94. /**
  95. * @brief The DIO module is not properly configured
  96. */
  97. #define DIO_E_PARAM_CONFIG ((uint8)0xF0)
  98. /**
  99. * @brief Invalid channel name requested.
  100. *
  101. * @implements Dio_ErrorCodes_define
  102. */
  103. #define DIO_E_PARAM_INVALID_CHANNEL_ID ((uint8)0x0A)
  104. /**
  105. * @brief Invalid port name requested.
  106. *
  107. * @implements Dio_ErrorCodes_define
  108. */
  109. #define DIO_E_PARAM_INVALID_PORT_ID ((uint8)0x14)
  110. /**
  111. * @brief Invalid ChannelGroup id passed.
  112. *
  113. * @implements Dio_ErrorCodes_define
  114. */
  115. #define DIO_E_PARAM_INVALID_GROUP_ID ((uint8)0x1F)
  116. /**
  117. * @brief API service called with a NULL pointer.
  118. * @details In case of this error, the API service shall return
  119. * immediately without any further action, beside reporting
  120. * this development error.
  121. *
  122. * @implements Dio_ErrorCodes_define
  123. */
  124. #define DIO_E_PARAM_POINTER ((uint8)0x20)
  125. /**
  126. * @brief API service called with invalid channel level value.
  127. * @details In case of this error, the API service shall return
  128. * immediately without any further action, beside reporting
  129. * this development error.
  130. *
  131. * @implements Dio_ErrorCodes_define
  132. */
  133. #define DIO_E_PARAM_LEVEL ((uint8)0x21)
  134. /**
  135. * @brief API service ID for @p Dio_ReadChannel() function.
  136. * @details Parameters used when raising an error/exception.
  137. */
  138. #define DIO_READCHANNEL_ID ((uint8)0x00)
  139. /**
  140. * @brief API service ID for @p Dio_WriteChannel() function.
  141. * @details Parameters used when raising an error/exception.
  142. */
  143. #define DIO_WRITECHANNEL_ID ((uint8)0x01)
  144. /**
  145. * @brief API service ID for @p Dio_FlipChannel() function.
  146. * @details Parameters used when raising an error/exception.
  147. */
  148. #define DIO_FLIPCHANNEL_ID ((uint8)0x11)
  149. /**
  150. * @brief API service ID for @p Dio_ReadPort() function.
  151. * @details Parameters used when raising an error/exception.
  152. */
  153. #define DIO_READPORT_ID ((uint8)0x02)
  154. /**
  155. * @brief API service ID for @p Dio_WritePort() function.
  156. * @details Parameters used when raising an error/exception.
  157. */
  158. #define DIO_WRITEPORT_ID ((uint8)0x03)
  159. /**
  160. * @brief API service ID for @p Dio_ReadChannel() Group function.
  161. * @details Parameters used when raising an error/exception.
  162. */
  163. #define DIO_READCHANNELGROUP_ID ((uint8)0x04)
  164. /**
  165. * @brief API service ID for @p Dio_WriteChannel() Group function.
  166. * @details Parameters used when raising an error/exception.
  167. */
  168. #define DIO_WRITECHANNELGROUP_ID ((uint8)0x05)
  169. /**
  170. * @brief API service ID for DIO Get Version() Info function.
  171. * @details Parameters used when raising an error/exception.
  172. */
  173. #define DIO_GETVERSIONINFO_ID ((uint8)0x12)
  174. /**
  175. * @brief API service ID for @p Dio_MaskedWritePort() function.
  176. * @details Parameters used when raising an error/exception.
  177. */
  178. #define DIO_MASKEDWRITEPORT_ID ((uint8)0x13)
  179. /**
  180. * @brief Instance ID of the Dio driver.
  181. *
  182. * @implements .
  183. */
  184. #define DIO_INSTANCE_ID ((uint8)0x00)
  185. /*=================================================================================================
  186. * DEFINES AND MACROS
  187. =================================================================================================*/
  188. /*=================================================================================================
  189. * ENUMS
  190. =================================================================================================*/
  191. /*=================================================================================================
  192. * STRUCTURES AND OTHER TYPEDEFS
  193. =================================================================================================*/
  194. /*=================================================================================================
  195. * GLOBAL VARIABLE DECLARATIONS
  196. =================================================================================================*/
  197. /*=================================================================================================
  198. * FUNCTION PROTOTYPES
  199. =================================================================================================*/
  200. #define DIO_START_SEC_CODE
  201. #include "Dio_MemMap.h"
  202. #if (STD_ON == DIO_VERSION_INFO_API)
  203. /*!
  204. * @brief Service to get the version information of this module.
  205. *
  206. * The @p Dio_GetVersionInfo() function shall return the version
  207. * information of this module. The version information includes:
  208. * - Module Id.
  209. * - Vendor Id.
  210. * - Vendor specific version numbers.
  211. *
  212. * @param[in] VersionInfo Pointer to where to store the version
  213. * information of this module.
  214. */
  215. void Dio_GetVersionInfo
  216. (
  217. Std_VersionInfoType * VersionInfo
  218. );
  219. #endif /* (STD_ON == DIO_VERSION_INFO_API) */
  220. /*!
  221. * @brief Returns the value of the specified DIO channel.
  222. *
  223. * This function returns the value of the specified DIO channel.
  224. *
  225. * @param[in] ChannelId Specifies the required channel id.
  226. *
  227. * @return Returns the level of the corresponding pin @p STD_HIGH or @p STD_LOW.
  228. */
  229. Dio_LevelType Dio_ReadChannel
  230. (
  231. Dio_ChannelType ChannelId
  232. );
  233. /*!
  234. * @brief Sets the level of a channel.
  235. *
  236. * If the specified channel is configured as an output channel,
  237. * this function shall set the specified level on the
  238. * specified channel. If the specified channel is configured
  239. * as an input channel, this function shall have no influence
  240. * on the physical output and on the result of the next read
  241. * service.
  242. *
  243. * @param[in] ChannelId Specifies the required channel id.
  244. * @param[in] Level Specifies the channel desired level.
  245. */
  246. void Dio_WriteChannel
  247. (
  248. Dio_ChannelType ChannelId,
  249. Dio_LevelType Level
  250. );
  251. #if (STD_ON == DIO_FLIP_CHANNEL_API)
  252. /*!
  253. * @brief Inverts the level of a channel.
  254. *
  255. * If the specified channel is configured as an output channel,
  256. * this function shall invert the level of the specified
  257. * channel. If the specified channel is configured as an
  258. * input channel, this function shall have no influence
  259. * on the physical output and on the result of the next
  260. * read service.
  261. *
  262. * @param[in] ChannelId Specifies the required channel id.
  263. *
  264. * @return Returns the level of the corresponding pin as @p STD_HIGH or @p STD_LOW.
  265. */
  266. Dio_LevelType Dio_FlipChannel
  267. (
  268. Dio_ChannelType ChannelId
  269. );
  270. #endif /* (STD_ON == DIO_FLIP_CHANNEL_API) */
  271. /*!
  272. * @brief Returns the level of all channels of specified port.
  273. *
  274. * This function will return the level of all channels
  275. * belonging to the specified port.
  276. *
  277. * @param[in] PortId Specifies the required port id.
  278. *
  279. * @return Levels of all channels of specified port.
  280. */
  281. Dio_PortLevelType Dio_ReadPort
  282. (
  283. Dio_PortType PortId
  284. );
  285. /*!
  286. * @brief Sets the value of a port.
  287. *
  288. * This function will set the specified value on the specified port.
  289. *
  290. * @param[in] PortId Specifies the required port id.
  291. * @param[in] Level Specifies the required levels for the port pins.
  292. */
  293. void Dio_WritePort
  294. (
  295. Dio_PortType PortId,
  296. Dio_PortLevelType Level
  297. );
  298. /*!
  299. * @brief This service reads a subset of the adjoining bits of a port.
  300. *
  301. * This function will read a subset of adjoining bits of a port (channel group).
  302. *
  303. * @param[in] ChannelGroupIdPtr Pointer to the channel group.
  304. *
  305. * @return The channel group levels.
  306. */
  307. Dio_PortLevelType Dio_ReadChannelGroup
  308. (
  309. const Dio_ChannelGroupType * ChannelGroupIdPtr
  310. );
  311. /*!
  312. * @brief Sets a subset of the adjoining bits of a port to the specified levels.
  313. *
  314. * This function will set a subset of adjoining bits of a port
  315. * (channel group) to the specified levels without changing
  316. * the remaining channels of the port and channels that are configured as input.
  317. * This function will do the masking of the channels and will
  318. * do the shifting so that the values written by the function
  319. * are aligned to the LSB.
  320. *
  321. * @param[in] ChannelGroupIdPtr Pointer to the channel group.
  322. * @param[in] Level Desired levels for the channel group.
  323. */
  324. void Dio_WriteChannelGroup
  325. (
  326. const Dio_ChannelGroupType * ChannelGroupIdPtr,
  327. Dio_PortLevelType Level
  328. );
  329. #if (STD_ON == DIO_MASKEDWRITEPORT_API)
  330. /*!
  331. * @brief DIO Mask write port using mask.
  332. *
  333. * Writes a DIO port with masked value.
  334. *
  335. * @param[in] PortId Specifies the required port id.
  336. * @param[in] Level Specifies the required levels for the port pins.
  337. * @param[in] Mask Specifies the Mask value of the port.
  338. *
  339. * @pre This function can be used only if @p DIO_MASKEDWRITEPORT_API has been enabled.
  340. */
  341. void Dio_MaskedWritePort
  342. (
  343. Dio_PortType PortId,
  344. Dio_PortLevelType Level,
  345. Dio_PortLevelType Mask
  346. );
  347. #endif /* (STD_ON == DIO_MASKEDWRITEPORT_API) */
  348. #define DIO_STOP_SEC_CODE
  349. #include "Dio_MemMap.h"
  350. #ifdef __cplusplus
  351. }
  352. #endif
  353. /** @} */
  354. #endif /* DIO_H */