fsl_pdb.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _FSL_PDB_H_
  31. #define _FSL_PDB_H_
  32. #include "fsl_common.h"
  33. /*!
  34. * @addtogroup pdb
  35. * @{
  36. */
  37. /*******************************************************************************
  38. * Definitions
  39. ******************************************************************************/
  40. /*! @name Driver version */
  41. /*@{*/
  42. /*! @brief PDB driver version 2.0.1. */
  43. #define FSL_PDB_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
  44. /*@}*/
  45. /*!
  46. * @brief PDB flags.
  47. */
  48. enum _pdb_status_flags
  49. {
  50. kPDB_LoadOKFlag = PDB_SC_LDOK_MASK, /*!< This flag is automatically cleared when the values in buffers are
  51. loaded into the internal registers after the LDOK bit is set or the
  52. PDBEN is cleared. */
  53. kPDB_DelayEventFlag = PDB_SC_PDBIF_MASK, /*!< PDB timer delay event flag. */
  54. };
  55. /*!
  56. * @brief PDB ADC PreTrigger channel flags.
  57. */
  58. enum _pdb_adc_pretrigger_flags
  59. {
  60. /* PDB PreTrigger channel match flags. */
  61. kPDB_ADCPreTriggerChannel0Flag = PDB_S_CF(1U << 0), /*!< Pre-trigger 0 flag. */
  62. kPDB_ADCPreTriggerChannel1Flag = PDB_S_CF(1U << 1), /*!< Pre-trigger 1 flag. */
  63. #if (PDB_DLY_COUNT2 > 2)
  64. kPDB_ADCPreTriggerChannel2Flag = PDB_S_CF(1U << 2), /*!< Pre-trigger 2 flag. */
  65. kPDB_ADCPreTriggerChannel3Flag = PDB_S_CF(1U << 3), /*!< Pre-trigger 3 flag. */
  66. #endif /* PDB_DLY_COUNT2 > 2 */
  67. #if (PDB_DLY_COUNT2 > 4)
  68. kPDB_ADCPreTriggerChannel4Flag = PDB_S_CF(1U << 4), /*!< Pre-trigger 4 flag. */
  69. kPDB_ADCPreTriggerChannel5Flag = PDB_S_CF(1U << 5), /*!< Pre-trigger 5 flag. */
  70. kPDB_ADCPreTriggerChannel6Flag = PDB_S_CF(1U << 6), /*!< Pre-trigger 6 flag. */
  71. kPDB_ADCPreTriggerChannel7Flag = PDB_S_CF(1U << 7), /*!< Pre-trigger 7 flag. */
  72. #endif /* PDB_DLY_COUNT2 > 4 */
  73. /* PDB PreTrigger channel error flags. */
  74. kPDB_ADCPreTriggerChannel0ErrorFlag = PDB_S_ERR(1U << 0), /*!< Pre-trigger 0 Error. */
  75. kPDB_ADCPreTriggerChannel1ErrorFlag = PDB_S_ERR(1U << 1), /*!< Pre-trigger 1 Error. */
  76. #if (PDB_DLY_COUNT2 > 2)
  77. kPDB_ADCPreTriggerChannel2ErrorFlag = PDB_S_ERR(1U << 2), /*!< Pre-trigger 2 Error. */
  78. kPDB_ADCPreTriggerChannel3ErrorFlag = PDB_S_ERR(1U << 3), /*!< Pre-trigger 3 Error. */
  79. #endif /* PDB_DLY_COUNT2 > 2 */
  80. #if (PDB_DLY_COUNT2 > 4)
  81. kPDB_ADCPreTriggerChannel4ErrorFlag = PDB_S_ERR(1U << 4), /*!< Pre-trigger 4 Error. */
  82. kPDB_ADCPreTriggerChannel5ErrorFlag = PDB_S_ERR(1U << 5), /*!< Pre-trigger 5 Error. */
  83. kPDB_ADCPreTriggerChannel6ErrorFlag = PDB_S_ERR(1U << 6), /*!< Pre-trigger 6 Error. */
  84. kPDB_ADCPreTriggerChannel7ErrorFlag = PDB_S_ERR(1U << 7), /*!< Pre-trigger 7 Error. */
  85. #endif /* PDB_DLY_COUNT2 > 4 */
  86. };
  87. /*!
  88. * @brief PDB buffer interrupts.
  89. */
  90. enum _pdb_interrupt_enable
  91. {
  92. kPDB_SequenceErrorInterruptEnable = PDB_SC_PDBEIE_MASK, /*!< PDB sequence error interrupt enable. */
  93. kPDB_DelayInterruptEnable = PDB_SC_PDBIE_MASK, /*!< PDB delay interrupt enable. */
  94. };
  95. /*!
  96. * @brief PDB load value mode.
  97. *
  98. * Selects the mode to load the internal values after doing the load operation (write 1 to PDBx_SC[LDOK]).
  99. * These values are for the following operations.
  100. * - PDB counter (PDBx_MOD, PDBx_IDLY)
  101. * - ADC trigger (PDBx_CHnDLYm)
  102. * - DAC trigger (PDBx_DACINTx)
  103. * - CMP trigger (PDBx_POyDLY)
  104. */
  105. typedef enum _pdb_load_value_mode
  106. {
  107. kPDB_LoadValueImmediately = 0U, /*!< Load immediately after 1 is written to LDOK. */
  108. kPDB_LoadValueOnCounterOverflow = 1U, /*!< Load when the PDB counter overflows (reaches the MOD
  109. register value). */
  110. kPDB_LoadValueOnTriggerInput = 2U, /*!< Load a trigger input event is detected. */
  111. kPDB_LoadValueOnCounterOverflowOrTriggerInput = 3U, /*!< Load either when the PDB counter overflows or a trigger
  112. input is detected. */
  113. } pdb_load_value_mode_t;
  114. /*!
  115. * @brief Prescaler divider.
  116. *
  117. * Counting uses the peripheral clock divided by multiplication factor selected by times of MULT.
  118. */
  119. typedef enum _pdb_prescaler_divider
  120. {
  121. kPDB_PrescalerDivider1 = 0U, /*!< Divider x1. */
  122. kPDB_PrescalerDivider2 = 1U, /*!< Divider x2. */
  123. kPDB_PrescalerDivider4 = 2U, /*!< Divider x4. */
  124. kPDB_PrescalerDivider8 = 3U, /*!< Divider x8. */
  125. kPDB_PrescalerDivider16 = 4U, /*!< Divider x16. */
  126. kPDB_PrescalerDivider32 = 5U, /*!< Divider x32. */
  127. kPDB_PrescalerDivider64 = 6U, /*!< Divider x64. */
  128. kPDB_PrescalerDivider128 = 7U, /*!< Divider x128. */
  129. } pdb_prescaler_divider_t;
  130. /*!
  131. * @brief Multiplication factor select for prescaler.
  132. *
  133. * Selects the multiplication factor of the prescaler divider for the counter clock.
  134. */
  135. typedef enum _pdb_divider_multiplication_factor
  136. {
  137. kPDB_DividerMultiplicationFactor1 = 0U, /*!< Multiplication factor is 1. */
  138. kPDB_DividerMultiplicationFactor10 = 1U, /*!< Multiplication factor is 10. */
  139. kPDB_DividerMultiplicationFactor20 = 2U, /*!< Multiplication factor is 20. */
  140. kPDB_DividerMultiplicationFactor40 = 3U, /*!< Multiplication factor is 40. */
  141. } pdb_divider_multiplication_factor_t;
  142. /*!
  143. * @brief Trigger input source
  144. *
  145. * Selects the trigger input source for the PDB. The trigger input source can be internal or external (EXTRG pin), or
  146. * the software trigger. See chip configuration details for the actual PDB input trigger connections.
  147. */
  148. typedef enum _pdb_trigger_input_source
  149. {
  150. kPDB_TriggerInput0 = 0U, /*!< Trigger-In 0. */
  151. kPDB_TriggerInput1 = 1U, /*!< Trigger-In 1. */
  152. kPDB_TriggerInput2 = 2U, /*!< Trigger-In 2. */
  153. kPDB_TriggerInput3 = 3U, /*!< Trigger-In 3. */
  154. kPDB_TriggerInput4 = 4U, /*!< Trigger-In 4. */
  155. kPDB_TriggerInput5 = 5U, /*!< Trigger-In 5. */
  156. kPDB_TriggerInput6 = 6U, /*!< Trigger-In 6. */
  157. kPDB_TriggerInput7 = 7U, /*!< Trigger-In 7. */
  158. kPDB_TriggerInput8 = 8U, /*!< Trigger-In 8. */
  159. kPDB_TriggerInput9 = 9U, /*!< Trigger-In 9. */
  160. kPDB_TriggerInput10 = 10U, /*!< Trigger-In 10. */
  161. kPDB_TriggerInput11 = 11U, /*!< Trigger-In 11. */
  162. kPDB_TriggerInput12 = 12U, /*!< Trigger-In 12. */
  163. kPDB_TriggerInput13 = 13U, /*!< Trigger-In 13. */
  164. kPDB_TriggerInput14 = 14U, /*!< Trigger-In 14. */
  165. kPDB_TriggerSoftware = 15U, /*!< Trigger-In 15, software trigger. */
  166. } pdb_trigger_input_source_t;
  167. /*!
  168. * @brief PDB module configuration.
  169. */
  170. typedef struct _pdb_config
  171. {
  172. pdb_load_value_mode_t loadValueMode; /*!< Select the load value mode. */
  173. pdb_prescaler_divider_t prescalerDivider; /*!< Select the prescaler divider. */
  174. pdb_divider_multiplication_factor_t dividerMultiplicationFactor; /*!< Multiplication factor select for prescaler. */
  175. pdb_trigger_input_source_t triggerInputSource; /*!< Select the trigger input source. */
  176. bool enableContinuousMode; /*!< Enable the PDB operation in Continuous mode.*/
  177. } pdb_config_t;
  178. /*!
  179. * @brief PDB ADC Pre-trigger configuration.
  180. */
  181. typedef struct _pdb_adc_pretrigger_config
  182. {
  183. uint32_t enablePreTriggerMask; /*!< PDB Channel Pre-trigger Enable. */
  184. uint32_t enableOutputMask; /*!< PDB Channel Pre-trigger Output Select.
  185. PDB channel's corresponding pre-trigger asserts when the counter
  186. reaches the channel delay register. */
  187. uint32_t enableBackToBackOperationMask; /*!< PDB Channel pre-trigger Back-to-Back Operation Enable.
  188. Back-to-back operation enables the ADC conversions complete to trigger
  189. the next PDB channel pre-trigger and trigger output, so that the ADC
  190. conversions can be triggered on next set of configuration and results
  191. registers.*/
  192. } pdb_adc_pretrigger_config_t;
  193. /*!
  194. * @brief PDB DAC trigger configuration.
  195. */
  196. typedef struct _pdb_dac_trigger_config
  197. {
  198. bool enableExternalTriggerInput; /*!< Enables the external trigger for DAC interval counter. */
  199. bool enableIntervalTrigger; /*!< Enables the DAC interval trigger. */
  200. } pdb_dac_trigger_config_t;
  201. /*******************************************************************************
  202. * API
  203. ******************************************************************************/
  204. #if defined(__cplusplus)
  205. extern "C" {
  206. #endif
  207. /*!
  208. * @name Initialization
  209. * @{
  210. */
  211. /*!
  212. * @brief Initializes the PDB module.
  213. *
  214. * This function initializes the PDB module. The operations included are as follows.
  215. * - Enable the clock for PDB instance.
  216. * - Configure the PDB module.
  217. * - Enable the PDB module.
  218. *
  219. * @param base PDB peripheral base address.
  220. * @param config Pointer to the configuration structure. See "pdb_config_t".
  221. */
  222. void PDB_Init(PDB_Type *base, const pdb_config_t *config);
  223. /*!
  224. * @brief De-initializes the PDB module.
  225. *
  226. * @param base PDB peripheral base address.
  227. */
  228. void PDB_Deinit(PDB_Type *base);
  229. /*!
  230. * @brief Initializes the PDB user configuration structure.
  231. *
  232. * This function initializes the user configuration structure to a default value. The default values are as follows.
  233. * @code
  234. * config->loadValueMode = kPDB_LoadValueImmediately;
  235. * config->prescalerDivider = kPDB_PrescalerDivider1;
  236. * config->dividerMultiplicationFactor = kPDB_DividerMultiplicationFactor1;
  237. * config->triggerInputSource = kPDB_TriggerSoftware;
  238. * config->enableContinuousMode = false;
  239. * @endcode
  240. * @param config Pointer to configuration structure. See "pdb_config_t".
  241. */
  242. void PDB_GetDefaultConfig(pdb_config_t *config);
  243. /*!
  244. * @brief Enables the PDB module.
  245. *
  246. * @param base PDB peripheral base address.
  247. * @param enable Enable the module or not.
  248. */
  249. static inline void PDB_Enable(PDB_Type *base, bool enable)
  250. {
  251. if (enable)
  252. {
  253. base->SC |= PDB_SC_PDBEN_MASK;
  254. }
  255. else
  256. {
  257. base->SC &= ~PDB_SC_PDBEN_MASK;
  258. }
  259. }
  260. /* @} */
  261. /*!
  262. * @name Basic Counter
  263. * @{
  264. */
  265. /*!
  266. * @brief Triggers the PDB counter by software.
  267. *
  268. * @param base PDB peripheral base address.
  269. */
  270. static inline void PDB_DoSoftwareTrigger(PDB_Type *base)
  271. {
  272. base->SC |= PDB_SC_SWTRIG_MASK;
  273. }
  274. /*!
  275. * @brief Loads the counter values.
  276. *
  277. * This function loads the counter values from the internal buffer.
  278. * See "pdb_load_value_mode_t" about PDB's load mode.
  279. *
  280. * @param base PDB peripheral base address.
  281. */
  282. static inline void PDB_DoLoadValues(PDB_Type *base)
  283. {
  284. base->SC |= PDB_SC_LDOK_MASK;
  285. }
  286. /*!
  287. * @brief Enables the DMA for the PDB module.
  288. *
  289. * @param base PDB peripheral base address.
  290. * @param enable Enable the feature or not.
  291. */
  292. static inline void PDB_EnableDMA(PDB_Type *base, bool enable)
  293. {
  294. if (enable)
  295. {
  296. base->SC |= PDB_SC_DMAEN_MASK;
  297. }
  298. else
  299. {
  300. base->SC &= ~PDB_SC_DMAEN_MASK;
  301. }
  302. }
  303. /*!
  304. * @brief Enables the interrupts for the PDB module.
  305. *
  306. * @param base PDB peripheral base address.
  307. * @param mask Mask value for interrupts. See "_pdb_interrupt_enable".
  308. */
  309. static inline void PDB_EnableInterrupts(PDB_Type *base, uint32_t mask)
  310. {
  311. assert(0U == (mask & ~(PDB_SC_PDBEIE_MASK | PDB_SC_PDBIE_MASK)));
  312. base->SC |= mask;
  313. }
  314. /*!
  315. * @brief Disables the interrupts for the PDB module.
  316. *
  317. * @param base PDB peripheral base address.
  318. * @param mask Mask value for interrupts. See "_pdb_interrupt_enable".
  319. */
  320. static inline void PDB_DisableInterrupts(PDB_Type *base, uint32_t mask)
  321. {
  322. assert(0U == (mask & ~(PDB_SC_PDBEIE_MASK | PDB_SC_PDBIE_MASK)));
  323. base->SC &= ~mask;
  324. }
  325. /*!
  326. * @brief Gets the status flags of the PDB module.
  327. *
  328. * @param base PDB peripheral base address.
  329. *
  330. * @return Mask value for asserted flags. See "_pdb_status_flags".
  331. */
  332. static inline uint32_t PDB_GetStatusFlags(PDB_Type *base)
  333. {
  334. return base->SC & (PDB_SC_PDBIF_MASK | PDB_SC_LDOK_MASK);
  335. }
  336. /*!
  337. * @brief Clears the status flags of the PDB module.
  338. *
  339. * @param base PDB peripheral base address.
  340. * @param mask Mask value of flags. See "_pdb_status_flags".
  341. */
  342. static inline void PDB_ClearStatusFlags(PDB_Type *base, uint32_t mask)
  343. {
  344. assert(0U == (mask & ~PDB_SC_PDBIF_MASK));
  345. base->SC &= ~mask;
  346. }
  347. /*!
  348. * @brief Specifies the counter period.
  349. *
  350. * @param base PDB peripheral base address.
  351. * @param value Setting value for the modulus. 16-bit is available.
  352. */
  353. static inline void PDB_SetModulusValue(PDB_Type *base, uint32_t value)
  354. {
  355. base->MOD = PDB_MOD_MOD(value);
  356. }
  357. /*!
  358. * @brief Gets the PDB counter's current value.
  359. *
  360. * @param base PDB peripheral base address.
  361. *
  362. * @return PDB counter's current value.
  363. */
  364. static inline uint32_t PDB_GetCounterValue(PDB_Type *base)
  365. {
  366. return base->CNT;
  367. }
  368. /*!
  369. * @brief Sets the value for the PDB counter delay event.
  370. *
  371. * @param base PDB peripheral base address.
  372. * @param value Setting value for PDB counter delay event. 16-bit is available.
  373. */
  374. static inline void PDB_SetCounterDelayValue(PDB_Type *base, uint32_t value)
  375. {
  376. base->IDLY = PDB_IDLY_IDLY(value);
  377. }
  378. /* @} */
  379. /*!
  380. * @name ADC Pre-trigger
  381. * @{
  382. */
  383. /*!
  384. * @brief Configures the ADC pre-trigger in the PDB module.
  385. *
  386. * @param base PDB peripheral base address.
  387. * @param channel Channel index for ADC instance.
  388. * @param config Pointer to the configuration structure. See "pdb_adc_pretrigger_config_t".
  389. */
  390. static inline void PDB_SetADCPreTriggerConfig(PDB_Type *base, uint32_t channel, pdb_adc_pretrigger_config_t *config)
  391. {
  392. assert(channel < PDB_C1_COUNT);
  393. assert(NULL != config);
  394. base->CH[channel].C1 = PDB_C1_BB(config->enableBackToBackOperationMask) | PDB_C1_TOS(config->enableOutputMask) |
  395. PDB_C1_EN(config->enablePreTriggerMask);
  396. }
  397. /*!
  398. * @brief Sets the value for the ADC pre-trigger delay event.
  399. *
  400. * This function sets the value for ADC pre-trigger delay event. It specifies the delay value for the channel's
  401. * corresponding pre-trigger. The pre-trigger asserts when the PDB counter is equal to the set value.
  402. *
  403. * @param base PDB peripheral base address.
  404. * @param channel Channel index for ADC instance.
  405. * @param preChannel Channel group index for ADC instance.
  406. * @param value Setting value for ADC pre-trigger delay event. 16-bit is available.
  407. */
  408. static inline void PDB_SetADCPreTriggerDelayValue(PDB_Type *base, uint32_t channel, uint32_t preChannel, uint32_t value)
  409. {
  410. assert(channel < PDB_C1_COUNT);
  411. assert(preChannel < PDB_DLY_COUNT2);
  412. /* xx_COUNT2 is actually the count for pre-triggers in header file. xx_COUNT is used for the count of channels. */
  413. base->CH[channel].DLY[preChannel] = PDB_DLY_DLY(value);
  414. }
  415. /*!
  416. * @brief Gets the ADC pre-trigger's status flags.
  417. *
  418. * @param base PDB peripheral base address.
  419. * @param channel Channel index for ADC instance.
  420. *
  421. * @return Mask value for asserted flags. See "_pdb_adc_pretrigger_flags".
  422. */
  423. static inline uint32_t PDB_GetADCPreTriggerStatusFlags(PDB_Type *base, uint32_t channel)
  424. {
  425. assert(channel < PDB_C1_COUNT);
  426. return base->CH[channel].S;
  427. }
  428. /*!
  429. * @brief Clears the ADC pre-trigger status flags.
  430. *
  431. * @param base PDB peripheral base address.
  432. * @param channel Channel index for ADC instance.
  433. * @param mask Mask value for flags. See "_pdb_adc_pretrigger_flags".
  434. */
  435. static inline void PDB_ClearADCPreTriggerStatusFlags(PDB_Type *base, uint32_t channel, uint32_t mask)
  436. {
  437. assert(channel < PDB_C1_COUNT);
  438. base->CH[channel].S &= ~mask;
  439. }
  440. /* @} */
  441. #if defined(FSL_FEATURE_PDB_HAS_DAC) && FSL_FEATURE_PDB_HAS_DAC
  442. /*!
  443. * @name DAC Interval Trigger
  444. * @{
  445. */
  446. /*!
  447. * @brief Configures the DAC trigger in the PDB module.
  448. *
  449. * @param base PDB peripheral base address.
  450. * @param channel Channel index for DAC instance.
  451. * @param config Pointer to the configuration structure. See "pdb_dac_trigger_config_t".
  452. */
  453. void PDB_SetDACTriggerConfig(PDB_Type *base, uint32_t channel, pdb_dac_trigger_config_t *config);
  454. /*!
  455. * @brief Sets the value for the DAC interval event.
  456. *
  457. * This fucntion sets the value for DAC interval event. DAC interval trigger triggers the DAC module to update
  458. * the buffer when the DAC interval counter is equal to the set value.
  459. *
  460. * @param base PDB peripheral base address.
  461. * @param channel Channel index for DAC instance.
  462. * @param value Setting value for the DAC interval event.
  463. */
  464. static inline void PDB_SetDACTriggerIntervalValue(PDB_Type *base, uint32_t channel, uint32_t value)
  465. {
  466. assert(channel < PDB_INT_COUNT);
  467. base->DAC[channel].INT = PDB_INT_INT(value);
  468. }
  469. /* @} */
  470. #endif /* FSL_FEATURE_PDB_HAS_DAC */
  471. /*!
  472. * @name Pulse-Out Trigger
  473. * @{
  474. */
  475. /*!
  476. * @brief Enables the pulse out trigger channels.
  477. *
  478. * @param base PDB peripheral base address.
  479. * @param channelMask Channel mask value for multiple pulse out trigger channel.
  480. * @param enable Whether the feature is enabled or not.
  481. */
  482. static inline void PDB_EnablePulseOutTrigger(PDB_Type *base, uint32_t channelMask, bool enable)
  483. {
  484. if (enable)
  485. {
  486. base->POEN |= PDB_POEN_POEN(channelMask);
  487. }
  488. else
  489. {
  490. base->POEN &= ~(PDB_POEN_POEN(channelMask));
  491. }
  492. }
  493. /*!
  494. * @brief Sets event values for the pulse out trigger.
  495. *
  496. * This function is used to set event values for the pulse output trigger.
  497. * These pulse output trigger delay values specify the delay for the PDB Pulse-out. Pulse-out goes high when the PDB
  498. * counter is equal to the pulse output high value (value1). Pulse-out goes low when the PDB counter is equal to the
  499. * pulse output low value (value2).
  500. *
  501. * @param base PDB peripheral base address.
  502. * @param channel Channel index for pulse out trigger channel.
  503. * @param value1 Setting value for pulse out high.
  504. * @param value2 Setting value for pulse out low.
  505. */
  506. static inline void PDB_SetPulseOutTriggerDelayValue(PDB_Type *base, uint32_t channel, uint32_t value1, uint32_t value2)
  507. {
  508. assert(channel < PDB_PODLY_COUNT);
  509. base->PODLY[channel] = PDB_PODLY_DLY1(value1) | PDB_PODLY_DLY2(value2);
  510. }
  511. /* @} */
  512. #if defined(__cplusplus)
  513. }
  514. #endif
  515. /*!
  516. * @}
  517. */
  518. #endif /* _FSL_PDB_H_ */