MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
HSADC: 12-bit 5MSPS Analog-to-Digital Converter

Overview

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

Modules

 HSADC Peripheral driver
 

Data Structures

struct  hsadc_config_t
 Defines the structure for configuring the HSADC's common setting. More...
 
struct  hsadc_converter_config_t
 Defines the structure for configuring each converter. More...
 
struct  hsadc_sample_config_t
 Defines the structure for configuring the sample slot. More...
 

Macros

#define FSL_HSADC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 HSADC driver version. More...
 
#define HSADC_SAMPLE_MASK(index)   (1U << (index))
 Converter index to mask for sample slot. More...
 
#define HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_MASK   HSADC_CALVAL_A_CALVSING_MASK
 Bit mask of calibration value for converter A in single ended mode. More...
 
#define HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_SHIFT   HSADC_CALVAL_A_CALVSING_SHIFT
 Bit shift of calibration value for converter A in single ended mode. More...
 
#define HSADC_CALIBRATION_VALUE_A_DIFFERENTIAL_MASK   HSADC_CALVAL_A_CALVDIF_MASK
 Bit mask of calibration value for converter A in differential mode. More...
 
#define HSADC_CALIBRATION_VALUE_A_DIFFERENTIAL_SHIFT   HSADC_CALVAL_A_CALVDIF_SHIFT
 Bit shift of calibration value for converter A in differential mode. More...
 
#define HSADC_CALIBRATION_VALUE_B_SINGLE_ENDED_MASK   (HSADC_CALVAL_B_CALVSING_MASK << 16U)
 Bit mask of calibration value for converter B in single ended mode. More...
 
#define HSADC_CALIBRATION_VALUE_B_SINGLE_ENDED_SHIFT   (HSADC_CALVAL_B_CALVSING_SHIFT + 16U)
 Bit shift of calibration value for converter B in single ended mode. More...
 
#define HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_MASK   (HSADC_CALVAL_B_CALVDIF_MASK << 16U)
 Bit mask of calibration value for converter B in differential mode. More...
 
#define HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_SHIFT   (HSADC_CALVAL_B_CALVDIF_SHIFT + 16U)
 Bit shift of calibration value for converter B in differential mode. More...
 

Enumerations

enum  _hsadc_status_flags {
  kHSADC_ZeroCrossingFlag = (1U << 0U),
  kHSADC_HighLimitFlag = (1U << 1U),
  kHSADC_LowLimitFlag = (1U << 2U),
  kHSADC_ConverterAEndOfScanFlag = (1U << 3U),
  kHSADC_ConverterBEndOfScanFlag = (1U << 4U),
  kHSADC_ConverterAEndOfCalibrationFlag = (1U << 5U),
  kHSADC_ConverterBEndOfCalibrationFlag = (1U << 6U),
  kHSADC_ConverterAConvertingFlag = (1U << 7U),
  kHSADC_ConverterBConvertingFlag = (1U << 8U),
  kHSADC_ConverterADummyConvertingFlag = (1U << 9U),
  kHSADC_ConverterBDummyConvertingFlag = (1U << 10U),
  kHSADC_ConverterACalibratingFlag = (1U << 11U),
  kHSADC_ConverterBCalibratingFlag = (1U << 12U),
  kHSADC_ConverterAPowerDownFlag = (1U << 13U),
  kHSADC_ConverterBPowerDownFlag = (1U << 14U)
}
 HSADC status flags. More...
 
enum  _hsadc_interrupt_enable {
  kHSADC_ZeroCrossingInterruptEnable = (1U << 0U),
  kHSADC_HighLimitInterruptEnable = (1U << 1U),
  kHSADC_LowLimitInterruptEnable = (1U << 2U),
  kHSADC_ConverterAEndOfScanInterruptEnable = (1U << 3U),
  kHSADC_ConverterBEndOfScanInterruptEnable = (1U << 4U),
  kHSADC_ConverterAEndOfCalibrationInterruptEnable = (1U << 5U),
  kHSADC_ConverterBEndOfCalibrationInterruptEnable = (1U << 6U)
}
 HSADC Interrupts. More...
 
enum  _hsadc_converter_id {
  kHSADC_ConverterA = (1U << 0U),
  kHSADC_ConverterB = (1U << 1U)
}
 HSADC Converter identifier. More...
 
