34 #if defined(VCMP_COUNT) && (VCMP_COUNT > 0)
60 void VCMP_Init(
const VCMP_Init_TypeDef *vcmpInit)
63 EFM_ASSERT((vcmpInit->inactive == 0) || (vcmpInit->inactive == 1));
64 EFM_ASSERT((vcmpInit->biasProg >= 0) && (vcmpInit->biasProg < 16));
67 if (vcmpInit->halfBias)
69 VCMP->CTRL |= VCMP_CTRL_HALFBIAS;
73 VCMP->CTRL &= ~(VCMP_CTRL_HALFBIAS);
77 VCMP->CTRL &= ~(_VCMP_CTRL_BIASPROG_MASK);
78 VCMP->CTRL |= (vcmpInit->biasProg << _VCMP_CTRL_BIASPROG_SHIFT);
81 if (vcmpInit->irqFalling)
83 VCMP->CTRL |= VCMP_CTRL_IFALL;
87 VCMP->CTRL &= ~(VCMP_CTRL_IFALL);
91 if (vcmpInit->irqRising)
93 VCMP->CTRL |= VCMP_CTRL_IRISE;
97 VCMP->CTRL &= ~(VCMP_CTRL_IRISE);
101 VCMP->CTRL &= ~(_VCMP_CTRL_WARMTIME_MASK);
102 VCMP->CTRL |= (vcmpInit->warmup << _VCMP_CTRL_WARMTIME_SHIFT);
105 switch (vcmpInit->hyst)
108 VCMP->CTRL |= VCMP_CTRL_HYSTEN;
111 VCMP->CTRL &= ~(VCMP_CTRL_HYSTEN);
118 VCMP->CTRL |= (vcmpInit->inactive << _VCMP_CTRL_INACTVAL_SHIFT);
121 VCMP_TriggerSet(vcmpInit->triggerLevel);
124 if (vcmpInit->enable)
126 VCMP->CTRL |= VCMP_CTRL_EN;
130 VCMP->CTRL &= ~(VCMP_CTRL_EN);
136 if(vcmpInit->lowPowerRef && vcmpInit->enable)
139 while(!VCMP_Ready());
140 VCMP_LowPowerRefSet(vcmpInit->lowPowerRef);
144 VCMP_IntClear(VCMP_IF_EDGE);
155 void VCMP_LowPowerRefSet(
bool enable)
159 VCMP->INPUTSEL |= VCMP_INPUTSEL_LPREF;
163 VCMP->INPUTSEL &= ~VCMP_INPUTSEL_LPREF;
175 void VCMP_TriggerSet(
int level)
178 EFM_ASSERT((level > 0) && (level < 64));
181 VCMP->INPUTSEL = (VCMP->INPUTSEL & ~(_VCMP_INPUTSEL_TRIGLEVEL_MASK))
182 | (level << _VCMP_INPUTSEL_TRIGLEVEL_SHIFT);
Emlib peripheral API "assert" implementation.
Voltage Comparator (VCMP) peripheral API.