Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the ADC16 HAL driver.

Data Structures

struct  adc16_chn_config_t
 Defines the structure to configure the ADC16 channel. More...
 
struct  adc16_converter_config_t
 Defines the structure to configure the ADC16's converter. More...
 
struct  adc16_hw_cmp_config_t
 Defines the structure to configure the ADC16 internal comparator. More...
 

Enumerations

enum  adc16_status_t {
  kStatus_ADC16_Success = 0U,
  kStatus_ADC16_InvalidArgument = 1U,
  kStatus_ADC16_Failed = 2U
}
 ADC16 status return codes. More...
 
enum  adc16_clk_divider_t {
  kAdc16ClkDividerOf1 = 0U,
  kAdc16ClkDividerOf2 = 1U,
  kAdc16ClkDividerOf4 = 2U,
  kAdc16ClkDividerOf8 = 3U
}
 Defines the type of the enumerating divider for the converter. More...
 
enum  adc16_resolution_t {
  kAdc16ResolutionBitOf8or9 = 0U,
  kAdc16ResolutionBitOfSingleEndAs8 = kAdc16ResolutionBitOf8or9,
  kAdc16ResolutionBitOfDiffModeAs9 = kAdc16ResolutionBitOf8or9,
  kAdc16ResolutionBitOf12or13 = 1U,
  kAdc16ResolutionBitOfSingleEndAs12 = kAdc16ResolutionBitOf12or13,
  kAdc16ResolutionBitOfDiffModeAs13 = kAdc16ResolutionBitOf12or13,
  kAdc16ResolutionBitOf10or11 = 2U,
  kAdc16ResolutionBitOfSingleEndAs10 = kAdc16ResolutionBitOf10or11,
  kAdc16ResolutionBitOfDiffModeAs11 = kAdc16ResolutionBitOf10or11
}
 Defines the type of the enumerating resolution for the converter. More...
 
enum  adc16_clk_src_mode_t {
  kAdc16ClkSrcOfBusClk = 0U,
  kAdc16ClkSrcOfAltClk2 = 1U,
  kAdc16ClkSrcOfAltClk = 2U,
  kAdc16ClkSrcOfAsynClk = 3U
}
 Defines the type of the enumerating source of the input clock. More...
 
enum  adc16_long_sample_cycle_t {
  kAdc16LongSampleCycleOf24 = 0U,
  kAdc16LongSampleCycleOf16 = 1U,
  kAdc16LongSampleCycleOf10 = 2U,
  kAdc16LongSampleCycleOf6 = 3U
}
 Defines the type of the enumerating long sample cycles. More...
 
enum  adc16_ref_volt_src_t {
  kAdc16RefVoltSrcOfVref = 0U,
  kAdc16RefVoltSrcOfValt = 1U
}
 Defines the type of the enumerating reference voltage source. More...
 
enum  adc16_chn_t {
  kAdc16Chn0 = 0U,
  kAdc16Chn1 = 1U,
  kAdc16Chn2 = 2U,
  kAdc16Chn3 = 3U,
  kAdc16Chn4 = 4U,
  kAdc16Chn5 = 5U,
  kAdc16Chn6 = 6U,
  kAdc16Chn7 = 7U,
  kAdc16Chn8 = 8U,
  kAdc16Chn9 = 9U,
  kAdc16Chn10 = 10U,
  kAdc16Chn11 = 11U,
  kAdc16Chn12 = 12U,
  kAdc16Chn13 = 13U,
  kAdc16Chn14 = 14U,
  kAdc16Chn15 = 15U,
  kAdc16Chn16 = 16U,
  kAdc16Chn17 = 17U,
  kAdc16Chn18 = 18U,
  kAdc16Chn19 = 19U,
  kAdc16Chn20 = 20U,
  kAdc16Chn21 = 21U,
  kAdc16Chn22 = 22U,
  kAdc16Chn23 = 23U,
  kAdc16Chn24 = 24U,
  kAdc16Chn25 = 25U,
  kAdc16Chn26 = 26U,
  kAdc16Chn27 = 27U,
  kAdc16Chn28 = 28U,
  kAdc16Chn29 = 29U,
  kAdc16Chn30 = 30U,
  kAdc16Chn31 = 31U,
  kAdc16Chn0d = kAdc16Chn0,
  kAdc16Chn1d = kAdc16Chn1,
  kAdc16Chn2d = kAdc16Chn2,
  kAdc16Chn3d = kAdc16Chn3,
  kAdc16Chn4a = kAdc16Chn4,
  kAdc16Chn5a = kAdc16Chn5,
  kAdc16Chn6a = kAdc16Chn6,
  kAdc16Chn7a = kAdc16Chn7,
  kAdc16Chn4b = kAdc16Chn4,
  kAdc16Chn5b = kAdc16Chn5,
  kAdc16Chn6b = kAdc16Chn6,
  kAdc16Chn7b = kAdc16Chn7
}
 Defines the type of enumerating ADC16's channel index. More...
 

