MCUXpresso SDK API Reference Manual  Rev 2.12.1
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
LPADC: 12-bit SAR Analog-to-Digital Converter Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the 12-bit SAR Analog-to-Digital Converter (LPADC) module of MCUXpresso SDK devices.

Typical use case

Polling Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/lpadc

Interrupt Configuration

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...
 

Enumerations

enum  _lpadc_status_flags {
  kLPADC_ResultFIFO0OverflowFlag = ADC_STAT_FOF0_MASK,
  kLPADC_ResultFIFO0ReadyFlag = ADC_STAT_RDY0_MASK,
  kLPADC_ResultFIFO1OverflowFlag = ADC_STAT_FOF1_MASK,
  kLPADC_ResultFIFO1ReadyFlag = ADC_STAT_RDY1_MASK
}
 Define hardware flags of the module. More...
 
enum  _lpadc_interrupt_enable {
  kLPADC_ResultFIFO0OverflowInterruptEnable = ADC_IE_FOFIE0_MASK,
  kLPADC_FIFO0WatermarkInterruptEnable = ADC_IE_FWMIE0_MASK,
  kLPADC_ResultFIFO1OverflowInterruptEnable = ADC_IE_FOFIE1_MASK,
  kLPADC_FIFO1WatermarkInterruptEnable = ADC_IE_FWMIE1_MASK,
  kLPADC_TriggerExceptionInterruptEnable = ADC_IE_TEXC_IE_MASK,
  kLPADC_Trigger0CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 0UL),
  kLPADC_Trigger1CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 1UL),
  kLPADC_Trigger2CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 2UL),
  kLPADC_Trigger3CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 3UL),
  kLPADC_Trigger4CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 4UL),
  kLPADC_Trigger5CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 5UL),
  kLPADC_Trigger6CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 6UL),
  kLPADC_Trigger7CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 7UL),
  kLPADC_Trigger8CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 8UL),
  kLPADC_Trigger9CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 9UL),
  kLPADC_Trigger10CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 10UL),
  kLPADC_Trigger11CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 11UL),
  kLPADC_Trigger12CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 12UL),
  kLPADC_Trigger13CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 13UL),
  kLPADC_Trigger14CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 14UL),
  kLPADC_Trigger15CompletionInterruptEnable = ADC_IE_TCOMP_IE(1UL << 15UL)
}
 Define interrupt switchers of the module. More...
 
enum  _lpadc_trigger_status_flags {
  kLPADC_Trigger0InterruptedFlag = 1UL << 0UL,
  kLPADC_Trigger1InterruptedFlag = 1UL << 1UL,
  kLPADC_Trigger2InterruptedFlag = 1UL << 2UL,
  kLPADC_Trigger3InterruptedFlag = 1UL << 3UL,
  kLPADC_Trigger4InterruptedFlag = 1UL << 4UL,
  kLPADC_Trigger5InterruptedFlag = 1UL << 5UL,
  kLPADC_Trigger6InterruptedFlag = 1UL << 6UL,
  kLPADC_Trigger7InterruptedFlag = 1UL << 7UL,
  kLPADC_Trigger8InterruptedFlag = 1UL << 8UL,
  kLPADC_Trigger9InterruptedFlag = 1UL << 9UL,
  kLPADC_Trigger10InterruptedFlag = 1UL << 10UL,
  kLPADC_Trigger11InterruptedFlag = 1UL << 11UL,
  kLPADC_Trigger12InterruptedFlag = 1UL << 12UL,
  kLPADC_Trigger13InterruptedFlag = 1UL << 13UL,
  kLPADC_Trigger14InterruptedFlag = 1UL << 14UL,
  kLPADC_Trigger15InterruptedFlag = 1UL << 15UL,
  kLPADC_Trigger0CompletedFlag = 1UL << 16UL,
  kLPADC_Trigger1CompletedFlag = 1UL << 17UL,
  kLPADC_Trigger2CompletedFlag = 1UL << 18UL,
  kLPADC_Trigger3CompletedFlag = 1UL << 19UL,
  kLPADC_Trigger4CompletedFlag = 1UL << 20UL,
  kLPADC_Trigger5CompletedFlag = 1UL << 21UL,
  kLPADC_Trigger6CompletedFlag = 1UL << 22UL,
  kLPADC_Trigger7CompletedFlag = 1UL << 23UL,
  kLPADC_Trigger8CompletedFlag = 1UL << 24UL,
  kLPADC_Trigger9CompletedFlag = 1UL << 25UL,
  kLPADC_Trigger10CompletedFlag = 1UL << 26UL,
  kLPADC_Trigger11CompletedFlag = 1UL << 27UL,
  kLPADC_Trigger12CompletedFlag = 1UL << 28UL,
  kLPADC_Trigger13CompletedFlag = 1UL << 29UL,
  kLPADC_Trigger14CompletedFlag = 1UL << 30UL,
  kLPADC_Trigger15CompletedFlag = 1UL << 31UL
}
 The enumerator of lpadc trigger status flags, including interrupted flags and completed flags. More...
 
