#[doc = "Register `CSRCFG` reader"]
pub type R = crate::R<CsrcfgSpec>;
#[doc = "Register `CSRCFG` writer"]
pub type W = crate::W<CsrcfgSpec>;
#[doc = "Field `DIR` reader - Direction"]
pub type DirR = crate::BitReader;
#[doc = "Field `DIR` writer - Direction"]
pub type DirW<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Frame Counter Selection\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Fcsselect {
    #[doc = "0: Frame Counter 0"]
    Fc0 = 0,
    #[doc = "1: Frame Counter 1"]
    Fc1 = 1,
    #[doc = "2: Frame Counter 2"]
    Fc2 = 2,
}
impl From<Fcsselect> for u8 {
    #[inline(always)]
    fn from(variant: Fcsselect) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for Fcsselect {
    type Ux = u8;
}
impl crate::IsEnum for Fcsselect {}
#[doc = "Field `FCS` reader - Frame Counter Selection"]
pub type FcsR = crate::FieldReader<Fcsselect>;
impl FcsR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Option<Fcsselect> {
        match self.bits {
            0 => Some(Fcsselect::Fc0),
            1 => Some(Fcsselect::Fc1),
            2 => Some(Fcsselect::Fc2),
            _ => None,
        }
    }
    #[doc = "Frame Counter 0"]
    #[inline(always)]
    pub fn is_fc0(&self) -> bool {
        *self == Fcsselect::Fc0
    }
    #[doc = "Frame Counter 1"]
    #[inline(always)]
    pub fn is_fc1(&self) -> bool {
        *self == Fcsselect::Fc1
    }
    #[doc = "Frame Counter 2"]
    #[inline(always)]
    pub fn is_fc2(&self) -> bool {
        *self == Fcsselect::Fc2
    }
}
#[doc = "Field `FCS` writer - Frame Counter Selection"]
pub type FcsW<'a, REG> = crate::FieldWriter<'a, REG, 2, Fcsselect>;
impl<'a, REG> FcsW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "Frame Counter 0"]
    #[inline(always)]
    pub fn fc0(self) -> &'a mut crate::W<REG> {
        self.variant(Fcsselect::Fc0)
    }
    #[doc = "Frame Counter 1"]
    #[inline(always)]
    pub fn fc1(self) -> &'a mut crate::W<REG> {
        self.variant(Fcsselect::Fc1)
    }
    #[doc = "Frame Counter 2"]
    #[inline(always)]
    pub fn fc2(self) -> &'a mut crate::W<REG> {
        self.variant(Fcsselect::Fc2)
    }
}
#[doc = "Field `SIZE` reader - Circular Shift Register Size"]
pub type SizeR = crate::FieldReader;
#[doc = "Field `SIZE` writer - Circular Shift Register Size"]
pub type SizeW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
#[doc = "Field `DATA` reader - Circular Shift Register Value"]
pub type DataR = crate::FieldReader<u16>;
#[doc = "Field `DATA` writer - Circular Shift Register Value"]
pub type DataW<'a, REG> = crate::FieldWriter<'a, REG, 16, u16>;
impl R {
    #[doc = "Bit 0 - Direction"]
    #[inline(always)]
    pub fn dir(&self) -> DirR {
        DirR::new((self.bits & 1) != 0)
    }
    #[doc = "Bits 1:2 - Frame Counter Selection"]
    #[inline(always)]
    pub fn fcs(&self) -> FcsR {
        FcsR::new(((self.bits >> 1) & 3) as u8)
    }
    #[doc = "Bits 4:7 - Circular Shift Register Size"]
    #[inline(always)]
    pub fn size(&self) -> SizeR {
        SizeR::new(((self.bits >> 4) & 0x0f) as u8)
    }
    #[doc = "Bits 8:23 - Circular Shift Register Value"]
    #[inline(always)]
    pub fn data(&self) -> DataR {
        DataR::new(((self.bits >> 8) & 0xffff) as u16)
    }
}
impl W {
    #[doc = "Bit 0 - Direction"]
    #[inline(always)]
    pub fn dir(&mut self) -> DirW<CsrcfgSpec> {
        DirW::new(self, 0)
    }
    #[doc = "Bits 1:2 - Frame Counter Selection"]
    #[inline(always)]
    pub fn fcs(&mut self) -> FcsW<CsrcfgSpec> {
        FcsW::new(self, 1)
    }
    #[doc = "Bits 4:7 - Circular Shift Register Size"]
    #[inline(always)]
    pub fn size(&mut self) -> SizeW<CsrcfgSpec> {
        SizeW::new(self, 4)
    }
    #[doc = "Bits 8:23 - Circular Shift Register Value"]
    #[inline(always)]
    pub fn data(&mut self) -> DataW<CsrcfgSpec> {
        DataW::new(self, 8)
    }
}
#[doc = "Circular Shift Register Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`csrcfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`csrcfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct CsrcfgSpec;
impl crate::RegisterSpec for CsrcfgSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`csrcfg::R`](R) reader structure"]
impl crate::Readable for CsrcfgSpec {}
#[doc = "`write(|w| ..)` method takes [`csrcfg::W`](W) writer structure"]
impl crate::Writable for CsrcfgSpec {
    type Safety = crate::Unsafe;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
#[doc = "`reset()` method sets CSRCFG to value 0"]
impl crate::Resettable for CsrcfgSpec {
    const RESET_VALUE: u32 = 0;
}
