Kevin Kadooka / mbed-dev

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Wed Jan 04 16:58:05 2017 +0000
Revision:
154:37f96f9d4de2
This updates the lib to the mbed lib v133

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 154:37f96f9d4de2 1 /*
<> 154:37f96f9d4de2 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
<> 154:37f96f9d4de2 3 * All rights reserved.
<> 154:37f96f9d4de2 4 *
<> 154:37f96f9d4de2 5 * Redistribution and use in source and binary forms, with or without modification,
<> 154:37f96f9d4de2 6 * are permitted provided that the following conditions are met:
<> 154:37f96f9d4de2 7 *
<> 154:37f96f9d4de2 8 * o Redistributions of source code must retain the above copyright notice, this list
<> 154:37f96f9d4de2 9 * of conditions and the following disclaimer.
<> 154:37f96f9d4de2 10 *
<> 154:37f96f9d4de2 11 * o Redistributions in binary form must reproduce the above copyright notice, this
<> 154:37f96f9d4de2 12 * list of conditions and the following disclaimer in the documentation and/or
<> 154:37f96f9d4de2 13 * other materials provided with the distribution.
<> 154:37f96f9d4de2 14 *
<> 154:37f96f9d4de2 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
<> 154:37f96f9d4de2 16 * contributors may be used to endorse or promote products derived from this
<> 154:37f96f9d4de2 17 * software without specific prior written permission.
<> 154:37f96f9d4de2 18 *
<> 154:37f96f9d4de2 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<> 154:37f96f9d4de2 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
<> 154:37f96f9d4de2 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 154:37f96f9d4de2 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
<> 154:37f96f9d4de2 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
<> 154:37f96f9d4de2 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
<> 154:37f96f9d4de2 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
<> 154:37f96f9d4de2 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<> 154:37f96f9d4de2 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
<> 154:37f96f9d4de2 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 154:37f96f9d4de2 29 */
<> 154:37f96f9d4de2 30
<> 154:37f96f9d4de2 31 #ifndef _FSL_ADC16_H_
<> 154:37f96f9d4de2 32 #define _FSL_ADC16_H_
<> 154:37f96f9d4de2 33
<> 154:37f96f9d4de2 34 #include "fsl_common.h"
<> 154:37f96f9d4de2 35
<> 154:37f96f9d4de2 36 /*!
<> 154:37f96f9d4de2 37 * @addtogroup adc16
<> 154:37f96f9d4de2 38 * @{
<> 154:37f96f9d4de2 39 */
<> 154:37f96f9d4de2 40
<> 154:37f96f9d4de2 41
<> 154:37f96f9d4de2 42 /*******************************************************************************
<> 154:37f96f9d4de2 43 * Definitions
<> 154:37f96f9d4de2 44 ******************************************************************************/
<> 154:37f96f9d4de2 45
<> 154:37f96f9d4de2 46 /*! @name Driver version */
<> 154:37f96f9d4de2 47 /*@{*/
<> 154:37f96f9d4de2 48 /*! @brief ADC16 driver version 2.0.0. */
<> 154:37f96f9d4de2 49 #define FSL_ADC16_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
<> 154:37f96f9d4de2 50 /*@}*/
<> 154:37f96f9d4de2 51
<> 154:37f96f9d4de2 52 /*!
<> 154:37f96f9d4de2 53 * @brief Channel status flags.
<> 154:37f96f9d4de2 54 */
<> 154:37f96f9d4de2 55 enum _adc16_channel_status_flags
<> 154:37f96f9d4de2 56 {
<> 154:37f96f9d4de2 57 kADC16_ChannelConversionDoneFlag = ADC_SC1_COCO_MASK, /*!< Conversion done. */
<> 154:37f96f9d4de2 58 };
<> 154:37f96f9d4de2 59
<> 154:37f96f9d4de2 60 /*!
<> 154:37f96f9d4de2 61 * @brief Converter status flags.
<> 154:37f96f9d4de2 62 */
<> 154:37f96f9d4de2 63 enum _adc16_status_flags
<> 154:37f96f9d4de2 64 {
<> 154:37f96f9d4de2 65 kADC16_ActiveFlag = ADC_SC2_ADACT_MASK, /*!< Converter is active. */
<> 154:37f96f9d4de2 66 #if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
<> 154:37f96f9d4de2 67 kADC16_CalibrationFailedFlag = ADC_SC3_CALF_MASK, /*!< Calibration is failed. */
<> 154:37f96f9d4de2 68 #endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
<> 154:37f96f9d4de2 69 };
<> 154:37f96f9d4de2 70
<> 154:37f96f9d4de2 71 #if defined(FSL_FEATURE_ADC16_HAS_MUX_SELECT) && FSL_FEATURE_ADC16_HAS_MUX_SELECT
<> 154:37f96f9d4de2 72 /*!
<> 154:37f96f9d4de2 73 * @brief Channel multiplexer mode for each channel.
<> 154:37f96f9d4de2 74 *
<> 154:37f96f9d4de2 75 * For some ADC16 channels, there are two pin selections in channel multiplexer. For example, ADC0_SE4a and ADC0_SE4b
<> 154:37f96f9d4de2 76 * are the different channels but share the same channel number.
<> 154:37f96f9d4de2 77 */
<> 154:37f96f9d4de2 78 typedef enum _adc_channel_mux_mode
<> 154:37f96f9d4de2 79 {
<> 154:37f96f9d4de2 80 kADC16_ChannelMuxA = 0U, /*!< For channel with channel mux a. */
<> 154:37f96f9d4de2 81 kADC16_ChannelMuxB = 1U, /*!< For channel with channel mux b. */
<> 154:37f96f9d4de2 82 } adc16_channel_mux_mode_t;
<> 154:37f96f9d4de2 83 #endif /* FSL_FEATURE_ADC16_HAS_MUX_SELECT */
<> 154:37f96f9d4de2 84
<> 154:37f96f9d4de2 85 /*!
<> 154:37f96f9d4de2 86 * @brief Clock divider for the converter.
<> 154:37f96f9d4de2 87 */
<> 154:37f96f9d4de2 88 typedef enum _adc16_clock_divider
<> 154:37f96f9d4de2 89 {
<> 154:37f96f9d4de2 90 kADC16_ClockDivider1 = 0U, /*!< For divider 1 from the input clock to the module. */
<> 154:37f96f9d4de2 91 kADC16_ClockDivider2 = 1U, /*!< For divider 2 from the input clock to the module. */
<> 154:37f96f9d4de2 92 kADC16_ClockDivider4 = 2U, /*!< For divider 4 from the input clock to the module. */
<> 154:37f96f9d4de2 93 kADC16_ClockDivider8 = 3U, /*!< For divider 8 from the input clock to the module. */
<> 154:37f96f9d4de2 94 } adc16_clock_divider_t;
<> 154:37f96f9d4de2 95
<> 154:37f96f9d4de2 96 /*!
<> 154:37f96f9d4de2 97 *@brief Converter's resolution.
<> 154:37f96f9d4de2 98 */
<> 154:37f96f9d4de2 99 typedef enum _adc16_resolution
<> 154:37f96f9d4de2 100 {
<> 154:37f96f9d4de2 101 /* This group of enumeration is for internal use which is related to register setting. */
<> 154:37f96f9d4de2 102 kADC16_Resolution8or9Bit = 0U, /*!< Single End 8-bit or Differential Sample 9-bit. */
<> 154:37f96f9d4de2 103 kADC16_Resolution12or13Bit = 1U, /*!< Single End 12-bit or Differential Sample 13-bit. */
<> 154:37f96f9d4de2 104 kADC16_Resolution10or11Bit = 2U, /*!< Single End 10-bit or Differential Sample 11-bit. */
<> 154:37f96f9d4de2 105
<> 154:37f96f9d4de2 106 /* This group of enumeration is for public user. */
<> 154:37f96f9d4de2 107 kADC16_ResolutionSE8Bit = kADC16_Resolution8or9Bit, /*!< Single End 8-bit. */
<> 154:37f96f9d4de2 108 kADC16_ResolutionSE12Bit = kADC16_Resolution12or13Bit, /*!< Single End 12-bit. */
<> 154:37f96f9d4de2 109 kADC16_ResolutionSE10Bit = kADC16_Resolution10or11Bit, /*!< Single End 10-bit. */
<> 154:37f96f9d4de2 110 #if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
<> 154:37f96f9d4de2 111 kADC16_ResolutionDF9Bit = kADC16_Resolution8or9Bit, /*!< Differential Sample 9-bit. */
<> 154:37f96f9d4de2 112 kADC16_ResolutionDF13Bit = kADC16_Resolution12or13Bit, /*!< Differential Sample 13-bit. */
<> 154:37f96f9d4de2 113 kADC16_ResolutionDF11Bit = kADC16_Resolution10or11Bit, /*!< Differential Sample 11-bit. */
<> 154:37f96f9d4de2 114 #endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
<> 154:37f96f9d4de2 115
<> 154:37f96f9d4de2 116 #if defined(FSL_FEATURE_ADC16_MAX_RESOLUTION) && (FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16U)
<> 154:37f96f9d4de2 117 /* 16-bit is supported by default. */
<> 154:37f96f9d4de2 118 kADC16_Resolution16Bit = 3U, /*!< Single End 16-bit or Differential Sample 16-bit. */
<> 154:37f96f9d4de2 119 kADC16_ResolutionSE16Bit = kADC16_Resolution16Bit, /*!< Single End 16-bit. */
<> 154:37f96f9d4de2 120 #if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
<> 154:37f96f9d4de2 121 kADC16_ResolutionDF16Bit = kADC16_Resolution16Bit, /*!< Differential Sample 16-bit. */
<> 154:37f96f9d4de2 122 #endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
<> 154:37f96f9d4de2 123 #endif /* FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16U */
<> 154:37f96f9d4de2 124 } adc16_resolution_t;
<> 154:37f96f9d4de2 125
<> 154:37f96f9d4de2 126 /*!
<> 154:37f96f9d4de2 127 * @brief Clock source.
<> 154:37f96f9d4de2 128 */
<> 154:37f96f9d4de2 129 typedef enum _adc16_clock_source
<> 154:37f96f9d4de2 130 {
<> 154:37f96f9d4de2 131 kADC16_ClockSourceAlt0 = 0U, /*!< Selection 0 of the clock source. */
<> 154:37f96f9d4de2 132 kADC16_ClockSourceAlt1 = 1U, /*!< Selection 1 of the clock source. */
<> 154:37f96f9d4de2 133 kADC16_ClockSourceAlt2 = 2U, /*!< Selection 2 of the clock source. */
<> 154:37f96f9d4de2 134 kADC16_ClockSourceAlt3 = 3U, /*!< Selection 3 of the clock source. */
<> 154:37f96f9d4de2 135
<> 154:37f96f9d4de2 136 /* Chip defined clock source */
<> 154:37f96f9d4de2 137 kADC16_ClockSourceAsynchronousClock = kADC16_ClockSourceAlt3, /*!< Using internal asynchronous clock. */
<> 154:37f96f9d4de2 138 } adc16_clock_source_t;
<> 154:37f96f9d4de2 139
<> 154:37f96f9d4de2 140 /*!
<> 154:37f96f9d4de2 141 * @brief Long sample mode.
<> 154:37f96f9d4de2 142 */
<> 154:37f96f9d4de2 143 typedef enum _adc16_long_sample_mode
<> 154:37f96f9d4de2 144 {
<> 154:37f96f9d4de2 145 kADC16_LongSampleCycle24 = 0U, /*!< 20 extra ADCK cycles, 24 ADCK cycles total. */
<> 154:37f96f9d4de2 146 kADC16_LongSampleCycle16 = 1U, /*!< 12 extra ADCK cycles, 16 ADCK cycles total. */
<> 154:37f96f9d4de2 147 kADC16_LongSampleCycle10 = 2U, /*!< 6 extra ADCK cycles, 10 ADCK cycles total. */
<> 154:37f96f9d4de2 148 kADC16_LongSampleCycle6 = 3U, /*!< 2 extra ADCK cycles, 6 ADCK cycles total. */
<> 154:37f96f9d4de2 149 kADC16_LongSampleDisabled = 4U, /*!< Disable the long sample feature. */
<> 154:37f96f9d4de2 150 } adc16_long_sample_mode_t;
<> 154:37f96f9d4de2 151
<> 154:37f96f9d4de2 152 /*!
<> 154:37f96f9d4de2 153 * @brief Reference voltage source.
<> 154:37f96f9d4de2 154 */
<> 154:37f96f9d4de2 155 typedef enum _adc16_reference_voltage_source
<> 154:37f96f9d4de2 156 {
<> 154:37f96f9d4de2 157 kADC16_ReferenceVoltageSourceVref = 0U, /*!< For external pins pair of VrefH and VrefL. */
<> 154:37f96f9d4de2 158 kADC16_ReferenceVoltageSourceValt = 1U, /*!< For alternate reference pair of ValtH and ValtL. */
<> 154:37f96f9d4de2 159 } adc16_reference_voltage_source_t;
<> 154:37f96f9d4de2 160
<> 154:37f96f9d4de2 161 #if defined(FSL_FEATURE_ADC16_HAS_HW_AVERAGE) && FSL_FEATURE_ADC16_HAS_HW_AVERAGE
<> 154:37f96f9d4de2 162 /*!
<> 154:37f96f9d4de2 163 * @brief Hardware average mode.
<> 154:37f96f9d4de2 164 */
<> 154:37f96f9d4de2 165 typedef enum _adc16_hardware_average_mode
<> 154:37f96f9d4de2 166 {
<> 154:37f96f9d4de2 167 kADC16_HardwareAverageCount4 = 0U, /*!< For hardware average with 4 samples. */
<> 154:37f96f9d4de2 168 kADC16_HardwareAverageCount8 = 1U, /*!< For hardware average with 8 samples. */
<> 154:37f96f9d4de2 169 kADC16_HardwareAverageCount16 = 2U, /*!< For hardware average with 16 samples. */
<> 154:37f96f9d4de2 170 kADC16_HardwareAverageCount32 = 3U, /*!< For hardware average with 32 samples. */
<> 154:37f96f9d4de2 171 kADC16_HardwareAverageDisabled = 4U, /*!< Disable the hardware average feature.*/
<> 154:37f96f9d4de2 172 } adc16_hardware_average_mode_t;
<> 154:37f96f9d4de2 173 #endif /* FSL_FEATURE_ADC16_HAS_HW_AVERAGE */
<> 154:37f96f9d4de2 174
<> 154:37f96f9d4de2 175 /*!
<> 154:37f96f9d4de2 176 * @brief Hardware compare mode.
<> 154:37f96f9d4de2 177 */
<> 154:37f96f9d4de2 178 typedef enum _adc16_hardware_compare_mode
<> 154:37f96f9d4de2 179 {
<> 154:37f96f9d4de2 180 kADC16_HardwareCompareMode0 = 0U, /*!< x < value1. */
<> 154:37f96f9d4de2 181 kADC16_HardwareCompareMode1 = 1U, /*!< x > value1. */
<> 154:37f96f9d4de2 182 kADC16_HardwareCompareMode2 = 2U, /*!< if value1 <= value2, then x < value1 || x > value2;
<> 154:37f96f9d4de2 183 else, value1 > x > value2. */
<> 154:37f96f9d4de2 184 kADC16_HardwareCompareMode3 = 3U, /*!< if value1 <= value2, then value1 <= x <= value2;
<> 154:37f96f9d4de2 185 else x >= value1 || x <= value2. */
<> 154:37f96f9d4de2 186 } adc16_hardware_compare_mode_t;
<> 154:37f96f9d4de2 187
<> 154:37f96f9d4de2 188 #if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
<> 154:37f96f9d4de2 189 /*!
<> 154:37f96f9d4de2 190 * @brief PGA's Gain mode.
<> 154:37f96f9d4de2 191 */
<> 154:37f96f9d4de2 192 typedef enum _adc16_pga_gain
<> 154:37f96f9d4de2 193 {
<> 154:37f96f9d4de2 194 kADC16_PGAGainValueOf1 = 0U, /*!< For amplifier gain of 1. */
<> 154:37f96f9d4de2 195 kADC16_PGAGainValueOf2 = 1U, /*!< For amplifier gain of 2. */
<> 154:37f96f9d4de2 196 kADC16_PGAGainValueOf4 = 2U, /*!< For amplifier gain of 4. */
<> 154:37f96f9d4de2 197 kADC16_PGAGainValueOf8 = 3U, /*!< For amplifier gain of 8. */
<> 154:37f96f9d4de2 198 kADC16_PGAGainValueOf16 = 4U, /*!< For amplifier gain of 16. */
<> 154:37f96f9d4de2 199 kADC16_PGAGainValueOf32 = 5U, /*!< For amplifier gain of 32. */
<> 154:37f96f9d4de2 200 kADC16_PGAGainValueOf64 = 6U, /*!< For amplifier gain of 64. */
<> 154:37f96f9d4de2 201 } adc16_pga_gain_t;
<> 154:37f96f9d4de2 202 #endif /* FSL_FEATURE_ADC16_HAS_PGA */
<> 154:37f96f9d4de2 203
<> 154:37f96f9d4de2 204 /*!
<> 154:37f96f9d4de2 205 * @brief ADC16 converter configuration .
<> 154:37f96f9d4de2 206 */
<> 154:37f96f9d4de2 207 typedef struct _adc16_config
<> 154:37f96f9d4de2 208 {
<> 154:37f96f9d4de2 209 adc16_reference_voltage_source_t referenceVoltageSource; /*!< Select the reference voltage source. */
<> 154:37f96f9d4de2 210 adc16_clock_source_t clockSource; /*!< Select the input clock source to converter. */
<> 154:37f96f9d4de2 211 bool enableAsynchronousClock; /*!< Enable the asynchronous clock output. */
<> 154:37f96f9d4de2 212 adc16_clock_divider_t clockDivider; /*!< Select the divider of input clock source. */
<> 154:37f96f9d4de2 213 adc16_resolution_t resolution; /*!< Select the sample resolution mode. */
<> 154:37f96f9d4de2 214 adc16_long_sample_mode_t longSampleMode; /*!< Select the long sample mode. */
<> 154:37f96f9d4de2 215 bool enableHighSpeed; /*!< Enable the high-speed mode. */
<> 154:37f96f9d4de2 216 bool enableLowPower; /*!< Enable low power. */
<> 154:37f96f9d4de2 217 bool enableContinuousConversion; /*!< Enable continuous conversion mode. */
<> 154:37f96f9d4de2 218 } adc16_config_t;
<> 154:37f96f9d4de2 219
<> 154:37f96f9d4de2 220 /*!
<> 154:37f96f9d4de2 221 * @brief ADC16 Hardware compare configuration.
<> 154:37f96f9d4de2 222 */
<> 154:37f96f9d4de2 223 typedef struct _adc16_hardware_compare_config
<> 154:37f96f9d4de2 224 {
<> 154:37f96f9d4de2 225 adc16_hardware_compare_mode_t hardwareCompareMode; /*!< Select the hardware compare mode.
<> 154:37f96f9d4de2 226 See "adc16_hardware_compare_mode_t". */
<> 154:37f96f9d4de2 227 int16_t value1; /*!< Setting value1 for hardware compare mode. */
<> 154:37f96f9d4de2 228 int16_t value2; /*!< Setting value2 for hardware compare mode. */
<> 154:37f96f9d4de2 229 } adc16_hardware_compare_config_t;
<> 154:37f96f9d4de2 230
<> 154:37f96f9d4de2 231 /*!
<> 154:37f96f9d4de2 232 * @brief ADC16 channel conversion configuration.
<> 154:37f96f9d4de2 233 */
<> 154:37f96f9d4de2 234 typedef struct _adc16_channel_config
<> 154:37f96f9d4de2 235 {
<> 154:37f96f9d4de2 236 uint32_t channelNumber; /*!< Setting the conversion channel number. The available range is 0-31.
<> 154:37f96f9d4de2 237 See channel connection information for each chip in Reference
<> 154:37f96f9d4de2 238 Manual document. */
<> 154:37f96f9d4de2 239 bool enableInterruptOnConversionCompleted; /*!< Generate an interrupt request once the conversion is completed. */
<> 154:37f96f9d4de2 240 #if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
<> 154:37f96f9d4de2 241 bool enableDifferentialConversion; /*!< Using Differential sample mode. */
<> 154:37f96f9d4de2 242 #endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
<> 154:37f96f9d4de2 243 } adc16_channel_config_t;
<> 154:37f96f9d4de2 244
<> 154:37f96f9d4de2 245 #if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
<> 154:37f96f9d4de2 246 /*!
<> 154:37f96f9d4de2 247 * @brief ADC16 programmable gain amplifier configuration.
<> 154:37f96f9d4de2 248 */
<> 154:37f96f9d4de2 249 typedef struct _adc16_pga_config
<> 154:37f96f9d4de2 250 {
<> 154:37f96f9d4de2 251 adc16_pga_gain_t pgaGain; /*!< Setting PGA gain. */
<> 154:37f96f9d4de2 252 bool enableRunInNormalMode; /*!< Enable PGA working in normal mode, or low power mode by default. */
<> 154:37f96f9d4de2 253 #if defined(FSL_FEATURE_ADC16_HAS_PGA_CHOPPING) && FSL_FEATURE_ADC16_HAS_PGA_CHOPPING
<> 154:37f96f9d4de2 254 bool disablePgaChopping; /*!< Disable the PGA chopping function.
<> 154:37f96f9d4de2 255 The PGA employs chopping to remove/reduce offset and 1/f noise and offers
<> 154:37f96f9d4de2 256 an offset measurement configuration that aids the offset calibration. */
<> 154:37f96f9d4de2 257 #endif /* FSL_FEATURE_ADC16_HAS_PGA_CHOPPING */
<> 154:37f96f9d4de2 258 #if defined(FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT) && FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT
<> 154:37f96f9d4de2 259 bool enableRunInOffsetMeasurement; /*!< Enable the PGA working in offset measurement mode.
<> 154:37f96f9d4de2 260 When this feature is enabled, the PGA disconnects itself from the external
<> 154:37f96f9d4de2 261 inputs and auto-configures into offset measurement mode. With this field
<> 154:37f96f9d4de2 262 set, run the ADC in the recommended settings and enable the maximum hardware
<> 154:37f96f9d4de2 263 averaging to get the PGA offset number. The output is the
<> 154:37f96f9d4de2 264 (PGA offset * (64+1)) for the given PGA setting. */
<> 154:37f96f9d4de2 265 #endif /* FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT */
<> 154:37f96f9d4de2 266 } adc16_pga_config_t;
<> 154:37f96f9d4de2 267 #endif /* FSL_FEATURE_ADC16_HAS_PGA */
<> 154:37f96f9d4de2 268
<> 154:37f96f9d4de2 269 #if defined(__cplusplus)
<> 154:37f96f9d4de2 270 extern "C" {
<> 154:37f96f9d4de2 271 #endif
<> 154:37f96f9d4de2 272
<> 154:37f96f9d4de2 273 /*******************************************************************************
<> 154:37f96f9d4de2 274 * API
<> 154:37f96f9d4de2 275 ******************************************************************************/
<> 154:37f96f9d4de2 276
<> 154:37f96f9d4de2 277 /*!
<> 154:37f96f9d4de2 278 * @name Initialization
<> 154:37f96f9d4de2 279 * @{
<> 154:37f96f9d4de2 280 */
<> 154:37f96f9d4de2 281
<> 154:37f96f9d4de2 282 /*!
<> 154:37f96f9d4de2 283 * @brief Initializes the ADC16 module.
<> 154:37f96f9d4de2 284 *
<> 154:37f96f9d4de2 285 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 286 * @param config Pointer to configuration structure. See "adc16_config_t".
<> 154:37f96f9d4de2 287 */
<> 154:37f96f9d4de2 288 void ADC16_Init(ADC_Type *base, const adc16_config_t *config);
<> 154:37f96f9d4de2 289
<> 154:37f96f9d4de2 290 /*!
<> 154:37f96f9d4de2 291 * @brief De-initializes the ADC16 module.
<> 154:37f96f9d4de2 292 *
<> 154:37f96f9d4de2 293 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 294 */
<> 154:37f96f9d4de2 295 void ADC16_Deinit(ADC_Type *base);
<> 154:37f96f9d4de2 296
<> 154:37f96f9d4de2 297 /*!
<> 154:37f96f9d4de2 298 * @brief Gets an available pre-defined settings for converter's configuration.
<> 154:37f96f9d4de2 299 *
<> 154:37f96f9d4de2 300 * This function initializes the converter configuration structure with an available settings. The default values are:
<> 154:37f96f9d4de2 301 * @code
<> 154:37f96f9d4de2 302 * config->referenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
<> 154:37f96f9d4de2 303 * config->clockSource = kADC16_ClockSourceAsynchronousClock;
<> 154:37f96f9d4de2 304 * config->enableAsynchronousClock = true;
<> 154:37f96f9d4de2 305 * config->clockDivider = kADC16_ClockDivider8;
<> 154:37f96f9d4de2 306 * config->resolution = kADC16_ResolutionSE12Bit;
<> 154:37f96f9d4de2 307 * config->longSampleMode = kADC16_LongSampleDisabled;
<> 154:37f96f9d4de2 308 * config->enableHighSpeed = false;
<> 154:37f96f9d4de2 309 * config->enableLowPower = false;
<> 154:37f96f9d4de2 310 * config->enableContinuousConversion = false;
<> 154:37f96f9d4de2 311 * @endcode
<> 154:37f96f9d4de2 312 * @param config Pointer to configuration structure.
<> 154:37f96f9d4de2 313 */
<> 154:37f96f9d4de2 314 void ADC16_GetDefaultConfig(adc16_config_t *config);
<> 154:37f96f9d4de2 315
<> 154:37f96f9d4de2 316 #if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
<> 154:37f96f9d4de2 317 /*!
<> 154:37f96f9d4de2 318 * @brief Automates the hardware calibration.
<> 154:37f96f9d4de2 319 *
<> 154:37f96f9d4de2 320 * This auto calibration helps to adjust the plus/minus side gain automatically on the converter's working situation.
<> 154:37f96f9d4de2 321 * Execute the calibration before using the converter. Note that the hardware trigger should be used
<> 154:37f96f9d4de2 322 * during calibration.
<> 154:37f96f9d4de2 323 *
<> 154:37f96f9d4de2 324 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 325 *
<> 154:37f96f9d4de2 326 * @return Execution status.
<> 154:37f96f9d4de2 327 * @retval kStatus_Success Calibration is done successfully.
<> 154:37f96f9d4de2 328 * @retval kStatus_Fail Calibration is failed.
<> 154:37f96f9d4de2 329 */
<> 154:37f96f9d4de2 330 status_t ADC16_DoAutoCalibration(ADC_Type *base);
<> 154:37f96f9d4de2 331 #endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
<> 154:37f96f9d4de2 332
<> 154:37f96f9d4de2 333 #if defined(FSL_FEATURE_ADC16_HAS_OFFSET_CORRECTION) && FSL_FEATURE_ADC16_HAS_OFFSET_CORRECTION
<> 154:37f96f9d4de2 334 /*!
<> 154:37f96f9d4de2 335 * @brief Sets the offset value for the conversion result.
<> 154:37f96f9d4de2 336 *
<> 154:37f96f9d4de2 337 * This offset value takes effect on the conversion result. If the offset value is not zero, the reading result
<> 154:37f96f9d4de2 338 * is subtracted by it. Note, the hardware calibration fills the offset value automatically.
<> 154:37f96f9d4de2 339 *
<> 154:37f96f9d4de2 340 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 341 * @param value Setting offset value.
<> 154:37f96f9d4de2 342 */
<> 154:37f96f9d4de2 343 static inline void ADC16_SetOffsetValue(ADC_Type *base, int16_t value)
<> 154:37f96f9d4de2 344 {
<> 154:37f96f9d4de2 345 base->OFS = (uint32_t)(value);
<> 154:37f96f9d4de2 346 }
<> 154:37f96f9d4de2 347 #endif /* FSL_FEATURE_ADC16_HAS_OFFSET_CORRECTION */
<> 154:37f96f9d4de2 348
<> 154:37f96f9d4de2 349 /* @} */
<> 154:37f96f9d4de2 350
<> 154:37f96f9d4de2 351 /*!
<> 154:37f96f9d4de2 352 * @name Advanced Feature
<> 154:37f96f9d4de2 353 * @{
<> 154:37f96f9d4de2 354 */
<> 154:37f96f9d4de2 355
<> 154:37f96f9d4de2 356 #if defined(FSL_FEATURE_ADC16_HAS_DMA) && FSL_FEATURE_ADC16_HAS_DMA
<> 154:37f96f9d4de2 357 /*!
<> 154:37f96f9d4de2 358 * @brief Enables generating the DMA trigger when conversion is completed.
<> 154:37f96f9d4de2 359 *
<> 154:37f96f9d4de2 360 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 361 * @param enable Switcher of DMA feature. "true" means to enable, "false" means not.
<> 154:37f96f9d4de2 362 */
<> 154:37f96f9d4de2 363 static inline void ADC16_EnableDMA(ADC_Type *base, bool enable)
<> 154:37f96f9d4de2 364 {
<> 154:37f96f9d4de2 365 if (enable)
<> 154:37f96f9d4de2 366 {
<> 154:37f96f9d4de2 367 base->SC2 |= ADC_SC2_DMAEN_MASK;
<> 154:37f96f9d4de2 368 }
<> 154:37f96f9d4de2 369 else
<> 154:37f96f9d4de2 370 {
<> 154:37f96f9d4de2 371 base->SC2 &= ~ADC_SC2_DMAEN_MASK;
<> 154:37f96f9d4de2 372 }
<> 154:37f96f9d4de2 373 }
<> 154:37f96f9d4de2 374 #endif /* FSL_FEATURE_ADC16_HAS_DMA */
<> 154:37f96f9d4de2 375
<> 154:37f96f9d4de2 376 /*!
<> 154:37f96f9d4de2 377 * @brief Enables the hardware trigger mode.
<> 154:37f96f9d4de2 378 *
<> 154:37f96f9d4de2 379 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 380 * @param enable Switcher of hardware trigger feature. "true" means to enable, "false" means not.
<> 154:37f96f9d4de2 381 */
<> 154:37f96f9d4de2 382 static inline void ADC16_EnableHardwareTrigger(ADC_Type *base, bool enable)
<> 154:37f96f9d4de2 383 {
<> 154:37f96f9d4de2 384 if (enable)
<> 154:37f96f9d4de2 385 {
<> 154:37f96f9d4de2 386 base->SC2 |= ADC_SC2_ADTRG_MASK;
<> 154:37f96f9d4de2 387 }
<> 154:37f96f9d4de2 388 else
<> 154:37f96f9d4de2 389 {
<> 154:37f96f9d4de2 390 base->SC2 &= ~ADC_SC2_ADTRG_MASK;
<> 154:37f96f9d4de2 391 }
<> 154:37f96f9d4de2 392 }
<> 154:37f96f9d4de2 393
<> 154:37f96f9d4de2 394 #if defined(FSL_FEATURE_ADC16_HAS_MUX_SELECT) && FSL_FEATURE_ADC16_HAS_MUX_SELECT
<> 154:37f96f9d4de2 395 /*!
<> 154:37f96f9d4de2 396 * @brief Sets the channel mux mode.
<> 154:37f96f9d4de2 397 *
<> 154:37f96f9d4de2 398 * Some sample pins share the same channel index. The channel mux mode decides which pin is used for an
<> 154:37f96f9d4de2 399 * indicated channel.
<> 154:37f96f9d4de2 400 *
<> 154:37f96f9d4de2 401 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 402 * @param mode Setting channel mux mode. See "adc16_channel_mux_mode_t".
<> 154:37f96f9d4de2 403 */
<> 154:37f96f9d4de2 404 void ADC16_SetChannelMuxMode(ADC_Type *base, adc16_channel_mux_mode_t mode);
<> 154:37f96f9d4de2 405 #endif /* FSL_FEATURE_ADC16_HAS_MUX_SELECT */
<> 154:37f96f9d4de2 406
<> 154:37f96f9d4de2 407 /*!
<> 154:37f96f9d4de2 408 * @brief Configures the hardware compare mode.
<> 154:37f96f9d4de2 409 *
<> 154:37f96f9d4de2 410 * The hardware compare mode provides a way to process the conversion result automatically by hardware. Only the result
<> 154:37f96f9d4de2 411 * in
<> 154:37f96f9d4de2 412 * compare range is available. To compare the range, see "adc16_hardware_compare_mode_t", or the reference
<> 154:37f96f9d4de2 413 * manual document for more detailed information.
<> 154:37f96f9d4de2 414 *
<> 154:37f96f9d4de2 415 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 416 * @param config Pointer to "adc16_hardware_compare_config_t" structure. Passing "NULL" is to disable the feature.
<> 154:37f96f9d4de2 417 */
<> 154:37f96f9d4de2 418 void ADC16_SetHardwareCompareConfig(ADC_Type *base, const adc16_hardware_compare_config_t *config);
<> 154:37f96f9d4de2 419
<> 154:37f96f9d4de2 420 #if defined(FSL_FEATURE_ADC16_HAS_HW_AVERAGE) && FSL_FEATURE_ADC16_HAS_HW_AVERAGE
<> 154:37f96f9d4de2 421 /*!
<> 154:37f96f9d4de2 422 * @brief Sets the hardware average mode.
<> 154:37f96f9d4de2 423 *
<> 154:37f96f9d4de2 424 * Hardware average mode provides a way to process the conversion result automatically by hardware. The multiple
<> 154:37f96f9d4de2 425 * conversion results are accumulated and averaged internally. This aids reading results.
<> 154:37f96f9d4de2 426 *
<> 154:37f96f9d4de2 427 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 428 * @param mode Setting hardware average mode. See "adc16_hardware_average_mode_t".
<> 154:37f96f9d4de2 429 */
<> 154:37f96f9d4de2 430 void ADC16_SetHardwareAverage(ADC_Type *base, adc16_hardware_average_mode_t mode);
<> 154:37f96f9d4de2 431 #endif /* FSL_FEATURE_ADC16_HAS_HW_AVERAGE */
<> 154:37f96f9d4de2 432
<> 154:37f96f9d4de2 433 #if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
<> 154:37f96f9d4de2 434 /*!
<> 154:37f96f9d4de2 435 * @brief Configures the PGA for converter's front end.
<> 154:37f96f9d4de2 436 *
<> 154:37f96f9d4de2 437 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 438 * @param config Pointer to "adc16_pga_config_t" structure. Passing "NULL" is to disable the feature.
<> 154:37f96f9d4de2 439 */
<> 154:37f96f9d4de2 440 void ADC16_SetPGAConfig(ADC_Type *base, const adc16_pga_config_t *config);
<> 154:37f96f9d4de2 441 #endif /* FSL_FEATURE_ADC16_HAS_PGA */
<> 154:37f96f9d4de2 442
<> 154:37f96f9d4de2 443 /*!
<> 154:37f96f9d4de2 444 * @brief Gets the status flags of the converter.
<> 154:37f96f9d4de2 445 *
<> 154:37f96f9d4de2 446 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 447 *
<> 154:37f96f9d4de2 448 * @return Flags' mask if indicated flags are asserted. See "_adc16_status_flags".
<> 154:37f96f9d4de2 449 */
<> 154:37f96f9d4de2 450 uint32_t ADC16_GetStatusFlags(ADC_Type *base);
<> 154:37f96f9d4de2 451
<> 154:37f96f9d4de2 452 /*!
<> 154:37f96f9d4de2 453 * @brief Clears the status flags of the converter.
<> 154:37f96f9d4de2 454 *
<> 154:37f96f9d4de2 455 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 456 * @param mask Mask value for the cleared flags. See "_adc16_status_flags".
<> 154:37f96f9d4de2 457 */
<> 154:37f96f9d4de2 458 void ADC16_ClearStatusFlags(ADC_Type *base, uint32_t mask);
<> 154:37f96f9d4de2 459
<> 154:37f96f9d4de2 460 /* @} */
<> 154:37f96f9d4de2 461
<> 154:37f96f9d4de2 462 /*!
<> 154:37f96f9d4de2 463 * @name Conversion Channel
<> 154:37f96f9d4de2 464 * @{
<> 154:37f96f9d4de2 465 */
<> 154:37f96f9d4de2 466
<> 154:37f96f9d4de2 467 /*!
<> 154:37f96f9d4de2 468 * @brief Configures the conversion channel.
<> 154:37f96f9d4de2 469 *
<> 154:37f96f9d4de2 470 * This operation triggers the conversion if in software trigger mode. When in hardware trigger mode, this API
<> 154:37f96f9d4de2 471 * configures the channel while the external trigger source helps to trigger the conversion.
<> 154:37f96f9d4de2 472 *
<> 154:37f96f9d4de2 473 * Note that the "Channel Group" has a detailed description.
<> 154:37f96f9d4de2 474 * To allow sequential conversions of the ADC to be triggered by internal peripherals, the ADC can have more than one
<> 154:37f96f9d4de2 475 * group of status and control register, one for each conversion. The channel group parameter indicates which group of
<> 154:37f96f9d4de2 476 * registers are used channel group 0 is for Group A registers and channel group 1 is for Group B registers. The
<> 154:37f96f9d4de2 477 * channel groups are used in a "ping-pong" approach to control the ADC operation. At any point, only one of
<> 154:37f96f9d4de2 478 * the channel groups is actively controlling ADC conversions. Channel group 0 is used for both software and hardware
<> 154:37f96f9d4de2 479 * trigger modes of operation. Channel groups 1 and greater indicate potentially multiple channel group registers for
<> 154:37f96f9d4de2 480 * use only in hardware trigger mode. See the chip configuration information in the MCU reference manual about the
<> 154:37f96f9d4de2 481 * number of SC1n registers (channel groups) specific to this device. None of the channel groups 1 or greater are used
<> 154:37f96f9d4de2 482 * for software trigger operation and therefore writes to these channel groups do not initiate a new conversion.
<> 154:37f96f9d4de2 483 * Updating channel group 0 while a different channel group is actively controlling a conversion is allowed and
<> 154:37f96f9d4de2 484 * vice versa. Writing any of the channel group registers while that specific channel group is actively controlling a
<> 154:37f96f9d4de2 485 * conversion aborts the current conversion.
<> 154:37f96f9d4de2 486 *
<> 154:37f96f9d4de2 487 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 488 * @param channelGroup Channel group index.
<> 154:37f96f9d4de2 489 * @param config Pointer to "adc16_channel_config_t" structure for conversion channel.
<> 154:37f96f9d4de2 490 */
<> 154:37f96f9d4de2 491 void ADC16_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc16_channel_config_t *config);
<> 154:37f96f9d4de2 492
<> 154:37f96f9d4de2 493 /*!
<> 154:37f96f9d4de2 494 * @brief Gets the conversion value.
<> 154:37f96f9d4de2 495 *
<> 154:37f96f9d4de2 496 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 497 * @param channelGroup Channel group index.
<> 154:37f96f9d4de2 498 *
<> 154:37f96f9d4de2 499 * @return Conversion value.
<> 154:37f96f9d4de2 500 */
<> 154:37f96f9d4de2 501 static inline uint32_t ADC16_GetChannelConversionValue(ADC_Type *base, uint32_t channelGroup)
<> 154:37f96f9d4de2 502 {
<> 154:37f96f9d4de2 503 assert(channelGroup < ADC_R_COUNT);
<> 154:37f96f9d4de2 504
<> 154:37f96f9d4de2 505 return base->R[channelGroup];
<> 154:37f96f9d4de2 506 }
<> 154:37f96f9d4de2 507
<> 154:37f96f9d4de2 508 /*!
<> 154:37f96f9d4de2 509 * @brief Gets the status flags of channel.
<> 154:37f96f9d4de2 510 *
<> 154:37f96f9d4de2 511 * @param base ADC16 peripheral base address.
<> 154:37f96f9d4de2 512 * @param channelGroup Channel group index.
<> 154:37f96f9d4de2 513 *
<> 154:37f96f9d4de2 514 * @return Flags' mask if indicated flags are asserted. See "_adc16_channel_status_flags".
<> 154:37f96f9d4de2 515 */
<> 154:37f96f9d4de2 516 uint32_t ADC16_GetChannelStatusFlags(ADC_Type *base, uint32_t channelGroup);
<> 154:37f96f9d4de2 517
<> 154:37f96f9d4de2 518 /* @} */
<> 154:37f96f9d4de2 519
<> 154:37f96f9d4de2 520 #if defined(__cplusplus)
<> 154:37f96f9d4de2 521 }
<> 154:37f96f9d4de2 522 #endif
<> 154:37f96f9d4de2 523 /*!
<> 154:37f96f9d4de2 524 * @}
<> 154:37f96f9d4de2 525 */
<> 154:37f96f9d4de2 526 #endif /* _FSL_ADC16_H_ */