enum  lpadc_sample_scale_mode_t {
  kLPADC_SamplePartScale = 0U,
  kLPADC_SampleFullScale = 1U
}
 Define enumeration of sample scale mode. More...
 
enum  lpadc_sample_channel_mode_t {
  kLPADC_SampleChannelSingleEndSideA = 0U,
  kLPADC_SampleChannelSingleEndSideB = 1U,
  kLPADC_SampleChannelDiffBothSide = 2U,
  kLPADC_SampleChannelDualSingleEndBothSide
}
 Define enumeration of channel sample mode. More...
 
enum  lpadc_hardware_average_mode_t {
  kLPADC_HardwareAverageCount1 = 0U,
  kLPADC_HardwareAverageCount2 = 1U,
  kLPADC_HardwareAverageCount4 = 2U,
  kLPADC_HardwareAverageCount8 = 3U,
  kLPADC_HardwareAverageCount16 = 4U,
  kLPADC_HardwareAverageCount32 = 5U,
  kLPADC_HardwareAverageCount64 = 6U,
  kLPADC_HardwareAverageCount128 = 7U
}
 Define enumeration of hardware average selection. More...
 
enum  lpadc_sample_time_mode_t {
  kLPADC_SampleTimeADCK3 = 0U,
  kLPADC_SampleTimeADCK5 = 1U,
  kLPADC_SampleTimeADCK7 = 2U,
  kLPADC_SampleTimeADCK11 = 3U,
  kLPADC_SampleTimeADCK19 = 4U,
  kLPADC_SampleTimeADCK35 = 5U,
  kLPADC_SampleTimeADCK67 = 6U,
  kLPADC_SampleTimeADCK131 = 7U
}
 Define enumeration of sample time selection. More...
 
enum  lpadc_hardware_compare_mode_t {
  kLPADC_HardwareCompareDisabled = 0U,
  kLPADC_HardwareCompareStoreOnTrue = 2U,
  kLPADC_HardwareCompareRepeatUntilTrue = 3U
}
 Define enumeration of hardware compare mode. More...
 
enum  lpadc_conversion_resolution_mode_t {
  kLPADC_ConversionResolutionStandard = 0U,
  kLPADC_ConversionResolutionHigh = 1U
}
 Define enumeration of conversion resolution mode. More...
 
enum  lpadc_conversion_average_mode_t {
  kLPADC_ConversionAverage1 = 0U,
  kLPADC_ConversionAverage2 = 1U,
  kLPADC_ConversionAverage4 = 2U,
  kLPADC_ConversionAverage8 = 3U,
  kLPADC_ConversionAverage16 = 4U,
  kLPADC_ConversionAverage32 = 5U,
  kLPADC_ConversionAverage64 = 6U,
  kLPADC_ConversionAverage128 = 7U
}
 Define enumeration of conversion averages mode. More...
 