enum  hsadc_dual_converter_scan_mode_t {
  kHSADC_DualConverterWorkAsOnceSequential = 0U,
  kHSADC_DualConverterWorkAsOnceParallel = 1U,
  kHSADC_DualConverterWorkAsLoopSequential = 2U,
  kHSADC_DualConverterWorkAsLoopParallel = 3U,
  kHSADC_DualConverterWorkAsTriggeredSequential = 4U,
  kHSADC_DualConverterWorkAsTriggeredParallel = 5U
}
 Defines the enumeration for dual converter scan mode. More...
 
enum  hsadc_resolution_t {
  kHSADC_Resolution6Bit = 0U,
  kHSADC_Resolution8Bit = 1U,
  kHSADC_Resolution10Bit = 2U,
  kHSADC_Resolution12Bit = 3U
}
 
enum  hsadc_dma_trigger_source_t {
  kHSADC_DMATriggerSourceAsEndOfScan = 0U,
  kHSADC_DMATriggerSourceAsSampleReady = 1U
}
 Defines the enumeration for the DMA trigger source. More...
 
enum  hsadc_zero_crossing_mode_t {
  kHSADC_ZeroCorssingDisabled = 0U,
  kHSADC_ZeroCorssingForPtoNSign = 1U,
  kHSADC_ZeroCorssingForNtoPSign = 2U,
  kHSADC_ZeroCorssingForAnySignChanged = 3U
}
 Defines the enumeration for the sample slot's zero crossing event. More...
 
enum  hsadc_idle_work_mode_t {
  kHSADC_IdleKeepNormal = 0U,
  kHSADC_IdleAutoStandby = 1U,
  kHSADC_IdleAutoPowerDown = 2U
}
 Defines the enumeration for the converter's work mode in idle mode. More...
 
enum  _hsadc_calibration_mode {
  kHSADC_CalibrationModeDifferential = (1U << 0U),
  kHSADC_CalibrationModeSingleEnded = (1U << 1U)
}
 Converter's calibration mode. More...
 

HSADC Initialization and deinitialization.

void HSADC_Init (HSADC_Type *base, const hsadc_config_t *config)
 Initializes the HSADC module. More...
 
void HSADC_GetDefaultConfig (hsadc_config_t *config)
 Gets an available pre-defined settings for module's configuration. More...
 
void HSADC_Deinit (HSADC_Type *base)
 De-initializes the HSADC module. More...
 

Converter.

void HSADC_SetConverterConfig (HSADC_Type *base, uint16_t converterMask, const hsadc_converter_config_t *config)
 Configures the converter. More...
 
void HSADC_GetDefaultConverterConfig (hsadc_converter_config_t *config)
 Gets an available pre-defined settings for each converter's configuration. More...
 
void HSADC_EnableConverter (HSADC_Type *base, uint16_t converterMask, bool enable)
 Enables the converter's conversion. More...
 
void HSADC_EnableConverterSyncInput (HSADC_Type *base, uint16_t converterMask, bool enable)
 Enables the input of an external sync signal. More...
 
void HSADC_EnableConverterPower (HSADC_Type *base, uint16_t converterMask, bool enable)
 Enables power for the converter. More...
 
void HSADC_DoSoftwareTriggerConverter (HSADC_Type *base, uint16_t converterMask)
 Triggers the converter by using the software trigger. More...
 
void HSADC_EnableConverterDMA (HSADC_Type *base, uint16_t converterMask, bool enable)
 Enables the DMA feature. More...
 
void HSADC_EnableInterrupts (HSADC_Type *base, uint16_t mask)
 Enables the interrupts. More...
 
void HSADC_DisableInterrupts (HSADC_Type *base, uint16_t mask)
 Disables the interrupts. More...
 
uint16_t HSADC_GetStatusFlags (HSADC_Type *base)
 Gets the status flags. More...
 
void HSADC_ClearStatusFlags (HSADC_Type *base, uint16_t mask)
 Clears the status flags. More...
 

Sample.

void HSADC_SetSampleConfig (HSADC_Type *base, uint16_t sampleIndex, const hsadc_sample_config_t *config)
 Configures the sample slot. More...
 
void HSADC_GetDefaultSampleConfig (hsadc_sample_config_t *config)
 Gets the default sample configuration. More...
 
static void HSADC_EnableSample (HSADC_Type *base, uint16_t sampleMask, bool enable)
 Enables the sample slot. More...
 