Variables

adc16_chn_t adc16_chn_config_t::chnIdx
 Select the sample channel index. More...
 
bool adc16_chn_config_t::convCompletedIntEnable
 Enable the conversion complete interrupt. More...
 
bool adc16_converter_config_t::lowPowerEnable
 Enables low power.
 
adc16_clk_divider_t adc16_converter_config_t::clkDividerMode
 Selects the divider of input clock source.
 
bool adc16_converter_config_t::longSampleTimeEnable
 Enables the long sample time.
 
adc16_resolution_t adc16_converter_config_t::resolution
 Selects the sample resolution mode.
 
adc16_clk_src_mode_t adc16_converter_config_t::clkSrc
 Selects the input clock source to converter.
 
bool adc16_converter_config_t::asyncClkEnable
 Enables the asynchronous clock inside the ADC.
 
bool adc16_converter_config_t::highSpeedEnable
 Enables the high-speed mode.
 
adc16_long_sample_cycle_t adc16_converter_config_t::longSampleCycleMode
 Selects the long sample mode.
 
bool adc16_converter_config_t::hwTriggerEnable
 Enables the hardware trigger function.
 
adc16_ref_volt_src_t adc16_converter_config_t::refVoltSrc
 Selects the reference voltage source.
 
bool adc16_converter_config_t::continuousConvEnable
 Enables continuous conversion mode.
 
bool adc16_hw_cmp_config_t::hwCmpEnable
 Enables the hardware compare function.
 
bool adc16_hw_cmp_config_t::hwCmpGreaterThanEnable
 Configures the compare function.
 
bool adc16_hw_cmp_config_t::hwCmpRangeEnable
 Configures the comparator function.
 
uint16_t adc16_hw_cmp_config_t::cmpValue1
 Setting value for CV1.
 
uint16_t adc16_hw_cmp_config_t::cmpValue2
 Setting value for CV2.
 

ADC16 HAL.

void ADC16_HAL_Init (ADC_Type *base)
 Resets all registers into a known state for the ADC16 module. More...
 
void ADC16_HAL_ConfigChn (ADC_Type *base, uint32_t chnGroup, const adc16_chn_config_t *configPtr)
 Configures the conversion channel for the ADC16 module. More...
 
static bool ADC16_HAL_GetChnConvCompletedFlag (ADC_Type *base, uint32_t chnGroup)
 Checks whether the channel conversion is completed. More...
 
void ADC16_HAL_ConfigConverter (ADC_Type *base, const adc16_converter_config_t *configPtr)
 Configures the sampling converter for the ADC16. More...
 
void ADC16_HAL_ConfigHwCompare (ADC_Type *base, const adc16_hw_cmp_config_t *configPtr)
 Configures the hardware comparator function for the ADC16. More...
 
static uint16_t ADC16_HAL_GetChnConvValue (ADC_Type *base, uint32_t chnGroup)
 Gets the raw result data of channel conversion for the ADC16 module. More...
 
static bool ADC16_HAL_GetConvActiveFlag (ADC_Type *base)
 Checks whether the converter is active for the ADC16 module. More...
 

Data Structure Documentation

struct adc16_chn_config_t

This type of variable is treated as the command to be set in ADC control register, which may execute the ADC's conversion.

Data Fields

adc16_chn_t chnIdx
 Select the sample channel index. More...
 
bool convCompletedIntEnable
 Enable the conversion complete interrupt. More...
 