enum  lpadc_reference_voltage_source_t {
  kLPADC_ReferenceVoltageAlt1 = 0U,
  kLPADC_ReferenceVoltageAlt2 = 1U,
  kLPADC_ReferenceVoltageAlt3 = 2U
}
 Define enumeration of reference voltage source. More...
 
enum  lpadc_power_level_mode_t {
  kLPADC_PowerLevelAlt1 = 0U,
  kLPADC_PowerLevelAlt2 = 1U,
  kLPADC_PowerLevelAlt3 = 2U,
  kLPADC_PowerLevelAlt4 = 3U
}
 Define enumeration of power configuration. More...
 
enum  lpadc_trigger_priority_policy_t {
  kLPADC_TriggerPriorityPreemptImmediately = 0U,
  kLPADC_TriggerPriorityPreemptSoftly = 1U,
  kLPADC_TriggerPriorityPreemptSubsequently = 2U
}
 Define enumeration of trigger priority policy. More...
 

Driver version

#define FSL_LPADC_DRIVER_VERSION   (MAKE_VERSION(2, 6, 0))
 LPADC driver version 2.6.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_DoResetFIFO0 (ADC_Type *base)
 Do reset the conversion FIFO0. More...
 
static void LPADC_DoResetFIFO1 (ADC_Type *base)
 Do reset the conversion FIFO1. 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...
 
static uint32_t LPADC_GetTriggerStatusFlags (ADC_Type *base)
 Get trigger status flags to indicate which trigger sequences have been completed or interrupted by a high priority trigger exception. More...
 
static void LPADC_ClearTriggerStatusFlags (ADC_Type *base, uint32_t mask)
 Clear trigger 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_EnableFIFO0WatermarkDMA (ADC_Type *base, bool enable)
 Switch on/off the DMA trigger for FIFO0 watermark event. More...
 
static void LPADC_EnableFIFO1WatermarkDMA (ADC_Type *base, bool enable)
 Switch on/off the DMA trigger for FIFO1 watermark event. More...
 

Trigger and conversion with FIFO.

static uint32_t LPADC_GetConvResultCount (ADC_Type *base, uint8_t index)
 Get the count of result kept in conversion FIFOn. More...
 
bool LPADC_GetConvResult (ADC_Type *base, lpadc_conv_result_t *result, uint8_t index)
 brief Get the result in conversion FIFOn. 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...
 
static void LPADC_SetOffsetValue (ADC_Type *base, uint32_t valueA, uint32_t valueB)
 Set proper offset value to trim ADC. More...
 
static void LPADC_EnableOffsetCalibration (ADC_Type *base, bool enable)
 Enable the offset calibration function. More...
 
void LPADC_DoOffsetCalibration (ADC_Type *base)
 Do offset calibration. More...
 
void LPADC_DoAutoCalibration (ADC_Type *base)
 Do auto calibration. More...
 
void LPADC_PrepareAutoCalibration (ADC_Type *base)
 Prepare auto calibration, LPADC_FinishAutoCalibration has to be called before using the LPADC. More...
 
void LPADC_FinishAutoCalibration (ADC_Type *base)
 Finish auto calibration start with LPADC_PrepareAutoCalibration. More...
 

Data Structure Documentation

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...
 
lpadc_conversion_average_mode_t conversionAverageMode
 Auto-Calibration Averages. 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_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 FIFO0Watermark
 FIFO0Watermark is a programmable threshold setting. More...
 
uint32_t FIFO1Watermark
 FIFO1Watermark is a programmable threshold setting. More...
 

Field Documentation

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.

lpadc_conversion_average_mode_t lpadc_config_t::conversionAverageMode
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::FIFO0Watermark

When the number of datawords stored in the ADC Result FIFO0 is greater than the value in this field, the ready flag would be asserted to indicate stored data has reached the programmable threshold.

uint32_t lpadc_config_t::FIFO1Watermark

When the number of datawords stored in the ADC Result FIFO1 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_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_conversion_resolution_mode_t conversionResolutionMode
 Conversion resolution mode. More...
 
bool enableWaitTrigger
 Wait for trigger assertion before execution: when disabled, this command will be automatically executed; when enabled, the active trigger must be asserted again before executing this command. More...
 

