Nano102_112 Series BSP  V3.03.002
The Board Support Package for Nano102_112 Series
Macros | Functions
ADC Exported Functions

Macros

#define ADC_GET_CONVERSION_DATA(adc, u32ChNum)
 Get the latest ADC conversion data. More...
 
#define ADC_GET_INT_FLAG(adc, u32Mask)
 Return the user-specified interrupt flags. More...
 
#define ADC_CLR_INT_FLAG(adc, u32Mask)
 This macro clear the selected interrupt status bits. More...
 
#define ADC_IS_BUSY(adc)
 Get the busy state of ADC. More...
 
#define ADC_IS_DATA_OVERRUN(adc, u32ChNum)
 Check if the ADC conversion data is over written or not. More...
 
#define ADC_IS_DATA_VALID(adc, u32ChNum)
 Check if the ADC conversion data is valid or not. More...
 
#define ADC_POWER_DOWN(adc)
 Power down ADC module. More...
 
#define ADC_POWER_ON(adc)
 Power on ADC module. More...
 
#define ADC_ENABLE_CMP0(adc, u32ChNum, u32Condition, u32Data, u32MatchCount)
 Configure the comparator 0 and enable it. More...
 
#define ADC_DISABLE_CMP0(adc)
 Disable comparator 0. More...
 
#define ADC_ENABLE_CMP1(adc, u32ChNum, u32Condition, u32Data, u32MatchCount)
 Configure the comparator 1 and enable it. More...
 
#define ADC_DISABLE_CMP1(adc)
 Disable comparator 1. More...
 
#define ADC_SET_INPUT_CHANNEL(adc, u32Mask)
 Set ADC input channel. Enabled channel will be converted while ADC starts. More...
 
#define ADC_START_CONV(adc)
 Start the A/D conversion. More...
 
#define ADC_STOP_CONV(adc)
 Stop the A/D conversion. More...
 
#define ADC_SET_DMOF(adc, u32Format)
 Set the output format in differential input mode. More...
 
#define ADC_SET_RESOLUTION(adc, u32Resolution)
 Set the resolution of conversion result. More...
 
#define ADC_SET_REF_VOLTAGE(adc, u32Ref)
 Set the reference voltage selection. More...
 
#define ADC_SET_POWERDOWN_MODE(adc, u32Mode, u32CalEn)
 Set power down mode. More...
 
#define ADC_ENABLE_PDMA(adc)
 Enable PDMA transfer. More...
 
#define ADC_DISABLE_PDMA(adc)
 Disable PDMA transfer. More...
 
#define ADC_GET_PDMA_DATA(adc)
 Get PDMA current transfer data. More...
 

Functions

void ADC_Open (ADC_T *adc, uint32_t u32InputMode, uint32_t u32OpMode, uint32_t u32ChMask)
 This API configures ADC module to be ready for convert the input from selected channel. More...
 
void ADC_Close (ADC_T *adc)
 Disable ADC module. More...
 
void ADC_EnableHWTrigger (ADC_T *adc, uint32_t u32Source, uint32_t u32Param)
 Configure the hardware trigger condition and enable hardware trigger. More...
 
void ADC_DisableHWTrigger (ADC_T *adc)
 Disable hardware trigger ADC function. More...
 
void ADC_EnableTimerTrigger (ADC_T *adc, uint32_t u32Source, uint32_t u32PDMACnt)
 Config and enable timer trigger. More...
 
void ADC_DisableTimerTrigger (ADC_T *adc)
 Disable timer trigger ADC function. More...
 
void ADC_SetExtraSampleTime (ADC_T *adc, uint32_t u32ChNum, uint32_t u32SampleTime)
 Configure the hardware trigger condition and enable hardware trigger. More...
 
void ADC_EnableInt (ADC_T *adc, uint32_t u32Mask)
 Enable the interrupt(s) selected by u32Mask parameter. More...
 
void ADC_DisableInt (ADC_T *adc, uint32_t u32Mask)
 Disable the interrupt(s) selected by u32Mask parameter. More...
 

Detailed Description

Macro Definition Documentation

◆ ADC_CLR_INT_FLAG

#define ADC_CLR_INT_FLAG (   adc,
  u32Mask 
)

This macro clear the selected interrupt status bits.

Parameters
[in]adcBase address of ADC module
[in]u32MaskThe combination of following interrupt status bits. Each bit corresponds to a interrupt status.
Returns
None

Definition at line 111 of file adc.h.

◆ ADC_DISABLE_CMP0

#define ADC_DISABLE_CMP0 (   adc)

Disable comparator 0.

Parameters
[in]adcBase address of ADC module

Definition at line 197 of file adc.h.

◆ ADC_DISABLE_CMP1

#define ADC_DISABLE_CMP1 (   adc)

Disable comparator 1.

Parameters
[in]adcBase address of ADC module

Definition at line 229 of file adc.h.

◆ ADC_DISABLE_PDMA

#define ADC_DISABLE_PDMA (   adc)

Disable PDMA transfer.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 318 of file adc.h.

