Gpio_Dio_Ip.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 GPIO_DIO_IP_H
  25. #define GPIO_DIO_IP_H
  26. /**
  27. * @file @file Gpio_Dio_Ip.h
  28. *
  29. * @defgroup DIO_IPL Dio IPL
  30. * @{
  31. */
  32. #if defined(__cplusplus)
  33. extern "C" {
  34. #endif
  35. /*==================================================================================================
  36. * INCLUDE FILES
  37. * 1) system and project includes
  38. * 2) needed interfaces from external units
  39. * 3) internal and external interfaces from this unit
  40. ==================================================================================================*/
  41. #include "StandardTypes.h"
  42. #include "Gpio_Dio_Ip_Cfg.h"
  43. /*=================================================================================================
  44. * SOURCE FILE VERSION INFORMATION
  45. =================================================================================================*/
  46. #define GPIO_DIO_IP_VENDOR_ID_H 43
  47. #define GPIO_DIO_IP_AR_RELEASE_MAJOR_VERSION_H 4
  48. #define GPIO_DIO_IP_AR_RELEASE_MINOR_VERSION_H 4
  49. #define GPIO_DIO_IP_AR_RELEASE_REVISION_VERSION_H 0
  50. #define GPIO_DIO_IP_SW_MAJOR_VERSION_H 1
  51. #define GPIO_DIO_IP_SW_MINOR_VERSION_H 0
  52. #define GPIO_DIO_IP_SW_PATCH_VERSION_H 0
  53. /*=================================================================================================
  54. FILE VERSION CHECKS
  55. =================================================================================================*/
  56. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  57. /* Check if Gpio_Dio_Ip header file and StandardTypes.h header file are of the same release version */
  58. #if ((GPIO_DIO_IP_AR_RELEASE_MAJOR_VERSION_H != STD_AR_RELEASE_MAJOR_VERSION) || \
  59. (GPIO_DIO_IP_AR_RELEASE_MINOR_VERSION_H != STD_AR_RELEASE_MINOR_VERSION) \
  60. )
  61. #error "AutoSar Version Numbers of Gpio_Dio_Ip.h and StandardTypes.h are different"
  62. #endif
  63. #endif
  64. /* Check if Gpio_Dio_Ip header file and Gpio_Dio_Ip_Cfg configuration header file are of the same vendor */
  65. #if (GPIO_DIO_IP_VENDOR_ID_H != GPIO_DIO_IP_VENDOR_ID_CFG_H)
  66. #error "Gpio_Dio_Ip.h and Gpio_Dio_Ip_Cfg.h have different vendor ids"
  67. #endif
  68. /* Check if Gpio_Dio_Ip header file and Gpio_Dio_Ip_Cfg configuration header file are of the same Autosar version */
  69. #if ((GPIO_DIO_IP_AR_RELEASE_MAJOR_VERSION_H != GPIO_DIO_IP_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
  70. (GPIO_DIO_IP_AR_RELEASE_MINOR_VERSION_H != GPIO_DIO_IP_AR_RELEASE_MINOR_VERSION_CFG_H) || \
  71. (GPIO_DIO_IP_AR_RELEASE_REVISION_VERSION_H != GPIO_DIO_IP_AR_RELEASE_REVISION_VERSION_CFG_H) \
  72. )
  73. #error "AutoSar Version Numbers of Gpio_Dio_Ip.h and Gpio_Dio_Ip_Cfg.h are different"
  74. #endif
  75. /* Check if Gpio_Dio_Ip header file and Gpio_Dio_Ip_Cfg configuration header file are of the same Software version */
  76. #if ((GPIO_DIO_IP_SW_MAJOR_VERSION_H != GPIO_DIO_IP_SW_MAJOR_VERSION_CFG_H) || \
  77. (GPIO_DIO_IP_SW_MINOR_VERSION_H != GPIO_DIO_IP_SW_MINOR_VERSION_CFG_H) || \
  78. (GPIO_DIO_IP_SW_PATCH_VERSION_H != GPIO_DIO_IP_SW_PATCH_VERSION_CFG_H) \
  79. )
  80. #error "Software Version Numbers of Gpio_Dio_Ip.h and Gpio_Dio_Ip_Cfg.h are different"
  81. #endif
  82. /*=================================================================================================
  83. * CONSTANTS
  84. =================================================================================================*/
  85. /*=================================================================================================
  86. * DEFINES AND MACROS
  87. =================================================================================================*/
  88. #define GPIO_DIO_IP_CHANNEL_MASK_U32 ((uint32)0x1F)
  89. #define GPIO_DIO_IP_PORTID_SHIFT_U8 ((uint8)5U)
  90. #define GPIO_DIO_IP_PORT_U32(channel) ((uint32)((uint32)(channel)>>GPIO_DIO_IP_PORTID_SHIFT_U8))
  91. #define GPIO_DIO_IP_CHANNEL_U32(channel) ((uint32)((uint32)(channel)&GPIO_DIO_IP_CHANNEL_MASK_U32))
  92. /*=================================================================================================
  93. * ENUMS
  94. =================================================================================================*/
  95. /*=================================================================================================
  96. * STRUCTURES AND OTHER TYPEDEFS
  97. =================================================================================================*/
  98. /*!
  99. * @brief Type of a GPIO channel representation
  100. * Implements : Gpio_Dio_Ip_PinsChannelType_Class
  101. */
  102. typedef uint32 Gpio_Dio_Ip_PinsChannelType;
  103. /*!
  104. * @brief Type of a port levels representation.
  105. * Implements : Gpio_Dio_Ip_PinsLevelType_Class
  106. */
  107. typedef uint8 Gpio_Dio_Ip_PinsLevelType;
  108. /*=================================================================================================
  109. * GLOBAL VARIABLE DECLARATIONS
  110. =================================================================================================*/
  111. #define DIO_START_SEC_VAR_INIT_32
  112. #include "Dio_MemMap.h"
  113. extern uint32 GpioBaseAdresses[GPIO_INSTANCE_COUNT];
  114. #define DIO_STOP_SEC_VAR_INIT_32
  115. #include "Dio_MemMap.h"
  116. /*=================================================================================================
  117. * FUNCTION PROTOTYPES
  118. =================================================================================================*/
  119. #define DIO_START_SEC_CODE
  120. #include "Dio_MemMap.h"
  121. /*!
  122. * @brief Write a pin of a port with a given value
  123. *
  124. * This function writes the given pin from a port, with the given value
  125. * ('0' represents LOW, '1' represents HIGH).
  126. *
  127. * @param base GPIO base pointer (PTA, PTB, PTC, etc.)
  128. * @param pin pin number to be written
  129. * @param value pin value to be written
  130. * - 0: corresponding pin is set to LOW
  131. * - 1: corresponding pin is set to HIGH
  132. */
  133. void Gpio_Dio_Ip_WritePin(GPIO_Type * const base,
  134. Gpio_Dio_Ip_PinsChannelType pin,
  135. Gpio_Dio_Ip_PinsLevelType value);
  136. /*!
  137. * @brief Write all pins of a port
  138. *
  139. * This function writes all pins configured as output with the values given in
  140. * the parameter pins. '0' represents LOW, '1' represents HIGH.
  141. *
  142. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  143. * @param[in] pins Pin mask to be written
  144. * - 0: corresponding pin is set to LOW
  145. * - 1: corresponding pin is set to HIGH
  146. */
  147. void Gpio_Dio_Ip_WritePins(GPIO_Type * const base,
  148. Gpio_Dio_Ip_PinsChannelType pins);
  149. /*!
  150. * @brief Get the current output from a port
  151. *
  152. * This function returns the current output that is written to a port. Only pins
  153. * that are configured as output will have meaningful values.
  154. *
  155. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  156. * @return GPIO outputs. Each bit represents one pin (LSB is pin 0, MSB is pin
  157. * 31). For each bit:
  158. * - 0: corresponding pin is set to LOW
  159. * - 1: corresponding pin is set to HIGH
  160. */
  161. Gpio_Dio_Ip_PinsChannelType Gpio_Dio_Ip_GetPinsOutput(const GPIO_Type * const base);
  162. /*!
  163. * @brief Write pins with 'Set' value
  164. *
  165. * This function configures output pins listed in parameter pins (bits that are
  166. * '1') to have a value of 'set' (HIGH). Pins corresponding to '0' will be
  167. * unaffected.
  168. *
  169. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  170. * @param[in] pins Pin mask of bits to be set. Each bit represents one pin (LSB is
  171. * pin 0, MSB is pin 31). For each bit:
  172. * - 0: corresponding pin is unaffected
  173. * - 1: corresponding pin is set to HIGH
  174. */
  175. void Gpio_Dio_Ip_SetPins(GPIO_Type * const base,
  176. Gpio_Dio_Ip_PinsChannelType pins);
  177. /*!
  178. * @brief Write pins to 'Clear' value
  179. *
  180. * This function configures output pins listed in parameter pins (bits that are
  181. * '1') to have a 'cleared' value (LOW). Pins corresponding to '0' will be
  182. * unaffected.
  183. *
  184. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  185. * @param[in] pins Pin mask of bits to be cleared. Each bit represents one pin (LSB
  186. * is pin 0, MSB is pin 31). For each bit:
  187. * - 0: corresponding pin is unaffected
  188. * - 1: corresponding pin is cleared(set to LOW)
  189. */
  190. void Gpio_Dio_Ip_ClearPins(GPIO_Type * const base,
  191. Gpio_Dio_Ip_PinsChannelType pins);
  192. /*!
  193. * @brief Toggle pins value
  194. *
  195. * This function toggles output pins listed in parameter pins (bits that are
  196. * '1'). Pins corresponding to '0' will be unaffected.
  197. *
  198. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  199. * @param[in] pins Pin mask of bits to be toggled. Each bit represents one pin (LSB
  200. * is pin 0, MSB is pin 31). For each bit:
  201. * - 0: corresponding pin is unaffected
  202. * - 1: corresponding pin is toggled
  203. */
  204. void Gpio_Dio_Ip_TogglePins(GPIO_Type * const base,
  205. Gpio_Dio_Ip_PinsChannelType pins);
  206. /*!
  207. * @brief Read input pins
  208. *
  209. * This function returns the current input values from a port. Only pins
  210. * configured as input will have meaningful values.
  211. *
  212. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  213. * @return GPIO inputs. Each bit represents one pin (LSB is pin 0, MSB is pin
  214. * 31). For each bit:
  215. * - 0: corresponding pin is read as LOW
  216. * - 1: corresponding pin is read as HIGH
  217. */
  218. Gpio_Dio_Ip_PinsChannelType Gpio_Dio_Ip_ReadPins(const GPIO_Type * const base);
  219. /*!
  220. * @brief Read input pin
  221. *
  222. * This function returns the current input value of the given pin from port. Only pin
  223. * configured as input will have meaningful value.
  224. *
  225. * @param[in] base GPIO base pointer (PTA, PTB, PTC, etc.)
  226. * @param[in] pin Pin index (0,1,2,3,..,15)
  227. * @return GPIO input value for coressponding pin
  228. * - 0: corresponding pin is read as LOW
  229. * - 1: corresponding pin is read as HIGH
  230. */
  231. Gpio_Dio_Ip_PinsLevelType Gpio_Dio_Ip_ReadPin(const GPIO_Type * const base, Gpio_Dio_Ip_PinsChannelType pin);
  232. #define DIO_STOP_SEC_CODE
  233. #include "Dio_MemMap.h"
  234. #ifdef __cplusplus
  235. }
  236. #endif
  237. #endif /* DIO_GPIO_H */
  238. /** @} */