cc430f5137 0.1.0

Peripheral access API for CC430F5137 microcontroller
#[doc = "Register `REFCTL0` reader"]
pub type R = crate::R<Refctl0Spec>;
#[doc = "Register `REFCTL0` writer"]
pub type W = crate::W<Refctl0Spec>;
#[doc = "Field `REFON` reader - REF Reference On"]
pub type RefonR = crate::BitReader;
#[doc = "Field `REFON` writer - REF Reference On"]
pub type RefonW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `REFOUT` reader - REF Reference output Buffer On"]
pub type RefoutR = crate::BitReader;
#[doc = "Field `REFOUT` writer - REF Reference output Buffer On"]
pub type RefoutW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `REFTCOFF` reader - REF Temp.Sensor off"]
pub type ReftcoffR = crate::BitReader;
#[doc = "Field `REFTCOFF` writer - REF Temp.Sensor off"]
pub type ReftcoffW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "REF Reference Voltage Level Select Bit:0\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Refvsel {
    #[doc = "0: REF Reference Voltage Level Select 1.5V"]
    Refvsel0 = 0,
    #[doc = "1: REF Reference Voltage Level Select 2.0V"]
    Refvsel1 = 1,
    #[doc = "2: REF Reference Voltage Level Select 2.5V"]
    Refvsel2 = 2,
    #[doc = "3: REF Reference Voltage Level Select 2.5V"]
    Refvsel3 = 3,
}
impl From<Refvsel> for u8 {
    #[inline(always)]
    fn from(variant: Refvsel) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for Refvsel {
    type Ux = u8;
}
impl crate::IsEnum for Refvsel {}
#[doc = "Field `REFVSEL` reader - REF Reference Voltage Level Select Bit:0"]
pub type RefvselR = crate::FieldReader<Refvsel>;
impl RefvselR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Refvsel {
        match self.bits {
            0 => Refvsel::Refvsel0,
            1 => Refvsel::Refvsel1,
            2 => Refvsel::Refvsel2,
            3 => Refvsel::Refvsel3,
            _ => unreachable!(),
        }
    }
    #[doc = "REF Reference Voltage Level Select 1.5V"]
    #[inline(always)]
    pub fn is_refvsel_0(&self) -> bool {
        *self == Refvsel::Refvsel0
    }
    #[doc = "REF Reference Voltage Level Select 2.0V"]
    #[inline(always)]
    pub fn is_refvsel_1(&self) -> bool {
        *self == Refvsel::Refvsel1
    }
    #[doc = "REF Reference Voltage Level Select 2.5V"]
    #[inline(always)]
    pub fn is_refvsel_2(&self) -> bool {
        *self == Refvsel::Refvsel2
    }
    #[doc = "REF Reference Voltage Level Select 2.5V"]
    #[inline(always)]
    pub fn is_refvsel_3(&self) -> bool {
        *self == Refvsel::Refvsel3
    }
}
#[doc = "Field `REFVSEL` writer - REF Reference Voltage Level Select Bit:0"]
pub type RefvselW<'a, REG> = crate::FieldWriter<'a, REG, 2, Refvsel, crate::Safe>;
impl<'a, REG> RefvselW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "REF Reference Voltage Level Select 1.5V"]
    #[inline(always)]
    pub fn refvsel_0(self) -> &'a mut crate::W<REG> {
        self.variant(Refvsel::Refvsel0)
    }
    #[doc = "REF Reference Voltage Level Select 2.0V"]
    #[inline(always)]
    pub fn refvsel_1(self) -> &'a mut crate::W<REG> {
        self.variant(Refvsel::Refvsel1)
    }
    #[doc = "REF Reference Voltage Level Select 2.5V"]
    #[inline(always)]
    pub fn refvsel_2(self) -> &'a mut crate::W<REG> {
        self.variant(Refvsel::Refvsel2)
    }
    #[doc = "REF Reference Voltage Level Select 2.5V"]
    #[inline(always)]
    pub fn refvsel_3(self) -> &'a mut crate::W<REG> {
        self.variant(Refvsel::Refvsel3)
    }
}
#[doc = "Field `REFMSTR` reader - REF Master Control"]
pub type RefmstrR = crate::BitReader;
#[doc = "Field `REFMSTR` writer - REF Master Control"]
pub type RefmstrW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `REFGENACT` reader - REF Reference generator active"]
pub type RefgenactR = crate::BitReader;
#[doc = "Field `REFGENACT` writer - REF Reference generator active"]
pub type RefgenactW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `REFBGACT` reader - REF Reference bandgap active"]
pub type RefbgactR = crate::BitReader;
#[doc = "Field `REFBGACT` writer - REF Reference bandgap active"]
pub type RefbgactW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `REFGENBUSY` reader - REF Reference generator busy"]
pub type RefgenbusyR = crate::BitReader;
#[doc = "Field `REFGENBUSY` writer - REF Reference generator busy"]
pub type RefgenbusyW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `BGMODE` reader - REF Bandgap mode"]
pub type BgmodeR = crate::BitReader;
#[doc = "Field `BGMODE` writer - REF Bandgap mode"]
pub type BgmodeW<'a, REG> = crate::BitWriter<'a, REG>;
impl R {
    #[doc = "Bit 0 - REF Reference On"]
    #[inline(always)]
    pub fn refon(&self) -> RefonR {
        RefonR::new((self.bits & 1) != 0)
    }
    #[doc = "Bit 1 - REF Reference output Buffer On"]
    #[inline(always)]
    pub fn refout(&self) -> RefoutR {
        RefoutR::new(((self.bits >> 1) & 1) != 0)
    }
    #[doc = "Bit 3 - REF Temp.Sensor off"]
    #[inline(always)]
    pub fn reftcoff(&self) -> ReftcoffR {
        ReftcoffR::new(((self.bits >> 3) & 1) != 0)
    }
    #[doc = "Bits 4:5 - REF Reference Voltage Level Select Bit:0"]
    #[inline(always)]
    pub fn refvsel(&self) -> RefvselR {
        RefvselR::new(((self.bits >> 4) & 3) as u8)
    }
    #[doc = "Bit 7 - REF Master Control"]
    #[inline(always)]
    pub fn refmstr(&self) -> RefmstrR {
        RefmstrR::new(((self.bits >> 7) & 1) != 0)
    }
    #[doc = "Bit 8 - REF Reference generator active"]
    #[inline(always)]
    pub fn refgenact(&self) -> RefgenactR {
        RefgenactR::new(((self.bits >> 8) & 1) != 0)
    }
    #[doc = "Bit 9 - REF Reference bandgap active"]
    #[inline(always)]
    pub fn refbgact(&self) -> RefbgactR {
        RefbgactR::new(((self.bits >> 9) & 1) != 0)
    }
    #[doc = "Bit 10 - REF Reference generator busy"]
    #[inline(always)]
    pub fn refgenbusy(&self) -> RefgenbusyR {
        RefgenbusyR::new(((self.bits >> 10) & 1) != 0)
    }
    #[doc = "Bit 11 - REF Bandgap mode"]
    #[inline(always)]
    pub fn bgmode(&self) -> BgmodeR {
        BgmodeR::new(((self.bits >> 11) & 1) != 0)
    }
}
impl W {
    #[doc = "Bit 0 - REF Reference On"]
    #[inline(always)]
    pub fn refon(&mut self) -> RefonW<'_, Refctl0Spec> {
        RefonW::new(self, 0)
    }
    #[doc = "Bit 1 - REF Reference output Buffer On"]
    #[inline(always)]
    pub fn refout(&mut self) -> RefoutW<'_, Refctl0Spec> {
        RefoutW::new(self, 1)
    }
    #[doc = "Bit 3 - REF Temp.Sensor off"]
    #[inline(always)]
    pub fn reftcoff(&mut self) -> ReftcoffW<'_, Refctl0Spec> {
        ReftcoffW::new(self, 3)
    }
    #[doc = "Bits 4:5 - REF Reference Voltage Level Select Bit:0"]
    #[inline(always)]
    pub fn refvsel(&mut self) -> RefvselW<'_, Refctl0Spec> {
        RefvselW::new(self, 4)
    }
    #[doc = "Bit 7 - REF Master Control"]
    #[inline(always)]
    pub fn refmstr(&mut self) -> RefmstrW<'_, Refctl0Spec> {
        RefmstrW::new(self, 7)
    }
    #[doc = "Bit 8 - REF Reference generator active"]
    #[inline(always)]
    pub fn refgenact(&mut self) -> RefgenactW<'_, Refctl0Spec> {
        RefgenactW::new(self, 8)
    }
    #[doc = "Bit 9 - REF Reference bandgap active"]
    #[inline(always)]
    pub fn refbgact(&mut self) -> RefbgactW<'_, Refctl0Spec> {
        RefbgactW::new(self, 9)
    }
    #[doc = "Bit 10 - REF Reference generator busy"]
    #[inline(always)]
    pub fn refgenbusy(&mut self) -> RefgenbusyW<'_, Refctl0Spec> {
        RefgenbusyW::new(self, 10)
    }
    #[doc = "Bit 11 - REF Bandgap mode"]
    #[inline(always)]
    pub fn bgmode(&mut self) -> BgmodeW<'_, Refctl0Spec> {
        BgmodeW::new(self, 11)
    }
}
#[doc = "REF Shared Reference control register 0\n\nYou can [`read`](crate::Reg::read) this register and get [`refctl0::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`refctl0::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct Refctl0Spec;
impl crate::RegisterSpec for Refctl0Spec {
    type Ux = u16;
}
#[doc = "`read()` method returns [`refctl0::R`](R) reader structure"]
impl crate::Readable for Refctl0Spec {}
#[doc = "`write(|w| ..)` method takes [`refctl0::W`](W) writer structure"]
impl crate::Writable for Refctl0Spec {
    type Safety = crate::Unsafe;
}
#[doc = "`reset()` method sets REFCTL0 to value 0"]
impl crate::Resettable for Refctl0Spec {}