| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

Macros | Functions
ADC Exported Functions
NUC472/NUC442 Device Driver » ADC Driver » ADC Exported Constants
Collaboration diagram for 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_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_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] | adc | Base address of ADC module
  [in] | u32Mask | The combination of following interrupt status bits. Each bit corresponds to a interrupt status. ADC_ADF_INT ADC_CMP0_INT ADC_CMP1_INT

Returns
  None

Definition at line 104 of file adc.h.

## ◆ ADC_DISABLE_CMP0

#define ADC_DISABLE_CMP0 | ( |  | adc | ) |

Disable comparator 0.

Parameters

  [in] | adc | Base address of ADC module

Definition at line 186 of file adc.h.

## ◆ ADC_DISABLE_CMP1

#define ADC_DISABLE_CMP1 | ( |  | adc | ) |

Disable comparator 1.

Parameters

  [in] | adc | Base address of ADC module

Definition at line 218 of file adc.h.

## ◆ ADC_DISABLE_PDMA

#define ADC_DISABLE_PDMA | ( |  | adc | ) |

Disable PDMA transfer.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 270 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] | adc | Base address of ADC module
  [in] | u32ChNum | Specifies the source channel, valid value are from 0 to 7
  [in] | u32Condition | Specifies the compare condition ADC_CMP_LESS_THAN ADC_CMP_GREATER_OR_EQUAL_TO
  [in] | u32Data | Specifies the compare value. Valid value are between 0 ~ 0x3FF
  [in] | u32MatchCount | Specifies 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 171 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] | adc | Base address of ADC module
  [in] | u32ChNum | Specifies the source channel, valid value are from 0 to 7
  [in] | u32Condition | Specifies the compare condition ADC_CMP_LESS_THAN ADC_CMP_GREATER_OR_EQUAL_TO
  [in] | u32Data | Specifies the compare value. Valid value are between 0 ~ 0x3FF
  [in] | u32MatchCount | Specifies 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 203 of file adc.h.

## ◆ ADC_ENABLE_PDMA

#define ADC_ENABLE_PDMA | ( |  | adc | ) |

Enable PDMA transfer.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 262 of file adc.h.

## ◆ ADC_GET_CONVERSION_DATA

#define ADC_GET_CONVERSION_DATA | ( |  | adc,
|  |  | u32ChNum
| ) |  |

Get the latest ADC conversion data.

Parameters

  [in] | adc | Base address of ADC module
  [in] | u32ChNum | Channel number

Returns
  Latest ADC conversion data

Definition at line 80 of file adc.h.

## ◆ ADC_GET_INT_FLAG

#define ADC_GET_INT_FLAG | ( |  | adc,
|  |  | u32Mask
| ) |  |

Return the user-specified interrupt flags.

Parameters

  [in] | adc | Base address of ADC module
  [in] | u32Mask | The combination of following interrupt status bits. Each bit corresponds to a interrupt status. ADC_ADF_INT ADC_CMP0_INT ADC_CMP1_INT

Returns
  User specified interrupt flags

Definition at line 92 of file adc.h.

## ◆ ADC_GET_PDMA_DATA

#define ADC_GET_PDMA_DATA | ( |  | adc | ) |

Get PDMA current transfer data.

Parameters

  [in] | adc | Base address of ADC module

Returns
  PDMA current transfer data

Definition at line 278 of file adc.h.

## ◆ ADC_IS_BUSY

#define ADC_IS_BUSY | ( |  | adc | ) |

Get the busy state of ADC.

Parameters

  [in] | adc | Base address of ADC module

Returns
  busy state of ADC

Return values

  0 | ADC is not busy
  1 | ADC is busy

Definition at line 116 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] | adc | Base address of ADC module
  [in] | u32ChNum | Currently not used

Returns
  Over run state of ADC data

Return values

  0 | ADC data is not overrun
  1 | ADC data us overrun

Definition at line 127 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] | adc | Base address of ADC module
  [in] | u32ChNum | Currently not used

Returns
  Valid state of ADC data

Return values

  0 | ADC data is not valid
  1 | ADC data us valid

Definition at line 138 of file adc.h.

## ◆ ADC_POWER_DOWN

