Pdb_Adc_Ip.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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 PDB_ADC_IP_H
  25. #define PDB_ADC_IP_H
  26. /**
  27. * @file
  28. *
  29. * @addtogroup pdb_adc_ip Pdb Adc IPL
  30. * @{
  31. */
  32. #include "Pdb_Adc_Ip_Types.h"
  33. #include "Pdb_Adc_Ip_Cfg.h"
  34. /*==================================================================================================
  35. * SOURCE FILE VERSION INFORMATION
  36. ==================================================================================================*/
  37. #define PDB_ADC_IP_VENDOR_ID_H 43
  38. #define PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_H 4
  39. #define PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_H 4
  40. #define PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_H 0
  41. #define PDB_ADC_IP_SW_MAJOR_VERSION_H 1
  42. #define PDB_ADC_IP_SW_MINOR_VERSION_H 0
  43. #define PDB_ADC_IP_SW_PATCH_VERSION_H 0
  44. /*==================================================================================================
  45. * FILE VERSION CHECKS
  46. ==================================================================================================*/
  47. /* Check if Pdb_Adc_Ip.h file and Pdb_Adc_Ip_Types.h file are of the same vendor */
  48. #if (PDB_ADC_IP_VENDOR_ID_H != PDB_ADC_IP_VENDOR_ID_TYPES_H)
  49. #error "Pdb_Adc_Ip.h and Pdb_Adc_Ip_Types.h have different vendor ids"
  50. #endif
  51. /* Check if Pdb_Adc_Ip.h file and Pdb_Adc_Ip_Types.h file are of the same Autosar version */
  52. #if ((PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_H != PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_TYPES_H) || \
  53. (PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_H != PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_TYPES_H) || \
  54. (PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_H != PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_TYPES_H) \
  55. )
  56. #error "AutoSar Version Numbers of Pdb_Adc_Ip.h and Pdb_Adc_Ip_Types.h are different"
  57. #endif
  58. /* Check if Pdb_Adc_Ip.h file and Pdb_Adc_Ip_Types.h file are of the same Software version */
  59. #if ((PDB_ADC_IP_SW_MAJOR_VERSION_H != PDB_ADC_IP_SW_MAJOR_VERSION_TYPES_H) || \
  60. (PDB_ADC_IP_SW_MINOR_VERSION_H != PDB_ADC_IP_SW_MINOR_VERSION_TYPES_H) || \
  61. (PDB_ADC_IP_SW_PATCH_VERSION_H != PDB_ADC_IP_SW_PATCH_VERSION_TYPES_H) \
  62. )
  63. #error "Software Version Numbers of Pdb_Adc_Ip.h and Pdb_Adc_Ip_Types.h are different"
  64. #endif
  65. /* Check if Pdb_Adc_Ip.h file and Pdb_Adc_Ip_Cfg.h file are of the same vendor */
  66. #if (PDB_ADC_IP_VENDOR_ID_H != PDB_ADC_IP_VENDOR_ID_CFG_H)
  67. #error "Pdb_Adc_Ip.h and Pdb_Adc_Ip_Cfg.h have different vendor ids"
  68. #endif
  69. /* Check if Pdb_Adc_Ip.h file and Pdb_Adc_Ip_Cfg.h file are of the same Autosar version */
  70. #if ((PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_H != PDB_ADC_IP_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
  71. (PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_H != PDB_ADC_IP_AR_RELEASE_MINOR_VERSION_CFG_H) || \
  72. (PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_H != PDB_ADC_IP_AR_RELEASE_REVISION_VERSION_CFG_H) \
  73. )
  74. #error "AutoSar Version Numbers of Pdb_Adc_Ip.h and Pdb_Adc_Ip_Cfg.h are different"
  75. #endif
  76. /* Check if Pdb_Adc_Ip.h file and Pdb_Adc_Ip_Cfg.h file are of the same Software version */
  77. #if ((PDB_ADC_IP_SW_MAJOR_VERSION_H != PDB_ADC_IP_SW_MAJOR_VERSION_CFG_H) || \
  78. (PDB_ADC_IP_SW_MINOR_VERSION_H != PDB_ADC_IP_SW_MINOR_VERSION_CFG_H) || \
  79. (PDB_ADC_IP_SW_PATCH_VERSION_H != PDB_ADC_IP_SW_PATCH_VERSION_CFG_H) \
  80. )
  81. #error "Software Version Numbers of Pdb_Adc_Ip.h and Pdb_Adc_Ip_Cfg.h are different"
  82. #endif
  83. /*==================================================================================================
  84. * DEFINITIONS
  85. ==================================================================================================*/
  86. /*******************************************************************************
  87. * API
  88. ******************************************************************************/
  89. #if defined (__cplusplus)
  90. extern "C" {
  91. #endif
  92. #define ADC_START_SEC_CODE
  93. #include "Adc_MemMap.h"
  94. /*!
  95. * @brief Initialize PDB module
  96. *
  97. * This function initializes the PDB counter, input triggers and general pretrigger settings.
  98. * It resets PDB registers and enables the PDB clock. Therefore, it should be
  99. * called before any other operation. After it is initialized, the PDB can
  100. * act as a triggered timer, which enables other features in PDB module.
  101. *
  102. * @param[in] Instance - PDB instance number
  103. * @param[in] Config - configuration struct pointer
  104. * @return void
  105. */
  106. void Pdb_Adc_Ip_Init(const uint32 Instance, const Pdb_Adc_Ip_ConfigType * const Config);
  107. /*!
  108. * @brief Deinitialize PDB module
  109. *
  110. * This function resets the PDB internal registers to default values.
  111. *
  112. * When the PDB module is not used. Calling this function would shut down the
  113. * PDB module and reduce the power consumption.
  114. *
  115. * Note: instance back to back configuration is common between PDB instances 0 and 1
  116. * (configures the same register even if configured for either PDB instance)
  117. * This function disables it, so affects all other instances.
  118. *
  119. * @param[in] Instance - PDB instance number
  120. * @return void
  121. */
  122. void Pdb_Adc_Ip_DeInit(const uint32 Instance);
  123. /*!
  124. * @brief Enable the PDB module
  125. *
  126. * This function enables the PDB module, counter is on.
  127. *
  128. * @param[in] Instance - PDB instance number
  129. * @return void
  130. */
  131. void Pdb_Adc_Ip_Enable(const uint32 Instance);
  132. /*!
  133. * @brief Disable the PDB module
  134. *
  135. * This function disables the PDB module, counter is off.
  136. *
  137. * @param[in] Instance - PDB instance number
  138. */
  139. void Pdb_Adc_Ip_Disable(const uint32 Instance);
  140. /*!
  141. * @brief Set PDB trigger source
  142. *
  143. * This function sets the PDB trigger source.
  144. *
  145. * @param[in] Instance - PDB instance number
  146. * @param[in] TriggerSource - trigger source
  147. * @return void
  148. */
  149. void Pdb_Adc_Ip_SetTriggerInput(const uint32 Instance, const Pdb_Adc_Ip_TriggerSrcType TriggerSource);
  150. /*!
  151. * @brief Set PDB mode
  152. *
  153. * This function sets the PDB mode to continuous or one shot.
  154. *
  155. * @param[in] Instance - PDB instance number
  156. * @param[in] State - mode to set: continuous(true) or one shot(FALSE)
  157. * @return void
  158. */
  159. void Pdb_Adc_Ip_SetContinuousMode(const uint32 Instance, const boolean State);
  160. /*!
  161. * @brief Trigger the PDB with a software trigger
  162. *
  163. * This function triggers the PDB with a software trigger.
  164. * When the PDB is set to use the software trigger as input, calling this function
  165. * triggers the PDB.
  166. *
  167. * @param[in] Instance - PDB instance number
  168. * @return void
  169. */
  170. void Pdb_Adc_Ip_SwTrigger(const uint32 Instance);
  171. /*!
  172. * @brief Get the current value of the PDB counter
  173. *
  174. * This function gets the current counter value.
  175. *
  176. * @param[in] Instance - PDB instance number
  177. * @return Current PDB counter value.
  178. */
  179. uint32 Pdb_Adc_Ip_GetTimerValue(const uint32 Instance);
  180. /*!
  181. * @brief Load buffered register values.
  182. *
  183. * This function sets the LDOK bit.
  184. * Writing one to this bit updates the internal registers MOD, IDLY, CHnDLYm and
  185. * POyDLY with the values written to their buffers. The MOD, IDLY,
  186. * CHnDLYm and POyDLY take effect according to the load mode settings.
  187. *
  188. * After one is written to the LDOK bit, the values in the buffers of above mentioned
  189. * registers are not effective and cannot be written until the values in the
  190. * buffers are loaded into their internal registers. The moment when this happens
  191. * depends on the value of the LDMOD register. Only when this register is in it's
  192. * default state(0), the load operation will happen immediately. Please check the
  193. * reference manual for more information.
  194. * The LDOK can be written only when the the PDB is enabled or as alone with it. It is
  195. * automatically cleared either when the values in the buffers are loaded into the
  196. * internal registers or when the PDB is disabled.
  197. *
  198. * @param[in] Instance - PDB instance number
  199. * @return void
  200. */
  201. void Pdb_Adc_Ip_LoadRegValues(const uint32 Instance);
  202. /*!
  203. * @brief Set the period of the counter
  204. *
  205. * This function sets the PDB Modulus value.
  206. * Note: This function writes in an internal buffer. Depending on the
  207. * value of the LDMOD register, it might be necessary to call
  208. * Pdb_Adc_Ip_LoadRegValues in order to update the value of the register.
  209. * The value of the register can be changed only when the PDB module is enabled.
  210. *
  211. * @param[in] Instance - PDB instance number
  212. * @param[in] ModVal - modulus value
  213. * @return void
  214. */
  215. void Pdb_Adc_Ip_SetModulus(const uint32 Instance, const uint16 ModVal);
  216. /*!
  217. * @brief Configure all pretriggers on the selected channel
  218. *
  219. * This function configures the back to back modes, delay enable and output
  220. * enable settings for all pretriggers on the selected channel.
  221. *
  222. * @param[in] Instance - PDB instance number
  223. * @param[in] ChanIdx - PDB channel
  224. * @param[in] Config - pretriggers config
  225. * @return void
  226. */
  227. void Pdb_Adc_Ip_ConfigAdcPretriggers(const uint32 Instance, const uint8 ChanIdx, const Pdb_Adc_Ip_PretriggersConfigType * const Config);
  228. /*!
  229. * @brief Get ADC pretrigger channel flags from the PDB module
  230. *
  231. * This function gets all ADC pretrigger flags from the selected channel.
  232. *
  233. * @param[in] Instance - PDB instance number
  234. * @param[in] ChanIdx - PDB channel
  235. * @return bitmask of channel flags selected by pretriggMask
  236. */
  237. uint32 Pdb_Adc_Ip_GetAdcPretriggerFlags(const uint32 Instance, const uint8 ChanIdx);
  238. /*!
  239. * @brief Clear ADC pretrigger channel flags from the PDB module
  240. *
  241. * This function clears the ADC pretrigger channel flags selected by pretriggMask
  242. * from channel channel.
  243. *
  244. * @param[in] Instance - PDB instance number
  245. * @param[in] ChanIdx - PDB channel
  246. * @param[in] PretriggMask - ADC pretriggers mask
  247. */
  248. void Pdb_Adc_Ip_ClearAdcPretriggerFlags(const uint32 Instance, const uint8 ChanIdx, const uint16 PretriggMask);
  249. /*!
  250. * @brief Set back to back mode for the selected pretrigger
  251. *
  252. * This function sets back to back mode for the selected pretrigger on
  253. * the given channel.
  254. *
  255. * @param[in] Instance - PDB instance number
  256. * @param[in] ChanIdx - PDB channel
  257. * @param[in] PretriggIdx - ADC pretrigger index
  258. * @param[in] Value - enable(true) or disable(FALSE)
  259. */
  260. void Pdb_Adc_Ip_SetAdcPretriggerBackToBack(const uint32 Instance, const uint8 ChanIdx, const uint8 PretriggIdx, const boolean Value);
  261. /*!
  262. * @brief Enable or disable the selected pretrigger
  263. *
  264. * This function enables or disables the selected pretrigger on the given channel.
  265. *
  266. * @param[in] Instance - PDB instance number
  267. * @param[in] ChanIdx - PDB channel
  268. * @param[in] PretriggIdx - ADC pretrigger mask
  269. * @param[in] Value - enable(true) or disable(FALSE)
  270. */
  271. void Pdb_Adc_Ip_SetAdcPretriggerEnable(const uint32 Instance, const uint8 ChanIdx, const uint8 PretriggIdx, const boolean Value);
  272. /*!
  273. * @brief Set the delay enable for the selected pretrigger
  274. *
  275. * This function sets the delay enable value for the selected pretrigger on
  276. * the given channel.
  277. *
  278. * @param[in] Instance - PDB instance number
  279. * @param[in] ChanIdx - PDB channel
  280. * @param[in] PretriggIdx - ADC pretrigger index
  281. * @param[in] Value - enable(true) or disable(FALSE)
  282. */
  283. void Pdb_Adc_Ip_SetAdcPretriggerDelayEnable(const uint32 Instance, const uint8 ChanIdx, const uint8 PretriggIdx, const boolean Value);
  284. /*!
  285. * @brief Set the pretrigger delay value.
  286. *
  287. * This function sets the pretrigger delay value
  288. * Note: This function writes in an internal buffer. Depending on the
  289. * value of the LDMOD register, it might be necessary to call
  290. * Pdb_Adc_Ip_LoadRegValues in order to update the value of the register.
  291. * The value of the register can be changed only when the PDB module is enabled.
  292. *
  293. * @param[in] Instance - PDB instance number
  294. * @param[in] ChanIdx - PDB channel
  295. * @param[in] PretriggIdx - ADC pretrigger index
  296. * @param[in] DelayValue - pretrigger delay value
  297. */
  298. void Pdb_Adc_Ip_SetAdcPretriggerDelayValue(const uint32 Instance, const uint8 ChanIdx, const uint8 PretriggIdx, const uint16 DelayValue);
  299. /*!
  300. * @brief Disable and clear PDB module
  301. *
  302. * This function disables PDB module and clears all channels
  303. * configuration and status registers.
  304. * Note: This function does not deinitialize the module.
  305. *
  306. * @param[in] Instance - PDB instance number
  307. */
  308. void Pdb_Adc_Ip_DisableAndClearPdb(const uint32 Instance);
  309. #define ADC_STOP_SEC_CODE
  310. #include "Adc_MemMap.h"
  311. #if defined (__cplusplus)
  312. }
  313. #endif
  314. /** @} */
  315. #endif /* PDB_ADC_IP_H */