Adc_Ipw.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : ADC
  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 ADC_IPW_H
  25. #define ADC_IPW_H
  26. /**
  27. * @file
  28. *
  29. * @internal
  30. * @addtogroup adc_ipw Adc Ipw
  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 "Adc_Ipw_Types.h"
  43. #include "Adc_Ipw_Cfg.h"
  44. #include "Adc_Ip.h"
  45. #ifdef ADC_DMA_SUPPORTED
  46. #include "Dma_Ip.h"
  47. #endif
  48. #include "Pdb_Adc_Ip.h"
  49. /*==================================================================================================
  50. * SOURCE FILE VERSION INFORMATION
  51. ==================================================================================================*/
  52. #define ADC_VENDOR_ID_IPW_H 43
  53. #define ADC_AR_RELEASE_MAJOR_VERSION_IPW_H 4
  54. #define ADC_AR_RELEASE_MINOR_VERSION_IPW_H 4
  55. #define ADC_AR_RELEASE_REVISION_VERSION_IPW_H 0
  56. #define ADC_SW_MAJOR_VERSION_IPW_H 1
  57. #define ADC_SW_MINOR_VERSION_IPW_H 0
  58. #define ADC_SW_PATCH_VERSION_IPW_H 0
  59. /*==================================================================================================
  60. * FILE VERSION CHECKS
  61. ==================================================================================================*/
  62. /* Check if Adc_Ipw.h file and Adc_Ipw_Types.h file are of the same vendor */
  63. #if (ADC_VENDOR_ID_IPW_H != ADC_VENDOR_ID_IPW_TYPES_H)
  64. #error "Adc_Ipw.h and Adc_Ipw_Types.h have different vendor ids"
  65. #endif
  66. /* Check if Adc_Ipw.h file and Adc_Ipw_Types.h file are of the same Autosar version */
  67. #if ((ADC_AR_RELEASE_MAJOR_VERSION_IPW_H != ADC_AR_RELEASE_MAJOR_VERSION_IPW_TYPES_H) || \
  68. (ADC_AR_RELEASE_MINOR_VERSION_IPW_H != ADC_AR_RELEASE_MINOR_VERSION_IPW_TYPES_H) || \
  69. (ADC_AR_RELEASE_REVISION_VERSION_IPW_H != ADC_AR_RELEASE_REVISION_VERSION_IPW_TYPES_H) \
  70. )
  71. #error "AutoSar Version Numbers of Adc_Ipw.h and Adc_Ipw_Types.h are different"
  72. #endif
  73. /* Check if Adc_Ipw.h file and Adc_Ipw_Types.h file are of the same Software version */
  74. #if ((ADC_SW_MAJOR_VERSION_IPW_H != ADC_SW_MAJOR_VERSION_IPW_TYPES_H) || \
  75. (ADC_SW_MINOR_VERSION_IPW_H != ADC_SW_MINOR_VERSION_IPW_TYPES_H) || \
  76. (ADC_SW_PATCH_VERSION_IPW_H != ADC_SW_PATCH_VERSION_IPW_TYPES_H) \
  77. )
  78. #error "Software Version Numbers of Adc_Ipw.h and Adc_Ipw_Types.h are different"
  79. #endif
  80. /* Check if Adc_Ipw.h file and Adc_Ipw_Cfg.h file are of the same vendor */
  81. #if (ADC_VENDOR_ID_IPW_H != ADC_VENDOR_ID_IPW_CFG_H)
  82. #error "Adc_Ipw.h and Adc_Ipw_Cfg.h have different vendor ids"
  83. #endif
  84. /* Check if Adc_Ipw.h file and Adc_Ipw_Cfg.h file are of the same Autosar version */
  85. #if ((ADC_AR_RELEASE_MAJOR_VERSION_IPW_H != ADC_AR_RELEASE_MAJOR_VERSION_IPW_CFG_H) || \
  86. (ADC_AR_RELEASE_MINOR_VERSION_IPW_H != ADC_AR_RELEASE_MINOR_VERSION_IPW_CFG_H) || \
  87. (ADC_AR_RELEASE_REVISION_VERSION_IPW_H != ADC_AR_RELEASE_REVISION_VERSION_IPW_CFG_H) \
  88. )
  89. #error "AutoSar Version Numbers of Adc_Ipw.h and Adc_Ipw_Cfg.h are different"
  90. #endif
  91. /* Check if Adc_Ipw.h file and Adc_Ipw_Cfg.h file are of the same Software version */
  92. #if ((ADC_SW_MAJOR_VERSION_IPW_H != ADC_SW_MAJOR_VERSION_IPW_CFG_H) || \
  93. (ADC_SW_MINOR_VERSION_IPW_H != ADC_SW_MINOR_VERSION_IPW_CFG_H) || \
  94. (ADC_SW_PATCH_VERSION_IPW_H != ADC_SW_PATCH_VERSION_IPW_CFG_H) \
  95. )
  96. #error "Software Version Numbers of Adc_Ipw.h and Adc_Ipw_Cfg.h are different"
  97. #endif
  98. /* Check if Adc_Ipw.h file and Adc_Ip.h file are of the same vendor */
  99. #if (ADC_VENDOR_ID_IPW_H != ADC_IP_VENDOR_ID_H)
  100. #error "Adc_Ipw.h and Adc_Ip.h have different vendor ids"
  101. #endif
  102. /* Check if Adc_Ipw.h file and Adc_Ip.h file are of the same Autosar version */
  103. #if ((ADC_AR_RELEASE_MAJOR_VERSION_IPW_H != ADC_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  104. (ADC_AR_RELEASE_MINOR_VERSION_IPW_H != ADC_IP_AR_RELEASE_MINOR_VERSION_H) || \
  105. (ADC_AR_RELEASE_REVISION_VERSION_IPW_H != ADC_IP_AR_RELEASE_REVISION_VERSION_H) \
  106. )
  107. #error "AutoSar Version Numbers of Adc_Ipw.h and Adc_Ip.h are different"
  108. #endif
  109. /* Check if Adc_Ipw.h file and Adc_Ip.h file are of the same Software version */
  110. #if ((ADC_SW_MAJOR_VERSION_IPW_H != ADC_IP_SW_MAJOR_VERSION_H) || \
  111. (ADC_SW_MINOR_VERSION_IPW_H != ADC_IP_SW_MINOR_VERSION_H) || \
  112. (ADC_SW_PATCH_VERSION_IPW_H != ADC_IP_SW_PATCH_VERSION_H) \
  113. )
  114. #error "Software Version Numbers of Adc_Ipw.h and Adc_Ip.h are different"
  115. #endif
  116. /* Check if Adc_Ipw.h file and Pdb_Adc_Ip.h file are of the same vendor */
  117. #if (ADC_VENDOR_ID_IPW_H != PDB_ADC_IP_VENDOR_ID_H)
  118. #error "Adc_Ipw.h and Pdb_Adc_Ip.h have different vendor ids"
  119. #endif
  120. /* Check if Adc_Ipw.h file and Pdb_Adc_Ip.h file are of the same Autosar version */
  121. #if ((ADC_AR_RELEASE_MAJOR_VERSION_IPW_H != PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  122. (ADC_AR_RELEASE_MINOR_VERSION_IPW_H != PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_H) || \
  123. (ADC_AR_RELEASE_REVISION_VERSION_IPW_H != PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_H) \
  124. )
  125. #error "AutoSar Version Numbers of Adc_Ipw.h and Pdb_Adc_Ip.h are different"
  126. #endif
  127. /* Check if Adc_Ipw.h file and Pdb_Adc_Ip.h file are of the same Software version */
  128. #if ((ADC_SW_MAJOR_VERSION_IPW_H != PDB_ADC_IP_SW_MAJOR_VERSION_H) || \
  129. (ADC_SW_MINOR_VERSION_IPW_H != PDB_ADC_IP_SW_MINOR_VERSION_H) || \
  130. (ADC_SW_PATCH_VERSION_IPW_H != PDB_ADC_IP_SW_PATCH_VERSION_H) \
  131. )
  132. #error "Software Version Numbers of Adc_Ipw.h and Pdb_Adc_Ip.h are different"
  133. #endif
  134. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  135. #ifdef ADC_DMA_SUPPORTED
  136. /* Check if Adc_Ipw.h file and Dma_Ip.h file are of the same Autosar version */
  137. #if ((ADC_AR_RELEASE_MAJOR_VERSION_IPW_H != DMA_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  138. (ADC_AR_RELEASE_MINOR_VERSION_IPW_H != DMA_IP_AR_RELEASE_MINOR_VERSION_H) \
  139. )
  140. #error "AutoSar Version Numbers of Adc_Ipw.h and Dma_Ip.h are different"
  141. #endif
  142. #endif /* ADC_DMA_SUPPORTED */
  143. #endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */
  144. /*==================================================================================================
  145. * CONSTANTS
  146. ==================================================================================================*/
  147. /*==================================================================================================
  148. * DEFINES AND MACROS
  149. ==================================================================================================*/
  150. /* The macro to calculate the number of channels for each configuration */
  151. #define ADC_IPW_CALCULATE_CHAN_NUMBER(x) (((x) >= ADC_MAX_CHAN_COUNT) ? ADC_MAX_CHAN_COUNT : ((x)%ADC_MAX_CHAN_COUNT))
  152. #ifdef ADC_DMA_SUPPORTED
  153. #define ADC_IPW_INVALID_DATA_RESULT_DMA (0xFFFFU)
  154. #define ADC_IPW_GET_COMPLEMENT_OF_2(x) ((uint32)(~((uint32)(x)) + 1U))
  155. #endif /* ADC_DMA_SUPPORTED */
  156. /*==================================================================================================
  157. * ENUMS
  158. ==================================================================================================*/
  159. /*==================================================================================================
  160. * STRUCTURES AND OTHER TYPEDEFS
  161. ==================================================================================================*/
  162. /*==================================================================================================
  163. * GLOBAL VARIABLE DECLARATIONS
  164. ==================================================================================================*/
  165. /*==================================================================================================
  166. * FUNCTION PROTOTYPES
  167. ==================================================================================================*/
  168. #define ADC_START_SEC_CODE
  169. #include "Adc_MemMap.h"
  170. #if ((defined(ADC_UNIT_0_ISR_USED)) || (defined(ADC_UNIT_1_ISR_USED)) || \
  171. (defined(ADC_DMA_SUPPORTED)) || (ADC_READ_GROUP_API == STD_ON) \
  172. )
  173. uint8 Adc_Ipw_CalculateNumsBitShift
  174. (
  175. Adc_Ip_ResolutionType Resolution
  176. );
  177. #endif /* (defined(ADC_UNIT_0_ISR_USED) || ... */
  178. #ifdef ADC_DMA_SUPPORTED
  179. void Adc_Ipw_StartDmaOperation
  180. (
  181. Adc_HwUnitType Unit,
  182. Adc_GroupType Group,
  183. uint8 u8NumChannel,
  184. uint32 u32CoreId
  185. );
  186. #endif /* ADC_DMA_SUPPORTED */
  187. /**
  188. * @brief Functions mapping.
  189. * @details Middle layer versus Low layer functions mapping
  190. *
  191. */
  192. Std_ReturnType Adc_Ipw_Init(const Adc_Ipw_Config * pIpwCfg, const uint32 u32CoreId);
  193. #if (ADC_DEINIT_API == STD_ON)
  194. Std_ReturnType Adc_Ipw_DeInit(uint32 u32CoreId);
  195. #endif /* ADC_DEINIT_API == STD_ON */
  196. #if (ADC_ENABLE_START_STOP_GROUP_API == STD_ON)
  197. void Adc_Ipw_StartNormalConversion
  198. (
  199. Adc_HwUnitType Unit,
  200. uint32 u32CoreId
  201. );
  202. Std_ReturnType Adc_Ipw_StopCurrentConversion
  203. (
  204. Adc_HwUnitType Unit,
  205. Adc_GroupType Group,
  206. uint32 u32CoreId
  207. );
  208. #endif /* ADC_ENABLE_START_STOP_GROUP_API == STD_ON */
  209. #if (ADC_HW_TRIGGER_API == STD_ON)
  210. Std_ReturnType Adc_Ipw_EnableHardwareTrigger
  211. (
  212. Adc_GroupType Group,
  213. Adc_HwUnitType Unit,
  214. uint32 u32CoreId
  215. );
  216. void Adc_Ipw_DisableHardwareTrigger
  217. (
  218. Adc_GroupType Group,
  219. Adc_HwUnitType Unit,
  220. uint32 u32CoreId
  221. );
  222. #endif /* ADC_HW_TRIGGER_API == STD_ON */
  223. boolean Adc_Ipw_CheckValidConversion
  224. (
  225. Adc_HwUnitType PhysicalHwUnitId,
  226. Adc_ChannelIndexType StartIndex,
  227. Adc_ChannelIndexType EndIndex
  228. );
  229. #if (ADC_READ_GROUP_API == STD_ON)
  230. Std_ReturnType Adc_Ipw_ReadGroup
  231. (
  232. const Adc_GroupType Group,
  233. Adc_ValueGroupType * pDataPtr,
  234. boolean * pFlag,
  235. uint32 u32CoreId
  236. );
  237. #endif /* ADC_READ_GROUP_API == STD_ON */
  238. #if (ADC_ENABLE_READ_RAW_DATA_API == STD_ON)
  239. Std_ReturnType Adc_Ipw_GetConvData
  240. (
  241. Adc_HwUnitType Unit,
  242. Adc_ChannelType Channel,
  243. uint32 u32CoreId,
  244. uint16 * Result
  245. );
  246. #endif /* (ADC_ENABLE_READ_RAW_DATA_API == STD_ON) */
  247. #if (ADC_CALIBRATION == STD_ON)
  248. void Adc_Ipw_Calibrate
  249. (
  250. Adc_HwUnitType Unit,
  251. Adc_CalibrationStatusType * Status,
  252. uint32 u32CoreId
  253. );
  254. #endif /* ADC_CALIBRATION == STD_ON */
  255. void Adc_Ipw_ConfigureConversion
  256. (
  257. Adc_HwUnitType Unit,
  258. Adc_GroupType Group,
  259. Adc_HwTriggerTimerType Trigger,
  260. uint8 NumChannel,
  261. uint32 u32CoreId
  262. );
  263. #ifdef ADC_DMA_SUPPORTED
  264. void Adc_Ipw_ConfigureDmaConversion
  265. (
  266. Adc_HwUnitType Unit,
  267. Adc_GroupType Group,
  268. Adc_HwTriggerTimerType Trigger,
  269. uint8 NumChannel
  270. );
  271. #endif /* ADC_DMA_SUPPORTED */
  272. #if (ADC_HW_TRIGGER_API == STD_ON)
  273. void Adc_Ipw_StartHwTrigConversion
  274. (
  275. Adc_HwUnitType Unit,
  276. Adc_GroupType Group,
  277. uint32 u32CoreId
  278. );
  279. #endif /* (ADC_HW_TRIGGER_API == STD_ON) */
  280. #if (ADC_DUAL_CLOCK_MODE == STD_ON)
  281. Std_ReturnType Adc_Ipw_SetClockMode
  282. (
  283. Adc_SelectPrescalerType Prescaler,
  284. uint32 u32CoreId
  285. );
  286. #endif /* (ADC_DUAL_CLOCK_MODE == STD_ON) */
  287. #if (ADC_ENABLE_LIMIT_CHECK == STD_ON)
  288. boolean Adc_Ipw_CheckConversionValuesInRange
  289. (
  290. Adc_ValueGroupType Value,
  291. Adc_HwUnitType LogicalHwUnitId,
  292. Adc_ChannelType ChannelIndex,
  293. uint32 u32CoreId
  294. );
  295. #endif /* (ADC_ENABLE_LIMIT_CHECK == STD_ON) */
  296. #if (ADC_ENABLE_QUEUING == STD_ON)
  297. void Adc_RemoveFromQueue
  298. (
  299. const Adc_HwUnitType Unit,
  300. const Adc_QueueIndexType CurQueueIndex
  301. );
  302. #endif /* (ADC_ENABLE_QUEUING == STD_ON) */
  303. uint32 Adc_GetCoreID(void);
  304. #define ADC_STOP_SEC_CODE
  305. #include "Adc_MemMap.h"
  306. #ifdef __cplusplus
  307. }
  308. #endif
  309. /** @} */
  310. #endif /* ADC_IPW_H */