fsl_pdb.h 20 KB

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