static void HSADC_EnableSampleResultReadyInterrupts (HSADC_Type *base, uint16_t sampleMask, bool enable)
 Enables the interrupt for each sample slot when its result is ready. More...
 
static uint16_t HSADC_GetSampleReadyStatusFlags (HSADC_Type *base)
 Returns the sample ready flags of sample slots. More...
 
static uint16_t HSADC_GetSampleLowLimitStatusFlags (HSADC_Type *base)
 Gets the low-limit flags of sample slots. More...
 
static void HSADC_ClearSampleLowLimitStatusFlags (HSADC_Type *base, uint16_t sampleMask)
 Clears low-limit flags of sample slots. More...
 
static uint16_t HSADC_GetSampleHighLimitStatusFlags (HSADC_Type *base)
 Gets the high-limit flags of sample slots. More...
 
static void HSADC_ClearSampleHighLimitStatusFlags (HSADC_Type *base, uint16_t sampleMask)
 Clears high-limit flags of sample slots. More...
 
static uint16_t HSADC_GetSampleZeroCrossingStatusFlags (HSADC_Type *base)
 Gets the zero crossing flags of sample slots. More...
 
static void HSADC_ClearSampleZeroCrossingStatusFlags (HSADC_Type *base, uint16_t sampleMask)
 Clears zero crossing flags of sample slots. More...
 
static uint16_t HSADC_GetSampleResultValue (HSADC_Type *base, uint16_t sampleIndex)
 Gets the sample result value. More...
 

Calibration.

void HSADC_DoAutoCalibration (HSADC_Type *base, uint16_t converterMask, uint16_t calibrationModeMask)
 Starts the hardware calibration. More...
 
uint32_t HSADC_GetCalibrationResultValue (HSADC_Type *base)
 Gets the calibration result value. More...
 
void HSADC_EnableCalibrationResultValue (HSADC_Type *base, uint16_t converterMask, bool enable)
 Enables or disables the calibration result value. More...
 

Data Structure Documentation

struct hsadc_config_t

Data Fields

hsadc_dual_converter_scan_mode_t dualConverterScanMode
 Dual converter's scan mode. More...
 
bool enableSimultaneousMode
 Using Simultaneous mode. More...
 
hsadc_resolution_t resolution
 Resolution mode. More...
 
hsadc_dma_trigger_source_t DMATriggerSoruce
 DMA trigger source. More...
 
hsadc_idle_work_mode_t idleWorkMode
 Converter's work mode when idle. More...
 
uint16_t powerUpDelayCount
 Delay count united as 32 clocks to wait for the clock to be stable. More...
 

Field Documentation

hsadc_dual_converter_scan_mode_t hsadc_config_t::dualConverterScanMode
bool hsadc_config_t::enableSimultaneousMode
hsadc_resolution_t hsadc_config_t::resolution
hsadc_dma_trigger_source_t hsadc_config_t::DMATriggerSoruce
hsadc_idle_work_mode_t hsadc_config_t::idleWorkMode
uint16_t hsadc_config_t::powerUpDelayCount

Available range is 0-63.

struct hsadc_converter_config_t

Data Fields

uint16_t clockDivisor
 Converter's clock divisor for the clock source. More...
 
uint16_t samplingTimeCount
 Sampling time count. More...
 
uint16_t powerUpCalibrationModeMask
 Calibration mode mask in the power up period. More...
 

Field Documentation

uint16_t hsadc_converter_config_t::clockDivisor

Available range is 2-64.

uint16_t hsadc_converter_config_t::samplingTimeCount

The resultant sampling time is (1.5 + samplingTimeCount) x clock period. Available range is 0-255.

uint16_t hsadc_converter_config_t::powerUpCalibrationModeMask

See the "_hsadc_calibration_mode". If this field isn't zero, call the function HSADC_GetStatusFlags() to check whether the End of Calibration flag is set to wait for sthe calibration process to complete. If this is zero, it indicates no calibration is executed in power up period.

struct hsadc_sample_config_t

