#[doc = "Reader of register CNT"]
pub type R = crate::R<u32, super::CNT>;
#[doc = "Writer for register CNT"]
pub type W = crate::W<u32, super::CNT>;
#[doc = "Register CNT `reset()`'s with value 0"]
impl crate::ResetValue for super::CNT {
    type Type = u32;
    #[inline(always)]
    fn reset_value() -> Self::Type {
        0
    }
}
#[doc = "Reader of field `CNT`"]
pub type CNT_R = crate::R<u16, u16>;
#[doc = "Write proxy for field `CNT`"]
pub struct CNT_W<'a> {
    w: &'a mut W,
}
impl<'a> CNT_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u16) -> &'a mut W {
        self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
        self.w
    }
}
#[doc = "Reader of field `CNTH`"]
pub type CNTH_R = crate::R<u16, u16>;
#[doc = "Write proxy for field `CNTH`"]
pub struct CNTH_W<'a> {
    w: &'a mut W,
}
impl<'a> CNTH_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u16) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x7fff << 16)) | (((value as u32) & 0x7fff) << 16);
        self.w
    }
}
#[doc = "Reader of field `CNT_or_UIFCPY`"]
pub type CNT_OR_UIFCPY_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CNT_or_UIFCPY`"]
pub struct CNT_OR_UIFCPY_W<'a> {
    w: &'a mut W,
}
impl<'a> CNT_OR_UIFCPY_W<'a> {
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:15 - Counter value"]
    #[inline(always)]
    pub fn cnt(&self) -> CNT_R {
        CNT_R::new((self.bits & 0xffff) as u16)
    }
    #[doc = "Bits 16:30 - High counter value"]
    #[inline(always)]
    pub fn cnth(&self) -> CNTH_R {
        CNTH_R::new(((self.bits >> 16) & 0x7fff) as u16)
    }
    #[doc = "Bit 31 - if IUFREMAP=0 than CNT with read write access else UIFCPY with read only access"]
    #[inline(always)]
    pub fn cnt_or_uifcpy(&self) -> CNT_OR_UIFCPY_R {
        CNT_OR_UIFCPY_R::new(((self.bits >> 31) & 0x01) != 0)
    }
}
impl W {
    #[doc = "Bits 0:15 - Counter value"]
    #[inline(always)]
    pub fn cnt(&mut self) -> CNT_W {
        CNT_W { w: self }
    }
    #[doc = "Bits 16:30 - High counter value"]
    #[inline(always)]
    pub fn cnth(&mut self) -> CNTH_W {
        CNTH_W { w: self }
    }
    #[doc = "Bit 31 - if IUFREMAP=0 than CNT with read write access else UIFCPY with read only access"]
    #[inline(always)]
    pub fn cnt_or_uifcpy(&mut self) -> CNT_OR_UIFCPY_W {
        CNT_OR_UIFCPY_W { w: self }
    }
}
