| NANO102/112 BSP V3.04.000 The Board Support Package for Nano102/112 Series

Macros | Functions
ACMP Exported Functions
NANO102/112 Device Driver » ACMP Driver » ACMP Exported Constants
Collaboration diagram for ACMP Exported Functions:

## Macros
#define | ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src)
| This macro is used to enable output inverse. More...
#define | ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum)
| This macro is used to enable hysteresis. More...
#define | ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum)
| This macro is used to disable hysteresis. More...
#define | ACMP_ENABLE_INT(acmp, u32ChNum)
| This macro is used to enable interrupt. More...
#define | ACMP_DISABLE_INT(acmp, u32ChNum)
| This macro is used to disable interrupt. More...
#define | ACMP_ENABLE(acmp, u32ChNum)
| This macro is used to enable ACMP. More...
#define | ACMP_DISABLE(acmp, u32ChNum)
| This macro is used to disable ACMP. More...
#define | ACMP_GET_OUTPUT(acmp, u32ChNum)
| This macro is used to get ACMP output value. More...
#define | ACMP_GET_INT_FLAG(acmp, u32ChNum)
| This macro is used to get ACMP interrupt flag. More...
#define | ACMP_CLR_INT_FLAG(acmp, u32ChNum)
| This macro is used to clear ACMP interrupt flag. More...
#define | ACMP_ENABLE_WAKEUP(acmp, u32ChNum)
| This macro is used to enable ACMP wake-up. More...
#define | ACMP_DISABLE_WAKEUP(acmp, u32ChNum)
| This macro is used to disable ACMP wake-up. More...
#define | ACMP_CRV_SEL(u32Level)
| This macro is used to enable ACMP wake-up. More...
#define | ACMP_ENABLE_CRV(acmp)
| This macro is used to enable CRV(comparator reference voltage) More...
#define | ACMP_DISABLE_CRV(acmp)
| This macro is used to disable CRV(comparator reference voltage) More...
#define | ACMP_SELECT_P(acmp, u32ChNum, u32Src) ((acmp)->CR[(u32ChNum)%2] = ((acmp)->CR[(u32ChNum)%2] & ~ACMP_CR_CPP0SEL_Msk) | (u32Src))
| This macro is used to select ACMP positive input source for ACMP0. More...
#define | ACMP_START_CONV(acmp)
| This macro is used to start ACMP on sigma-delta mode or slope mode. More...

## Functions
void | ACMP_Open (ACMP_T *Acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn)
| This function open and configure comparator parameters. More...
void | ACMP_Close (ACMP_T *Acmp, uint32_t u32ChNum)
| This function close comparator. More...
void | ACMP_SetSigmaDeltaConv (uint32_t u32TimerNum, uint32_t u32TriggerPolarity, uint32_t u32PosPin, uint32_t u32ChargePin)
| This function configure ACMP to sigma-delta mode. More...
void | ACMP_SetSlopeConv (uint32_t u32TimerNum, uint32_t u32TriggerPolarity, uint32_t u32PosPin, uint32_t u32ChargePin)
| This function configure ACMP to slope mode. More...

## Detailed Description

## Macro Definition Documentation

## ◆ ACMP_CLR_INT_FLAG

#define ACMP_CLR_INT_FLAG | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to clear ACMP interrupt flag.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 167 of file acmp.h.

## ◆ ACMP_CRV_SEL

#define ACMP_CRV_SEL | ( |  | u32Level | ) |

This macro is used to enable ACMP wake-up.

Parameters

  [in] | u32Level | comparator reference voltage setting. The formula is: comparator reference voltage = AVDD x (1/6 +u32Level/24) The range of u32Level is 0 ~ 15.

Returns
  None

Definition at line 196 of file acmp.h.

## ◆ ACMP_DISABLE

#define ACMP_DISABLE | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to disable ACMP.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 140 of file acmp.h.

## ◆ ACMP_DISABLE_CRV

#define ACMP_DISABLE_CRV | ( |  | acmp | ) |

This macro is used to disable CRV(comparator reference voltage)

Parameters

  [in] | acmp | The base address of ACMP module

Returns
  None

Definition at line 212 of file acmp.h.

## ◆ ACMP_DISABLE_HYSTERESIS

#define ACMP_DISABLE_HYSTERESIS | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to disable hysteresis.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 103 of file acmp.h.

