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