channelNumber, channel67MuxNumber, and enableDifferentialPair have following relationship: channelNumber equals 0~7 represents channel 0~7 of converter A. channelNumber equals 8~15 represents channel 0~7 of converter B. 1) When channelNumber = 6 and enableDifferentialPair = false, channel67MuxNumber represents converter A's channel 6's sub multiplex channel number. 2) When channelNumber = 6 and enableDifferentialPair = true, channel67MuxNumber represents converter A's channel 6 and channel 7's sub multiplex channel number. 3) When channelNumber = 7 and enableDifferentialPair = false, channel67MuxNumber represents converter A's channel 7's sub multiplex channel number. 4) When channelNumber = 7 and enableDifferentialPair = true, channel67MuxNumber represents converter A's channel 6 and channel 7's sub multiplex channel number. 5) When channelNumber = 14 and enableDifferentialPair = false, channel67MuxNumber represents converter B's channel 6's sub multiplex channel number. 6) When channelNumber = 14 and enableDifferentialPair = true, channel67MuxNumber represents converter B's channel 6 and channel 7's sub multiplex channel number. 7) When channelNumber = 15 and enableDifferentialPair = false, channel67MuxNumber represents converter B's channel 7's sub multiplex channel number. 8) When channelNumber = 15 and enableDifferentialPair = true, channel67MuxNumber represents converter B's channel 6 and channel 7's sub multiplex channel number. 9) In other cases, channel67MuxNumber won't be functional.

Data Fields

uint16_t channelNumber
 Channel number. More...
 
uint16_t channel67MuxNumber
 Channel 6/7's sub multiplex channel number. More...
 
bool enableDifferentialPair
 Use differential sample input or not. More...
 
hsadc_zero_crossing_mode_t zeroCrossingMode
 Zero crossing mode. More...
 
uint16_t highLimitValue
 High-limit value. More...
 
uint16_t lowLimitValue
 Low-limit value. More...
 
uint16_t offsetValue
 Offset value. More...
 
bool enableWaitSync
 Wait for sync input to launch this sample's conversion or not. More...
 

Field Documentation

uint16_t hsadc_sample_config_t::channelNumber

Available range is 0-15.

uint16_t hsadc_sample_config_t::channel67MuxNumber

When channelNumber = 6 or 14, its available range is 0~6. When channelNumber = 7 or 15, its available range is 0~5.

bool hsadc_sample_config_t::enableDifferentialPair

In differential mode, the sub multiplex channel number of channel 6 and channel 7 must be configured to be same.

hsadc_zero_crossing_mode_t hsadc_sample_config_t::zeroCrossingMode
uint16_t hsadc_sample_config_t::highLimitValue

Original value format as hardware register, with 3-bits left shifted.

uint16_t hsadc_sample_config_t::lowLimitValue

Original value format as hardware register, with 3-bits left shifted.

uint16_t hsadc_sample_config_t::offsetValue

Original value format as hardware register, with 3-bits left shifted.

bool hsadc_sample_config_t::enableWaitSync

Macro Definition Documentation

#define FSL_HSADC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
#define HSADC_SAMPLE_MASK (   index)    (1U << (index))
#define HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_MASK   HSADC_CALVAL_A_CALVSING_MASK
#define HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_SHIFT   HSADC_CALVAL_A_CALVSING_SHIFT
#define HSADC_CALIBRATION_VALUE_A_DIFFERENTIAL_MASK   HSADC_CALVAL_A_CALVDIF_MASK
#define HSADC_CALIBRATION_VALUE_A_DIFFERENTIAL_SHIFT   HSADC_CALVAL_A_CALVDIF_SHIFT
#define HSADC_CALIBRATION_VALUE_B_SINGLE_ENDED_MASK   (HSADC_CALVAL_B_CALVSING_MASK << 16U)
#define HSADC_CALIBRATION_VALUE_B_SINGLE_ENDED_SHIFT   (HSADC_CALVAL_B_CALVSING_SHIFT + 16U)
#define HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_MASK   (HSADC_CALVAL_B_CALVDIF_MASK << 16U)
#define HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_SHIFT   (HSADC_CALVAL_B_CALVDIF_SHIFT + 16U)

Enumeration Type Documentation

Enumerator
kHSADC_ZeroCrossingFlag 

Zero crossing.

kHSADC_HighLimitFlag 

High-limit.

kHSADC_LowLimitFlag 

Low-limit.

kHSADC_ConverterAEndOfScanFlag 

End of Scan, converter A.

kHSADC_ConverterBEndOfScanFlag 

End of Scan, converter B.

kHSADC_ConverterAEndOfCalibrationFlag 

End of Calibration, converter A.