## ◆ ACMP_DISABLE_INT

#define ACMP_DISABLE_INT | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to disable interrupt.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 121 of file acmp.h.

## ◆ ACMP_DISABLE_WAKEUP

#define ACMP_DISABLE_WAKEUP | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to disable ACMP wake-up.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 185 of file acmp.h.

## ◆ ACMP_ENABLE

#define ACMP_ENABLE | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to enable ACMP.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 131 of file acmp.h.

## ◆ ACMP_ENABLE_CRV

#define ACMP_ENABLE_CRV | ( |  | acmp | ) |

This macro is used to enable CRV(comparator reference voltage)

Parameters

  [in] | acmp | The base address of ACMP module

Returns
  None

Definition at line 204 of file acmp.h.

## ◆ ACMP_ENABLE_HYSTERESIS

#define ACMP_ENABLE_HYSTERESIS | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to enable hysteresis.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 94 of file acmp.h.

## ◆ ACMP_ENABLE_INT

#define ACMP_ENABLE_INT | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to enable interrupt.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 112 of file acmp.h.

## ◆ ACMP_ENABLE_WAKEUP

#define ACMP_ENABLE_WAKEUP | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to enable ACMP wake-up.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  None

Definition at line 176 of file acmp.h.

## ◆ ACMP_GET_INT_FLAG

#define ACMP_GET_INT_FLAG | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to get ACMP interrupt flag.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  ACMP interrupt occurred or not

Definition at line 158 of file acmp.h.

## ◆ ACMP_GET_OUTPUT

#define ACMP_GET_OUTPUT | ( |  | acmp,
|  |  | u32ChNum
| ) |  |

This macro is used to get ACMP output value.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number

Returns
  1 or 0

Definition at line 149 of file acmp.h.

## ◆ ACMP_SELECT_P

#define ACMP_SELECT_P | ( |  | acmp,
|  |  | u32ChNum,
|  |  | u32Src
| ) |  | ((acmp)->CR[(u32ChNum)%2] = ((acmp)->CR[(u32ChNum)%2] & ~ACMP_CR_CPP0SEL_Msk) | (u32Src))

This macro is used to select ACMP positive input source for ACMP0.

Parameters

  [in] | acmp | The pointer of the specified ACMP module
  [in] | u32ChNum | The ACMP number
  [in] | u32Src | Comparator positive input selection. Including: ACMP_CR_CPP0SEL_PA1 ACMP_CR_CPP0SEL_PA2 ACMP_CR_CPP0SEL_PA3 ACMP_CR_CPP0SEL_PA4

Returns
  None

This macro will set CPP0SEL (CR[0]) to determine the comparator positive input source.

Definition at line 226 of file acmp.h.

## ◆ ACMP_SET_NEG_SRC

#define ACMP_SET_NEG_SRC | ( |  | acmp,
|  |  | u32ChNum,
|  |  | u32Src
| ) |  |

This macro is used to enable output inverse.

Parameters

  [in] | acmp | The base address of ACMP module
  [in] | u32ChNum | The ACMP number
  [in] | u32Src | is comparator0 negative input selection. Including : ACMP_CR_CN_PIN ACMP_CR_CN_CRV ACMP_CR_CN_VREFI ACMP_CR_CN_AGND

Returns
  None

Definition at line 85 of file acmp.h.

## ◆ ACMP_START_CONV

#define ACMP_START_CONV | ( |  | acmp | ) |

This macro is used to start ACMP on sigma-delta mode or slope mode.

Parameters

  [in] | acmp | The base address of ACMP module

Returns
  None

Definition at line 234 of file acmp.h.

## Function Documentation

## ◆ ACMP_Close()

void ACMP_Close | ( | ACMP_T * | Acmp,
|  | uint32_t | u32ChNum
| ) |  |

This function close comparator.

Parameters

  [in] | Acmp | The base address of ACMP module
  [in] | u32ChNum | comparator number.

Definition at line 71 of file acmp.c.

## ◆ ACMP_Open()

void ACMP_Open | ( | ACMP_T * | Acmp,
|  | uint32_t | u32ChNum,
|  | uint32_t | u32NegSrc,
|  | uint32_t | u32HysteresisEn
| ) |  |

This function open and configure comparator parameters.

