#[doc = "Register `MOD` reader"]
pub type R = crate::R<ModSpec>;
#[doc = "Register `MOD` writer"]
pub type W = crate::W<ModSpec>;
#[doc = "Reset Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModRmEnum {
    #[doc = "0: Normal.The CAN Controller is in the Operating Mode, and certain registers can not be written."]
    NormalTheCanContr = 0,
    #[doc = "1: Reset. CAN operation is disabled, writable registers can be written and the current transmission/reception of a message is aborted."]
    ResetCanOperation = 1,
}
impl From<Can1ModRmEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModRmEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `RM` reader - Reset Mode."]
pub type RmR = crate::BitReader<Can1ModRmEnum>;
impl RmR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModRmEnum {
        match self.bits {
            false => Can1ModRmEnum::NormalTheCanContr,
            true => Can1ModRmEnum::ResetCanOperation,
        }
    }
    #[doc = "Normal.The CAN Controller is in the Operating Mode, and certain registers can not be written."]
    #[inline(always)]
    pub fn is_normal_the_can_contr(&self) -> bool {
        *self == Can1ModRmEnum::NormalTheCanContr
    }
    #[doc = "Reset. CAN operation is disabled, writable registers can be written and the current transmission/reception of a message is aborted."]
    #[inline(always)]
    pub fn is_reset_can_operation(&self) -> bool {
        *self == Can1ModRmEnum::ResetCanOperation
    }
}
#[doc = "Field `RM` writer - Reset Mode."]
pub type RmW<'a, REG> = crate::BitWriter<'a, REG, Can1ModRmEnum>;
impl<'a, REG> RmW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Normal.The CAN Controller is in the Operating Mode, and certain registers can not be written."]
    #[inline(always)]
    pub fn normal_the_can_contr(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModRmEnum::NormalTheCanContr)
    }
    #[doc = "Reset. CAN operation is disabled, writable registers can be written and the current transmission/reception of a message is aborted."]
    #[inline(always)]
    pub fn reset_can_operation(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModRmEnum::ResetCanOperation)
    }
}
#[doc = "Listen Only Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModLomEnum {
    #[doc = "0: Normal. The CAN controller acknowledges a successfully received message on the CAN bus. The error counters are stopped at the current value."]
    NormalTheCanCont = 0,
    #[doc = "1: Listen only. The controller gives no acknowledgment, even if a message is successfully received. Messages cannot be sent, and the controller operates in error passive mode. This mode is intended for software bit rate detection and hot plugging."]
    ListenOnlyTheCon = 1,
}
impl From<Can1ModLomEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModLomEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `LOM` reader - Listen Only Mode."]
pub type LomR = crate::BitReader<Can1ModLomEnum>;
impl LomR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModLomEnum {
        match self.bits {
            false => Can1ModLomEnum::NormalTheCanCont,
            true => Can1ModLomEnum::ListenOnlyTheCon,
        }
    }
    #[doc = "Normal. The CAN controller acknowledges a successfully received message on the CAN bus. The error counters are stopped at the current value."]
    #[inline(always)]
    pub fn is_normal_the_can_cont(&self) -> bool {
        *self == Can1ModLomEnum::NormalTheCanCont
    }
    #[doc = "Listen only. The controller gives no acknowledgment, even if a message is successfully received. Messages cannot be sent, and the controller operates in error passive mode. This mode is intended for software bit rate detection and hot plugging."]
    #[inline(always)]
    pub fn is_listen_only_the_con(&self) -> bool {
        *self == Can1ModLomEnum::ListenOnlyTheCon
    }
}
#[doc = "Field `LOM` writer - Listen Only Mode."]
pub type LomW<'a, REG> = crate::BitWriter<'a, REG, Can1ModLomEnum>;
impl<'a, REG> LomW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Normal. The CAN controller acknowledges a successfully received message on the CAN bus. The error counters are stopped at the current value."]
    #[inline(always)]
    pub fn normal_the_can_cont(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModLomEnum::NormalTheCanCont)
    }
    #[doc = "Listen only. The controller gives no acknowledgment, even if a message is successfully received. Messages cannot be sent, and the controller operates in error passive mode. This mode is intended for software bit rate detection and hot plugging."]
    #[inline(always)]
    pub fn listen_only_the_con(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModLomEnum::ListenOnlyTheCon)
    }
}
#[doc = "Self Test Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModStmEnum {
    #[doc = "0: Normal. A transmitted message must be acknowledged to be considered successful."]
    NormalATransmitte = 0,
    #[doc = "1: Self test. The controller will consider a Tx message successful even if there is no acknowledgment received. In this mode a full node test is possible without any other active node on the bus using the SRR bit in CANxCMR."]
    SelfTestTheContr = 1,
}
impl From<Can1ModStmEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModStmEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `STM` reader - Self Test Mode."]
pub type StmR = crate::BitReader<Can1ModStmEnum>;
impl StmR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModStmEnum {
        match self.bits {
            false => Can1ModStmEnum::NormalATransmitte,
            true => Can1ModStmEnum::SelfTestTheContr,
        }
    }
    #[doc = "Normal. A transmitted message must be acknowledged to be considered successful."]
    #[inline(always)]
    pub fn is_normal_a_transmitte(&self) -> bool {
        *self == Can1ModStmEnum::NormalATransmitte
    }
    #[doc = "Self test. The controller will consider a Tx message successful even if there is no acknowledgment received. In this mode a full node test is possible without any other active node on the bus using the SRR bit in CANxCMR."]
    #[inline(always)]
    pub fn is_self_test_the_contr(&self) -> bool {
        *self == Can1ModStmEnum::SelfTestTheContr
    }
}
#[doc = "Field `STM` writer - Self Test Mode."]
pub type StmW<'a, REG> = crate::BitWriter<'a, REG, Can1ModStmEnum>;
impl<'a, REG> StmW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Normal. A transmitted message must be acknowledged to be considered successful."]
    #[inline(always)]
    pub fn normal_a_transmitte(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModStmEnum::NormalATransmitte)
    }
    #[doc = "Self test. The controller will consider a Tx message successful even if there is no acknowledgment received. In this mode a full node test is possible without any other active node on the bus using the SRR bit in CANxCMR."]
    #[inline(always)]
    pub fn self_test_the_contr(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModStmEnum::SelfTestTheContr)
    }
}
#[doc = "Transmit Priority Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModTpmEnum {
    #[doc = "0: CAN ID. The transmit priority for 3 Transmit Buffers depends on the CAN Identifier."]
    CanIdTheTransmit = 0,
    #[doc = "1: Local priority. The transmit priority for 3 Transmit Buffers depends on the contents of the Tx Priority register within the Transmit Buffer."]
    LocalPriorityThe_ = 1,
}
impl From<Can1ModTpmEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModTpmEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `TPM` reader - Transmit Priority Mode."]
pub type TpmR = crate::BitReader<Can1ModTpmEnum>;
impl TpmR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModTpmEnum {
        match self.bits {
            false => Can1ModTpmEnum::CanIdTheTransmit,
            true => Can1ModTpmEnum::LocalPriorityThe_,
        }
    }
    #[doc = "CAN ID. The transmit priority for 3 Transmit Buffers depends on the CAN Identifier."]
    #[inline(always)]
    pub fn is_can_id_the_transmit(&self) -> bool {
        *self == Can1ModTpmEnum::CanIdTheTransmit
    }
    #[doc = "Local priority. The transmit priority for 3 Transmit Buffers depends on the contents of the Tx Priority register within the Transmit Buffer."]
    #[inline(always)]
    pub fn is_local_priority_the_(&self) -> bool {
        *self == Can1ModTpmEnum::LocalPriorityThe_
    }
}
#[doc = "Field `TPM` writer - Transmit Priority Mode."]
pub type TpmW<'a, REG> = crate::BitWriter<'a, REG, Can1ModTpmEnum>;
impl<'a, REG> TpmW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "CAN ID. The transmit priority for 3 Transmit Buffers depends on the CAN Identifier."]
    #[inline(always)]
    pub fn can_id_the_transmit(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModTpmEnum::CanIdTheTransmit)
    }
    #[doc = "Local priority. The transmit priority for 3 Transmit Buffers depends on the contents of the Tx Priority register within the Transmit Buffer."]
    #[inline(always)]
    pub fn local_priority_the_(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModTpmEnum::LocalPriorityThe_)
    }
}
#[doc = "Sleep Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModSmEnum {
    #[doc = "0: Wake-up. Normal operation."]
    WakeUpNormalOper = 0,
    #[doc = "1: Sleep. The CAN controller enters Sleep Mode if no CAN interrupt is pending and there is no bus activity. See the Sleep Mode description Section 21.8.2 on page 565."]
    SleepTheCanContr = 1,
}
impl From<Can1ModSmEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModSmEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `SM` reader - Sleep Mode."]
pub type SmR = crate::BitReader<Can1ModSmEnum>;
impl SmR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModSmEnum {
        match self.bits {
            false => Can1ModSmEnum::WakeUpNormalOper,
            true => Can1ModSmEnum::SleepTheCanContr,
        }
    }
    #[doc = "Wake-up. Normal operation."]
    #[inline(always)]
    pub fn is_wake_up_normal_oper(&self) -> bool {
        *self == Can1ModSmEnum::WakeUpNormalOper
    }
    #[doc = "Sleep. The CAN controller enters Sleep Mode if no CAN interrupt is pending and there is no bus activity. See the Sleep Mode description Section 21.8.2 on page 565."]
    #[inline(always)]
    pub fn is_sleep_the_can_contr(&self) -> bool {
        *self == Can1ModSmEnum::SleepTheCanContr
    }
}
#[doc = "Field `SM` writer - Sleep Mode."]
pub type SmW<'a, REG> = crate::BitWriter<'a, REG, Can1ModSmEnum>;
impl<'a, REG> SmW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Wake-up. Normal operation."]
    #[inline(always)]
    pub fn wake_up_normal_oper(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModSmEnum::WakeUpNormalOper)
    }
    #[doc = "Sleep. The CAN controller enters Sleep Mode if no CAN interrupt is pending and there is no bus activity. See the Sleep Mode description Section 21.8.2 on page 565."]
    #[inline(always)]
    pub fn sleep_the_can_contr(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModSmEnum::SleepTheCanContr)
    }
}
#[doc = "Receive Polarity Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModRpmEnum {
    #[doc = "0: Low active. RD input is active Low (dominant bit = 0)."]
    LowActiveRdInput = 0,
    #[doc = "1: High active. RD input is active High (dominant bit = 1) -- reverse polarity."]
    HighActiveRdInpu = 1,
}
impl From<Can1ModRpmEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModRpmEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `RPM` reader - Receive Polarity Mode."]
pub type RpmR = crate::BitReader<Can1ModRpmEnum>;
impl RpmR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModRpmEnum {
        match self.bits {
            false => Can1ModRpmEnum::LowActiveRdInput,
            true => Can1ModRpmEnum::HighActiveRdInpu,
        }
    }
    #[doc = "Low active. RD input is active Low (dominant bit = 0)."]
    #[inline(always)]
    pub fn is_low_active_rd_input(&self) -> bool {
        *self == Can1ModRpmEnum::LowActiveRdInput
    }
    #[doc = "High active. RD input is active High (dominant bit = 1) -- reverse polarity."]
    #[inline(always)]
    pub fn is_high_active_rd_inpu(&self) -> bool {
        *self == Can1ModRpmEnum::HighActiveRdInpu
    }
}
#[doc = "Field `RPM` writer - Receive Polarity Mode."]
pub type RpmW<'a, REG> = crate::BitWriter<'a, REG, Can1ModRpmEnum>;
impl<'a, REG> RpmW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Low active. RD input is active Low (dominant bit = 0)."]
    #[inline(always)]
    pub fn low_active_rd_input(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModRpmEnum::LowActiveRdInput)
    }
    #[doc = "High active. RD input is active High (dominant bit = 1) -- reverse polarity."]
    #[inline(always)]
    pub fn high_active_rd_inpu(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModRpmEnum::HighActiveRdInpu)
    }
}
#[doc = "Test Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Can1ModTmEnum {
    #[doc = "0: Disabled. Normal operation."]
    DisabledNormalOpe = 0,
    #[doc = "1: Enabled. The TD pin will reflect the bit, detected on RD pin, with the next positive edge of the system clock."]
    EnabledTheTdPin_ = 1,
}
impl From<Can1ModTmEnum> for bool {
    #[inline(always)]
    fn from(variant: Can1ModTmEnum) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `TM` reader - Test Mode."]
pub type TmR = crate::BitReader<Can1ModTmEnum>;
impl TmR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Can1ModTmEnum {
        match self.bits {
            false => Can1ModTmEnum::DisabledNormalOpe,
            true => Can1ModTmEnum::EnabledTheTdPin_,
        }
    }
    #[doc = "Disabled. Normal operation."]
    #[inline(always)]
    pub fn is_disabled_normal_ope(&self) -> bool {
        *self == Can1ModTmEnum::DisabledNormalOpe
    }
    #[doc = "Enabled. The TD pin will reflect the bit, detected on RD pin, with the next positive edge of the system clock."]
    #[inline(always)]
    pub fn is_enabled_the_td_pin_(&self) -> bool {
        *self == Can1ModTmEnum::EnabledTheTdPin_
    }
}
#[doc = "Field `TM` writer - Test Mode."]
pub type TmW<'a, REG> = crate::BitWriter<'a, REG, Can1ModTmEnum>;
impl<'a, REG> TmW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Disabled. Normal operation."]
    #[inline(always)]
    pub fn disabled_normal_ope(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModTmEnum::DisabledNormalOpe)
    }
    #[doc = "Enabled. The TD pin will reflect the bit, detected on RD pin, with the next positive edge of the system clock."]
    #[inline(always)]
    pub fn enabled_the_td_pin_(self) -> &'a mut crate::W<REG> {
        self.variant(Can1ModTmEnum::EnabledTheTdPin_)
    }
}
impl R {
    #[doc = "Bit 0 - Reset Mode."]
    #[inline(always)]
    pub fn rm(&self) -> RmR {
        RmR::new((self.bits & 1) != 0)
    }
    #[doc = "Bit 1 - Listen Only Mode."]
    #[inline(always)]
    pub fn lom(&self) -> LomR {
        LomR::new(((self.bits >> 1) & 1) != 0)
    }
    #[doc = "Bit 2 - Self Test Mode."]
    #[inline(always)]
    pub fn stm(&self) -> StmR {
        StmR::new(((self.bits >> 2) & 1) != 0)
    }
    #[doc = "Bit 3 - Transmit Priority Mode."]
    #[inline(always)]
    pub fn tpm(&self) -> TpmR {
        TpmR::new(((self.bits >> 3) & 1) != 0)
    }
    #[doc = "Bit 4 - Sleep Mode."]
    #[inline(always)]
    pub fn sm(&self) -> SmR {
        SmR::new(((self.bits >> 4) & 1) != 0)
    }
    #[doc = "Bit 5 - Receive Polarity Mode."]
    #[inline(always)]
    pub fn rpm(&self) -> RpmR {
        RpmR::new(((self.bits >> 5) & 1) != 0)
    }
    #[doc = "Bit 7 - Test Mode."]
    #[inline(always)]
    pub fn tm(&self) -> TmR {
        TmR::new(((self.bits >> 7) & 1) != 0)
    }
}
impl W {
    #[doc = "Bit 0 - Reset Mode."]
    #[inline(always)]
    pub fn rm(&mut self) -> RmW<'_, ModSpec> {
        RmW::new(self, 0)
    }
    #[doc = "Bit 1 - Listen Only Mode."]
    #[inline(always)]
    pub fn lom(&mut self) -> LomW<'_, ModSpec> {
        LomW::new(self, 1)
    }
    #[doc = "Bit 2 - Self Test Mode."]
    #[inline(always)]
    pub fn stm(&mut self) -> StmW<'_, ModSpec> {
        StmW::new(self, 2)
    }
    #[doc = "Bit 3 - Transmit Priority Mode."]
    #[inline(always)]
    pub fn tpm(&mut self) -> TpmW<'_, ModSpec> {
        TpmW::new(self, 3)
    }
    #[doc = "Bit 4 - Sleep Mode."]
    #[inline(always)]
    pub fn sm(&mut self) -> SmW<'_, ModSpec> {
        SmW::new(self, 4)
    }
    #[doc = "Bit 5 - Receive Polarity Mode."]
    #[inline(always)]
    pub fn rpm(&mut self) -> RpmW<'_, ModSpec> {
        RpmW::new(self, 5)
    }
    #[doc = "Bit 7 - Test Mode."]
    #[inline(always)]
    pub fn tm(&mut self) -> TmW<'_, ModSpec> {
        TmW::new(self, 7)
    }
}
#[doc = "Controls the operating mode of the CAN Controller.\n\nYou can [`read`](crate::Reg::read) this register and get [`mod_::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`mod_::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct ModSpec;
impl crate::RegisterSpec for ModSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`mod_::R`](R) reader structure"]
impl crate::Readable for ModSpec {}
#[doc = "`write(|w| ..)` method takes [`mod_::W`](W) writer structure"]
impl crate::Writable for ModSpec {
    type Safety = crate::Unsafe;
}
#[doc = "`reset()` method sets MOD to value 0"]
impl crate::Resettable for ModSpec {}
