VCMP
[EM_Library]

Voltage Comparator (VCMP) Peripheral API. More...

Collaboration diagram for VCMP:

Data Structures

struct  VCMP_Init_TypeDef

Defines

#define VCMP_INIT_DEFAULT

Enumerations

enum  VCMP_WarmTime_TypeDef {
  vcmpWarmTime4Cycles = _VCMP_CTRL_WARMTIME_4CYCLES,
  vcmpWarmTime8Cycles = _VCMP_CTRL_WARMTIME_8CYCLES,
  vcmpWarmTime16Cycles = _VCMP_CTRL_WARMTIME_16CYCLES,
  vcmpWarmTime32Cycles = _VCMP_CTRL_WARMTIME_32CYCLES,
  vcmpWarmTime64Cycles = _VCMP_CTRL_WARMTIME_64CYCLES,
  vcmpWarmTime128Cycles = _VCMP_CTRL_WARMTIME_128CYCLES,
  vcmpWarmTime256Cycles = _VCMP_CTRL_WARMTIME_256CYCLES,
  vcmpWarmTime512Cycles = _VCMP_CTRL_WARMTIME_512CYCLES
}
enum  VCMP_Hysteresis_TypeDef {
  vcmpHystNone,
  vcmpHyst20mV
}

Functions

void VCMP_Init (const VCMP_Init_TypeDef *vcmpInit)
 Configure and enable Voltage Comparator.
void VCMP_LowPowerRefSet (bool enable)
 Enable or disable Low Power Reference setting.
void VCMP_TriggerSet (int level)
 Configure trigger level of voltage comparator.
__STATIC_INLINE void VCMP_Enable (void)
 Enable Voltage Comparator.
__STATIC_INLINE void VCMP_Disable (void)
 Disable Voltage Comparator.
__STATIC_INLINE uint32_t VCMP_VoltageToLevel (float v)
 Calculate voltage to trigger level.
__STATIC_INLINE bool VCMP_VDDLower (void)
 Returns true, if Voltage Comparator indicated VDD < trigger level, else false.
__STATIC_INLINE bool VCMP_VDDHigher (void)
 Returns true, if Voltage Comparator indicated VDD > trigger level, else false.
__STATIC_INLINE bool VCMP_Ready (void)
 VCMP output is ready.
__STATIC_INLINE void VCMP_IntClear (uint32_t flags)
 Clear one or more pending VCMP interrupts.
__STATIC_INLINE void VCMP_IntSet (uint32_t flags)
 Set one or more pending VCMP interrupts from SW.
__STATIC_INLINE void VCMP_IntDisable (uint32_t flags)
 Disable one or more VCMP interrupts.
__STATIC_INLINE void VCMP_IntEnable (uint32_t flags)
 Enable one or more VCMP interrupts.
__STATIC_INLINE uint32_t VCMP_IntGet (void)
 Get pending VCMP interrupt flags.
__STATIC_INLINE uint32_t VCMP_IntGetEnabled (void)
 Get enabled and pending VCMP interrupt flags.

Detailed Description

Voltage Comparator (VCMP) Peripheral API.


Define Documentation

#define VCMP_INIT_DEFAULT
Value:
{ true,                                          \
    0x7,                  \
    false,                            \
    false,                             \
    vcmpWarmTime4Cycles,                 \
    vcmpHystNone,                                      \
    0,                              \
    true,                             \
    39,                                  \
    true,                                          \
  }

Default VCMP initialization structure

Definition at line 124 of file em_vcmp.h.


Enumeration Type Documentation

Hyseresis configuration

Enumerator:
vcmpHystNone 

Normal operation, no hysteresis

vcmpHyst20mV 

Digital output will not toggle until positive edge is at least 20mV above or below negative input voltage

Definition at line 83 of file em_vcmp.h.

Warm-up Time in High Frequency Peripheral Clock cycles

Enumerator:
vcmpWarmTime4Cycles 

4 cycles

vcmpWarmTime8Cycles 

8 cycles

vcmpWarmTime16Cycles 

16 cycles

vcmpWarmTime32Cycles 

32 cycles

vcmpWarmTime64Cycles 

64 cycles

vcmpWarmTime128Cycles 

128 cycles

vcmpWarmTime256Cycles 

256 cycles

vcmpWarmTime512Cycles 

512 cycles

Definition at line 62 of file em_vcmp.h.


Function Documentation

__STATIC_INLINE void VCMP_Disable ( void   ) 

Disable Voltage Comparator.

Definition at line 171 of file em_vcmp.h.

__STATIC_INLINE void VCMP_Enable ( void   ) 

Enable Voltage Comparator.

Definition at line 161 of file em_vcmp.h.

