MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides Peripheral driver for the 12-bit Analog to Digital Converter (ADC) module of MCUXpresso SDK devices.
Data Structures | |
struct | adc_config_t |
Converter configuration. More... | |
struct | adc_offest_config_t |
Converter Offset configuration. More... | |
struct | adc_hardware_compare_config_t |
ADC hardware compare configuration. More... | |
struct | adc_channel_config_t |
ADC channel conversion configuration. More... | |
Macros | |
#define | FSL_ADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
ADC driver version. More... | |
Variables | |
bool | adc_config_t::enableOverWrite |
Enable the overwriting. More... | |
bool | adc_config_t::enableContinuousConversion |
Enable the continuous conversion mode. More... | |
bool | adc_config_t::enableHighSpeed |
Enable the high-speed mode. More... | |
bool | adc_config_t::enableLowPower |
Enable the low power mode. More... | |
bool | adc_config_t::enableLongSample |
Enable the long sample mode. More... | |
bool | adc_config_t::enableAsynchronousClockOutput |
Enable the asynchronous clock output. More... | |
adc_reference_voltage_source_t | adc_config_t::referenceVoltageSource |
Select the reference voltage source. More... | |
adc_sample_period_mode_t | adc_config_t::samplePeriodMode |
Select the sample period in long sample mode or short mode. More... | |
adc_clock_source_t | adc_config_t::clockSource |
Select the input clock source to generate the internal clock ADCK. More... | |
adc_clock_driver_t | adc_config_t::clockDriver |
Select the divide ratio used by the ADC to generate the internal clock ADCK. More... | |
adc_resolution_t | adc_config_t::resolution |
Select the ADC resolution mode. More... | |
bool | adc_offest_config_t::enableSigned |
if false,The offset value is added with the raw result. More... | |
uint32_t | adc_offest_config_t::offsetValue |
User configurable offset value(0-4095). More... | |
adc_hardware_compare_mode_t | adc_hardware_compare_config_t::hardwareCompareMode |
Select the hardware compare mode. More... | |
uint16_t | adc_hardware_compare_config_t::value1 |
Setting value1(0-4095) for hardware compare mode. More... | |
uint16_t | adc_hardware_compare_config_t::value2 |
Setting value2(0-4095) for hardware compare mode. More... | |
uint32_t | adc_channel_config_t::channelNumber |
Setting the conversion channel number. More... | |
bool | adc_channel_config_t::enableInterruptOnConversionCompleted |
Generate an interrupt request once the conversion is completed. More... | |
Initialization | |
void | ADC_Init (ADC_Type *base, const adc_config_t *config) |
Initialize the ADC module. More... | |
void | ADC_Deinit (ADC_Type *base) |
De-initializes the ADC module. More... | |
void | ADC_GetDefaultConfig (adc_config_t *config) |
Gets an available pre-defined settings for the converter's configuration. More... | |
void | ADC_SetChannelConfig (ADC_Type *base, uint32_t channelGroup, const adc_channel_config_t *config) |
Configures the conversion channel. More... | |
static uint32_t | ADC_GetChannelConversionValue (ADC_Type *base, uint32_t channelGroup) |
Gets the conversion value. More... | |
static uint32_t | ADC_GetChannelStatusFlags (ADC_Type *base, uint32_t channelGroup) |
Gets the status flags of channel. More... | |
status_t | ADC_DoAutoCalibration (ADC_Type *base) |
Automates the hardware calibration. More... | |
void | ADC_SetOffsetConfig (ADC_Type *base, const adc_offest_config_t *config) |
Set user defined offset. More... | |
static void | ADC_EnableDMA (ADC_Type *base, bool enable) |
Enables generating the DMA trigger when the conversion is complete. More... | |
static void | ADC_EnableHardwareTrigger (ADC_Type *base, bool enable) |
Enables the hardware trigger mode. More... | |
void | ADC_SetHardwareCompareConfig (ADC_Type *base, const adc_hardware_compare_config_t *config) |
Configures the hardware compare mode. More... | |
void | ADC_SetHardwareAverageConfig (ADC_Type *base, adc_hardware_average_mode_t mode) |
Configures the hardware average mode. More... | |
static uint32_t | ADC_GetStatusFlags (ADC_Type *base) |
Gets the converter's status flags. More... | |
void | ADC_ClearStatusFlags (ADC_Type *base, uint32_t mask) |
Clears the converter's status falgs. More... | |
struct adc_config_t |
Data Fields | |
bool | enableOverWrite |
Enable the overwriting. More... | |
bool | enableContinuousConversion |
Enable the continuous conversion mode. More... | |
bool | enableHighSpeed |
Enable the high-speed mode. More... | |
bool | enableLowPower |
Enable the low power mode. More... | |
bool | enableLongSample |
Enable the long sample mode. More... | |
bool | enableAsynchronousClockOutput |
Enable the asynchronous clock output. More... | |
adc_reference_voltage_source_t | referenceVoltageSource |
Select the reference voltage source. More... | |
adc_sample_period_mode_t | samplePeriodMode |
Select the sample period in long sample mode or short mode. More... | |
adc_clock_source_t | clockSource |
Select the input clock source to generate the internal clock ADCK. More... | |
adc_clock_driver_t | clockDriver |
Select the divide ratio used by the ADC to generate the internal clock ADCK. More... | |
adc_resolution_t | resolution |
Select the ADC resolution mode. More... | |
struct adc_offest_config_t |
Data Fields | |
bool | enableSigned |
if false,The offset value is added with the raw result. More... | |
uint32_t | offsetValue |
User configurable offset value(0-4095). More... | |
struct adc_hardware_compare_config_t |
In kADC_HardwareCompareMode0, compare true if the result is less than the value1. In kADC_HardwareCompareMode1, compare true if the result is greater than or equal to value1. In kADC_HardwareCompareMode2, Value1 <= Value2, compare true if the result is less than value1 Or the result is Greater than value2. Value1 > Value2, compare true if the result is less than value1 And the result is Greater than value2. In kADC_HardwareCompareMode3, Value1 <= Value2, compare true if the result is greater than or equal to value1 And the result is less than or equal to value2. Value1 > Value2, compare true if the result is greater than or equal to value1 Or the result is less than or equal to value2.
Data Fields | |
adc_hardware_compare_mode_t | hardwareCompareMode |
Select the hardware compare mode. More... | |
uint16_t | value1 |
Setting value1(0-4095) for hardware compare mode. More... | |
uint16_t | value2 |
Setting value2(0-4095) for hardware compare mode. More... | |
struct adc_channel_config_t |
Data Fields | |
uint32_t | channelNumber |
Setting the conversion channel number. More... | |
bool | enableInterruptOnConversionCompleted |
Generate an interrupt request once the conversion is completed. More... | |
#define FSL_ADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
Version 2.0.0.
enum adc_status_flags_t |
enum adc_clock_source_t |
enum adc_clock_driver_t |
enum adc_resolution_t |
void ADC_Init | ( | ADC_Type * | base, |
const adc_config_t * | config | ||
) |
base | ADC peripheral base address. |
config | Pointer to "adc_config_t" structure. |
void ADC_Deinit | ( | ADC_Type * | base | ) |
base | ADC peripheral base address. |
void ADC_GetDefaultConfig | ( | adc_config_t * | config | ) |
This function initializes the converter configuration structure with available settings. The default values are:
base | ADC peripheral base address. |
config | Pointer to the configuration structure. |
void ADC_SetChannelConfig | ( | ADC_Type * | base, |
uint32_t | channelGroup, | ||
const adc_channel_config_t * | config | ||
) |
This operation triggers the conversion when in software trigger mode. When in hardware trigger mode, this API configures the channel while the external trigger source helps to trigger the conversion.
Note that the "Channel Group" has a detailed description. To allow sequential conversions of the ADC to be triggered by internal peripherals, the ADC has more than one group of status and control registers, one for each conversion. The channel group parameter indicates which group of registers are used, for example channel group 0 is for Group A registers and channel group 1 is for Group B registers. The channel groups are used in a "ping-pong" approach to control the ADC operation. At any point, only one of the channel groups is actively controlling ADC conversions. The channel group 0 is used for both software and hardware trigger modes. Channel groups 1 and greater indicate potentially multiple channel group registers for use only in hardware trigger mode. See the chip configuration information in the appropriate MCU reference manual about the number of SC1n registers (channel groups) specific to this device. None of the channel groups 1 or greater are used for software trigger operation. Therefore, writing to these channel groups does not initiate a new conversion. Updating the channel group 0 while a different channel group is actively controlling a conversion is allowed and vice versa. Writing any of the channel group registers while that specific channel group is actively controlling a conversion aborts the current conversion.
base | ADC peripheral base address. |
channelGroup | Channel group index. |
config | Pointer to the "adc_channel_config_t" structure for the conversion channel. |
|
inlinestatic |
base | ADC peripheral base address. |
channelGroup | Channel group index. |
|
inlinestatic |
A conversion is completed when the result of the conversion is transferred into the data result registers. (provided the compare function & hardware averaging is disabled), this is indicated by the setting of COCOn. If hardware averaging is enabled, COCOn sets only, if the last of the selected number of conversions is complete. If the compare function is enabled, COCOn sets and conversion result data is transferred only if the compare condition is true. If both hardware averaging and compare functions are enabled, then COCOn sets only if the last of the selected number of conversions is complete and the compare condition is true.
base | ADC peripheral base address. |
channelGroup | Channel group index. |
status_t ADC_DoAutoCalibration | ( | ADC_Type * | base | ) |
This auto calibration helps to adjust the plus/minus side gain automatically. Execute the calibration before using the converter. Note that the software trigger should be used during calibration.
base | ADC peripheral base address. |
kStatus_Success | Calibration is done successfully. |
kStatus_Fail | Calibration has failed. |
void ADC_SetOffsetConfig | ( | ADC_Type * | base, |
const adc_offest_config_t * | config | ||
) |
base | ADC peripheral base address. |
config | Pointer to "adc_offest_config_t" structure. |
|
inlinestatic |
base | ADC peripheral base address. |
enable | Switcher of the DMA feature. "true" means enabled, "false" means not enabled. |
|
inlinestatic |
base | ADC peripheral base address. |
enable | Switcher of the trigger mode. "true" means hardware tirgger mode,"false" means software mode. |
void ADC_SetHardwareCompareConfig | ( | ADC_Type * | base, |
const adc_hardware_compare_config_t * | config | ||
) |
The hardware compare mode provides a way to process the conversion result automatically by using hardware. Only the result in the compare range is available. To compare the range, see "adc_hardware_compare_mode_t" or the appopriate reference manual for more information.
base | ADC peripheral base address. |
Pointer | to "adc_hardware_compare_config_t" structure. |
void ADC_SetHardwareAverageConfig | ( | ADC_Type * | base, |
adc_hardware_average_mode_t | mode | ||
) |
The hardware average mode provides a way to process the conversion result automatically by using hardware. The multiple conversion results are accumulated and averaged internally making them easier to read.
base | ADC peripheral base address. |
mode | Setting the hardware average mode. See "adc_hardware_average_mode_t". |
|
inlinestatic |
base | ADC peripheral base address. |
void ADC_ClearStatusFlags | ( | ADC_Type * | base, |
uint32_t | mask | ||
) |
base | ADC peripheral base address. |
mask | Mask value for the cleared flags. See "adc_status_flags_t". |
bool adc_config_t::enableOverWrite |
bool adc_config_t::enableContinuousConversion |
bool adc_config_t::enableHighSpeed |
bool adc_config_t::enableLowPower |
bool adc_config_t::enableLongSample |
bool adc_config_t::enableAsynchronousClockOutput |
adc_reference_voltage_source_t adc_config_t::referenceVoltageSource |
adc_sample_period_mode_t adc_config_t::samplePeriodMode |
adc_clock_source_t adc_config_t::clockSource |
adc_clock_driver_t adc_config_t::clockDriver |
adc_resolution_t adc_config_t::resolution |
bool adc_offest_config_t::enableSigned |
if true,The offset value is subtracted from the raw converted value.
uint32_t adc_offest_config_t::offsetValue |
adc_hardware_compare_mode_t adc_hardware_compare_config_t::hardwareCompareMode |
See "adc_hardware_compare_mode_t".
uint16_t adc_hardware_compare_config_t::value1 |
uint16_t adc_hardware_compare_config_t::value2 |
uint32_t adc_channel_config_t::channelNumber |
The available range is 0-31. See channel connection information for each chip in Reference Manual document.
bool adc_channel_config_t::enableInterruptOnConversionCompleted |