struct adc16_converter_config_t

This type of variable is treated as a group of configurations. Most of the time, these configurations are a one-time setting for converter sampling condition. Usually, they are set before executing the ADC16 job.

Data Fields

bool lowPowerEnable
 Enables low power.
 
adc16_clk_divider_t clkDividerMode
 Selects the divider of input clock source.
 
bool longSampleTimeEnable
 Enables the long sample time.
 
adc16_resolution_t resolution
 Selects the sample resolution mode.
 
adc16_clk_src_mode_t clkSrc
 Selects the input clock source to converter.
 
bool asyncClkEnable
 Enables the asynchronous clock inside the ADC.
 
bool highSpeedEnable
 Enables the high-speed mode.
 
adc16_long_sample_cycle_t longSampleCycleMode
 Selects the long sample mode.
 
bool hwTriggerEnable
 Enables the hardware trigger function.
 
adc16_ref_volt_src_t refVoltSrc
 Selects the reference voltage source.
 
bool continuousConvEnable
 Enables continuous conversion mode.
 
struct adc16_hw_cmp_config_t

Data Fields

bool hwCmpEnable
 Enables the hardware compare function.
 
bool hwCmpGreaterThanEnable
 Configures the compare function.
 
bool hwCmpRangeEnable
 Configures the comparator function.
 
uint16_t cmpValue1
 Setting value for CV1.
 
uint16_t cmpValue2
 Setting value for CV2.
 

Enumeration Type Documentation

Enumerator
kStatus_ADC16_Success 

Success.

kStatus_ADC16_InvalidArgument 

Invalid argument.

kStatus_ADC16_Failed 

Execution failed.

Enumerator
kAdc16ClkDividerOf1 

For divider 1 from the input clock to ADC16.

kAdc16ClkDividerOf2 

For divider 2 from the input clock to ADC16.

kAdc16ClkDividerOf4 

For divider 4 from the input clock to ADC16.

kAdc16ClkDividerOf8 

For divider 8 from the input clock to ADC16.

Enumerator
kAdc16ResolutionBitOf8or9 

8-bit for single end sample, or 9-bit for differential sample.

kAdc16ResolutionBitOfSingleEndAs8 

8-bit for single end sample.

kAdc16ResolutionBitOfDiffModeAs9 

9-bit for differential sample.

kAdc16ResolutionBitOf12or13 

12-bit for single end sample, or 13-bit for differential sample.

kAdc16ResolutionBitOfSingleEndAs12 

12-bit for single end sample.

kAdc16ResolutionBitOfDiffModeAs13 

13-bit for differential sample.

kAdc16ResolutionBitOf10or11 

10-bit for single end sample, or 11-bit for differential sample.

kAdc16ResolutionBitOfSingleEndAs10 

10-bit for single end sample.

kAdc16ResolutionBitOfDiffModeAs11 

11-bit for differential sample.

Enumerator
kAdc16ClkSrcOfBusClk 

For input as bus clock.

kAdc16ClkSrcOfAltClk2 

For input as alternate clock 2 (AltClk2).

kAdc16ClkSrcOfAltClk 

For input as alternate clock (ALTCLK).

kAdc16ClkSrcOfAsynClk 

For input as asynchronous clock (ADACK).

Enumerator
kAdc16LongSampleCycleOf24 

20 extra ADCK cycles, 24 ADCK cycles total.

kAdc16LongSampleCycleOf16 

12 extra ADCK cycles, 16 ADCK cycles total.

kAdc16LongSampleCycleOf10 

6 extra ADCK cycles, 10 ADCK cycles total.

kAdc16LongSampleCycleOf6 

2 extra ADCK cycles, 6 ADCK cycles total.

Enumerator
kAdc16RefVoltSrcOfVref 

For external pins pair of VrefH and VrefL.

kAdc16RefVoltSrcOfValt 

For alternate reference pair of ValtH and ValtL.

Enumerator
kAdc16Chn0 

AD0.

kAdc16Chn1 

AD1.

kAdc16Chn2 

AD2.

kAdc16Chn3 

AD3.

kAdc16Chn4 

AD4.

kAdc16Chn5 

AD5.