Parameters

  [in] | Acmp | The base address of ACMP module
  [in] | u32ChNum | comparator number.
  [in] | u32NegSrc | is comparator0 negative input selection. Including : ACMP_CR_CN_PIN ACMP_CR_CN_CRV ACMP_CR_CN_VREFI ACMP_CR_CN_AGND if select ACMP_CR_CN_CRV can add comparator reference voltage setting. The formula is: comparator reference voltage = AVDD x (1/6 +CRV/24) The range of CRV is 0 ~ 15. Example : u32NegSrc = ( ACMP_CR_CN_CRV | 10)
  [in] | u32HysteresisEn | is charge or discharge pin selection. Including : ACMP_CR_ACMP_HYSTERSIS_ENABLE ACMP_CR_ACMP_HYSTERSIS_DISABLE

Returns
  None

Definition at line 55 of file acmp.c.

## ◆ ACMP_SetSigmaDeltaConv()

void ACMP_SetSigmaDeltaConv | ( | uint32_t | u32TimerNum,
|  | uint32_t | u32TriggerPolarity,
|  | uint32_t | u32PosPin,
|  | uint32_t | u32ChargePin
| ) |  |

This function configure ACMP to sigma-delta mode.

Parameters

  [in] | u32TimerNum | is set to 0 to use timer0 and timer1, set to 1 to use timer0 and timer1. Including : ACMP_TIMER01 ACMP_TIMER23
  [in] | u32TriggerPolarity | is set rising trigger or falling trigger. Including : ACMP_MODCR0_TMR_TRI_LV_RISING ACMP_MODCR0_TMR_TRI_LV_FALLING
  [in] | u32PosPin | is comparator0 positive input selection. Including : ACMP_CR_CPP0SEL_PA1 ACMP_CR_CPP0SEL_PA2 ACMP_CR_CPP0SEL_PA3 ACMP_CR_CPP0SEL_PA4
  [in] | u32ChargePin | is charge or discharge pin selection. Including : ACMP_MODCR0_CH_DIS_PINSEL_PA1 ACMP_MODCR0_CH_DIS_PINSEL_PA2 ACMP_MODCR0_CH_DIS_PINSEL_PA3 ACMP_MODCR0_CH_DIS_PINSEL_PA4 ACMP_MODCR0_CH_DIS_PINSEL_PA5 ACMP_MODCR0_CH_DIS_PINSEL_PA6 ACMP_MODCR0_CH_DIS_PINSEL_PA14 ACMP_MODCR0_CH_DIS_PINSEL_PF5

Returns
  None

Definition at line 102 of file acmp.c.

## ◆ ACMP_SetSlopeConv()

void ACMP_SetSlopeConv | ( | uint32_t | u32TimerNum,
|  | uint32_t | u32TriggerPolarity,
|  | uint32_t | u32PosPin,
|  | uint32_t | u32ChargePin
| ) |  |

This function configure ACMP to slope mode.

Parameters

  [in] | u32TimerNum | is set to 0 to use timer0 and timer1, set to 1 to use timer0 and timer1. Including : ACMP_TIMER01 ACMP_TIMER23
  [in] | u32TriggerPolarity | is set rising trigger or falling trigger. Including : ACMP_MODCR0_TMR_TRI_LV_RISING ACMP_MODCR0_TMR_TRI_LV_FALLING
  [in] | u32PosPin | is comparator0 positive input selection. Including : ACMP_CR_CPP0SEL_PA1 ACMP_CR_CPP0SEL_PA2 ACMP_CR_CPP0SEL_PA3 ACMP_CR_CPP0SEL_PA4
  [in] | u32ChargePin | is charge or discharge pin selection. Including : ACMP_MODCR0_CH_DIS_PINSEL_PA1 ACMP_MODCR0_CH_DIS_PINSEL_PA2 ACMP_MODCR0_CH_DIS_PINSEL_PA3 ACMP_MODCR0_CH_DIS_PINSEL_PA4 ACMP_MODCR0_CH_DIS_PINSEL_PA5 ACMP_MODCR0_CH_DIS_PINSEL_PA6 ACMP_MODCR0_CH_DIS_PINSEL_PA14 ACMP_MODCR0_CH_DIS_PINSEL_PF5

Returns
  None

Definition at line 142 of file acmp.c.