Field Documentation

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.

lpadc_conversion_resolution_mode_t lpadc_conv_command_config_t::conversionResolutionMode
bool lpadc_conv_command_config_t::enableWaitTrigger
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...
 

Field Documentation

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...
 

Field Documentation

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

Macro Definition Documentation

#define FSL_LPADC_DRIVER_VERSION   (MAKE_VERSION(2, 6, 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().

Enumeration Type Documentation

Enumerator
kLPADC_ResultFIFO0OverflowFlag 

Indicates that more data has been written to the Result FIFO 0 than it can hold.

kLPADC_ResultFIFO0ReadyFlag 

Indicates when the number of valid datawords in the result FIFO 0 is greater than the setting watermark level.

kLPADC_ResultFIFO1OverflowFlag 

Indicates that more data has been written to the Result FIFO 1 than it can hold.

kLPADC_ResultFIFO1ReadyFlag 

Indicates when the number of valid datawords in the result FIFO 1 is greater than the setting watermark level.

Enumerator
kLPADC_ResultFIFO0OverflowInterruptEnable 

Configures ADC to generate overflow interrupt requests when FOF0 flag is asserted.

kLPADC_FIFO0WatermarkInterruptEnable 

Configures ADC to generate watermark interrupt requests when RDY0 flag is asserted.

kLPADC_ResultFIFO1OverflowInterruptEnable 

Configures ADC to generate overflow interrupt requests when FOF1 flag is asserted.

kLPADC_FIFO1WatermarkInterruptEnable 

Configures ADC to generate watermark interrupt requests when RDY1 flag is asserted.

kLPADC_TriggerExceptionInterruptEnable 

Configures ADC to generate trigger exception interrupt.

kLPADC_Trigger0CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 0 completion.

kLPADC_Trigger1CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 1 completion.

kLPADC_Trigger2CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 2 completion.

kLPADC_Trigger3CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 3 completion.

kLPADC_Trigger4CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 4 completion.

kLPADC_Trigger5CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 5 completion.

kLPADC_Trigger6CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 6 completion.

kLPADC_Trigger7CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 7 completion.

kLPADC_Trigger8CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 8 completion.

kLPADC_Trigger9CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 9 completion.

kLPADC_Trigger10CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 10 completion.

kLPADC_Trigger11CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 11 completion.

kLPADC_Trigger12CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 12 completion.

kLPADC_Trigger13CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 13 completion.

kLPADC_Trigger14CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 14 completion.

kLPADC_Trigger15CompletionInterruptEnable 

Configures ADC to generate interrupt when trigger 15 completion.

Enumerator
kLPADC_Trigger0InterruptedFlag 

Trigger 0 is interrupted by a high priority exception.

kLPADC_Trigger1InterruptedFlag 

Trigger 1 is interrupted by a high priority exception.

kLPADC_Trigger2InterruptedFlag 

Trigger 2 is interrupted by a high priority exception.

kLPADC_Trigger3InterruptedFlag 

Trigger 3 is interrupted by a high priority exception.

kLPADC_Trigger4InterruptedFlag 

Trigger 4 is interrupted by a high priority exception.

kLPADC_Trigger5InterruptedFlag 

Trigger 5 is interrupted by a high priority exception.

kLPADC_Trigger6InterruptedFlag 

Trigger 6 is interrupted by a high priority exception.

kLPADC_Trigger7InterruptedFlag 

Trigger 7 is interrupted by a high priority exception.

kLPADC_Trigger8InterruptedFlag 

Trigger 8 is interrupted by a high priority exception.

kLPADC_Trigger9InterruptedFlag 

Trigger 9 is interrupted by a high priority exception.

kLPADC_Trigger10InterruptedFlag 

Trigger 10 is interrupted by a high priority exception.

kLPADC_Trigger11InterruptedFlag 

Trigger 11 is interrupted by a high priority exception.

kLPADC_Trigger12InterruptedFlag 

