#[doc = "Register `TTCAN_TIMING` reader"]
pub struct R(crate::R<TTCAN_TIMING_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<TTCAN_TIMING_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<TTCAN_TIMING_SPEC>> for R {
    fn from(reader: crate::R<TTCAN_TIMING_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `TTCAN_TIMING` writer"]
pub struct W(crate::W<TTCAN_TIMING_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<TTCAN_TIMING_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<TTCAN_TIMING_SPEC>> for W {
    fn from(writer: crate::W<TTCAN_TIMING_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `SAMPLING_MODE` reader - CAN bus bit sampling??0?: One sampling point is used in the receiver path??1?: 3 sampling points with majority decision are used"]
pub struct SAMPLING_MODE_R(crate::FieldReader<bool, bool>);
impl SAMPLING_MODE_R {
    pub(crate) fn new(bits: bool) -> Self {
        SAMPLING_MODE_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for SAMPLING_MODE_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `SAMPLING_MODE` writer - CAN bus bit sampling??0?: One sampling point is used in the receiver path??1?: 3 sampling points with majority decision are used"]
pub struct SAMPLING_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> SAMPLING_MODE_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 << 1)) | ((value as u32 & 0x01) << 1);
        self.w
    }
}
#[doc = "Field `CFG_TSEG2` reader - Time segment 2?Length of the second time segment:?tseg2 = cfg_tseg2 + 1?cfg_tseg2=0 is not allowed; cfg_tseg2=1 is only?allowed in direct sampling mode."]
pub struct CFG_TSEG2_R(crate::FieldReader<u8, u8>);
impl CFG_TSEG2_R {
    pub(crate) fn new(bits: u8) -> Self {
        CFG_TSEG2_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for CFG_TSEG2_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CFG_TSEG2` writer - Time segment 2?Length of the second time segment:?tseg2 = cfg_tseg2 + 1?cfg_tseg2=0 is not allowed; cfg_tseg2=1 is only?allowed in direct sampling mode."]
pub struct CFG_TSEG2_W<'a> {
    w: &'a mut W,
}
impl<'a> CFG_TSEG2_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x07 << 5)) | ((value as u32 & 0x07) << 5);
        self.w
    }
}
#[doc = "Field `CFG_TSEG1` reader - Time segment 1?Length of the first time segment:?tseg1 = cfg_tseg1 + 1?Time segment 1 includes the propagation time.?cfg_tseg1=0 and cfg_tseg1=1 are not allowed."]
pub struct CFG_TSEG1_R(crate::FieldReader<u8, u8>);
impl CFG_TSEG1_R {
    pub(crate) fn new(bits: u8) -> Self {
        CFG_TSEG1_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for CFG_TSEG1_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CFG_TSEG1` writer - Time segment 1?Length of the first time segment:?tseg1 = cfg_tseg1 + 1?Time segment 1 includes the propagation time.?cfg_tseg1=0 and cfg_tseg1=1 are not allowed."]
pub struct CFG_TSEG1_W<'a> {
    w: &'a mut W,
}
impl<'a> CFG_TSEG1_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x0f << 8)) | ((value as u32 & 0x0f) << 8);
        self.w
    }
}
#[doc = "Field `CFG_BITRATE` reader - Prescaler for generating the time quantum?which defines the TQ:?0: One time quantum equals 1 clock cycle?1: One time quantum equals 2 clock cycles?...?32767: One time quantum equals 32768 clock?cycles"]
pub struct CFG_BITRATE_R(crate::FieldReader<u16, u16>);
impl CFG_BITRATE_R {
    pub(crate) fn new(bits: u16) -> Self {
        CFG_BITRATE_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for CFG_BITRATE_R {
    type Target = crate::FieldReader<u16, u16>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `CFG_BITRATE` writer - Prescaler for generating the time quantum?which defines the TQ:?0: One time quantum equals 1 clock cycle?1: One time quantum equals 2 clock cycles?...?32767: One time quantum equals 32768 clock?cycles"]
pub struct CFG_BITRATE_W<'a> {
    w: &'a mut W,
}
impl<'a> CFG_BITRATE_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
    }
}
impl R {
    #[doc = "Bit 1 - CAN bus bit sampling??0?: One sampling point is used in the receiver path??1?: 3 sampling points with majority decision are used"]
    #[inline(always)]
    pub fn sampling_mode(&self) -> SAMPLING_MODE_R {
        SAMPLING_MODE_R::new(((self.bits >> 1) & 0x01) != 0)
    }
    #[doc = "Bits 5:7 - Time segment 2?Length of the second time segment:?tseg2 = cfg_tseg2 + 1?cfg_tseg2=0 is not allowed; cfg_tseg2=1 is only?allowed in direct sampling mode."]
    #[inline(always)]
    pub fn cfg_tseg2(&self) -> CFG_TSEG2_R {
        CFG_TSEG2_R::new(((self.bits >> 5) & 0x07) as u8)
    }
    #[doc = "Bits 8:11 - Time segment 1?Length of the first time segment:?tseg1 = cfg_tseg1 + 1?Time segment 1 includes the propagation time.?cfg_tseg1=0 and cfg_tseg1=1 are not allowed."]
    #[inline(always)]
    pub fn cfg_tseg1(&self) -> CFG_TSEG1_R {
        CFG_TSEG1_R::new(((self.bits >> 8) & 0x0f) as u8)
    }
    #[doc = "Bits 16:30 - Prescaler for generating the time quantum?which defines the TQ:?0: One time quantum equals 1 clock cycle?1: One time quantum equals 2 clock cycles?...?32767: One time quantum equals 32768 clock?cycles"]
    #[inline(always)]
    pub fn cfg_bitrate(&self) -> CFG_BITRATE_R {
        CFG_BITRATE_R::new(((self.bits >> 16) & 0x7fff) as u16)
    }
}
impl W {
    #[doc = "Bit 1 - CAN bus bit sampling??0?: One sampling point is used in the receiver path??1?: 3 sampling points with majority decision are used"]
    #[inline(always)]
    pub fn sampling_mode(&mut self) -> SAMPLING_MODE_W {
        SAMPLING_MODE_W { w: self }
    }
    #[doc = "Bits 5:7 - Time segment 2?Length of the second time segment:?tseg2 = cfg_tseg2 + 1?cfg_tseg2=0 is not allowed; cfg_tseg2=1 is only?allowed in direct sampling mode."]
    #[inline(always)]
    pub fn cfg_tseg2(&mut self) -> CFG_TSEG2_W {
        CFG_TSEG2_W { w: self }
    }
    #[doc = "Bits 8:11 - Time segment 1?Length of the first time segment:?tseg1 = cfg_tseg1 + 1?Time segment 1 includes the propagation time.?cfg_tseg1=0 and cfg_tseg1=1 are not allowed."]
    #[inline(always)]
    pub fn cfg_tseg1(&mut self) -> CFG_TSEG1_W {
        CFG_TSEG1_W { w: self }
    }
    #[doc = "Bits 16:30 - Prescaler for generating the time quantum?which defines the TQ:?0: One time quantum equals 1 clock cycle?1: One time quantum equals 2 clock cycles?...?32767: One time quantum equals 32768 clock?cycles"]
    #[inline(always)]
    pub fn cfg_bitrate(&mut self) -> CFG_BITRATE_W {
        CFG_BITRATE_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "TTCAN Level1 timing configuration, duplicate of CONFIG fields\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ttcan_timing](index.html) module"]
pub struct TTCAN_TIMING_SPEC;
impl crate::RegisterSpec for TTCAN_TIMING_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [ttcan_timing::R](R) reader structure"]
impl crate::Readable for TTCAN_TIMING_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [ttcan_timing::W](W) writer structure"]
impl crate::Writable for TTCAN_TIMING_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets TTCAN_TIMING to value 0"]
impl crate::Resettable for TTCAN_TIMING_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
