#[doc = "Register `COMMAND` reader"]
pub struct R(crate::R<COMMAND_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<COMMAND_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<COMMAND_SPEC>> for R {
    fn from(reader: crate::R<COMMAND_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `COMMAND` writer"]
pub struct W(crate::W<COMMAND_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<COMMAND_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<COMMAND_SPEC>> for W {
    fn from(writer: crate::W<COMMAND_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `RUN` reader - Run/Stop mode:?\"0\": Sets the CAN controller into stop mode.?Stop mode can be granted only in \"bus idle\" field?Returns \"0\" when stopped.?\"1\": Sets the CAN controller into run mode.?Returns \"1\" when running."]
pub struct RUN_R(crate::FieldReader<bool, bool>);
impl RUN_R {
    pub(crate) fn new(bits: bool) -> Self {
        RUN_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for RUN_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `RUN` writer - Run/Stop mode:?\"0\": Sets the CAN controller into stop mode.?Stop mode can be granted only in \"bus idle\" field?Returns \"0\" when stopped.?\"1\": Sets the CAN controller into run mode.?Returns \"1\" when running."]
pub struct RUN_W<'a> {
    w: &'a mut W,
}
impl<'a> RUN_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) | (value as u32 & 0x01);
        self.w
    }
}
#[doc = "Field `LISTEN` reader - TEST_MODE\\[1\\]"]
pub struct LISTEN_R(crate::FieldReader<bool, bool>);
impl LISTEN_R {
    pub(crate) fn new(bits: bool) -> Self {
        LISTEN_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for LISTEN_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `LISTEN` writer - TEST_MODE\\[1\\]"]
pub struct LISTEN_W<'a> {
    w: &'a mut W,
}
impl<'a> LISTEN_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 `LOOPBACK_TEST` reader - TEST_MODE\\[2\\].?With TEST_MODE\\[2:1\\],?00: normal operation?01: Listen-only mode,? The output is held at \"R\" level. The CANmodule-III is only listening.?10: external loopback mode?11: internal loopback mode"]
pub struct LOOPBACK_TEST_R(crate::FieldReader<bool, bool>);
impl LOOPBACK_TEST_R {
    pub(crate) fn new(bits: bool) -> Self {
        LOOPBACK_TEST_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for LOOPBACK_TEST_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `LOOPBACK_TEST` writer - TEST_MODE\\[2\\].?With TEST_MODE\\[2:1\\],?00: normal operation?01: Listen-only mode,? The output is held at \"R\" level. The CANmodule-III is only listening.?10: external loopback mode?11: internal loopback mode"]
pub struct LOOPBACK_TEST_W<'a> {
    w: &'a mut W,
}
impl<'a> LOOPBACK_TEST_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 << 2)) | ((value as u32 & 0x01) << 2);
        self.w
    }
}
#[doc = "Field `SRAM_TEST` reader - SRAM test mode?\"0\": Normal operation?\"1\": Enable SRAM test mode?it can be set, only when the IP is stopped (COMMAND.RUN=0, and really finished transition from run mode),?this mode will not be used, so it should never be set."]
pub struct SRAM_TEST_R(crate::FieldReader<bool, bool>);
impl SRAM_TEST_R {
    pub(crate) fn new(bits: bool) -> Self {
        SRAM_TEST_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for SRAM_TEST_R {
    type Target = crate::FieldReader<bool, bool>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `SRAM_TEST` writer - SRAM test mode?\"0\": Normal operation?\"1\": Enable SRAM test mode?it can be set, only when the IP is stopped (COMMAND.RUN=0, and really finished transition from run mode),?this mode will not be used, so it should never be set."]
pub struct SRAM_TEST_W<'a> {
    w: &'a mut W,
}
impl<'a> SRAM_TEST_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 << 3)) | ((value as u32 & 0x01) << 3);
        self.w
    }
}
#[doc = "Field `IP_REV_NUMBER` reader - IP Revision Number"]
pub struct IP_REV_NUMBER_R(crate::FieldReader<u8, u8>);
impl IP_REV_NUMBER_R {
    pub(crate) fn new(bits: u8) -> Self {
        IP_REV_NUMBER_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for IP_REV_NUMBER_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `IP_MINOR_VERSION` reader - IP Minor Version Number"]
pub struct IP_MINOR_VERSION_R(crate::FieldReader<u8, u8>);
impl IP_MINOR_VERSION_R {
    pub(crate) fn new(bits: u8) -> Self {
        IP_MINOR_VERSION_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for IP_MINOR_VERSION_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `IP_MAJOR_VERSION` reader - IP Major Version Number"]
pub struct IP_MAJOR_VERSION_R(crate::FieldReader<u8, u8>);
impl IP_MAJOR_VERSION_R {
    pub(crate) fn new(bits: u8) -> Self {
        IP_MAJOR_VERSION_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for IP_MAJOR_VERSION_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl R {
    #[doc = "Bit 0 - Run/Stop mode:?\"0\": Sets the CAN controller into stop mode.?Stop mode can be granted only in \"bus idle\" field?Returns \"0\" when stopped.?\"1\": Sets the CAN controller into run mode.?Returns \"1\" when running."]
    #[inline(always)]
    pub fn run(&self) -> RUN_R {
        RUN_R::new((self.bits & 0x01) != 0)
    }
    #[doc = "Bit 1 - TEST_MODE\\[1\\]"]
    #[inline(always)]
    pub fn listen(&self) -> LISTEN_R {
        LISTEN_R::new(((self.bits >> 1) & 0x01) != 0)
    }
    #[doc = "Bit 2 - TEST_MODE\\[2\\].?With TEST_MODE\\[2:1\\],?00: normal operation?01: Listen-only mode,? The output is held at \"R\" level. The CANmodule-III is only listening.?10: external loopback mode?11: internal loopback mode"]
    #[inline(always)]
    pub fn loopback_test(&self) -> LOOPBACK_TEST_R {
        LOOPBACK_TEST_R::new(((self.bits >> 2) & 0x01) != 0)
    }
    #[doc = "Bit 3 - SRAM test mode?\"0\": Normal operation?\"1\": Enable SRAM test mode?it can be set, only when the IP is stopped (COMMAND.RUN=0, and really finished transition from run mode),?this mode will not be used, so it should never be set."]
    #[inline(always)]
    pub fn sram_test(&self) -> SRAM_TEST_R {
        SRAM_TEST_R::new(((self.bits >> 3) & 0x01) != 0)
    }
    #[doc = "Bits 16:23 - IP Revision Number"]
    #[inline(always)]
    pub fn ip_rev_number(&self) -> IP_REV_NUMBER_R {
        IP_REV_NUMBER_R::new(((self.bits >> 16) & 0xff) as u8)
    }
    #[doc = "Bits 24:27 - IP Minor Version Number"]
    #[inline(always)]
    pub fn ip_minor_version(&self) -> IP_MINOR_VERSION_R {
        IP_MINOR_VERSION_R::new(((self.bits >> 24) & 0x0f) as u8)
    }
    #[doc = "Bits 28:31 - IP Major Version Number"]
    #[inline(always)]
    pub fn ip_major_version(&self) -> IP_MAJOR_VERSION_R {
        IP_MAJOR_VERSION_R::new(((self.bits >> 28) & 0x0f) as u8)
    }
}
impl W {
    #[doc = "Bit 0 - Run/Stop mode:?\"0\": Sets the CAN controller into stop mode.?Stop mode can be granted only in \"bus idle\" field?Returns \"0\" when stopped.?\"1\": Sets the CAN controller into run mode.?Returns \"1\" when running."]
    #[inline(always)]
    pub fn run(&mut self) -> RUN_W {
        RUN_W { w: self }
    }
    #[doc = "Bit 1 - TEST_MODE\\[1\\]"]
    #[inline(always)]
    pub fn listen(&mut self) -> LISTEN_W {
        LISTEN_W { w: self }
    }
    #[doc = "Bit 2 - TEST_MODE\\[2\\].?With TEST_MODE\\[2:1\\],?00: normal operation?01: Listen-only mode,? The output is held at \"R\" level. The CANmodule-III is only listening.?10: external loopback mode?11: internal loopback mode"]
    #[inline(always)]
    pub fn loopback_test(&mut self) -> LOOPBACK_TEST_W {
        LOOPBACK_TEST_W { w: self }
    }
    #[doc = "Bit 3 - SRAM test mode?\"0\": Normal operation?\"1\": Enable SRAM test mode?it can be set, only when the IP is stopped (COMMAND.RUN=0, and really finished transition from run mode),?this mode will not be used, so it should never be set."]
    #[inline(always)]
    pub fn sram_test(&mut self) -> SRAM_TEST_W {
        SRAM_TEST_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 = "CAN Command Register\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 [command](index.html) module"]
pub struct COMMAND_SPEC;
impl crate::RegisterSpec for COMMAND_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [command::R](R) reader structure"]
impl crate::Readable for COMMAND_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [command::W](W) writer structure"]
impl crate::Writable for COMMAND_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets COMMAND to value 0"]
impl crate::Resettable for COMMAND_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