kHSADC_ConverterBEndOfCalibrationFlag 

End of Calibration, converter B.

kHSADC_ConverterAConvertingFlag 

Conversion in progress, converter A.

kHSADC_ConverterBConvertingFlag 

Conversion in progress, converter B.

kHSADC_ConverterADummyConvertingFlag 

Dummy conversion in progress, converter A.

kHSADC_ConverterBDummyConvertingFlag 

Dummy conversion in progress, converter B.

kHSADC_ConverterACalibratingFlag 

Calibration in progress, converter A.

kHSADC_ConverterBCalibratingFlag 

Calibration in progress, converter B.

kHSADC_ConverterAPowerDownFlag 

The converter is powered down, converter A.

kHSADC_ConverterBPowerDownFlag 

The converter is powered down, converter B.

Enumerator
kHSADC_ZeroCrossingInterruptEnable 

Zero crossing interrupt.

kHSADC_HighLimitInterruptEnable 

High-limit interrupt.

kHSADC_LowLimitInterruptEnable 

Low-limit interrupt.

kHSADC_ConverterAEndOfScanInterruptEnable 

End of Scan interrupt, converter A.

kHSADC_ConverterBEndOfScanInterruptEnable 

End of Scan interrupt, converter B.

kHSADC_ConverterAEndOfCalibrationInterruptEnable 

End of Calibration, converter A.

kHSADC_ConverterBEndOfCalibrationInterruptEnable 

End of Calibration, converter B.

Enumerator
kHSADC_ConverterA 

Converter A.

kHSADC_ConverterB 

Converter B.

Enumerator
kHSADC_DualConverterWorkAsOnceSequential 

Once (single) sequential.

kHSADC_DualConverterWorkAsOnceParallel 

Once parallel.

kHSADC_DualConverterWorkAsLoopSequential 

Loop sequential.

kHSADC_DualConverterWorkAsLoopParallel 

Loop parallel.

kHSADC_DualConverterWorkAsTriggeredSequential 

Triggered sequential.

kHSADC_DualConverterWorkAsTriggeredParallel 

Triggered parallel.

Enumerator
kHSADC_Resolution6Bit 

6 bit resolution mode.

kHSADC_Resolution8Bit 

8 bit resolution mode.

kHSADC_Resolution10Bit 

10 bit resolution mode.

kHSADC_Resolution12Bit 

12 bit resolution mode.

Enumerator
kHSADC_DMATriggerSourceAsEndOfScan 

DMA trigger source is end of scan interrupt.

kHSADC_DMATriggerSourceAsSampleReady 

DMA trigger source is RDY bits.

Enumerator
kHSADC_ZeroCorssingDisabled 

Zero Crossing disabled.

kHSADC_ZeroCorssingForPtoNSign 

Zero Crossing enabled for positive to negative sign change.

kHSADC_ZeroCorssingForNtoPSign 

Zero Crossing enabled for negative to positive sign change.

kHSADC_ZeroCorssingForAnySignChanged 

Zero Crossing enabled for any sign change.

Enumerator
kHSADC_IdleKeepNormal 

Keep normal.

kHSADC_IdleAutoStandby 

Fall into standby mode automatically.

kHSADC_IdleAutoPowerDown 

Fall into power down mode automatically.

Enumerator
kHSADC_CalibrationModeDifferential 

Calibration request for differential mode.

kHSADC_CalibrationModeSingleEnded 

Calibration request for single ended mode.

Function Documentation

void HSADC_Init ( HSADC_Type *  base,
const hsadc_config_t config 
)

This function initializes the HSADC module. The operations are:

  • Enable the clock for HSADC.
  • Set the global settings for HSADC converter.
Parameters
baseHSADC peripheral base address.
configPointer to configuration structure. See the "hsadc_config_t".
void HSADC_GetDefaultConfig ( hsadc_config_t config)

This function initializes the module's configuration structure with an available settings. The default value are:

* config->dualConverterScanMode = kHSADC_DualConverterWorkAsTriggeredParallel;
* config->enableSimultaneousMode = true;
* config->resolution = kHSADC_Resolution12Bit;
* config->DMATriggerSoruce = kHSADC_DMATriggerSourceAsEndOfScan;
* config->idleWorkMode = kHSADC_IdleKeepNormal;
* config->powerUpDelay = 18U;
*
Parameters
configPointer to configuration structure. See the "hsadc_config_t"
void HSADC_Deinit ( HSADC_Type *  base)