kAdc16Chn6 

AD6.

kAdc16Chn7 

AD6.

kAdc16Chn8 

AD8.

kAdc16Chn9 

AD9.

kAdc16Chn10 

AD10.

kAdc16Chn11 

AD11.

kAdc16Chn12 

AD12.

kAdc16Chn13 

AD13.

kAdc16Chn14 

AD14.

kAdc16Chn15 

AD15.

kAdc16Chn16 

AD16.

kAdc16Chn17 

AD17.

kAdc16Chn18 

AD18.

kAdc16Chn19 

AD19.

kAdc16Chn20 

AD20.

kAdc16Chn21 

AD21.

kAdc16Chn22 

AD22.

kAdc16Chn23 

AD23.

kAdc16Chn24 

AD24.

kAdc16Chn25 

AD25.

kAdc16Chn26 

AD26.

kAdc16Chn27 

AD27.

kAdc16Chn28 

AD28.

kAdc16Chn29 

AD29.

kAdc16Chn30 

AD30.

kAdc16Chn31 

AD31.

kAdc16Chn0d 

DAD0.

kAdc16Chn1d 

DAD1.

kAdc16Chn2d 

DAD2.

kAdc16Chn3d 

DAD3.

kAdc16Chn4a 

AD4a.

kAdc16Chn5a 

AD5a.

kAdc16Chn6a 

AD6a.

kAdc16Chn7a 

AD7a.

kAdc16Chn4b 

AD4b.

kAdc16Chn5b 

AD5b.

kAdc16Chn6b 

AD6b.

kAdc16Chn7b 

AD7b.

Function Documentation

void ADC16_HAL_Init ( ADC_Type *  base)

This function resets all registers into a known state for the ADC module. This known state is the reset value indicated by the Reference manual. It is strongly recommended to call this API before any other operation when initializing the ADC16 module.

Parameters
baseRegister base address for the module.
void ADC16_HAL_ConfigChn ( ADC_Type *  base,
uint32_t  chnGroup,
const adc16_chn_config_t configPtr 
)

This function configures the channel for the ADC16 module. At any point, only one of the configuration groups takes effect. The other channel group of the first group (group A, 0) is only for the hardware trigger. Both software and hardware trigger can be used to the first group. When in software trigger mode, after the available channel is set, the conversion begins to execute.

Parameters
baseRegister base address for the module.
chnGroupChannel configuration group ID.
configPtrPointer to configuration structure.
static bool ADC16_HAL_GetChnConvCompletedFlag ( ADC_Type *  base,
uint32_t  chnGroup 
)
inlinestatic

This function checks whether the channel conversion for the ADC module is completed.

Parameters
baseRegister base address for the module.
chnGroupChannel configuration group ID.
Returns
Assertion of completed conversion mode.
void ADC16_HAL_ConfigConverter ( ADC_Type *  base,
const adc16_converter_config_t configPtr 
)

This function configures the sampling converter for the ADC16. Most of the time, the configurations are a one-time setting for the converter sampling condition. Usually, it is called before executing the ADC16 job.

Parameters
baseRegister base address for the module.
configPtrPointer to configuration structure.
void ADC16_HAL_ConfigHwCompare ( ADC_Type *  base,
const adc16_hw_cmp_config_t configPtr 
)

This function configures the hardware comparator function for the ADC16. These are the settings for the ADC16 comparator.

Parameters
baseRegister base address for the module.
configPtrPointer to configuration structure.
static uint16_t ADC16_HAL_GetChnConvValue ( ADC_Type *  base,
uint32_t  chnGroup 
)
inlinestatic

This function gets the conversion result data for the ADC16 module. The return value is the raw data that is not processed.

Parameters
baseRegister base address for the module.
chnGroupChannel configuration group ID.
Returns
Conversion value of RAW.
static bool ADC16_HAL_GetConvActiveFlag ( ADC_Type *  base)
inlinestatic

This function checks whether the converter is active for the ADC16 module.

Parameters
baseRegister base address for the module.
Returns
Assertion of that the converter is active.

Variable Documentation

adc16_chn_t adc16_chn_config_t::chnIdx
bool adc16_chn_config_t::convCompletedIntEnable