MCUXpresso SDK API Reference Manual
Rev 2.15.000
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the 12-bit Analog to Digital Converter (ADC) module of MCUXpresso SDK devices.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/fsl_adc
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/fsl_adc
Data Structures | |
struct | _adc_config |
Converter configuration. More... | |
struct | _adc_offest_config |
Converter Offset configuration. More... | |
struct | _adc_hardware_compare_config |
ADC hardware compare configuration. More... | |
struct | _adc_channel_config |
ADC channel conversion configuration. More... | |
Macros | |
#define | FSL_ADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 4)) |
ADC driver version. More... | |
Typedefs | |
typedef enum _adc_status_flags | adc_status_flags_t |
Converter's status flags. | |
typedef enum _adc_reference_voltage_source | adc_reference_voltage_source_t |
Reference voltage source. | |
typedef enum _adc_sample_period_mode | adc_sample_period_mode_t |
Sample time duration. | |
typedef enum _adc_clock_source | adc_clock_source_t |
Clock source. | |
typedef enum _adc_clock_drvier | adc_clock_driver_t |
Clock divider for the converter. | |
typedef enum _adc_resolution | adc_resolution_t |
Converter's resolution. | |
typedef enum _adc_hardware_compare_mode | adc_hardware_compare_mode_t |
Converter hardware compare mode. | |
typedef enum _adc_hardware_average_mode | adc_hardware_average_mode_t |
Converter hardware average mode. | |
typedef struct _adc_config | adc_config_t |
Converter configuration. | |
typedef struct _adc_offest_config | adc_offest_config_t |
Converter Offset configuration. | |
typedef struct _adc_hardware_compare_config | adc_hardware_compare_config_t |
ADC hardware compare configuration. More... | |
typedef struct _adc_channel_config | adc_channel_config_t |
ADC channel conversion configuration. | |
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 |
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... | |
bool _adc_config::enableOverWrite |
bool _adc_config::enableContinuousConversion |
bool _adc_config::enableHighSpeed |
bool _adc_config::enableLowPower |
bool _adc_config::enableLongSample |
bool _adc_config::enableAsynchronousClockOutput |
adc_reference_voltage_source_t _adc_config::referenceVoltageSource |
adc_sample_period_mode_t _adc_config::samplePeriodMode |
adc_clock_source_t _adc_config::clockSource |
adc_clock_driver_t _adc_config::clockDriver |
adc_resolution_t _adc_config::resolution |
struct _adc_offest_config |
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... | |
bool _adc_offest_config::enableSigned |
if true,The offset value is subtracted from the raw converted value.
uint32_t _adc_offest_config::offsetValue |
struct _adc_hardware_compare_config |
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... | |
adc_hardware_compare_mode_t _adc_hardware_compare_config::hardwareCompareMode |
See "adc_hardware_compare_mode_t".
uint16_t _adc_hardware_compare_config::value1 |
uint16_t _adc_hardware_compare_config::value2 |
struct _adc_channel_config |
Data Fields | |
uint32_t | channelNumber |
Setting the conversion channel number. More... | |
bool | enableInterruptOnConversionCompleted |
Generate an interrupt request once the conversion is completed. More... | |
uint32_t _adc_channel_config::channelNumber |
The available range is 0-31. See channel connection information for each chip in Reference Manual document.
bool _adc_channel_config::enableInterruptOnConversionCompleted |
#define FSL_ADC_DRIVER_VERSION (MAKE_VERSION(2, 0, 4)) |
Version 2.0.4.
typedef struct _adc_hardware_compare_config 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.
enum _adc_status_flags |
enum _adc_clock_source |
enum _adc_clock_drvier |
enum _adc_resolution |
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:
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. |
config | 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". |