The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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