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