Trigger 12 is interrupted by a high priority exception.

kLPADC_Trigger13InterruptedFlag 

Trigger 13 is interrupted by a high priority exception.

kLPADC_Trigger14InterruptedFlag 

Trigger 14 is interrupted by a high priority exception.

kLPADC_Trigger15InterruptedFlag 

Trigger 15 is interrupted by a high priority exception.

kLPADC_Trigger0CompletedFlag 

Trigger 0 is completed and trigger 0 has enabled completion interrupts.

kLPADC_Trigger1CompletedFlag 

Trigger 1 is completed and trigger 1 has enabled completion interrupts.

kLPADC_Trigger2CompletedFlag 

Trigger 2 is completed and trigger 2 has enabled completion interrupts.

kLPADC_Trigger3CompletedFlag 

Trigger 3 is completed and trigger 3 has enabled completion interrupts.

kLPADC_Trigger4CompletedFlag 

Trigger 4 is completed and trigger 4 has enabled completion interrupts.

kLPADC_Trigger5CompletedFlag 

Trigger 5 is completed and trigger 5 has enabled completion interrupts.

kLPADC_Trigger6CompletedFlag 

Trigger 6 is completed and trigger 6 has enabled completion interrupts.

kLPADC_Trigger7CompletedFlag 

Trigger 7 is completed and trigger 7 has enabled completion interrupts.

kLPADC_Trigger8CompletedFlag 

Trigger 8 is completed and trigger 8 has enabled completion interrupts.

kLPADC_Trigger9CompletedFlag 

Trigger 9 is completed and trigger 9 has enabled completion interrupts.

kLPADC_Trigger10CompletedFlag 

Trigger 10 is completed and trigger 10 has enabled completion interrupts.

kLPADC_Trigger11CompletedFlag 

Trigger 11 is completed and trigger 11 has enabled completion interrupts.

kLPADC_Trigger12CompletedFlag 

Trigger 12 is completed and trigger 12 has enabled completion interrupts.

kLPADC_Trigger13CompletedFlag 

Trigger 13 is completed and trigger 13 has enabled completion interrupts.

kLPADC_Trigger14CompletedFlag 

Trigger 14 is completed and trigger 14 has enabled completion interrupts.

kLPADC_Trigger15CompletedFlag 

Trigger 15 is completed and trigger 15 has enabled completion interrupts.

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.

Enumerator
kLPADC_SampleChannelSingleEndSideA 

Single end mode, using side A.

kLPADC_SampleChannelSingleEndSideB 

Single end mode, using side B.

kLPADC_SampleChannelDiffBothSide 

Differential mode, using A and B.

kLPADC_SampleChannelDualSingleEndBothSide 

Dual-Single-Ended Mode.

Both A side and B side channels are converted independently.

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.

Enumerator
kLPADC_HardwareAverageCount1 

Single conversion.

kLPADC_HardwareAverageCount2 

2 conversions averaged.

kLPADC_HardwareAverageCount4 

4 conversions averaged.

kLPADC_HardwareAverageCount8 

8 conversions averaged.

kLPADC_HardwareAverageCount16 

16 conversions averaged.

kLPADC_HardwareAverageCount32 

32 conversions averaged.

kLPADC_HardwareAverageCount64 

64 conversions averaged.

kLPADC_HardwareAverageCount128 

128 conversions averaged.

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.

Enumerator
kLPADC_SampleTimeADCK3 

3 ADCK cycles total sample time.

kLPADC_SampleTimeADCK5 

5 ADCK cycles total sample time.

kLPADC_SampleTimeADCK7 

7 ADCK cycles total sample time.

kLPADC_SampleTimeADCK11 

11 ADCK cycles total sample time.

kLPADC_SampleTimeADCK19 

19 ADCK cycles total sample time.

kLPADC_SampleTimeADCK35 

35 ADCK cycles total sample time.

kLPADC_SampleTimeADCK67 

69 ADCK cycles total sample time.

kLPADC_SampleTimeADCK131 

131 ADCK cycles total sample time.

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.

