MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the 12-bit SAR Analog-to-Digital Converter (LPADC) module of MCUXpresso SDK devices.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/lpadc
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/lpadc
Files | |
file | fsl_lpadc.h |
Data Structures | |
struct | lpadc_config_t |
LPADC global configuration. More... | |
struct | lpadc_conv_command_config_t |
Define structure to keep the configuration for conversion command. More... | |
struct | lpadc_conv_trigger_config_t |
Define structure to keep the configuration for conversion trigger. More... | |
struct | lpadc_conv_result_t |
Define the structure to keep the conversion result. More... | |
Macros | |
#define | LPADC_GET_ACTIVE_COMMAND_STATUS(statusVal) ((statusVal & ADC_STAT_CMDACT_MASK) >> ADC_STAT_CMDACT_SHIFT) |
Define the MACRO function to get command status from status value. More... | |
#define | LPADC_GET_ACTIVE_TRIGGER_STATUE(statusVal) ((statusVal & ADC_STAT_TRGACT_MASK) >> ADC_STAT_TRGACT_SHIFT) |
Define the MACRO function to get trigger status from status value. More... | |
Driver version | |
#define | FSL_LPADC_DRIVER_VERSION (MAKE_VERSION(2, 3, 0)) |
LPADC driver version 2.3.0. More... | |
Initialization & de-initialization. | |
void | LPADC_Init (ADC_Type *base, const lpadc_config_t *config) |
Initializes the LPADC module. More... | |
void | LPADC_GetDefaultConfig (lpadc_config_t *config) |
Gets an available pre-defined settings for initial configuration. More... | |
void | LPADC_Deinit (ADC_Type *base) |
De-initializes the LPADC module. More... | |
static void | LPADC_Enable (ADC_Type *base, bool enable) |
Switch on/off the LPADC module. More... | |
static void | LPADC_DoResetFIFO (ADC_Type *base) |
Do reset the conversion FIFO. More... | |
static void | LPADC_DoResetConfig (ADC_Type *base) |
Do reset the module's configuration. More... | |
Status | |
static uint32_t | LPADC_GetStatusFlags (ADC_Type *base) |
Get status flags. More... | |
static void | LPADC_ClearStatusFlags (ADC_Type *base, uint32_t mask) |
Clear status flags. More... | |
Interrupts | |
static void | LPADC_EnableInterrupts (ADC_Type *base, uint32_t mask) |
Enable interrupts. More... | |
static void | LPADC_DisableInterrupts (ADC_Type *base, uint32_t mask) |
Disable interrupts. More... | |
DMA Control | |
static void | LPADC_EnableFIFOWatermarkDMA (ADC_Type *base, bool enable) |
Switch on/off the DMA trigger for FIFO watermark event. More... | |
Trigger and conversion with FIFO. | |
static uint32_t | LPADC_GetConvResultCount (ADC_Type *base) |
Get the count of result kept in conversion FIFO. More... | |
bool | LPADC_GetConvResult (ADC_Type *base, lpadc_conv_result_t *result) |
Get the result in conversion FIFO. More... | |
void | LPADC_SetConvTriggerConfig (ADC_Type *base, uint32_t triggerId, const lpadc_conv_trigger_config_t *config) |
Configure the conversion trigger source. More... | |
void | LPADC_GetDefaultConvTriggerConfig (lpadc_conv_trigger_config_t *config) |
Gets an available pre-defined settings for trigger's configuration. More... | |
static void | LPADC_DoSoftwareTrigger (ADC_Type *base, uint32_t triggerIdMask) |
Do software trigger to conversion command. More... | |
void | LPADC_SetConvCommandConfig (ADC_Type *base, uint32_t commandId, const lpadc_conv_command_config_t *config) |
Configure conversion command. More... | |
void | LPADC_GetDefaultConvCommandConfig (lpadc_conv_command_config_t *config) |
Gets an available pre-defined settings for conversion command's configuration. More... | |
struct lpadc_config_t |
This structure would used to keep the settings for initialization.
Data Fields | |
bool | enableInDozeMode |
Control system transition to Stop and Wait power modes while ADC is converting. More... | |
bool | enableAnalogPreliminary |
ADC analog circuits are pre-enabled and ready to execute conversions without startup delays(at the cost of higher DC current consumption). More... | |
uint32_t | powerUpDelay |
When the analog circuits are not pre-enabled, the ADC analog circuits are only powered while the ADC is active and there is a counted delay defined by this field after an initial trigger transitions the ADC from its Idle state to allow time for the analog circuits to stabilize. More... | |
lpadc_reference_voltage_source_t | referenceVoltageSource |
Selects the voltage reference high used for conversions. More... | |
lpadc_power_level_mode_t | powerLevelMode |
Power Configuration Selection. More... | |
lpadc_trigger_priority_policy_t | triggerPriorityPolicy |
Control how higher priority triggers are handled, see to lpadc_trigger_priority_policy_mode_t. More... | |
bool | enableConvPause |
Enables the ADC pausing function. More... | |
uint32_t | convPauseDelay |
Controls the duration of pausing during command execution sequencing. More... | |
uint32_t | FIFOWatermark |
FIFOWatermark is a programmable threshold setting. More... | |
bool lpadc_config_t::enableInDozeMode |
When enabled in Doze mode, immediate entries to Wait or Stop are allowed. When disabled, the ADC will wait for the current averaging iteration/FIFO storage to complete before acknowledging stop or wait mode entry.
bool lpadc_config_t::enableAnalogPreliminary |
uint32_t lpadc_config_t::powerUpDelay |
The startup delay count of (powerUpDelay * 4) ADCK cycles must result in a longer delay than the analog startup time.
lpadc_reference_voltage_source_t lpadc_config_t::referenceVoltageSource |
lpadc_power_level_mode_t lpadc_config_t::powerLevelMode |
lpadc_trigger_priority_policy_t lpadc_config_t::triggerPriorityPolicy |
bool lpadc_config_t::enableConvPause |
When enabled, a programmable delay is inserted during command execution sequencing between LOOP iterations, between commands in a sequence, and between conversions when command is executing in "Compare Until True" configuration.
uint32_t lpadc_config_t::convPauseDelay |
The pause delay is a count of (convPauseDelay*4) ADCK cycles. Only available when ADC pausing function is enabled. The available value range is in 9-bit.
uint32_t lpadc_config_t::FIFOWatermark |
When the number of datawords stored in the ADC Result FIFO is greater than the value in this field, the ready flag would be asserted to indicate stored data has reached the programmable threshold.
struct lpadc_conv_command_config_t |
Data Fields | |
lpadc_sample_scale_mode_t | sampleScaleMode |
Sample scale mode. More... | |
lpadc_sample_channel_mode_t | sampleChannelMode |
Channel sample mode. More... | |
uint32_t | channelNumber |
Channel number, select the channel or channel pair. More... | |
uint32_t | chainedNextCommandNumber |
Selects the next command to be executed after this command completes. More... | |
bool | enableAutoChannelIncrement |
Loop with increment: when disabled, the "loopCount" field selects the number of times the selected channel is converted consecutively; when enabled, the "loopCount" field defines how many consecutive channels are converted as part of the command execution. More... | |
uint32_t | loopCount |
Selects how many times this command executes before finish and transition to the next command or Idle state. More... | |
lpadc_hardware_average_mode_t | hardwareAverageMode |
Hardware average selection. More... | |
lpadc_sample_time_mode_t | sampleTimeMode |
Sample time selection. More... | |
lpadc_hardware_compare_mode_t | hardwareCompareMode |
Hardware compare selection. More... | |
uint32_t | hardwareCompareValueHigh |
Compare Value High. More... | |
uint32_t | hardwareCompareValueLow |
Compare Value Low. More... | |
lpadc_sample_scale_mode_t lpadc_conv_command_config_t::sampleScaleMode |
lpadc_sample_channel_mode_t lpadc_conv_command_config_t::sampleChannelMode |
uint32_t lpadc_conv_command_config_t::channelNumber |
uint32_t lpadc_conv_command_config_t::chainedNextCommandNumber |
1-15 is available, 0 is to terminate the chain after this command.
bool lpadc_conv_command_config_t::enableAutoChannelIncrement |
uint32_t lpadc_conv_command_config_t::loopCount |
Command executes LOOP+1 times. 0-15 is available.
lpadc_hardware_average_mode_t lpadc_conv_command_config_t::hardwareAverageMode |
lpadc_sample_time_mode_t lpadc_conv_command_config_t::sampleTimeMode |
lpadc_hardware_compare_mode_t lpadc_conv_command_config_t::hardwareCompareMode |
uint32_t lpadc_conv_command_config_t::hardwareCompareValueHigh |
The available value range is in 16-bit.
uint32_t lpadc_conv_command_config_t::hardwareCompareValueLow |
The available value range is in 16-bit.
struct lpadc_conv_trigger_config_t |
Data Fields | |
uint32_t | targetCommandId |
Select the command from command buffer to execute upon detect of the associated trigger event. More... | |
uint32_t | delayPower |
Select the trigger delay duration to wait at the start of servicing a trigger event. More... | |
uint32_t | priority |
Sets the priority of the associated trigger source. More... | |
bool | enableHardwareTrigger |
Enable hardware trigger source to initiate conversion on the rising edge of the input trigger source or not. More... | |
uint32_t lpadc_conv_trigger_config_t::targetCommandId |
uint32_t lpadc_conv_trigger_config_t::delayPower |
When this field is clear, then no delay is incurred. When this field is set to a non-zero value, the duration for the delay is 2^delayPower ADCK cycles. The available value range is 4-bit.
uint32_t lpadc_conv_trigger_config_t::priority |
If two or more triggers have the same priority level setting, the lower order trigger event has the higher priority. The lower value for this field is for the higher priority, the available value range is 1-bit.
bool lpadc_conv_trigger_config_t::enableHardwareTrigger |
THe software trigger is always available.
struct lpadc_conv_result_t |
Data Fields | |
uint32_t | commandIdSource |
Indicate the command buffer being executed that generated this result. More... | |
uint32_t | loopCountIndex |
Indicate the loop count value during command execution that generated this result. More... | |
uint32_t | triggerIdSource |
Indicate the trigger source that initiated a conversion and generated this result. More... | |
uint16_t | convValue |
Data result. More... | |
uint32_t lpadc_conv_result_t::commandIdSource |
uint32_t lpadc_conv_result_t::loopCountIndex |
uint32_t lpadc_conv_result_t::triggerIdSource |
uint16_t lpadc_conv_result_t::convValue |
#define FSL_LPADC_DRIVER_VERSION (MAKE_VERSION(2, 3, 0)) |
#define LPADC_GET_ACTIVE_COMMAND_STATUS | ( | statusVal | ) | ((statusVal & ADC_STAT_CMDACT_MASK) >> ADC_STAT_CMDACT_SHIFT) |
The statusVal is the return value from LPADC_GetStatusFlags().
#define LPADC_GET_ACTIVE_TRIGGER_STATUE | ( | statusVal | ) | ((statusVal & ADC_STAT_TRGACT_MASK) >> ADC_STAT_TRGACT_SHIFT) |
The statusVal is the return value from LPADC_GetStatusFlags().
enum _lpadc_status_flags |
The sample scale mode is used to reduce the selected ADC analog channel input voltage level by a factor. The maximum possible voltage on the ADC channel input should be considered when selecting a scale mode to ensure that the reducing factor always results voltage level at or below the VREFH reference. This reducing capability allows conversion of analog inputs higher than VREFH. A-side and B-side channel inputs are both scaled using the scale mode.
Enumerator | |
---|---|
kLPADC_SamplePartScale |
Use divided input voltage signal. (Factor of 30/64). |
kLPADC_SampleFullScale |
Full scale (Factor of 1). |
The channel sample mode configures the channel with single-end/differential/dual-single-end, side A/B.
It Selects how many ADC conversions are averaged to create the ADC result. An internal storage buffer is used to capture temporary results while the averaging iterations are executed.
The shortest sample time maximizes conversion speed for lower impedance inputs. Extending sample time allows higher impedance inputs to be accurately sampled. Longer sample times can also be used to lower overall power consumption when command looping and sequencing is configured and high conversion rates are not required.
After an ADC channel input is sampled and converted and any averaging iterations are performed, this mode setting guides operation of the automatic compare function to optionally only store when the compare operation is true. When compare is enabled, the conversion result is compared to the compare values.
Configures the ADC for power and performance. In the highest power setting the highest conversion rates will be possible. Refer to the device data sheet for power and performance capabilities for each setting.
Enumerator | |
---|---|
kLPADC_PowerLevelAlt1 |
Lowest power setting. |
kLPADC_PowerLevelAlt2 |
Next lowest power setting. |
kLPADC_PowerLevelAlt3 |
... |
kLPADC_PowerLevelAlt4 |
Highest power setting. |
This selection controls how higher priority triggers are handled.
void LPADC_Init | ( | ADC_Type * | base, |
const lpadc_config_t * | config | ||
) |
base | LPADC peripheral base address. |
config | Pointer to configuration structure. See "lpadc_config_t". |
void LPADC_GetDefaultConfig | ( | lpadc_config_t * | config | ) |
This function initializes the converter configuration structure with an available settings. The default values are:
config | Pointer to configuration structure. |
void LPADC_Deinit | ( | ADC_Type * | base | ) |
base | LPADC peripheral base address. |
|
inlinestatic |
base | LPADC peripheral base address. |
enable | switcher to the module. |
|
inlinestatic |
base | LPADC peripheral base address. |
|
inlinestatic |
Reset all ADC internal logic and registers, except the Control Register (ADCx_CTRL).
base | LPADC peripheral base address. |
|
inlinestatic |
base | LPADC peripheral base address. |
|
inlinestatic |
Only the flags can be cleared by writing ADCx_STATUS register would be cleared by this API.
base | LPADC peripheral base address. |
mask | Mask value for flags to be cleared. See to _lpadc_status_flags. |
|
inlinestatic |
base | LPADC peripheral base address. |
mask | Mask value for interrupt events. See to _lpadc_interrupt_enable. |
|
inlinestatic |
base | LPADC peripheral base address. |
mask | Mask value for interrupt events. See to _lpadc_interrupt_enable. |
|
inlinestatic |
base | LPADC peripheral base address. |
enable | Switcher to the event. |
|
inlinestatic |
base | LPADC peripheral base address. |
bool LPADC_GetConvResult | ( | ADC_Type * | base, |
lpadc_conv_result_t * | result | ||
) |
base | LPADC peripheral base address. |
result | Pointer to structure variable that keeps the conversion result in conversion FIFO. |
void LPADC_SetConvTriggerConfig | ( | ADC_Type * | base, |
uint32_t | triggerId, | ||
const lpadc_conv_trigger_config_t * | config | ||
) |
Each programmable trigger can launch the conversion command in command buffer.
base | LPADC peripheral base address. |
triggerId | ID for each trigger. Typically, the available value range is from 0. |
config | Pointer to configuration structure. See to lpadc_conv_trigger_config_t. |
void LPADC_GetDefaultConvTriggerConfig | ( | lpadc_conv_trigger_config_t * | config | ) |
This function initializes the trigger's configuration structure with an available settings. The default values are:
config | Pointer to configuration structure. |
|
inlinestatic |
base | LPADC peripheral base address. |
triggerIdMask | Mask value for software trigger indexes, which count from zero. |
void LPADC_SetConvCommandConfig | ( | ADC_Type * | base, |
uint32_t | commandId, | ||
const lpadc_conv_command_config_t * | config | ||
) |
base | LPADC peripheral base address. |
commandId | ID for command in command buffer. Typically, the available value range is 1 - 15. |
config | Pointer to configuration structure. See to lpadc_conv_command_config_t. |
void LPADC_GetDefaultConvCommandConfig | ( | lpadc_conv_command_config_t * | config | ) |
This function initializes the conversion command's configuration structure with an available settings. The default values are:
config | Pointer to configuration structure. |