This function de-initializes the HSADC module. The operations are:

  • Power down both converters.
  • Disable the clock for HSADC.
Parameters
baseHSADC peripheral base address.
void HSADC_SetConverterConfig ( HSADC_Type *  base,
uint16_t  converterMask,
const hsadc_converter_config_t config 
)
Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be configured. See the "_hsadc_converter_id".
configPointer to configuration structure. See the "hsadc_converter_config_t".
void HSADC_GetDefaultConverterConfig ( hsadc_converter_config_t config)

This function initializes each converter's configuration structure with available settings. The default value are:

* config->clockDivisor = 4U;
* config->samplingTimeCount = 0U;
* config->enablePowerUpCalibration = false;
* config->powerUpCalibrationModeMask = kHSADC_CalibrationModeSingleEnded;
*
Parameters
configPointer to configuration structure. See the "hsadc_converter_config_t"
void HSADC_EnableConverter ( HSADC_Type *  base,
uint16_t  converterMask,
bool  enable 
)

This function enables the converter's conversion by making the converter exit stop mode. The conversion should only be launched after the converter is enabled. When this feature is asserted to be "false", the current scan is stopped and no further scans can start. All the software and hardware triggers are ignored.

Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
enableEnable or disable the feature.
void HSADC_EnableConverterSyncInput ( HSADC_Type *  base,
uint16_t  converterMask,
bool  enable 
)

This function enables the input of the external sync signal. The external sync signal could be used to trigger the conversion if the hardware trigger-related setting is used. Note: When in "Once" scan mode, this gate is off automatically after an available sync is received. Enable the input again manually if another sync signal is needed.

Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
enableEnable or disable the feature.
void HSADC_EnableConverterPower ( HSADC_Type *  base,
uint16_t  converterMask,
bool  enable 
)

This function enables the power for the converter. The converter should be powered on before conversion. Once this API is called, the converter is powered on after a few moments (so-called power up delay) to make the power stable.

Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
enableEnable or disable the feature.
void HSADC_DoSoftwareTriggerConverter ( HSADC_Type *  base,
uint16_t  converterMask 
)

This function triggers the converter using a software trigger. The software trigger can be used to start a conversion sequence.

Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
void HSADC_EnableConverterDMA ( HSADC_Type *  base,
uint16_t  converterMask,
bool  enable 
)
Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
enableEnable or disable the feature.
void HSADC_EnableInterrupts ( HSADC_Type *  base,
uint16_t  mask 
)
Parameters
baseHSADC peripheral base address.
maskMask value for interrupt events. See the "_hsadc_interrupt_enable".
void HSADC_DisableInterrupts ( HSADC_Type *  base,
uint16_t  mask 
)
Parameters
baseHSADC peripheral base address.
maskMask value for interrupt events. See the "_hsadc_interrupt_enable".
uint16_t HSADC_GetStatusFlags ( HSADC_Type *  base)
Parameters
baseHSADC peripheral base address.
Returns
Mask value for the event flags. See the "_hsadc_status_flags".
void HSADC_ClearStatusFlags ( HSADC_Type *  base,
uint16_t  mask 
)
Parameters
baseHSADC peripheral base address.
flagsMask value for the event flags to be cleared. See the "_hsadc_status_flags".
void HSADC_SetSampleConfig ( HSADC_Type *  base,
uint16_t  sampleIndex,
const hsadc_sample_config_t config 
)

A sample list in this module works like a conversion sequence. Each sample slot can be used to designate to sample which channel is in converter A and converter B. The detail mapping relationship between sample slot and converter's channel can be found in the SoC reference manual.

Parameters
baseHSADC peripheral base address.
sampleIndexIndex of sample slot in conversion sequence. Available range is 0-15.
configPointer to configuration structure. See the "hsadc_sample_config_t".
void HSADC_GetDefaultSampleConfig ( hsadc_sample_config_t config)

This function initializes each sample's configuration structure with an available settings. The default values are:

* config->channelNumber = 0U;
* config->channel6MuxNumber = 0U;
* config->channel7MuxNumber = 0U;
* config->enableDifferentialPair = false;
* config->zeroCrossingMode = kHSADC_ZeroCorssingDisabled;
* config->highLimitValue = 0x7FF8U;
* config->lowLimitValue = 0U;
* config->offsetValue = 0U;
* config->enableWaitSync = false;
*
Parameters
configPointer to configuration structure. See the "hsadc_sample_config_t".
static void HSADC_EnableSample ( HSADC_Type *  base,
uint16_t  sampleMask,
bool  enable 
)
inlinestatic

