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));
292 dac->CMD |= VDAC_CMD_OPA0DIS;
293 while (dac->STATUS & VDAC_STATUS_OPA0ENS)
297 else if (opa == OPA1)
299 dac->CMD |= VDAC_CMD_OPA1DIS;
300 while (dac->STATUS & VDAC_STATUS_OPA1ENS)
306 dac->CMD |= VDAC_CMD_OPA2DIS;
307 while (dac->STATUS & VDAC_STATUS_OPA2ENS)
373 #
if defined(_SILICON_LABS_32B_SERIES_0)
379 const OPAMP_Init_TypeDef *init)
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
415 | (uint32_t)init->outMode
417 | (uint32_t)init->resInMux
418 | (uint32_t)init->negSel
419 | (uint32_t)init->posSel
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
463 | (uint32_t)init->outMode
465 | (uint32_t)init->resInMux
466 | (uint32_t)init->negSel
467 | (uint32_t)init->posSel
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
517 | (uint32_t)init->outMode
519 | (uint32_t)init->resInMux
520 | (uint32_t)init->negSel
521 | (uint32_t)init->posSel
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));
545 EFM_ASSERT(init->settleTime <= (_VDAC_OPA_TIMER_SETTLETIME_MASK
546 >> _VDAC_OPA_TIMER_SETTLETIME_SHIFT));
547 EFM_ASSERT(init->startupDly <= (_VDAC_OPA_TIMER_STARTUPDLY_MASK
548 >> _VDAC_OPA_TIMER_STARTUPDLY_SHIFT));
549 EFM_ASSERT((init->outPen & ~_VDAC_OPA_OUT_ALTOUTPADEN_MASK) == 0);
550 EFM_ASSERT(!((init->gain3xEn ==
true)
551 && ((init->negSel == opaNegSelResTap)
552 || (init->posSel == opaPosSelResTap))));
553 EFM_ASSERT((init->drvStr == opaDrvStrLowerAccLowStr)
554 || (init->drvStr == opaDrvStrLowAccLowStr)
555 || (init->drvStr == opaDrvStrHighAccHighStr)
556 || (init->drvStr == opaDrvStrHigherAccHighStr));
559 OPAMP_Disable(dac, opa);
565 switch (init->drvStr)
567 case opaDrvStrLowerAccLowStr:
568 calData = (init->ugBwScale ?
DEVINFO->OPA0CAL0 :
DEVINFO->OPA0CAL4);
570 case opaDrvStrLowAccLowStr:
571 calData = (init->ugBwScale ?
DEVINFO->OPA0CAL1 :
DEVINFO->OPA0CAL5);
573 case opaDrvStrHighAccHighStr:
574 calData = (init->ugBwScale ?
DEVINFO->OPA0CAL2 :
DEVINFO->OPA0CAL6);
576 case opaDrvStrHigherAccHighStr:
577 calData = (init->ugBwScale ?
DEVINFO->OPA0CAL3 :
DEVINFO->OPA0CAL7);
583 switch (init->drvStr)
585 case opaDrvStrLowerAccLowStr:
586 calData = (init->ugBwScale ?
DEVINFO->OPA1CAL0 :
DEVINFO->OPA1CAL4);
588 case opaDrvStrLowAccLowStr:
589 calData = (init->ugBwScale ?
DEVINFO->OPA1CAL1 :
DEVINFO->OPA1CAL5);
591 case opaDrvStrHighAccHighStr:
592 calData = (init->ugBwScale ?
DEVINFO->OPA1CAL2 :
DEVINFO->OPA1CAL6);
594 case opaDrvStrHigherAccHighStr:
595 calData = (init->ugBwScale ?
DEVINFO->OPA1CAL3 :
DEVINFO->OPA1CAL7);
601 switch (init->drvStr)
603 case opaDrvStrLowerAccLowStr:
604 calData = (init->ugBwScale ?
DEVINFO->OPA2CAL0 :
DEVINFO->OPA2CAL4);
606 case opaDrvStrLowAccLowStr:
607 calData = (init->ugBwScale ?
DEVINFO->OPA2CAL1 :
DEVINFO->OPA2CAL5);
609 case opaDrvStrHighAccHighStr:
610 calData = (init->ugBwScale ?
DEVINFO->OPA2CAL2 :
DEVINFO->OPA2CAL6);
612 case opaDrvStrHigherAccHighStr:
613 calData = (init->ugBwScale ?
DEVINFO->OPA2CAL3 :
DEVINFO->OPA2CAL7);
618 if (!init->defaultOffsetN)
620 EFM_ASSERT(init->offsetN <= (_VDAC_OPA_CAL_OFFSETN_MASK
621 >> _VDAC_OPA_CAL_OFFSETN_SHIFT));
622 calData = (calData & ~_VDAC_OPA_CAL_OFFSETN_MASK)
623 | (init->offsetN << _VDAC_OPA_CAL_OFFSETN_SHIFT);
625 if (!init->defaultOffsetP)
627 EFM_ASSERT(init->offsetP <= (_VDAC_OPA_CAL_OFFSETP_MASK
628 >> _VDAC_OPA_CAL_OFFSETP_SHIFT));
629 calData = (calData & ~_VDAC_OPA_CAL_OFFSETP_MASK)
630 | (init->offsetP << _VDAC_OPA_CAL_OFFSETP_SHIFT);
633 dac->OPA[opa].CAL = (calData & _VDAC_OPA_CAL_MASK);
635 dac->OPA[opa].MUX = (uint32_t)init->resSel
636 | (init->gain3xEn ? VDAC_OPA_MUX_GAIN3X : 0)
637 | (uint32_t)init->resInMux
638 | (uint32_t)init->negSel
639 | (uint32_t)init->posSel;
641 dac->OPA[opa].OUT = (uint32_t)init->outMode
642 | (uint32_t)init->outPen;
644 switch (init->drvStr)
646 case opaDrvStrHigherAccHighStr:
650 case opaDrvStrHighAccHighStr:
654 case opaDrvStrLowAccLowStr:
658 case opaDrvStrLowerAccLowStr:
664 dac->OPA[opa].TIMER = (uint32_t)(init->settleTime
665 << _VDAC_OPA_TIMER_SETTLETIME_SHIFT)
666 | (uint32_t)(warmupTime
667 << _VDAC_OPA_TIMER_WARMUPTIME_SHIFT)
668 | (uint32_t)(init->startupDly
669 << _VDAC_OPA_TIMER_STARTUPDLY_SHIFT);
671 dac->OPA[opa].CTRL = (init->aportYMasterDisable
672 ? VDAC_OPA_CTRL_APORTYMASTERDIS : 0)
673 | (init->aportXMasterDisable
674 ? VDAC_OPA_CTRL_APORTXMASTERDIS : 0)
675 | (uint32_t)init->prsOutSel
676 | (uint32_t)init->prsSel
677 | (uint32_t)init->prsMode
678 | (init->prsEn ? VDAC_OPA_CTRL_PRSEN : 0)
680 ? VDAC_OPA_CTRL_OUTSCALE_HALF
681 : VDAC_OPA_CTRL_OUTSCALE_FULL)
682 | (init->hcmDisable ? VDAC_OPA_CTRL_HCMDIS : 0)
683 | (init->ugBwScale ? VDAC_OPA_CTRL_INCBW : 0)
684 | (uint32_t)init->drvStr;
688 dac->CMD |= VDAC_CMD_OPA0EN;
690 else if (opa == OPA1)
692 dac->CMD |= VDAC_CMD_OPA1EN;
696 dac->CMD |= VDAC_CMD_OPA2EN;
Emlib peripheral API "assert" implementation.
bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress)
Get factory calibration value for a given peripheral register.
#define _SILICON_LABS_32B_SERIES_1
Operational Amplifier (OPAMP) peripheral API.