#define ADC_POWER_DOWN | ( |  | adc | ) |

Power down ADC module.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 146 of file adc.h.

## ◆ ADC_POWER_ON

#define ADC_POWER_ON | ( |  | adc | ) |

Power on ADC module.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 154 of file adc.h.

## ◆ ADC_SET_DMOF

#define ADC_SET_DMOF | ( |  | adc,
|  |  | u32Format
| ) |  |

Set the output format in differential input mode.

Parameters

  [in] | adc | Base address of ADC module
  [in] | u32Format | Differential input mode output format. Valid values are: ADC_DMODE_OUT_FORMAT_UNSIGNED ADC_DMODE_OUT_FORMAT_2COMPLEMENT

Returns
  None

Definition at line 254 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] | adc | Base address of ADC module
  [in] | u32Mask | Channel enable bit. Each bit corresponds to a input channel. Bit 0 is channel 0, bit 1 is channel 1...

Returns
  None

Definition at line 227 of file adc.h.

## ◆ ADC_START_CONV

#define ADC_START_CONV | ( |  | adc | ) |

Start the A/D conversion.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 235 of file adc.h.

## ◆ ADC_STOP_CONV

#define ADC_STOP_CONV | ( |  | adc | ) |

Stop the A/D conversion.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 243 of file adc.h.

## Function Documentation

## ◆ ADC_Close()

void ADC_Close | ( | ADC_T * | adc | ) |

Disable ADC module.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 72 of file adc.c.

## ◆ ADC_DisableHWTrigger()

void ADC_DisableHWTrigger | ( | ADC_T * | adc | ) |

Disable hardware trigger ADC function.

Parameters

  [in] | adc | Base address of ADC module

Returns
  None

Definition at line 120 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] | adc | Base address of ADC module
  [in] | u32Mask | The combination of interrupt status bits listed below. Each bit corresponds to a interrupt status. This parameter decides which interrupts will be disabled. ADC_ADF_INT ADC_CMP0_INT ADC_CMP1_INT

Returns
  None

Definition at line 160 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] | adc | Base address of ADC module
  [in] | u32Source | Decides the hardware trigger source. Valid values are: ADC_TRIGGER_BY_EXT_PIN ADC_TRIGGER_BY_PWM
  [in] | u32Param | While ADC trigger by PWM, this parameter is used to set the delay between PWM trigger and ADC conversion. Valid values are from 0 ~ 0xFF, and actual delay time is (4 * u32Param * HCLK). While ADC trigger by external pin, this parameter is used to set trigger condition. Valid values are: ADC_LOW_LEVEL_TRIGGER ADC_HIGH_LEVEL_TRIGGER ADC_FALLING_EDGE_TRIGGER ADC_RISING_EDGE_TRIGGER

Returns
  None

Definition at line 96 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] | adc | Base address of ADC module
  [in] | u32Mask | The combination of interrupt status bits listed below. Each bit corresponds to a interrupt status. This parameter decides which interrupts will be enabled. ADC_ADF_INT ADC_CMP0_INT ADC_CMP1_INT

Returns
  None

Definition at line 137 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] | adc | Base address of ADC module
  [in] | u32InputMode | Input mode (single-end/differential). Valid values are: ADC_INPUT_MODE_SINGLE_END ADC_INPUT_MODE_DIFFERENTIAL
  [in] | u32OpMode | Operation mode (single/single cycle/continuous). Valid values are: ADC_OPERATION_MODE_SINGLE ADC_OPERATION_MODE_SINGLE_CYCLE ADC_OPERATION_MODE_CONTINUOUS
  [in] | u32ChMask | Channel enable bit. Valid values are: ADC_CH_0_MASK ADC_CH_1_MASK ADC_CH_2_MASK ADC_CH_3_MASK ADC_CH_4_MASK ADC_CH_5_MASK ADC_CH_6_MASK ADC_CH_7_MASK ADC_CH_8_MASK ADC_CH_9_MASK ADC_CH_10_MASK ADC_CH_11_MASK ADC_CH_TS_MASK ADC_CH_BG_MASK

Returns
  None

Note
  This API does not turn on ADC power nor does trigger ADC conversion

Definition at line 55 of file adc.c.