This function enables the sample slot. Only the enabled sample slot can join the conversion sequence.

Parameters
baseHSADC peripheral base address.
sampleMaskMask value of sample slots in conversion sequence. Each bit corresponds to a sample slot.
enableEnable or disable the feature.
static void HSADC_EnableSampleResultReadyInterrupts ( HSADC_Type *  base,
uint16_t  sampleMask,
bool  enable 
)
inlinestatic
Parameters
baseHSADC peripheral base address.
sampleMaskMask value of sample slots in conversion sequence. Each bit is corresponding to a sample slot.
enableEnable or disable the feature.
static uint16_t HSADC_GetSampleReadyStatusFlags ( HSADC_Type *  base)
inlinestatic
Parameters
baseHSADC peripheral base address.
Returns
Mask value for the sample slots if their result are ready.
static uint16_t HSADC_GetSampleLowLimitStatusFlags ( HSADC_Type *  base)
inlinestatic
Parameters
baseHSADC peripheral base address.
Returns
Mask value for the sample slots if their results exceed the low limit.
static void HSADC_ClearSampleLowLimitStatusFlags ( HSADC_Type *  base,
uint16_t  sampleMask 
)
inlinestatic
Parameters
baseHSADC peripheral base address.
sampleMaskMask value for the sample slots' flags to be cleared.
static uint16_t HSADC_GetSampleHighLimitStatusFlags ( HSADC_Type *  base)
inlinestatic
Parameters
baseHSADC peripheral base address.
Returns
Mask value for the sample slots if their results exceed the high limit.
static void HSADC_ClearSampleHighLimitStatusFlags ( HSADC_Type *  base,
uint16_t  sampleMask 
)
inlinestatic
Parameters
baseHSADC peripheral base address.
sampleMaskMask value for the sample slots to be cleared flags.
static uint16_t HSADC_GetSampleZeroCrossingStatusFlags ( HSADC_Type *  base)
inlinestatic
Parameters
baseHSADC peripheral base address.
Returns
Mask value for the sample slots if their results cause the zero crossing event.
static void HSADC_ClearSampleZeroCrossingStatusFlags ( HSADC_Type *  base,
uint16_t  sampleMask 
)
inlinestatic
Parameters
baseHSADC peripheral base address.
sampleMaskMask value for the sample slots to be cleared flags.
static uint16_t HSADC_GetSampleResultValue ( HSADC_Type *  base,
uint16_t  sampleIndex 
)
inlinestatic

This function gets the sample result value. This returned value keeps its original formation just like in the hardware result register. It includes the sign bit as the MSB and 3-bit left shifted value.

Parameters
baseHSADC peripheral base address.
sampleIndexIndex of sample slot.
Returns
Sample's conversion value.
void HSADC_DoAutoCalibration ( HSADC_Type *  base,
uint16_t  converterMask,
uint16_t  calibrationModeMask 
)

This function starts the single ended calibration and differential calibration for converter A and converter B at the same time. Note that this is a non blocking function. End of Scan flag and End of Calibration flag are both be set after the calibration process. As a result, the user should check these two flags by using the function HSADC_GetStatusFlags() to wait for the calibration process to complete.

Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
calibrationModeMaskMask for calibration mode to be operated. See the "_hsadc_calibration_mode". Shouldn't be zero.
uint32_t HSADC_GetCalibrationResultValue ( HSADC_Type *  base)

This function returns the single ended calibration value and differential calibration value for converter A and converter B. The calibration value of each calibration mode for each converter can be received from this function's return value by using the mask and shift definition from HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_MASK to HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_SHIFT.

Parameters
baseHSADC peripheral base address.
Returns
Calibration value for converter A and converter B.
void HSADC_EnableCalibrationResultValue ( HSADC_Type *  base,
uint16_t  converterMask,
bool  enable 
)

This function enables or disables converter A and converter B to use the calibration values to obtain the final conversion result by calibration sum operation.

Parameters
baseHSADC peripheral base address.
converterMaskMask for converters to be operated. See the "_hsadc_converter_id".
enableEnable or disable the feature.