mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

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

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Child:
432:9eff63c6c55a
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 324:406fd2029f23 30
mbed_official 146:f64d43ff0c18 31 #ifndef __FSL_ADC_HAL_H__
mbed_official 146:f64d43ff0c18 32 #define __FSL_ADC_HAL_H__
mbed_official 146:f64d43ff0c18 33
mbed_official 146:f64d43ff0c18 34 #include <stdint.h>
mbed_official 146:f64d43ff0c18 35 #include <stdbool.h>
mbed_official 324:406fd2029f23 36 #include <assert.h>
mbed_official 324:406fd2029f23 37 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 38 #include "fsl_adc_features.h"
mbed_official 146:f64d43ff0c18 39
mbed_official 146:f64d43ff0c18 40 /*!
mbed_official 146:f64d43ff0c18 41 * @addtogroup adc_hal
mbed_official 146:f64d43ff0c18 42 * @{
mbed_official 146:f64d43ff0c18 43 */
mbed_official 146:f64d43ff0c18 44
mbed_official 324:406fd2029f23 45 /******************************************************************************
mbed_official 146:f64d43ff0c18 46 * Definitions
mbed_official 324:406fd2029f23 47 *****************************************************************************/
mbed_official 146:f64d43ff0c18 48
mbed_official 324:406fd2029f23 49 /*!
mbed_official 324:406fd2029f23 50 * @brief ADC status return codes.
mbed_official 324:406fd2029f23 51 */
mbed_official 324:406fd2029f23 52 typedef enum _adc_status
mbed_official 146:f64d43ff0c18 53 {
mbed_official 324:406fd2029f23 54 kStatus_ADC_Success = 0U, /*!< Success. */
mbed_official 324:406fd2029f23 55 kStatus_ADC_InvalidArgument = 1U, /*!< Invalid argument existed. */
mbed_official 324:406fd2029f23 56 kStatus_ADC_Failed = 2U /*!< Execution failed. */
mbed_official 324:406fd2029f23 57 } adc_status_t;
mbed_official 324:406fd2029f23 58
mbed_official 324:406fd2029f23 59 #if FSL_FEATURE_ADC_HAS_MUX_SELECT
mbed_official 146:f64d43ff0c18 60
mbed_official 324:406fd2029f23 61 /*!
mbed_official 324:406fd2029f23 62 * @brief Defines the type of the enumerating channel multiplexer mode for each channel.
mbed_official 324:406fd2029f23 63 *
mbed_official 324:406fd2029f23 64 * For some ADC channels, there are two selections for the channel multiplexer. For
mbed_official 324:406fd2029f23 65 * example, ADC0_SE4a and ADC0_SE4b are the different channels but share the same
mbed_official 324:406fd2029f23 66 * channel number.
mbed_official 324:406fd2029f23 67 */
mbed_official 324:406fd2029f23 68 typedef enum _adc_chn_mux_mode
mbed_official 146:f64d43ff0c18 69 {
mbed_official 324:406fd2029f23 70 kAdcChnMuxOfA = 0U, /*!< For channel with channel mux a. */
mbed_official 324:406fd2029f23 71 kAdcChnMuxOfB = 1U, /*!< For channel with channel mux b. */
mbed_official 324:406fd2029f23 72 kAdcChnMuxOfDefault = kAdcChnMuxOfA /*!< For channel without any channel mux identifier. */
mbed_official 324:406fd2029f23 73 } adc_chn_mux_mode_t;
mbed_official 324:406fd2029f23 74 #endif /* FSL_FEATURE_ADC_HAS_MUX_SELECT */
mbed_official 146:f64d43ff0c18 75
mbed_official 324:406fd2029f23 76 /*!
mbed_official 324:406fd2029f23 77 * @brief Defines the type of the enumerating divider for the converter.
mbed_official 324:406fd2029f23 78 */
mbed_official 324:406fd2029f23 79 typedef enum _adc_clk_divider_mode
mbed_official 146:f64d43ff0c18 80 {
mbed_official 324:406fd2029f23 81 kAdcClkDividerInputOf1 = 0U, /*!< For divider 1 from the input clock to ADC. */
mbed_official 324:406fd2029f23 82 kAdcClkDividerInputOf2 = 1U, /*!< For divider 2 from the input clock to ADC. */
mbed_official 324:406fd2029f23 83 kAdcClkDividerInputOf4 = 2U, /*!< For divider 4 from the input clock to ADC. */
mbed_official 324:406fd2029f23 84 kAdcClkDividerInputOf8 = 3U /*!< For divider 8 from the input clock to ADC. */
mbed_official 324:406fd2029f23 85 } adc_clk_divider_mode_t;
mbed_official 146:f64d43ff0c18 86
mbed_official 324:406fd2029f23 87 /*!
mbed_official 324:406fd2029f23 88 *@brief Defines the type of the enumerating resolution for the converter.
mbed_official 324:406fd2029f23 89 */
mbed_official 146:f64d43ff0c18 90 typedef enum _adc_resolution_mode
mbed_official 146:f64d43ff0c18 91 {
mbed_official 324:406fd2029f23 92 kAdcResolutionBitOf8or9 = 0U,
mbed_official 324:406fd2029f23 93 /*!< 8-bit for single end sample, or 9-bit for differential sample. */
mbed_official 324:406fd2029f23 94 kAdcResolutionBitOfSingleEndAs8 = kAdcResolutionBitOf8or9, /*!< 8-bit for single end sample. */
mbed_official 324:406fd2029f23 95 kAdcResolutionBitOfDiffModeAs9 = kAdcResolutionBitOf8or9, /*!< 9-bit for differential sample. */
mbed_official 324:406fd2029f23 96
mbed_official 324:406fd2029f23 97 kAdcResolutionBitOf12or13 = 1U,
mbed_official 324:406fd2029f23 98 /*!< 12-bit for single end sample, or 13-bit for differential sample. */
mbed_official 324:406fd2029f23 99 kAdcResolutionBitOfSingleEndAs12 = kAdcResolutionBitOf12or13, /*!< 12-bit for single end sample. */
mbed_official 324:406fd2029f23 100 kAdcResolutionBitOfDiffModeAs13 = kAdcResolutionBitOf12or13, /*!< 13-bit for differential sample. */
mbed_official 324:406fd2029f23 101
mbed_official 324:406fd2029f23 102 kAdcResolutionBitOf10or11 = 2U,
mbed_official 324:406fd2029f23 103 /*!< 10-bit for single end sample, or 11-bit for differential sample. */
mbed_official 324:406fd2029f23 104 kAdcResolutionBitOfSingleEndAs10 = kAdcResolutionBitOf10or11, /*!< 10-bit for single end sample. */
mbed_official 324:406fd2029f23 105 kAdcResolutionBitOfDiffModeAs11 = kAdcResolutionBitOf10or11 /*!< 11-bit for differential sample. */
mbed_official 324:406fd2029f23 106 #if (FSL_FEATURE_ADC_MAX_RESOLUTION>=16)
mbed_official 324:406fd2029f23 107 , kAdcResolutionBitOf16 = 3U,
mbed_official 324:406fd2029f23 108 /*!< 16-bit for both single end sample and differential sample. */
mbed_official 324:406fd2029f23 109 kAdcResolutionBitOfSingleEndAs16 = kAdcResolutionBitOf16, /*!< 16-bit for single end sample. */
mbed_official 324:406fd2029f23 110 kAdcResolutionBitOfDiffModeAs16 = kAdcResolutionBitOf16 /*!< 16-bit for differential sample. */
mbed_official 324:406fd2029f23 111
mbed_official 324:406fd2029f23 112 #endif /* FSL_FEATURE_ADC_MAX_RESOLUTION */
mbed_official 146:f64d43ff0c18 113 } adc_resolution_mode_t;
mbed_official 146:f64d43ff0c18 114
mbed_official 324:406fd2029f23 115 /*!
mbed_official 324:406fd2029f23 116 * @brief Defines the type of the enumerating source of the input clock.
mbed_official 324:406fd2029f23 117 */
mbed_official 324:406fd2029f23 118 typedef enum _adc_clk_src_mode
mbed_official 146:f64d43ff0c18 119 {
mbed_official 324:406fd2029f23 120 kAdcClkSrcOfBusClk = 0U, /*!< For input as bus clock. */
mbed_official 324:406fd2029f23 121 kAdcClkSrcOfBusOrAltClk2 = 1U, /*!< For input as bus clock /2 or AltClk2. */
mbed_official 324:406fd2029f23 122 kAdcClkSrcOfAltClk = 2U, /*!< For input as alternate clock (ALTCLK). */
mbed_official 324:406fd2029f23 123 kAdcClkSrcOfAsynClk = 3U /*!< For input as asynchronous clock (ADACK). */
mbed_official 324:406fd2029f23 124 } adc_clk_src_mode_t;
mbed_official 146:f64d43ff0c18 125
mbed_official 324:406fd2029f23 126 /*
mbed_official 324:406fd2029f23 127 * @brief Defines the type of the enumerating long sample cycles.
mbed_official 324:406fd2029f23 128 */
mbed_official 324:406fd2029f23 129 typedef enum _adc_long_sample_cycle_mode
mbed_official 146:f64d43ff0c18 130 {
mbed_official 324:406fd2029f23 131 kAdcLongSampleCycleOf24 = 0U, /*!< 20 extra ADCK cycles, 24 ADCK cycles total. */
mbed_official 324:406fd2029f23 132 kAdcLongSampleCycleOf16 = 1U, /*!< 12 extra ADCK cycles, 16 ADCK cycles total. */
mbed_official 324:406fd2029f23 133 kAdcLongSampleCycleOf10 = 2U, /*!< 6 extra ADCK cycles, 10 ADCK cycles total. */
mbed_official 324:406fd2029f23 134 kAdcLongSampleCycleOf4 = 3U /*!< 2 extra ADCK cycles, 6 ADCK cycles total. */
mbed_official 324:406fd2029f23 135 } adc_long_sample_cycle_mode_t;
mbed_official 146:f64d43ff0c18 136
mbed_official 324:406fd2029f23 137 /*
mbed_official 324:406fd2029f23 138 * @brief Defines the type of the enumerating reference voltage source.
mbed_official 324:406fd2029f23 139 */
mbed_official 324:406fd2029f23 140 typedef enum _adc_ref_volt_src_mode
mbed_official 324:406fd2029f23 141 {
mbed_official 324:406fd2029f23 142 kAdcRefVoltSrcOfVref = 0U, /*!< For external pins pair of VrefH and VrefL. */
mbed_official 324:406fd2029f23 143 kAdcRefVoltSrcOfValt = 1U /*!< For alternate reference pair of ValtH and ValtL.*/
mbed_official 324:406fd2029f23 144 } adc_ref_volt_src_mode_t;
mbed_official 324:406fd2029f23 145
mbed_official 324:406fd2029f23 146 #if FSL_FEATURE_ADC_HAS_HW_AVERAGE
mbed_official 324:406fd2029f23 147
mbed_official 324:406fd2029f23 148 /*
mbed_official 324:406fd2029f23 149 * @brief Defines the type of the enumerating hardware average mode.
mbed_official 324:406fd2029f23 150 */
mbed_official 324:406fd2029f23 151 typedef enum _adc_hw_average_count_mode
mbed_official 146:f64d43ff0c18 152 {
mbed_official 324:406fd2029f23 153 kAdcHwAverageCountOf4 = 0U, /*!< For hardware average with 4 samples. */
mbed_official 324:406fd2029f23 154 kAdcHwAverageCountOf8 = 1U, /*!< For hardware average with 8 samples. */
mbed_official 324:406fd2029f23 155 kAdcHwAverageCountOf16 = 2U, /*!< For hardware average with 16 samples. */
mbed_official 324:406fd2029f23 156 kAdcHwAverageCountOf32 = 3U /*!< For hardware average with 32 samples. */
mbed_official 324:406fd2029f23 157 } adc_hw_average_count_mode_t;
mbed_official 324:406fd2029f23 158
mbed_official 324:406fd2029f23 159 #endif /* FSL_FEATURE_ADC_HAS_HW_AVERAGE */
mbed_official 146:f64d43ff0c18 160
mbed_official 324:406fd2029f23 161 /*!
mbed_official 324:406fd2029f23 162 * @brief Defines the type of the enumerating asserted range in the hardware compare.
mbed_official 324:406fd2029f23 163 *
mbed_official 324:406fd2029f23 164 * When the internal CMP is enabled, the COCO flag, which represents the complement
mbed_official 324:406fd2029f23 165 * of the conversion, is not asserted if the sample value is not in the indicated
mbed_official 324:406fd2029f23 166 * range. Eventually, the data of conversion result is not kept in the result
mbed_official 324:406fd2029f23 167 * data register. The two values, cmpValue1 and cmpValue2, mark
mbed_official 324:406fd2029f23 168 * the thresholds with the comparator feature.
mbed_official 324:406fd2029f23 169 * kAdcHwCmpRangeModeOf1:
mbed_official 324:406fd2029f23 170 * Both greater than and in range switchers are disabled.
mbed_official 324:406fd2029f23 171 * The available range is "< cmpValue1".
mbed_official 324:406fd2029f23 172 * kAdcHwCmpRangeModeOf2:
mbed_official 324:406fd2029f23 173 * Greater than switcher is enabled while the in range switcher is disabled.
mbed_official 324:406fd2029f23 174 * The available range is " > cmpValue1".
mbed_official 324:406fd2029f23 175 * kAdcHwCmpRangeModeOf3:
mbed_official 324:406fd2029f23 176 * Greater than switcher is disabled while in range switcher is enabled.
mbed_official 324:406fd2029f23 177 * The available range is "< cmpValue1" or "> cmpValue2" when
mbed_official 324:406fd2029f23 178 * cmpValue1 <= cmpValue2, or "< cmpValue1" and "> cmpValue2" when
mbed_official 324:406fd2029f23 179 * cmpValue1 >= cmpValue2.
mbed_official 324:406fd2029f23 180 * kAdcHwCmpRangeModeOf4:
mbed_official 324:406fd2029f23 181 * Both greater than and in range switchers are enabled.
mbed_official 324:406fd2029f23 182 * The available range is "> cmpValue1" and "< cmpValue2" when
mbed_official 324:406fd2029f23 183 * cmpValue1 <= cmpValue2, or "> cmpValue1" or "< cmpValue2" when
mbed_official 324:406fd2029f23 184 * cmpValue1 < cmpValue2.
mbed_official 324:406fd2029f23 185 */
mbed_official 324:406fd2029f23 186 typedef enum _adc_hw_cmp_range_mode
mbed_official 146:f64d43ff0c18 187 {
mbed_official 324:406fd2029f23 188 kAdcHwCmpRangeModeOf1 = 0U, /*!< For selection mode 1. */
mbed_official 324:406fd2029f23 189 kAdcHwCmpRangeModeOf2 = 1U, /*!< For selection mode 2. */
mbed_official 324:406fd2029f23 190 kAdcHwCmpRangeModeOf3 = 2U, /*!< For selection mode 3. */
mbed_official 324:406fd2029f23 191 kAdcHwCmpRangeModeOf4 = 3U /*!< For selection mode 4. */
mbed_official 324:406fd2029f23 192 } adc_hw_cmp_range_mode_t;
mbed_official 146:f64d43ff0c18 193
mbed_official 146:f64d43ff0c18 194 #if FSL_FEATURE_ADC_HAS_PGA
mbed_official 324:406fd2029f23 195
mbed_official 324:406fd2029f23 196 /*!
mbed_official 324:406fd2029f23 197 * @brief Defines the type of enumerating PGA's Gain mode.
mbed_official 324:406fd2029f23 198 */
mbed_official 324:406fd2029f23 199 typedef enum _adc_pga_gain_mode
mbed_official 146:f64d43ff0c18 200 {
mbed_official 324:406fd2029f23 201 kAdcPgaGainValueOf1 = 0U, /*!< For amplifier gain of 1.*/
mbed_official 324:406fd2029f23 202 kAdcPgaGainValueOf2 = 1U, /*!< For amplifier gain of 2.*/
mbed_official 324:406fd2029f23 203 kAdcPgaGainValueOf4 = 2U, /*!< For amplifier gain of 4.*/
mbed_official 324:406fd2029f23 204 kAdcPgaGainValueOf8 = 3U, /*!< For amplifier gain of 8.*/
mbed_official 324:406fd2029f23 205 kAdcPgaGainValueOf16 = 4U, /*!< For amplifier gain of 16.*/
mbed_official 324:406fd2029f23 206 kAdcPgaGainValueOf32 = 5U, /*!< For amplifier gain of 32.*/
mbed_official 324:406fd2029f23 207 kAdcPgaGainValueOf64 = 6U /*!< For amplifier gain of 64.*/
mbed_official 324:406fd2029f23 208 } adc_pga_gain_mode_t;
mbed_official 324:406fd2029f23 209
mbed_official 146:f64d43ff0c18 210 #endif /* FSL_FEATURE_ADC_HAS_PGA */
mbed_official 146:f64d43ff0c18 211
mbed_official 146:f64d43ff0c18 212 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 213 extern "C" {
mbed_official 146:f64d43ff0c18 214 #endif
mbed_official 146:f64d43ff0c18 215
mbed_official 324:406fd2029f23 216 /*******************************************************************************
mbed_official 324:406fd2029f23 217 * API
mbed_official 324:406fd2029f23 218 ******************************************************************************/
mbed_official 324:406fd2029f23 219
mbed_official 146:f64d43ff0c18 220
mbed_official 146:f64d43ff0c18 221 /*!
mbed_official 324:406fd2029f23 222 * @brief Resets all registers into a known state for the ADC module.
mbed_official 146:f64d43ff0c18 223 *
mbed_official 324:406fd2029f23 224 * This function resets all registers into a known state for the ADC
mbed_official 324:406fd2029f23 225 * module. This known state is the reset value indicated by the Reference
mbed_official 324:406fd2029f23 226 * manual. It is strongly recommended to call this API before any other operation
mbed_official 324:406fd2029f23 227 * when initializing the ADC module.
mbed_official 146:f64d43ff0c18 228 *
mbed_official 324:406fd2029f23 229 * @param baseAddr Register base address for the module.
mbed_official 146:f64d43ff0c18 230 */
mbed_official 324:406fd2029f23 231 void ADC_HAL_Init(uint32_t baseAddr);
mbed_official 146:f64d43ff0c18 232
mbed_official 146:f64d43ff0c18 233 /*!
mbed_official 324:406fd2029f23 234 * @brief Configures the conversion channel for the ADC module.
mbed_official 324:406fd2029f23 235 *
mbed_official 324:406fd2029f23 236 * This function configures the channel for the ADC module. At any point,
mbed_official 324:406fd2029f23 237 * only one of the configuration groups takes effect. The other channel mux of
mbed_official 324:406fd2029f23 238 * the first group (group A, 0) is only for the hardware trigger. Both software and
mbed_official 324:406fd2029f23 239 * hardware trigger can be used to the first group. When in software trigger
mbed_official 324:406fd2029f23 240 * mode, once the available channel is set, the conversion begins to execute.
mbed_official 146:f64d43ff0c18 241 *
mbed_official 324:406fd2029f23 242 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 243 * @param chnGroup Channel configuration group ID.
mbed_official 324:406fd2029f23 244 * @param intEnable Switcher to enable interrupt when conversion is completed.
mbed_official 324:406fd2029f23 245 * @param diffEnable Switcher to enable differential channel mode.
mbed_official 324:406fd2029f23 246 * @param chnNum ADC channel for next conversion.
mbed_official 146:f64d43ff0c18 247 */
mbed_official 324:406fd2029f23 248 static inline void ADC_HAL_ConfigChn(uint32_t baseAddr, uint32_t chnGroup,
mbed_official 324:406fd2029f23 249 bool intEnable, bool diffEnable, uint8_t chnNum)
mbed_official 146:f64d43ff0c18 250 {
mbed_official 324:406fd2029f23 251 assert(chnGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
mbed_official 324:406fd2029f23 252
mbed_official 324:406fd2029f23 253 #if FSL_FEATURE_ADC_HAS_DIFF_MODE
mbed_official 324:406fd2029f23 254 HW_ADC_SC1n_WR(baseAddr, chnGroup, \
mbed_official 324:406fd2029f23 255 ( (intEnable ? BM_ADC_SC1n_AIEN : 0U) \
mbed_official 324:406fd2029f23 256 | ( (diffEnable)? BM_ADC_SC1n_DIFF : 0U) \
mbed_official 324:406fd2029f23 257 | BF_ADC_SC1n_ADCH(chnNum) \
mbed_official 324:406fd2029f23 258 ) );
mbed_official 324:406fd2029f23 259 #else
mbed_official 324:406fd2029f23 260 HW_ADC_SC1n_WR(baseAddr, chnGroup, \
mbed_official 324:406fd2029f23 261 ( (intEnable ? BM_ADC_SC1n_AIEN : 0U) \
mbed_official 324:406fd2029f23 262 | BF_ADC_SC1n_ADCH(chnNum) \
mbed_official 324:406fd2029f23 263 ) );
mbed_official 324:406fd2029f23 264
mbed_official 324:406fd2029f23 265 #endif /* FSL_FEATURE_ADC_HAS_DIFF_MODE */
mbed_official 324:406fd2029f23 266
mbed_official 146:f64d43ff0c18 267 }
mbed_official 146:f64d43ff0c18 268
mbed_official 324:406fd2029f23 269 #if FSL_FEATURE_ADC_HAS_DIFF_MODE
mbed_official 324:406fd2029f23 270
mbed_official 146:f64d43ff0c18 271 /*!
mbed_official 324:406fd2029f23 272 * @brief Checks whether the channel differential mode is enabled.
mbed_official 324:406fd2029f23 273 *
mbed_official 324:406fd2029f23 274 * This function checks whether the channel differential mode for
mbed_official 324:406fd2029f23 275 * is enabled.
mbed_official 146:f64d43ff0c18 276 *
mbed_official 324:406fd2029f23 277 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 278 * @param chnGroup Channel configuration group ID.
mbed_official 324:406fd2029f23 279 * @return Assertion of enabling differential mode.
mbed_official 146:f64d43ff0c18 280 */
mbed_official 324:406fd2029f23 281 static inline bool ADC_HAL_GetChnDiffCmd(uint32_t baseAddr, uint32_t chnGroup)
mbed_official 324:406fd2029f23 282 {
mbed_official 324:406fd2029f23 283 assert(chnGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
mbed_official 324:406fd2029f23 284 return (1U == BR_ADC_SC1n_DIFF(baseAddr, chnGroup));
mbed_official 324:406fd2029f23 285 }
mbed_official 324:406fd2029f23 286 #endif /* FSL_FEATURE_ADC_HAS_DIFF_MODE */
mbed_official 146:f64d43ff0c18 287
mbed_official 146:f64d43ff0c18 288 /*!
mbed_official 324:406fd2029f23 289 * @brief Checks whether the channel conversion is completed.
mbed_official 324:406fd2029f23 290 *
mbed_official 324:406fd2029f23 291 * This function checks whether the channel conversion for the ADC
mbed_official 324:406fd2029f23 292 * module is completed.
mbed_official 146:f64d43ff0c18 293 *
mbed_official 324:406fd2029f23 294 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 295 * @param chnGroup Channel configuration group ID.
mbed_official 324:406fd2029f23 296 * @return Assertion of completed conversion mode.
mbed_official 146:f64d43ff0c18 297 */
mbed_official 324:406fd2029f23 298 static inline bool ADC_HAL_GetChnConvCompletedCmd(uint32_t baseAddr, uint32_t chnGroup)
mbed_official 146:f64d43ff0c18 299 {
mbed_official 324:406fd2029f23 300 assert(chnGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
mbed_official 324:406fd2029f23 301 return (1U == BR_ADC_SC1n_COCO(baseAddr, chnGroup) );
mbed_official 146:f64d43ff0c18 302 }
mbed_official 146:f64d43ff0c18 303
mbed_official 146:f64d43ff0c18 304 /*!
mbed_official 324:406fd2029f23 305 * @brief Switches to enable the low power mode for ADC module.
mbed_official 146:f64d43ff0c18 306 *
mbed_official 324:406fd2029f23 307 * This function switches to enable the low power mode for ADC module.
mbed_official 146:f64d43ff0c18 308 *
mbed_official 324:406fd2029f23 309 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 310 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 311 */
mbed_official 324:406fd2029f23 312 static inline void ADC_HAL_SetLowPowerCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 313 {
mbed_official 324:406fd2029f23 314 BW_ADC_CFG1_ADLPC(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 315 }
mbed_official 146:f64d43ff0c18 316
mbed_official 146:f64d43ff0c18 317 /*!
mbed_official 324:406fd2029f23 318 * @brief Selects the clock divider mode for the ADC module.
mbed_official 324:406fd2029f23 319 *
mbed_official 324:406fd2029f23 320 * This function selects the clock divider mode for the ADC module.
mbed_official 146:f64d43ff0c18 321 *
mbed_official 324:406fd2029f23 322 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 323 * @param mode Selection of mode enumeration. See to "adc_clk_divider_mode_t".
mbed_official 146:f64d43ff0c18 324 */
mbed_official 324:406fd2029f23 325 static inline void ADC_HAL_SetClkDividerMode(uint32_t baseAddr, adc_clk_divider_mode_t mode)
mbed_official 146:f64d43ff0c18 326 {
mbed_official 324:406fd2029f23 327 BW_ADC_CFG1_ADIV(baseAddr, (uint32_t)mode );
mbed_official 146:f64d43ff0c18 328 }
mbed_official 146:f64d43ff0c18 329
mbed_official 146:f64d43ff0c18 330 /*!
mbed_official 324:406fd2029f23 331 * @brief Switches to enable the long sample mode for the ADC module.
mbed_official 146:f64d43ff0c18 332 *
mbed_official 324:406fd2029f23 333 * This function switches to enable the long sample mode for the ADC module.
mbed_official 324:406fd2029f23 334 * This function adjusts the sample period to allow the higher impedance inputs to
mbed_official 324:406fd2029f23 335 * be accurately sampled or to maximize the conversion speed for the lower impedance
mbed_official 324:406fd2029f23 336 * inputs. Longer sample times can also be used to lower overall power
mbed_official 324:406fd2029f23 337 * consumption if the continuous conversions are enabled and the high conversion rates
mbed_official 324:406fd2029f23 338 * are not required. If the long sample mode is enabled, more configuration
mbed_official 324:406fd2029f23 339 * is set by calling the "ADC_HAL_SetLongSampleCycleMode()" function.
mbed_official 146:f64d43ff0c18 340 *
mbed_official 324:406fd2029f23 341 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 342 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 343 */
mbed_official 324:406fd2029f23 344 static inline void ADC_HAL_SetLongSampleCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 345 {
mbed_official 324:406fd2029f23 346 BW_ADC_CFG1_ADLSMP(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 347 }
mbed_official 146:f64d43ff0c18 348
mbed_official 146:f64d43ff0c18 349 /*!
mbed_official 324:406fd2029f23 350 * @brief Selects the conversion resolution mode for ADC module.
mbed_official 324:406fd2029f23 351 *
mbed_official 324:406fd2029f23 352 * This function selects the conversion resolution mode for the ADC module.
mbed_official 146:f64d43ff0c18 353 *
mbed_official 324:406fd2029f23 354 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 355 * @param mode Selection of mode enumeration. See to "adc_resolution_mode_t".
mbed_official 146:f64d43ff0c18 356 */
mbed_official 324:406fd2029f23 357 static inline void ADC_HAL_SetResolutionMode(uint32_t baseAddr, adc_resolution_mode_t mode)
mbed_official 146:f64d43ff0c18 358 {
mbed_official 324:406fd2029f23 359 BW_ADC_CFG1_MODE(baseAddr, (uint32_t)mode );
mbed_official 324:406fd2029f23 360 }
mbed_official 324:406fd2029f23 361
mbed_official 324:406fd2029f23 362 /*!
mbed_official 324:406fd2029f23 363 * @brief Gets the conversion resolution mode for ADC module.
mbed_official 324:406fd2029f23 364 *
mbed_official 324:406fd2029f23 365 * This function gets the conversion resolution mode for the ADC module.
mbed_official 324:406fd2029f23 366 * It is specially used when processing the conversion result of RAW format.
mbed_official 324:406fd2029f23 367 *
mbed_official 324:406fd2029f23 368 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 369 * @return Current conversion resolution mode.
mbed_official 324:406fd2029f23 370 */
mbed_official 324:406fd2029f23 371 static inline adc_resolution_mode_t ADC_HAL_GetResolutionMode(uint32_t baseAddr)
mbed_official 324:406fd2029f23 372 {
mbed_official 324:406fd2029f23 373 return (adc_resolution_mode_t)( BR_ADC_CFG1_MODE(baseAddr) );
mbed_official 146:f64d43ff0c18 374 }
mbed_official 146:f64d43ff0c18 375
mbed_official 146:f64d43ff0c18 376 /*!
mbed_official 324:406fd2029f23 377 * @brief Selects the input clock source for the ADC module.
mbed_official 146:f64d43ff0c18 378 *
mbed_official 324:406fd2029f23 379 * This function selects the input clock source for the ADC module.
mbed_official 146:f64d43ff0c18 380 *
mbed_official 324:406fd2029f23 381 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 382 * @param mode Selection of mode enumeration. See to "adc_clk_src_mode_t".
mbed_official 146:f64d43ff0c18 383 */
mbed_official 324:406fd2029f23 384 static inline void ADC_HAL_SetClkSrcMode(uint32_t baseAddr, adc_clk_src_mode_t mode)
mbed_official 146:f64d43ff0c18 385 {
mbed_official 324:406fd2029f23 386 BW_ADC_CFG1_ADICLK(baseAddr, (uint32_t)mode );
mbed_official 146:f64d43ff0c18 387 }
mbed_official 146:f64d43ff0c18 388
mbed_official 324:406fd2029f23 389 #if FSL_FEATURE_ADC_HAS_MUX_SELECT
mbed_official 324:406fd2029f23 390
mbed_official 146:f64d43ff0c18 391 /*!
mbed_official 324:406fd2029f23 392 * @brief Selects the channel mux mode for the ADC module.
mbed_official 324:406fd2029f23 393 *
mbed_official 324:406fd2029f23 394 * This function selects the channel mux mode for the ADC module.
mbed_official 146:f64d43ff0c18 395 *
mbed_official 324:406fd2029f23 396 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 397 * @param mode Selection of mode enumeration. See to "adc_chn_mux_mode_t".
mbed_official 146:f64d43ff0c18 398 */
mbed_official 324:406fd2029f23 399 static inline void ADC_HAL_SetChnMuxMode(uint32_t baseAddr, adc_chn_mux_mode_t mode)
mbed_official 146:f64d43ff0c18 400 {
mbed_official 324:406fd2029f23 401 BW_ADC_CFG2_MUXSEL(baseAddr, ((kAdcChnMuxOfA == mode) ? 0U : 1U) );
mbed_official 146:f64d43ff0c18 402 }
mbed_official 146:f64d43ff0c18 403
mbed_official 146:f64d43ff0c18 404 /*!
mbed_official 324:406fd2029f23 405 * @brief Gets the current channel mux mode for the ADC module.
mbed_official 146:f64d43ff0c18 406 *
mbed_official 324:406fd2029f23 407 * This function selects the channel mux mode for the ADC module.
mbed_official 146:f64d43ff0c18 408 *
mbed_official 324:406fd2029f23 409 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 410 * @return Selection of mode enumeration. See to "adc_chn_mux_mode_t".
mbed_official 146:f64d43ff0c18 411 */
mbed_official 324:406fd2029f23 412 static inline adc_chn_mux_mode_t ADC_HAL_GetChnMuxMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 413 {
mbed_official 324:406fd2029f23 414 return (adc_chn_mux_mode_t)(BR_ADC_CFG2_MUXSEL(baseAddr) );
mbed_official 324:406fd2029f23 415 }
mbed_official 324:406fd2029f23 416
mbed_official 324:406fd2029f23 417 #endif /* FSL_FEATURE_ADC_HAS_MUX_SELECT */
mbed_official 324:406fd2029f23 418
mbed_official 324:406fd2029f23 419 /*!
mbed_official 324:406fd2029f23 420 * @brief Switches to enable the asynchronous clock for the ADC module.
mbed_official 324:406fd2029f23 421 *
mbed_official 324:406fd2029f23 422 * This function switches to enable the asynchronous clock for the ADC module.
mbed_official 324:406fd2029f23 423 * It enables the ADC's asynchronous clock source and the clock source
mbed_official 324:406fd2029f23 424 * output regardless of the conversion and the input clock select status of the
mbed_official 324:406fd2029f23 425 * ADC. Asserting this function allows the clock to be used even while the ADC
mbed_official 324:406fd2029f23 426 * is idle or operating from a different clock source. Also, latency of
mbed_official 324:406fd2029f23 427 * initiating a single or first-continuous conversion with the asynchronous
mbed_official 324:406fd2029f23 428 * clock selected is reduced since the ADC internal clock has been already
mbed_official 324:406fd2029f23 429 * operational.
mbed_official 324:406fd2029f23 430 *
mbed_official 324:406fd2029f23 431 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 432 * @param enable Switcher to asserted the feature.
mbed_official 324:406fd2029f23 433 */
mbed_official 324:406fd2029f23 434 static inline void ADC_HAL_SetAsyncClkCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 435 {
mbed_official 324:406fd2029f23 436 BW_ADC_CFG2_ADACKEN(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 437 }
mbed_official 146:f64d43ff0c18 438
mbed_official 146:f64d43ff0c18 439 /*!
mbed_official 324:406fd2029f23 440 * @brief Switches to enable the high speed mode for the ADC module.
mbed_official 324:406fd2029f23 441 *
mbed_official 324:406fd2029f23 442 * This function switches to enable the high speed mode for the ADC module.
mbed_official 146:f64d43ff0c18 443 *
mbed_official 324:406fd2029f23 444 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 445 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 446 */
mbed_official 324:406fd2029f23 447 static inline void ADC_HAL_SetHighSpeedCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 448 {
mbed_official 324:406fd2029f23 449 BW_ADC_CFG2_ADHSC(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 450 }
mbed_official 146:f64d43ff0c18 451
mbed_official 146:f64d43ff0c18 452 /*!
mbed_official 324:406fd2029f23 453 * @brief Selects the long sample cycle mode for the ADC module.
mbed_official 324:406fd2029f23 454 *
mbed_official 324:406fd2029f23 455 * This function selects the long sample cycle mode for the ADC module.
mbed_official 324:406fd2029f23 456 * This function should be called along with "ADC_HAL_SetLongSampleCmd()".
mbed_official 146:f64d43ff0c18 457 *
mbed_official 324:406fd2029f23 458 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 459 * @param mode Selection of long sample cycle mode. See the "adc_long_sample_cycle_mode_t".
mbed_official 146:f64d43ff0c18 460 */
mbed_official 324:406fd2029f23 461 static inline void ADC_HAL_SetLongSampleCycleMode(uint32_t baseAddr,
mbed_official 324:406fd2029f23 462 adc_long_sample_cycle_mode_t mode)
mbed_official 146:f64d43ff0c18 463 {
mbed_official 324:406fd2029f23 464 BW_ADC_CFG2_ADLSTS(baseAddr, (uint32_t)mode );
mbed_official 146:f64d43ff0c18 465 }
mbed_official 146:f64d43ff0c18 466
mbed_official 146:f64d43ff0c18 467 /*!
mbed_official 324:406fd2029f23 468 * @brief Gets the raw result data of channel conversion for the ADC module.
mbed_official 324:406fd2029f23 469 *
mbed_official 324:406fd2029f23 470 * This function gets the result data of conversion for the ADC module.
mbed_official 324:406fd2029f23 471 * The return value is raw data that is not processed. The unavailable bits would be
mbed_official 324:406fd2029f23 472 * filled with "0" in single-ended mode and sign bit in differential mode.
mbed_official 146:f64d43ff0c18 473 *
mbed_official 324:406fd2029f23 474 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 475 * @param chnGroup Channel configuration group ID.
mbed_official 324:406fd2029f23 476 * @return Conversion value of RAW.
mbed_official 146:f64d43ff0c18 477 */
mbed_official 324:406fd2029f23 478 static inline uint16_t ADC_HAL_GetChnConvValueRAW(uint32_t baseAddr,
mbed_official 324:406fd2029f23 479 uint32_t chnGroup )
mbed_official 146:f64d43ff0c18 480 {
mbed_official 324:406fd2029f23 481 assert(chnGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
mbed_official 324:406fd2029f23 482 return (uint16_t)(BR_ADC_Rn_D(baseAddr, chnGroup) );
mbed_official 146:f64d43ff0c18 483 }
mbed_official 146:f64d43ff0c18 484
mbed_official 146:f64d43ff0c18 485 /*!
mbed_official 324:406fd2029f23 486 * @brief Sets the compare value of the lower limitation for the ADC module.
mbed_official 324:406fd2029f23 487 *
mbed_official 324:406fd2029f23 488 * This function sets the compare value of the lower limitation for the ADC module.
mbed_official 146:f64d43ff0c18 489 *
mbed_official 324:406fd2029f23 490 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 491 * @param value Setting value.
mbed_official 146:f64d43ff0c18 492 */
mbed_official 324:406fd2029f23 493 static inline void ADC_HAL_SetHwCmpValue1(uint32_t baseAddr, uint16_t value)
mbed_official 146:f64d43ff0c18 494 {
mbed_official 324:406fd2029f23 495 BW_ADC_CV1_CV(baseAddr,value);
mbed_official 324:406fd2029f23 496 }
mbed_official 324:406fd2029f23 497
mbed_official 324:406fd2029f23 498 /*!
mbed_official 324:406fd2029f23 499 * @brief Sets the compare value of the higher limitation for the ADC module.
mbed_official 324:406fd2029f23 500 *
mbed_official 324:406fd2029f23 501 * This function sets the compare value of the higher limitation for the ADC module.
mbed_official 324:406fd2029f23 502 *
mbed_official 324:406fd2029f23 503 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 504 * @param value Setting value.
mbed_official 324:406fd2029f23 505 */
mbed_official 324:406fd2029f23 506 static inline void ADC_HAL_SetHwCmpValue2(uint32_t baseAddr, uint16_t value)
mbed_official 324:406fd2029f23 507 {
mbed_official 324:406fd2029f23 508 BW_ADC_CV2_CV(baseAddr,value);
mbed_official 146:f64d43ff0c18 509 }
mbed_official 146:f64d43ff0c18 510
mbed_official 146:f64d43ff0c18 511 /*!
mbed_official 324:406fd2029f23 512 * @brief Checks whether the converter is active for the ADC module.
mbed_official 324:406fd2029f23 513 *
mbed_official 324:406fd2029f23 514 * This function checks whether the converter is active for the ADC
mbed_official 324:406fd2029f23 515 * module. If it is dis-asserted when the conversion is completed, one of the
mbed_official 324:406fd2029f23 516 * completed flag is asserted for the indicated group mux. See the
mbed_official 324:406fd2029f23 517 * "ADC_HAL_GetChnConvCompletedCmd()".
mbed_official 146:f64d43ff0c18 518 *
mbed_official 324:406fd2029f23 519 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 520 * @return Assertion of that the converter is active.
mbed_official 146:f64d43ff0c18 521 */
mbed_official 324:406fd2029f23 522 static inline bool ADC_HAL_GetConvActiveCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 523 {
mbed_official 324:406fd2029f23 524 return (1U == BR_ADC_SC2_ADACT(baseAddr) );
mbed_official 146:f64d43ff0c18 525 }
mbed_official 146:f64d43ff0c18 526
mbed_official 146:f64d43ff0c18 527 /*!
mbed_official 324:406fd2029f23 528 * @brief Switches to enable the hardware trigger mode for the ADC module.
mbed_official 324:406fd2029f23 529 *
mbed_official 324:406fd2029f23 530 * This function switches to enable the hardware trigger mode for the ADC
mbed_official 324:406fd2029f23 531 * module.
mbed_official 146:f64d43ff0c18 532 *
mbed_official 324:406fd2029f23 533 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 534 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 535 */
mbed_official 324:406fd2029f23 536 static inline void ADC_HAL_SetHwTriggerCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 537 {
mbed_official 324:406fd2029f23 538 BW_ADC_SC2_ADTRG(baseAddr,(enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 539 }
mbed_official 146:f64d43ff0c18 540
mbed_official 146:f64d43ff0c18 541 /*!
mbed_official 324:406fd2029f23 542 * @brief Switches to enable the hardware comparator for the ADC module.
mbed_official 324:406fd2029f23 543 *
mbed_official 324:406fd2029f23 544 * This function switches to enable the hardware comparator for the ADC module.
mbed_official 146:f64d43ff0c18 545 *
mbed_official 324:406fd2029f23 546 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 547 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 548 */
mbed_official 324:406fd2029f23 549 static inline void ADC_HAL_SetHwCmpCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 550 {
mbed_official 324:406fd2029f23 551 BW_ADC_SC2_ACFE(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 552 }
mbed_official 146:f64d43ff0c18 553
mbed_official 146:f64d43ff0c18 554 /*!
mbed_official 324:406fd2029f23 555 * @brief Switches to enable the setting that is greater than the hardware comparator.
mbed_official 324:406fd2029f23 556 *
mbed_official 324:406fd2029f23 557 * This function switches to enable the setting that is greater than the
mbed_official 324:406fd2029f23 558 * hardware comparator.
mbed_official 146:f64d43ff0c18 559 *
mbed_official 324:406fd2029f23 560 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 561 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 562 */
mbed_official 324:406fd2029f23 563 static inline void ADC_HAL_SetHwCmpGreaterCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 564 {
mbed_official 324:406fd2029f23 565 BW_ADC_SC2_ACFGT(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 566 }
mbed_official 146:f64d43ff0c18 567
mbed_official 146:f64d43ff0c18 568 /*!
mbed_official 324:406fd2029f23 569 * @brief Switches to enable the setting of the range for hardware comparator.
mbed_official 324:406fd2029f23 570 *
mbed_official 324:406fd2029f23 571 * This function switches to enable the setting of range for the hardware
mbed_official 324:406fd2029f23 572 * comparator.
mbed_official 146:f64d43ff0c18 573 *
mbed_official 324:406fd2029f23 574 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 575 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 576 */
mbed_official 324:406fd2029f23 577 static inline void ADC_HAL_SetHwCmpRangeCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 578 {
mbed_official 324:406fd2029f23 579 BW_ADC_SC2_ACREN(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 580 }
mbed_official 146:f64d43ff0c18 581
mbed_official 146:f64d43ff0c18 582 /*!
mbed_official 324:406fd2029f23 583 * @brief Configures the asserted range of the hardware comparator for the ADC module.
mbed_official 146:f64d43ff0c18 584 *
mbed_official 324:406fd2029f23 585 * This function configures the asserted range of the hardware comparator for the
mbed_official 324:406fd2029f23 586 * ADC module.
mbed_official 146:f64d43ff0c18 587 *
mbed_official 324:406fd2029f23 588 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 589 * @param mode Selection of range mode, see to "adc_hw_cmp_range_mode_t".
mbed_official 146:f64d43ff0c18 590 */
mbed_official 324:406fd2029f23 591 void ADC_HAL_SetHwCmpMode(uint32_t baseAddr, adc_hw_cmp_range_mode_t mode);
mbed_official 324:406fd2029f23 592
mbed_official 324:406fd2029f23 593 #if FSL_FEATURE_ADC_HAS_DMA
mbed_official 146:f64d43ff0c18 594
mbed_official 146:f64d43ff0c18 595 /*!
mbed_official 324:406fd2029f23 596 * @brief Switches to enable the DMA for the ADC module.
mbed_official 146:f64d43ff0c18 597 *
mbed_official 324:406fd2029f23 598 * This function switches to enable the DMA for the ADC module. When enabled, the
mbed_official 324:406fd2029f23 599 * DMA request is asserted during the ADC conversion complete event, which is noted
mbed_official 324:406fd2029f23 600 * by the assertion of any of the ADC channel completed flags.
mbed_official 146:f64d43ff0c18 601 *
mbed_official 324:406fd2029f23 602 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 603 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 604 */
mbed_official 324:406fd2029f23 605 static inline void ADC_HAL_SetDmaCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 606 {
mbed_official 324:406fd2029f23 607 BW_ADC_SC2_DMAEN(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 608 }
mbed_official 146:f64d43ff0c18 609
mbed_official 324:406fd2029f23 610 #endif /* FSL_FEATURE_ADC_HAS_DMA */
mbed_official 324:406fd2029f23 611
mbed_official 146:f64d43ff0c18 612 /*!
mbed_official 324:406fd2029f23 613 * @brief Selects the reference voltage source for the ADC module.
mbed_official 324:406fd2029f23 614 *
mbed_official 324:406fd2029f23 615 * This function selects the reference voltage source for the ADC module.
mbed_official 146:f64d43ff0c18 616 *
mbed_official 324:406fd2029f23 617 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 618 * @param mode Selection of asserted the feature.
mbed_official 146:f64d43ff0c18 619 */
mbed_official 324:406fd2029f23 620 static inline void ADC_HAL_SetRefVoltSrcMode(uint32_t baseAddr, adc_ref_volt_src_mode_t mode)
mbed_official 146:f64d43ff0c18 621 {
mbed_official 324:406fd2029f23 622 BW_ADC_SC2_REFSEL(baseAddr, (uint32_t)mode );
mbed_official 324:406fd2029f23 623 }
mbed_official 324:406fd2029f23 624
mbed_official 324:406fd2029f23 625 #if FSL_FEATURE_ADC_HAS_CALIBRATION
mbed_official 324:406fd2029f23 626
mbed_official 324:406fd2029f23 627 /*!
mbed_official 324:406fd2029f23 628 * @brief Switches to enable the hardware calibration for the ADC module.
mbed_official 324:406fd2029f23 629 *
mbed_official 324:406fd2029f23 630 * This function launches the hardware calibration for the ADC module.
mbed_official 324:406fd2029f23 631 *
mbed_official 324:406fd2029f23 632 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 633 * @param enable Switcher to asserted the feature.
mbed_official 324:406fd2029f23 634 */
mbed_official 324:406fd2029f23 635 static inline void ADC_HAL_SetAutoCalibrationCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 636 {
mbed_official 324:406fd2029f23 637 BW_ADC_SC3_CAL(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 638 }
mbed_official 146:f64d43ff0c18 639
mbed_official 146:f64d43ff0c18 640 /*!
mbed_official 324:406fd2029f23 641 * @brief Gets the hardware calibration status for the ADC module.
mbed_official 146:f64d43ff0c18 642 *
mbed_official 324:406fd2029f23 643 * This function gets the status whether the hardware calibration is active
mbed_official 324:406fd2029f23 644 * for the ADC module. The return value holds on as asserted during the hardware
mbed_official 324:406fd2029f23 645 * calibration. Then, it is cleared and dis-asserted after the
mbed_official 324:406fd2029f23 646 * calibration.
mbed_official 324:406fd2029f23 647 *
mbed_official 324:406fd2029f23 648 * @param baseAddr Register base address for the module.
mbed_official 146:f64d43ff0c18 649 */
mbed_official 324:406fd2029f23 650 static inline bool ADC_HAL_GetAutoCalibrationActiveCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 651 {
mbed_official 324:406fd2029f23 652 return (1U == BR_ADC_SC3_CAL(baseAddr) );
mbed_official 146:f64d43ff0c18 653 }
mbed_official 146:f64d43ff0c18 654
mbed_official 146:f64d43ff0c18 655 /*!
mbed_official 324:406fd2029f23 656 * @brief Gets the hardware calibration status for the ADC module.
mbed_official 146:f64d43ff0c18 657 *
mbed_official 324:406fd2029f23 658 * This function gets the status whether the hardware calibration has failed
mbed_official 324:406fd2029f23 659 * for the ADC module. The return value is asserted if there is anything wrong
mbed_official 324:406fd2029f23 660 * with the hardware calibration.
mbed_official 324:406fd2029f23 661 *
mbed_official 324:406fd2029f23 662 * @param baseAddr Register base address for the module.
mbed_official 146:f64d43ff0c18 663 */
mbed_official 324:406fd2029f23 664 static inline bool ADC_HAL_GetAutoCalibrationFailedCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 665 {
mbed_official 324:406fd2029f23 666 return (1U == BR_ADC_SC3_CALF(baseAddr) );
mbed_official 146:f64d43ff0c18 667 }
mbed_official 146:f64d43ff0c18 668
mbed_official 146:f64d43ff0c18 669 /*!
mbed_official 324:406fd2029f23 670 * @brief Gets and calculates the plus side calibration parameter from the auto calibration.
mbed_official 324:406fd2029f23 671 *
mbed_official 324:406fd2029f23 672 * This function gets the values of CLP0 - CLP4 and CLPS internally,
mbed_official 324:406fd2029f23 673 * accumulates them, and returns the value that can be used to be set in the PG
mbed_official 324:406fd2029f23 674 * register directly. Note that this API should be called after the process of
mbed_official 324:406fd2029f23 675 * auto calibration is complete.
mbed_official 146:f64d43ff0c18 676 *
mbed_official 324:406fd2029f23 677 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 678 * @return value that can be set into PG directly.
mbed_official 146:f64d43ff0c18 679 */
mbed_official 324:406fd2029f23 680 uint16_t ADC_HAL_GetAutoPlusSideGainValue(uint32_t baseAddr);
mbed_official 324:406fd2029f23 681
mbed_official 324:406fd2029f23 682 /*!
mbed_official 324:406fd2029f23 683 * @brief Sets the plus side gain calibration value for the ADC module.
mbed_official 324:406fd2029f23 684 *
mbed_official 324:406fd2029f23 685 * This function sets the plus side gain calibration value for the ADC module.
mbed_official 324:406fd2029f23 686 *
mbed_official 324:406fd2029f23 687 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 688 * @param value Setting value for plus side gain.
mbed_official 324:406fd2029f23 689 */
mbed_official 324:406fd2029f23 690 static inline void ADC_HAL_SetPlusSideGainValue(uint32_t baseAddr, uint16_t value)
mbed_official 146:f64d43ff0c18 691 {
mbed_official 324:406fd2029f23 692 BW_ADC_PG_PG(baseAddr, value);
mbed_official 146:f64d43ff0c18 693 }
mbed_official 146:f64d43ff0c18 694
mbed_official 324:406fd2029f23 695 #if FSL_FEATURE_ADC_HAS_DIFF_MODE
mbed_official 324:406fd2029f23 696
mbed_official 146:f64d43ff0c18 697 /*!
mbed_official 324:406fd2029f23 698 * @brief Gets and calculates the minus side calibration parameter from the auto calibration.
mbed_official 146:f64d43ff0c18 699 *
mbed_official 324:406fd2029f23 700 * This function gets the values of CLM0 - CLM4 and CLMS internally,
mbed_official 324:406fd2029f23 701 * accumulates them, and returns the value that can be used to be set in the MG
mbed_official 324:406fd2029f23 702 * register directly. Note that this API should be called after the process of
mbed_official 324:406fd2029f23 703 * auto calibration is complete.
mbed_official 324:406fd2029f23 704 *
mbed_official 324:406fd2029f23 705 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 706 * @return value that can be set into MG directly.
mbed_official 146:f64d43ff0c18 707 */
mbed_official 324:406fd2029f23 708 uint16_t ADC_HAL_GetAutoMinusSideGainValue(uint32_t baseAddr);
mbed_official 146:f64d43ff0c18 709
mbed_official 146:f64d43ff0c18 710 /*!
mbed_official 324:406fd2029f23 711 * @brief Sets the minus side gain calibration value for the ADC module.
mbed_official 324:406fd2029f23 712 *
mbed_official 324:406fd2029f23 713 * This function sets the minus side gain calibration value for the ADC module.
mbed_official 146:f64d43ff0c18 714 *
mbed_official 324:406fd2029f23 715 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 716 * @param value Setting value for minus side gain.
mbed_official 146:f64d43ff0c18 717 */
mbed_official 324:406fd2029f23 718 static inline void ADC_HAL_SetMinusSideGainValue(uint32_t baseAddr, uint16_t value)
mbed_official 146:f64d43ff0c18 719 {
mbed_official 324:406fd2029f23 720 BW_ADC_MG_MG(baseAddr, value);
mbed_official 146:f64d43ff0c18 721 }
mbed_official 146:f64d43ff0c18 722
mbed_official 324:406fd2029f23 723 #endif /* FSL_FEATURE_ADC_HAS_DIFF_MODE */
mbed_official 324:406fd2029f23 724
mbed_official 324:406fd2029f23 725 #endif /* FSL_FEATURE_ADC_HAS_CALIBRATION */
mbed_official 324:406fd2029f23 726
mbed_official 324:406fd2029f23 727 #if FSL_FEATURE_ADC_HAS_OFFSET_CORRECTION
mbed_official 324:406fd2029f23 728
mbed_official 146:f64d43ff0c18 729 /*!
mbed_official 324:406fd2029f23 730 * @brief Gets the offset correction value for the ADC module.
mbed_official 324:406fd2029f23 731 *
mbed_official 324:406fd2029f23 732 * This function gets the offset correction value for the ADC module.
mbed_official 324:406fd2029f23 733 * When auto calibration is executed, the OFS register holds the new value
mbed_official 324:406fd2029f23 734 * generated by the calibration. It can be left as default or modified
mbed_official 324:406fd2029f23 735 * according to the use case.
mbed_official 146:f64d43ff0c18 736 *
mbed_official 324:406fd2029f23 737 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 738 * @return current value for OFS.
mbed_official 146:f64d43ff0c18 739 */
mbed_official 324:406fd2029f23 740 static inline uint16_t ADC_HAL_GetOffsetValue(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 741 {
mbed_official 324:406fd2029f23 742 return (uint16_t)(BR_ADC_OFS_OFS(baseAddr) );
mbed_official 146:f64d43ff0c18 743 }
mbed_official 146:f64d43ff0c18 744
mbed_official 146:f64d43ff0c18 745 /*!
mbed_official 324:406fd2029f23 746 * @brief Sets the offset correction value for the ADC module.
mbed_official 146:f64d43ff0c18 747 *
mbed_official 324:406fd2029f23 748 * This function sets the offset correction value for the ADC module. The ADC
mbed_official 324:406fd2029f23 749 * offset correction register (OFS) contains the user-selected or calibration-generated
mbed_official 324:406fd2029f23 750 * offset error correction value. The value in the offset correction
mbed_official 324:406fd2029f23 751 * registers (OFS) is subtracted from the conversion and the result is
mbed_official 324:406fd2029f23 752 * transferred into the result registers (Rn). If the result is above the
mbed_official 324:406fd2029f23 753 * maximum or below the minimum result value, it is forced to the appropriate
mbed_official 324:406fd2029f23 754 * limit for the current mode of operation.
mbed_official 324:406fd2029f23 755 *
mbed_official 324:406fd2029f23 756 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 757 * @param value Setting value for OFS.
mbed_official 146:f64d43ff0c18 758 */
mbed_official 324:406fd2029f23 759 static inline void ADC_HAL_SetOffsetValue(uint32_t baseAddr, uint16_t value)
mbed_official 146:f64d43ff0c18 760 {
mbed_official 324:406fd2029f23 761 BW_ADC_OFS_OFS(baseAddr, value);
mbed_official 146:f64d43ff0c18 762 }
mbed_official 146:f64d43ff0c18 763
mbed_official 324:406fd2029f23 764 #endif /* FSL_FEATURE_ADC_HAS_OFFSET_CORRECTION */
mbed_official 324:406fd2029f23 765
mbed_official 146:f64d43ff0c18 766 /*!
mbed_official 324:406fd2029f23 767 * @brief Switches to enable the continuous conversion mode for the ADC module.
mbed_official 146:f64d43ff0c18 768 *
mbed_official 324:406fd2029f23 769 * This function switches to enable the continuous conversion mode for the ADC
mbed_official 324:406fd2029f23 770 * module. Once enabled, continuous conversions, or sets of conversions if the
mbed_official 324:406fd2029f23 771 * hardware average function, is enabled after initiating a conversion.
mbed_official 324:406fd2029f23 772 *
mbed_official 324:406fd2029f23 773 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 774 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 775 */
mbed_official 324:406fd2029f23 776 static inline void ADC_HAL_SetContinuousConvCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 777 {
mbed_official 324:406fd2029f23 778 BW_ADC_SC3_ADCO(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 779 }
mbed_official 146:f64d43ff0c18 780
mbed_official 324:406fd2029f23 781 #if FSL_FEATURE_ADC_HAS_HW_AVERAGE
mbed_official 324:406fd2029f23 782
mbed_official 146:f64d43ff0c18 783 /*!
mbed_official 324:406fd2029f23 784 * @brief Switches to enable the hardware average for the ADC module.
mbed_official 146:f64d43ff0c18 785 *
mbed_official 324:406fd2029f23 786 * This function switches to enable the hardware average for the ADC module.
mbed_official 324:406fd2029f23 787 * Once enabled, the conversion does not stop before the average
mbed_official 324:406fd2029f23 788 * count has been reached.
mbed_official 324:406fd2029f23 789 *
mbed_official 324:406fd2029f23 790 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 791 * @param enable Switcher to asserted the feature.
mbed_official 146:f64d43ff0c18 792 */
mbed_official 324:406fd2029f23 793 static inline void ADC_HAL_SetHwAverageCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 794 {
mbed_official 324:406fd2029f23 795 BW_ADC_SC3_AVGE(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 796 }
mbed_official 146:f64d43ff0c18 797
mbed_official 146:f64d43ff0c18 798 /*!
mbed_official 324:406fd2029f23 799 * @brief Selects the hardware average mode for the ADC module.
mbed_official 324:406fd2029f23 800 *
mbed_official 324:406fd2029f23 801 * This function switches to select the hardware average mode for the ADC
mbed_official 324:406fd2029f23 802 * module.
mbed_official 146:f64d43ff0c18 803 *
mbed_official 324:406fd2029f23 804 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 805 * @param mode Selection of hardware average count mode, see to "adc_hw_average_count_mode_t".
mbed_official 146:f64d43ff0c18 806 */
mbed_official 324:406fd2029f23 807 static inline void ADC_HAL_SetHwAverageMode(uint32_t baseAddr, adc_hw_average_count_mode_t mode)
mbed_official 146:f64d43ff0c18 808 {
mbed_official 324:406fd2029f23 809 BW_ADC_SC3_AVGS(baseAddr, (uint32_t)mode );
mbed_official 324:406fd2029f23 810 }
mbed_official 324:406fd2029f23 811
mbed_official 324:406fd2029f23 812 #endif /* FSL_FEATURE_ADC_HAS_HW_AVERAGE */
mbed_official 324:406fd2029f23 813
mbed_official 324:406fd2029f23 814 #if FSL_FEATURE_ADC_HAS_PGA
mbed_official 324:406fd2029f23 815
mbed_official 324:406fd2029f23 816 /*!
mbed_official 324:406fd2029f23 817 * @brief Switches to enable the Programmable Gain Amplifier for ADC module.
mbed_official 324:406fd2029f23 818 *
mbed_official 324:406fd2029f23 819 * This function enables the PGA for the ADC module. The Programmable Gain
mbed_official 324:406fd2029f23 820 * Amplifier (PGA) is designed to increase the dynamic range by amplifying the
mbed_official 324:406fd2029f23 821 * low-amplitude signals before they are fed to the 16 bit SAR ADC.
mbed_official 324:406fd2029f23 822 *
mbed_official 324:406fd2029f23 823 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 824 * @param enable Switcher to asserted feature.
mbed_official 324:406fd2029f23 825 */
mbed_official 324:406fd2029f23 826 static inline void ADC_HAL_SetPgaCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 827 {
mbed_official 324:406fd2029f23 828 BW_ADC_PGA_PGAEN(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 829 }
mbed_official 146:f64d43ff0c18 830
mbed_official 146:f64d43ff0c18 831 /*!
mbed_official 324:406fd2029f23 832 * @brief Switches to enable the PGA chopping mode for the ADC module.
mbed_official 324:406fd2029f23 833 *
mbed_official 324:406fd2029f23 834 * This function switches to enable the PGA chopping mode for the ADC module.
mbed_official 324:406fd2029f23 835 * The PGA employs chopping to remove/reduce offset and 1/f noise and offers an
mbed_official 324:406fd2029f23 836 * offset measurement configuration that aids the offset calibration.
mbed_official 146:f64d43ff0c18 837 *
mbed_official 324:406fd2029f23 838 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 839 * @param enable Switcher to asserted feature.
mbed_official 146:f64d43ff0c18 840 */
mbed_official 324:406fd2029f23 841 static inline void ADC_HAL_SetPgaChoppingCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 842 {
mbed_official 324:406fd2029f23 843 BW_ADC_PGA_PGACHPb(baseAddr, (enable ? 0U : 1U) );
mbed_official 324:406fd2029f23 844 }
mbed_official 324:406fd2029f23 845
mbed_official 324:406fd2029f23 846 /*!
mbed_official 324:406fd2029f23 847 * @brief Switches to enable the PGA working in low power mode for the ADC module.
mbed_official 324:406fd2029f23 848 *
mbed_official 324:406fd2029f23 849 * This function switches to enable the PGA working in low power mode for
mbed_official 324:406fd2029f23 850 * ADC module.
mbed_official 324:406fd2029f23 851 *
mbed_official 324:406fd2029f23 852 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 853 * @param enable Switcher to asserted feature.
mbed_official 324:406fd2029f23 854 */
mbed_official 324:406fd2029f23 855 static inline void ADC_HAL_SetPgaLowPowerCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 856 {
mbed_official 324:406fd2029f23 857 BW_ADC_PGA_PGALPb(baseAddr, (enable ? 0U : 1U) );
mbed_official 146:f64d43ff0c18 858 }
mbed_official 146:f64d43ff0c18 859
mbed_official 146:f64d43ff0c18 860 /*!
mbed_official 324:406fd2029f23 861 * @brief Selects the amplifier mode for the PGA.
mbed_official 324:406fd2029f23 862 *
mbed_official 324:406fd2029f23 863 * This function selects the amplifier mode for the PGA.
mbed_official 146:f64d43ff0c18 864 *
mbed_official 324:406fd2029f23 865 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 866 * @param mode Selection of asserted feature. See to "adc_pga_gain_mode_t".
mbed_official 146:f64d43ff0c18 867 */
mbed_official 324:406fd2029f23 868 static inline void ADC_HAL_SetPgaGainMode(uint32_t baseAddr, adc_pga_gain_mode_t mode)
mbed_official 146:f64d43ff0c18 869 {
mbed_official 324:406fd2029f23 870 BW_ADC_PGA_PGAG(baseAddr, (uint32_t)mode );
mbed_official 146:f64d43ff0c18 871 }
mbed_official 146:f64d43ff0c18 872
mbed_official 146:f64d43ff0c18 873 /*!
mbed_official 324:406fd2029f23 874 * @brief Switches to enable the offset measurement mode for the ADC module.
mbed_official 146:f64d43ff0c18 875 *
mbed_official 324:406fd2029f23 876 * This function switches to enable the offset measurement mode for the ADC
mbed_official 324:406fd2029f23 877 * module. When asserted, the PGA disconnects from the external inputs and
mbed_official 324:406fd2029f23 878 * auto-configures into offset measurement mode. With this function asserted,
mbed_official 324:406fd2029f23 879 * run the ADC in recommended settings and enable maximum hardware averaging
mbed_official 324:406fd2029f23 880 * to get the PGA offset number. The output is the (PGA offset * (64+1))
mbed_official 324:406fd2029f23 881 * for a given setting.
mbed_official 324:406fd2029f23 882 *
mbed_official 324:406fd2029f23 883 * @param baseAddr Register base address for the module.
mbed_official 324:406fd2029f23 884 * @param enable Switcher to asserted feature.
mbed_official 146:f64d43ff0c18 885 */
mbed_official 324:406fd2029f23 886 static inline void ADC_HAL_SetPgaOffsetMeasurementCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 887 {
mbed_official 324:406fd2029f23 888 BW_ADC_PGA_PGAOFSM(baseAddr, (enable ? 1U : 0U) );
mbed_official 146:f64d43ff0c18 889 }
mbed_official 146:f64d43ff0c18 890
mbed_official 146:f64d43ff0c18 891 #endif /* FSL_FEATURE_ADC_HAS_PGA */
mbed_official 146:f64d43ff0c18 892
mbed_official 146:f64d43ff0c18 893 #if defined(__cplusplus)
mbed_official 324:406fd2029f23 894 extern }
mbed_official 146:f64d43ff0c18 895 #endif
mbed_official 146:f64d43ff0c18 896
mbed_official 324:406fd2029f23 897 /*!
mbed_official 324:406fd2029f23 898 * @}
mbed_official 324:406fd2029f23 899 */
mbed_official 146:f64d43ff0c18 900
mbed_official 146:f64d43ff0c18 901 #endif /* __FSL_ADC_HAL_H__ */
mbed_official 324:406fd2029f23 902
mbed_official 324:406fd2029f23 903 /******************************************************************************
mbed_official 324:406fd2029f23 904 * EOF
mbed_official 324:406fd2029f23 905 *****************************************************************************/
mbed_official 324:406fd2029f23 906