Enumerator
kLPADC_HardwareCompareDisabled 

Compare disabled.

kLPADC_HardwareCompareStoreOnTrue 

Compare enabled.

Store on true.

kLPADC_HardwareCompareRepeatUntilTrue 

Compare enabled.

Repeat channel acquisition until true.

Configure the resolution bit in specific conversion type. For detailed resolution accuracy, see to lpadc_sample_channel_mode_t

Enumerator
kLPADC_ConversionResolutionStandard 

Standard resolution.

Single-ended 12-bit conversion, Differential 13-bit conversion with 2’s complement output.

kLPADC_ConversionResolutionHigh 

High resolution.

Single-ended 16-bit conversion; Differential 16-bit conversion with 2’s complement output.

Configure the converion average number for auto-calibration.

Enumerator
kLPADC_ConversionAverage1 

Single conversion.

kLPADC_ConversionAverage2 

2 conversions averaged.

kLPADC_ConversionAverage4 

4 conversions averaged.

kLPADC_ConversionAverage8 

8 conversions averaged.

kLPADC_ConversionAverage16 

16 conversions averaged.

kLPADC_ConversionAverage32 

32 conversions averaged.

kLPADC_ConversionAverage64 

64 conversions averaged.

kLPADC_ConversionAverage128 

128 conversions averaged.

For detail information, need to check the SoC's specification.

Enumerator
kLPADC_ReferenceVoltageAlt1 

Option 1 setting.

kLPADC_ReferenceVoltageAlt2 

Option 2 setting.

kLPADC_ReferenceVoltageAlt3 

Option 3 setting.

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.

Enumerator
kLPADC_TriggerPriorityPreemptImmediately 

If a higher priority trigger is detected during command processing, the current conversion is aborted and the new command specified by the trigger is started.

kLPADC_TriggerPriorityPreemptSoftly 

If a higher priority trigger is received during command processing, the current conversion is completed (including averaging iterations and compare function if enabled) and stored to the result FIFO before the higher priority trigger/command is initiated.

kLPADC_TriggerPriorityPreemptSubsequently 

If a higher priority trigger is received during command processing, the current command will be completed (averaging, looping, compare) before servicing the higher priority trigger.

Function Documentation