◆ ADC_ENABLE_CMP0

#define ADC_ENABLE_CMP0 (   adc,
  u32ChNum,
  u32Condition,
  u32Data,
  u32MatchCount 
)

Configure the comparator 0 and enable it.

Parameters
[in]adcBase address of ADC module
[in]u32ChNumSpecifies the source channel, valid value are from 0 to 7
[in]u32ConditionSpecifies the compare condition
[in]u32DataSpecifies the compare value. Valid value are between 0 ~ 0x3FF
[in]u32MatchCountSpecifies the match count setting, valid values are between 1~16
Returns
None

For example, ADC_ENABLE_CMP0(ADC, 5, ADC_CMP_GREATER_OR_EQUAL_TO, 0x800, 10); Means ADC will assert comparator 0 flag if channel 5 conversion result is greater or equal to 0x800 for 10 times continuously.

Definition at line 182 of file adc.h.

◆ ADC_ENABLE_CMP1

#define ADC_ENABLE_CMP1 (   adc,
  u32ChNum,
  u32Condition,
  u32Data,
  u32MatchCount 
)

Configure the comparator 1 and enable it.

Parameters
[in]adcBase address of ADC module
[in]u32ChNumSpecifies the source channel, valid value are from 0 to 7
[in]u32ConditionSpecifies the compare condition
[in]u32DataSpecifies the compare value. Valid value are between 0 ~ 0x3FF
[in]u32MatchCountSpecifies the match count setting, valid values are between 1~16
Returns
None

For example, ADC_ENABLE_CMP1(ADC, 5, ADC_CMP_GREATER_OR_EQUAL_TO, 0x800, 10); Means ADC will assert comparator 1 flag if channel 5 conversion result is greater or equal to 0x800 for 10 times continuously.

Definition at line 214 of file adc.h.

◆ ADC_ENABLE_PDMA

#define ADC_ENABLE_PDMA (   adc)

Enable PDMA transfer.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 310 of file adc.h.

◆ ADC_GET_CONVERSION_DATA

#define ADC_GET_CONVERSION_DATA (   adc,
  u32ChNum 
)

Get the latest ADC conversion data.

Parameters
[in]adcBase address of ADC module
[in]u32ChNumChannel number
Returns
Latest ADC conversion data

Definition at line 87 of file adc.h.

◆ ADC_GET_INT_FLAG

#define ADC_GET_INT_FLAG (   adc,
  u32Mask 
)

Return the user-specified interrupt flags.

Parameters
[in]adcBase address of ADC module
[in]u32MaskThe combination of following interrupt status bits. Each bit corresponds to a interrupt status.
Returns
User specified interrupt flags

Definition at line 99 of file adc.h.

◆ ADC_GET_PDMA_DATA

#define ADC_GET_PDMA_DATA (   adc)

Get PDMA current transfer data.

Parameters
[in]adcBase address of ADC module
Returns
PDMA current transfer data

Definition at line 326 of file adc.h.

◆ ADC_IS_BUSY

#define ADC_IS_BUSY (   adc)

Get the busy state of ADC.

Parameters
[in]adcBase address of ADC module
Returns
busy state of ADC
Return values
0ADC is not busy
1ADC is busy

Definition at line 123 of file adc.h.

◆ ADC_IS_DATA_OVERRUN

#define ADC_IS_DATA_OVERRUN (   adc,
  u32ChNum 
)

Check if the ADC conversion data is over written or not.

Parameters
[in]adcBase address of ADC module
[in]u32ChNumCurrently not used
Returns
Over run state of ADC data
Return values
0ADC data is not overrun
1ADC data us overrun

Definition at line 134 of file adc.h.

◆ ADC_IS_DATA_VALID

#define ADC_IS_DATA_VALID (   adc,
  u32ChNum 
)

Check if the ADC conversion data is valid or not.

Parameters
[in]adcBase address of ADC module
[in]u32ChNumCurrently not used
Returns
Valid state of ADC data
Return values
0ADC data is not valid
1ADC data us valid

Definition at line 145 of file adc.h.

◆ ADC_POWER_DOWN

#define ADC_POWER_DOWN (   adc)

Power down ADC module.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 153 of file adc.h.

◆ ADC_POWER_ON

#define ADC_POWER_ON (   adc)

Power on ADC module.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 161 of file adc.h.

◆ ADC_SET_DMOF

#define ADC_SET_DMOF (   adc,
  u32Format 
)

Set the output format in differential input mode.

Parameters
[in]adcBase address of ADC module
[in]u32FormatDifferential input mode output format. Valid values are:
Returns
None

Definition at line 265 of file adc.h.

◆ ADC_SET_INPUT_CHANNEL

#define ADC_SET_INPUT_CHANNEL (   adc,
  u32Mask 
)

Set ADC input channel. Enabled channel will be converted while ADC starts.

Parameters
[in]adcBase address of ADC module
[in]u32MaskChannel enable bit. Each bit corresponds to a input channel. Bit 0 is channel 0, bit 1 is channel 1...
Returns
None

