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