void VCMP_Init ( const VCMP_Init_TypeDef vcmpInit  ) 

Configure and enable Voltage Comparator.

Half Bias enabled Bias curernt 0.7 uA when half bias enabled Falling edge sense not enabled Rising edge sense not enabled 4 clock cycles warm-up time No hysteresis 0 in digital ouput when inactive Do not use low power reference Trigger level just below 3V Enable after init

Parameters:
[in] vcmpInit VCMP Initialization structure

Definition at line 57 of file em_vcmp.c.

References VCMP_Init_TypeDef::biasProg, VCMP_Init_TypeDef::enable, VCMP_Init_TypeDef::halfBias, VCMP_Init_TypeDef::hyst, VCMP_Init_TypeDef::inactive, VCMP_Init_TypeDef::irqFalling, VCMP_Init_TypeDef::irqRising, VCMP_Init_TypeDef::lowPowerRef, VCMP_Init_TypeDef::triggerLevel, VCMP_IntClear(), VCMP_LowPowerRefSet(), VCMP_Ready(), VCMP_TriggerSet(), vcmpHyst20mV, vcmpHystNone, and VCMP_Init_TypeDef::warmup.

Here is the call graph for this function:

__STATIC_INLINE void VCMP_IntClear ( uint32_t  flags  ) 

Clear one or more pending VCMP interrupts.

Parameters:
[in] flags VCMP interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).

Definition at line 255 of file em_vcmp.h.

Referenced by VCMP_Init().

Here is the caller graph for this function:

__STATIC_INLINE void VCMP_IntDisable ( uint32_t  flags  ) 

Disable one or more VCMP interrupts.

Parameters:
[in] flags VCMP interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).

Definition at line 285 of file em_vcmp.h.

__STATIC_INLINE void VCMP_IntEnable ( uint32_t  flags  ) 

Enable one or more VCMP interrupts.

Parameters:
[in] flags VCMP interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).

Definition at line 300 of file em_vcmp.h.

__STATIC_INLINE uint32_t VCMP_IntGet ( void   ) 

Get pending VCMP interrupt flags.

Note:
The event bits are not cleared by the use of this function
Returns:
Pending VCMP interrupt sources. Returns a set of interrupt flags OR-ed together for multiple interrupt sources in the VCMP module (VCMP_IFS_nnn).

Definition at line 317 of file em_vcmp.h.

__STATIC_INLINE uint32_t VCMP_IntGetEnabled ( void   ) 

Get enabled and pending VCMP interrupt flags.

Useful for handling more interrupt sources in the same interrupt handler.

Note:
The event bits are not cleared by the use of this function.
Returns:
Pending and enabled VCMP interrupt sources. The return value is the bitwise AND combination of
  • the OR combination of enabled interrupt sources in VCMP_IEN_nnn register (VCMP_IEN_nnn) and
  • the OR combination of valid interrupt flags of the VCMP module (VCMP_IF_nnn).

Definition at line 341 of file em_vcmp.h.

__STATIC_INLINE void VCMP_IntSet ( uint32_t  flags  ) 

Set one or more pending VCMP interrupts from SW.

Parameters:
[in] flags VCMP interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).

Definition at line 270 of file em_vcmp.h.

void VCMP_LowPowerRefSet ( bool  enable  ) 

Enable or disable Low Power Reference setting.

Parameters:
[in] enable If true, enables low power reference, if false disable low power reference

Definition at line 152 of file em_vcmp.c.

Referenced by VCMP_Init().

Here is the caller graph for this function:

__STATIC_INLINE bool VCMP_Ready ( void   ) 

VCMP output is ready.

Definition at line 233 of file em_vcmp.h.

Referenced by VCMP_Init().

Here is the caller graph for this function:

void VCMP_TriggerSet ( int  level  ) 

Configure trigger level of voltage comparator.

Parameters:
[in] level Trigger value, in range 0-63

Definition at line 172 of file em_vcmp.c.

Referenced by VCMP_Init().

Here is the caller graph for this function:

__STATIC_INLINE bool VCMP_VDDHigher ( void   ) 

Returns true, if Voltage Comparator indicated VDD > trigger level, else false.

Definition at line 216 of file em_vcmp.h.

__STATIC_INLINE bool VCMP_VDDLower ( void   ) 

Returns true, if Voltage Comparator indicated VDD < trigger level, else false.

Definition at line 198 of file em_vcmp.h.

__STATIC_INLINE uint32_t VCMP_VoltageToLevel ( float  v  ) 

Calculate voltage to trigger level.

Note:
You need soft float support for this function to be working
Parameters:
[in] v Voltage Level for trigger

Definition at line 187 of file em_vcmp.h.