34 #if ((defined(_SILICON_LABS_32B_SERIES_0) && defined(OPAMP_PRESENT) && (OPAMP_COUNT == 1)) \
35 || (defined(_SILICON_LABS_32B_SERIES_1) && defined(VDAC_PRESENT) && (VDAC_COUNT > 0)))
260 #
if defined(_SILICON_LABS_32B_SERIES_0)
267 #if defined(_SILICON_LABS_32B_SERIES_0)
268 EFM_ASSERT(DAC_REF_VALID(dac));
269 EFM_ASSERT(DAC_OPA_VALID(opa));
273 dac->CH0CTRL &= ~DAC_CH0CTRL_EN;
274 dac->OPACTRL &= ~DAC_OPACTRL_OPA0EN;
276 else if (opa ==
OPA1)
278 dac->CH1CTRL &= ~DAC_CH1CTRL_EN;
279 dac->OPACTRL &= ~DAC_OPACTRL_OPA1EN;
283 dac->OPACTRL &= ~DAC_OPACTRL_OPA2EN;
286 #elif defined(_SILICON_LABS_32B_SERIES_1)
287 EFM_ASSERT(VDAC_REF_VALID(dac));
288 EFM_ASSERT(VDAC_OPA_VALID(opa));
297 else if (opa ==
OPA1)
373 #
if defined(_SILICON_LABS_32B_SERIES_0)
381 #if defined(_SILICON_LABS_32B_SERIES_0)
384 EFM_ASSERT(DAC_REF_VALID(dac));
385 EFM_ASSERT(DAC_OPA_VALID(opa));
386 EFM_ASSERT(init->bias <= (_DAC_BIASPROG_BIASPROG_MASK
387 >> _DAC_BIASPROG_BIASPROG_SHIFT));
391 EFM_ASSERT((init->
outPen & ~_DAC_OPA0MUX_OUTPEN_MASK) == 0);
393 dac->BIASPROG = (dac->BIASPROG
394 & ~(_DAC_BIASPROG_BIASPROG_MASK
395 | DAC_BIASPROG_HALFBIAS))
396 | (init->bias << _DAC_BIASPROG_BIASPROG_SHIFT)
397 | (init->halfBias ? DAC_BIASPROG_HALFBIAS : 0);
399 if (init->defaultOffset)
402 dac->CAL = (dac->CAL & ~_DAC_CAL_CH0OFFSET_MASK)
403 | (offset & _DAC_CAL_CH0OFFSET_MASK);
407 EFM_ASSERT(init->offset <= (_DAC_CAL_CH0OFFSET_MASK
408 >> _DAC_CAL_CH0OFFSET_SHIFT));
410 dac->CAL = (dac->CAL & ~_DAC_CAL_CH0OFFSET_MASK)
411 | (init->offset << _DAC_CAL_CH0OFFSET_SHIFT);
414 dac->OPA0MUX = (uint32_t)init->
resSel
420 | ( init->nextOut ? DAC_OPA0MUX_NEXTOUT : 0)
421 | ( init->npEn ? DAC_OPA0MUX_NPEN : 0)
422 | ( init->ppEn ? DAC_OPA0MUX_PPEN : 0);
424 dac->CH0CTRL |= DAC_CH0CTRL_EN;
425 dac->OPACTRL = (dac->OPACTRL
426 & ~(DAC_OPACTRL_OPA0SHORT
427 | _DAC_OPACTRL_OPA0LPFDIS_MASK
428 | DAC_OPACTRL_OPA0HCMDIS))
429 | (init->shortInputs ? DAC_OPACTRL_OPA0SHORT : 0)
430 | (init->lpfPosPadDisable
431 ? DAC_OPACTRL_OPA0LPFDIS_PLPFDIS : 0)
432 | (init->lpfNegPadDisable
433 ? DAC_OPACTRL_OPA0LPFDIS_NLPFDIS : 0)
434 | (init->
hcmDisable ? DAC_OPACTRL_OPA0HCMDIS : 0)
435 | DAC_OPACTRL_OPA0EN;
437 else if ( opa ==
OPA1 )
439 EFM_ASSERT((init->
outPen & ~_DAC_OPA1MUX_OUTPEN_MASK) == 0);
441 dac->BIASPROG = (dac->BIASPROG
442 & ~(_DAC_BIASPROG_BIASPROG_MASK
443 | DAC_BIASPROG_HALFBIAS))
444 | (init->bias << _DAC_BIASPROG_BIASPROG_SHIFT)
445 | (init->halfBias ? DAC_BIASPROG_HALFBIAS : 0 );
447 if (init->defaultOffset)
450 dac->CAL = (dac->CAL & ~_DAC_CAL_CH1OFFSET_MASK)
451 | (offset & _DAC_CAL_CH1OFFSET_MASK);
455 EFM_ASSERT(init->offset <= (_DAC_CAL_CH1OFFSET_MASK
456 >> _DAC_CAL_CH1OFFSET_SHIFT));
458 dac->CAL = (dac->CAL & ~_DAC_CAL_CH1OFFSET_MASK)
459 | (init->offset << _DAC_CAL_CH1OFFSET_SHIFT);
462 dac->OPA1MUX = (uint32_t)init->
resSel
468 | (init->nextOut ? DAC_OPA1MUX_NEXTOUT : 0)
469 | (init->npEn ? DAC_OPA1MUX_NPEN : 0)
470 | (init->ppEn ? DAC_OPA1MUX_PPEN : 0);
472 dac->CH1CTRL |= DAC_CH1CTRL_EN;
473 dac->OPACTRL = (dac->OPACTRL
474 & ~(DAC_OPACTRL_OPA1SHORT
475 | _DAC_OPACTRL_OPA1LPFDIS_MASK
476 | DAC_OPACTRL_OPA1HCMDIS))
477 | (init->shortInputs ? DAC_OPACTRL_OPA1SHORT : 0)
478 | (init->lpfPosPadDisable
479 ? DAC_OPACTRL_OPA1LPFDIS_PLPFDIS : 0)
480 | (init->lpfNegPadDisable
481 ? DAC_OPACTRL_OPA1LPFDIS_NLPFDIS : 0)
482 | (init->
hcmDisable ? DAC_OPACTRL_OPA1HCMDIS : 0)
483 | DAC_OPACTRL_OPA1EN;
487 EFM_ASSERT((init->
posSel == DAC_OPA2MUX_POSSEL_DISABLE)
488 || (init->
posSel == DAC_OPA2MUX_POSSEL_POSPAD)
489 || (init->
posSel == DAC_OPA2MUX_POSSEL_OPA1INP)
490 || (init->
posSel == DAC_OPA2MUX_POSSEL_OPATAP));
492 EFM_ASSERT((init->
outMode & ~DAC_OPA2MUX_OUTMODE) == 0);
494 EFM_ASSERT((init->
outPen & ~_DAC_OPA2MUX_OUTPEN_MASK) == 0);
496 dac->BIASPROG = (dac->BIASPROG
497 & ~(_DAC_BIASPROG_OPA2BIASPROG_MASK
498 | DAC_BIASPROG_OPA2HALFBIAS))
499 | (init->bias << _DAC_BIASPROG_OPA2BIASPROG_SHIFT)
500 | (init->halfBias ? DAC_BIASPROG_OPA2HALFBIAS : 0);
502 if (init->defaultOffset)
505 dac->OPAOFFSET = (dac->OPAOFFSET & ~_DAC_OPAOFFSET_OPA2OFFSET_MASK)
506 | (offset & _DAC_OPAOFFSET_OPA2OFFSET_MASK);
510 EFM_ASSERT(init->offset <= (_DAC_OPAOFFSET_OPA2OFFSET_MASK
511 >> _DAC_OPAOFFSET_OPA2OFFSET_SHIFT));
512 dac->OPAOFFSET = (dac->OPAOFFSET & ~_DAC_OPAOFFSET_OPA2OFFSET_MASK)
513 | (init->offset << _DAC_OPAOFFSET_OPA2OFFSET_SHIFT);
516 dac->OPA2MUX = (uint32_t)init->
resSel
522 | ( init->nextOut ? DAC_OPA2MUX_NEXTOUT : 0 )
523 | ( init->npEn ? DAC_OPA2MUX_NPEN : 0 )
524 | ( init->ppEn ? DAC_OPA2MUX_PPEN : 0 );
526 dac->OPACTRL = (dac->OPACTRL
527 & ~(DAC_OPACTRL_OPA2SHORT
528 | _DAC_OPACTRL_OPA2LPFDIS_MASK
529 | DAC_OPACTRL_OPA2HCMDIS))
530 | (init->shortInputs ? DAC_OPACTRL_OPA2SHORT : 0)
531 | (init->lpfPosPadDisable
532 ? DAC_OPACTRL_OPA2LPFDIS_PLPFDIS : 0)
533 | (init->lpfNegPadDisable
534 ? DAC_OPACTRL_OPA2LPFDIS_NLPFDIS : 0)
535 | (init->
hcmDisable ? DAC_OPACTRL_OPA2HCMDIS : 0)
536 | DAC_OPACTRL_OPA2EN;
539 #elif defined(_SILICON_LABS_32B_SERIES_1)
540 uint32_t calData = 0;
543 EFM_ASSERT(VDAC_REF_VALID(dac));
544 EFM_ASSERT(VDAC_OPA_VALID(opa));
550 EFM_ASSERT(!((init->
gain3xEn ==
true)
635 dac->OPA[opa].MUX = (uint32_t)init->
resSel
641 dac->OPA[opa].OUT = (uint32_t)init->
outMode
664 dac->OPA[opa].TIMER = (uint32_t)(init->
settleTime
666 | (uint32_t)(warmupTime
690 else if (opa ==
OPA1)
#define VDAC_STATUS_OPA1ENS
OPAMP_PosSel_TypeDef posSel
Emlib peripheral API "assert" implementation.
#define VDAC_OPA_CTRL_APORTYMASTERDIS
#define VDAC_STATUS_OPA0ENS
#define _VDAC_OPA_CAL_OFFSETN_SHIFT
OPAMP_ResInMux_TypeDef resInMux
#define _VDAC_OPA_TIMER_SETTLETIME_SHIFT
OPAMP_NegSel_TypeDef negSel
bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress)
Get factory calibration value for a given peripheral register.
#define VDAC_OPA_MUX_GAIN3X
#define VDAC_OPA_CTRL_APORTXMASTERDIS
#define _VDAC_OPA_TIMER_WARMUPTIME_SHIFT
#define _VDAC_OPA_TIMER_STARTUPDLY_SHIFT
#define _VDAC_OPA_TIMER_SETTLETIME_MASK
void OPAMP_Disable(VDAC_TypeDef *dac, OPAMP_TypeDef opa)
Disable an Operational Amplifier.
OPAMP_ResSel_TypeDef resSel
#define _VDAC_OPA_CAL_MASK
OPAMP_PrsOut_TypeDef prsOutSel
OPAMP_PrsSel_TypeDef prsSel
#define VDAC_OPA_CTRL_OUTSCALE_FULL
#define _VDAC_OPA_CAL_OFFSETP_MASK
#define _VDAC_OPA_CAL_OFFSETP_SHIFT
OPAMP_DrvStr_Typedef drvStr
#define VDAC_STATUS_OPA2ENS
#define VDAC_OPA_CTRL_HCMDIS
#define VDAC_OPA_CTRL_PRSEN
#define VDAC_OPA_CTRL_INCBW
#define _VDAC_OPA_CAL_OFFSETN_MASK
#define _VDAC_OPA_OUT_ALTOUTPADEN_MASK
#define _VDAC_OPA_TIMER_STARTUPDLY_MASK
Operational Amplifier (OPAMP) peripheral API.
#define VDAC_OPA_CTRL_OUTSCALE_HALF
OPAMP_PrsMode_TypeDef prsMode
OPAMP_OutMode_TypeDef outMode
#define _SILICON_LABS_32B_SERIES_1
void OPAMP_Enable(VDAC_TypeDef *dac, OPAMP_TypeDef opa, const OPAMP_Init_TypeDef *init)
Configure and enable an Operational Amplifier.