void LPADC_Init ( ADC_Type *  base,
const lpadc_config_t config 
)
Parameters
baseLPADC peripheral base address.
configPointer 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->enableInDozeMode = true;
* config->enableAnalogPreliminary = false;
* config->powerUpDelay = 0x80;
* config->referenceVoltageSource = kLPADC_ReferenceVoltageAlt1;
* config->powerLevelMode = kLPADC_PowerLevelAlt1;
* config->triggerPriorityPolicy = kLPADC_TriggerPriorityPreemptImmediately;
* config->enableConvPause = false;
* config->convPauseDelay = 0U;
* config->FIFOWatermark = 0U;
*
Parameters
configPointer to configuration structure.
void LPADC_Deinit ( ADC_Type *  base)
Parameters
baseLPADC peripheral base address.
static void LPADC_Enable ( ADC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
enableswitcher to the module.
static void LPADC_DoResetFIFO0 ( ADC_Type *  base)
inlinestatic
Parameters
baseLPADC peripheral base address.
static void LPADC_DoResetFIFO1 ( ADC_Type *  base)
inlinestatic
Parameters
baseLPADC peripheral base address.
static void LPADC_DoResetConfig ( ADC_Type *  base)
inlinestatic

Reset all ADC internal logic and registers, except the Control Register (ADCx_CTRL).

Parameters
baseLPADC peripheral base address.
static uint32_t LPADC_GetStatusFlags ( ADC_Type *  base)
inlinestatic
Parameters
baseLPADC peripheral base address.
Returns
status flags' mask. See to _lpadc_status_flags.
static void LPADC_ClearStatusFlags ( ADC_Type *  base,
uint32_t  mask 
)
inlinestatic

Only the flags can be cleared by writing ADCx_STATUS register would be cleared by this API.

Parameters
baseLPADC peripheral base address.
maskMask value for flags to be cleared. See to _lpadc_status_flags.
static uint32_t LPADC_GetTriggerStatusFlags ( ADC_Type *  base)
inlinestatic
Parameters
baseLPADC peripheral base address.
Returns
The OR'ed value of _lpadc_trigger_status_flags.
static void LPADC_ClearTriggerStatusFlags ( ADC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
maskThe mask of trigger status flags to be cleared, should be the OR'ed value of _lpadc_trigger_status_flags.
static void LPADC_EnableInterrupts ( ADC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
maskMask value for interrupt events. See to _lpadc_interrupt_enable.
static void LPADC_DisableInterrupts ( ADC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
maskMask value for interrupt events. See to _lpadc_interrupt_enable.
static void LPADC_EnableFIFO0WatermarkDMA ( ADC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
enableSwitcher to the event.
static void LPADC_EnableFIFO1WatermarkDMA ( ADC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
enableSwitcher to the event.
static uint32_t LPADC_GetConvResultCount ( ADC_Type *  base,
uint8_t  index 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
indexResult FIFO index.
Returns
The count of result kept in conversion FIFOn.
bool LPADC_GetConvResult ( ADC_Type *  base,
lpadc_conv_result_t result,
uint8_t  index 
)

param base LPADC peripheral base address. param result Pointer to structure variable that keeps the conversion result in conversion FIFOn. param index Result FIFO index.

return Status whether FIFOn entry is valid.

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.

Parameters
baseLPADC peripheral base address.
triggerIdID for each trigger. Typically, the available value range is from 0.
configPointer 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->commandIdSource = 0U;
* config->loopCountIndex = 0U;
* config->triggerIdSource = 0U;
* config->enableHardwareTrigger = false;
*
Parameters
configPointer to configuration structure.
static void LPADC_DoSoftwareTrigger ( ADC_Type *  base,
uint32_t  triggerIdMask 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
triggerIdMaskMask 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 
)
Parameters
baseLPADC peripheral base address.
commandIdID for command in command buffer. Typically, the available value range is 1 - 15.
configPointer 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->sampleScaleMode = kLPADC_SampleFullScale;
* config->channelSampleMode = kLPADC_SampleChannelSingleEndSideA;
* config->channelNumber = 0U;
* config->chainedNextCmdNumber = 0U;
* config->enableAutoChannelIncrement = false;
* config->loopCount = 0U;
* config->hardwareAverageMode = kLPADC_HardwareAverageCount1;
* config->sampleTimeMode = kLPADC_SampleTimeADCK3;
* config->hardwareCompareMode = kLPADC_HardwareCompareDisabled;
* config->hardwareCompareValueHigh = 0U;
* config->hardwareCompareValueLow = 0U;
* config->conversionResolutionMode = kLPADC_ConversionResolutionStandard;
* config->enableWaitTrigger = false;
*
Parameters
configPointer to configuration structure.
static void LPADC_SetOffsetValue ( ADC_Type *  base,
uint32_t  valueA,
uint32_t  valueB 
)
inlinestatic

Set the offset trim value for offset calibration manually.

Parameters
baseLPADC peripheral base address.
valueASetting offset value A.
valueBSetting offset value B.
Note
In normal adc sequence, the values are automatically calculated by LPADC_EnableOffsetCalibration.
static void LPADC_EnableOffsetCalibration ( ADC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseLPADC peripheral base address.
enableswitcher to the calibration function.
void LPADC_DoOffsetCalibration ( ADC_Type *  base)
Parameters
baseLPADC peripheral base address.
void LPADC_DoAutoCalibration ( ADC_Type *  base)
Parameters
baseLPADC peripheral base address.
void LPADC_PrepareAutoCalibration ( ADC_Type *  base)

LPADC_DoAutoCalibration has been split in two API to avoid to be stuck too long in the function.

Parameters
baseLPADC peripheral base address.
void LPADC_FinishAutoCalibration ( ADC_Type *  base)
Parameters
baseLPADC peripheral base address.