Definition at line 238 of file adc.h.

◆ ADC_SET_POWERDOWN_MODE

#define ADC_SET_POWERDOWN_MODE (   adc,
  u32Mode,
  u32CalEn 
)

Set power down mode.

Parameters
[in]adcBase address of ADC module
[in]u32ModeThe power down mode. 0: power down mode, 2: standby mode
[in]u32CalEnDo calibration when power up.
Returns
None

Definition at line 300 of file adc.h.

◆ ADC_SET_REF_VOLTAGE

#define ADC_SET_REF_VOLTAGE (   adc,
  u32Ref 
)

Set the reference voltage selection.

Parameters
[in]adcBase address of ADC module
[in]u32RefThe reference voltage selection. Valid values are:
Returns
None

Definition at line 290 of file adc.h.

◆ ADC_SET_RESOLUTION

#define ADC_SET_RESOLUTION (   adc,
  u32Resolution 
)

Set the resolution of conversion result.

Parameters
[in]adcBase address of ADC module
[in]u32ResolutionThe resolution of conversion result. Valid values are:
Returns
None

Definition at line 278 of file adc.h.

◆ ADC_START_CONV

#define ADC_START_CONV (   adc)

Start the A/D conversion.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 246 of file adc.h.

◆ ADC_STOP_CONV

#define ADC_STOP_CONV (   adc)

Stop the A/D conversion.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 254 of file adc.h.

Function Documentation

◆ ADC_Close()

void ADC_Close ( ADC_T adc)

Disable ADC module.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 59 of file adc.c.

◆ ADC_DisableHWTrigger()

void ADC_DisableHWTrigger ( ADC_T adc)

Disable hardware trigger ADC function.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 103 of file adc.c.

◆ ADC_DisableInt()

void ADC_DisableInt ( ADC_T adc,
uint32_t  u32Mask 
)

Disable the interrupt(s) selected by u32Mask parameter.

Parameters
[in]adcBase address of ADC module
[in]u32MaskThe combination of interrupt status bits listed below. Each bit corresponds to a interrupt status. This parameter decides which interrupts will be disabled.
Returns
None

Definition at line 190 of file adc.c.

◆ ADC_DisableTimerTrigger()

void ADC_DisableTimerTrigger ( ADC_T adc)

Disable timer trigger ADC function.

Parameters
[in]adcBase address of ADC module
Returns
None

Definition at line 131 of file adc.c.

◆ ADC_EnableHWTrigger()

void ADC_EnableHWTrigger ( ADC_T adc,
uint32_t  u32Source,
uint32_t  u32Param 
)

Configure the hardware trigger condition and enable hardware trigger.

Parameters
[in]adcBase address of ADC module
[in]u32SourceDecides the hardware trigger source. Valid values are:
[in]u32ParamWhile ADC trigger by external pin, this parameter is used to set trigger condition. Valid values are:
Returns
None

Definition at line 81 of file adc.c.

◆ ADC_EnableInt()

void ADC_EnableInt ( ADC_T adc,
uint32_t  u32Mask 
)

Enable the interrupt(s) selected by u32Mask parameter.

Parameters
[in]adcBase address of ADC module
[in]u32MaskThe combination of interrupt status bits listed below. Each bit corresponds to a interrupt status. This parameter decides which interrupts will be enabled.
Returns
None

Definition at line 167 of file adc.c.

◆ ADC_EnableTimerTrigger()

void ADC_EnableTimerTrigger ( ADC_T adc,
uint32_t  u32Source,
uint32_t  u32PDMACnt 
)

Config and enable timer trigger.

Parameters
[in]adcBase address of ADC module
[in]u32SourceDecides which timer trigger ADC. Valid values are: 0 ~ 3
[in]u32PDMACntWhen timer event occurred, PDMA will transfer u32PDMACnt+1 ADC result
Returns
None

Definition at line 116 of file adc.c.

◆ ADC_Open()

void ADC_Open ( ADC_T adc,
uint32_t  u32InputMode,
uint32_t  u32OpMode,
uint32_t  u32ChMask 
)

This API configures ADC module to be ready for convert the input from selected channel.

Parameters
[in]adcBase address of ADC module
[in]u32InputModeInput mode (single-end/differential). Valid values are:
[in]u32OpModeOperation mode (single/single cycle/continuous). Valid values are:
[in]u32ChMaskChannel enable bit. Each bit corresponds to a input channel. Bit 0 is channel 0, bit 1 is channel 1...
Returns
None
Note
This API does not turn on ADC power nor does trigger ADC conversion

Definition at line 41 of file adc.c.

◆ ADC_SetExtraSampleTime()

void ADC_SetExtraSampleTime ( ADC_T adc,
uint32_t  u32ChNum,
uint32_t  u32SampleTime 
)

Configure the hardware trigger condition and enable hardware trigger.

Parameters
[in]adcBase address of ADC module
[in]u32ChNumThe channel number
[in]u32SampleTimeDecides the extend sampling counter. Valid values are 0 ~ 15
Returns
None

Definition at line 145 of file adc.c.