xmc4200/can/
panctr.rs

1#[doc = "Register `PANCTR` reader"]
2pub type R = crate::R<PANCTR_SPEC>;
3#[doc = "Register `PANCTR` writer"]
4pub type W = crate::W<PANCTR_SPEC>;
5#[doc = "Field `PANCMD` reader - Panel Command"]
6pub type PANCMD_R = crate::FieldReader;
7#[doc = "Field `PANCMD` writer - Panel Command"]
8pub type PANCMD_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
9#[doc = "Panel Busy Flag\n\nValue on reset: 1"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11pub enum BUSY_A {
12    #[doc = "0: Panel has finished command and is ready to accept a new command."]
13    VALUE1 = 0,
14    #[doc = "1: Panel operation is in progress."]
15    VALUE2 = 1,
16}
17impl From<BUSY_A> for bool {
18    #[inline(always)]
19    fn from(variant: BUSY_A) -> Self {
20        variant as u8 != 0
21    }
22}
23#[doc = "Field `BUSY` reader - Panel Busy Flag"]
24pub type BUSY_R = crate::BitReader<BUSY_A>;
25impl BUSY_R {
26    #[doc = "Get enumerated values variant"]
27    #[inline(always)]
28    pub const fn variant(&self) -> BUSY_A {
29        match self.bits {
30            false => BUSY_A::VALUE1,
31            true => BUSY_A::VALUE2,
32        }
33    }
34    #[doc = "Panel has finished command and is ready to accept a new command."]
35    #[inline(always)]
36    pub fn is_value1(&self) -> bool {
37        *self == BUSY_A::VALUE1
38    }
39    #[doc = "Panel operation is in progress."]
40    #[inline(always)]
41    pub fn is_value2(&self) -> bool {
42        *self == BUSY_A::VALUE2
43    }
44}
45#[doc = "Result Busy Flag\n\nValue on reset: 1"]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub enum RBUSY_A {
48    #[doc = "0: No update of PANAR1 and PANAR2 is scheduled by the list controller."]
49    VALUE1 = 0,
50    #[doc = "1: A list command is running (BUSY = 1) that will write results to PANAR1 and PANAR2, but the results are not yet available."]
51    VALUE2 = 1,
52}
53impl From<RBUSY_A> for bool {
54    #[inline(always)]
55    fn from(variant: RBUSY_A) -> Self {
56        variant as u8 != 0
57    }
58}
59#[doc = "Field `RBUSY` reader - Result Busy Flag"]
60pub type RBUSY_R = crate::BitReader<RBUSY_A>;
61impl RBUSY_R {
62    #[doc = "Get enumerated values variant"]
63    #[inline(always)]
64    pub const fn variant(&self) -> RBUSY_A {
65        match self.bits {
66            false => RBUSY_A::VALUE1,
67            true => RBUSY_A::VALUE2,
68        }
69    }
70    #[doc = "No update of PANAR1 and PANAR2 is scheduled by the list controller."]
71    #[inline(always)]
72    pub fn is_value1(&self) -> bool {
73        *self == RBUSY_A::VALUE1
74    }
75    #[doc = "A list command is running (BUSY = 1) that will write results to PANAR1 and PANAR2, but the results are not yet available."]
76    #[inline(always)]
77    pub fn is_value2(&self) -> bool {
78        *self == RBUSY_A::VALUE2
79    }
80}
81#[doc = "Field `PANAR1` reader - Panel Argument 1"]
82pub type PANAR1_R = crate::FieldReader;
83#[doc = "Field `PANAR1` writer - Panel Argument 1"]
84pub type PANAR1_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
85#[doc = "Field `PANAR2` reader - Panel Argument 2"]
86pub type PANAR2_R = crate::FieldReader;
87#[doc = "Field `PANAR2` writer - Panel Argument 2"]
88pub type PANAR2_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
89impl R {
90    #[doc = "Bits 0:7 - Panel Command"]
91    #[inline(always)]
92    pub fn pancmd(&self) -> PANCMD_R {
93        PANCMD_R::new((self.bits & 0xff) as u8)
94    }
95    #[doc = "Bit 8 - Panel Busy Flag"]
96    #[inline(always)]
97    pub fn busy(&self) -> BUSY_R {
98        BUSY_R::new(((self.bits >> 8) & 1) != 0)
99    }
100    #[doc = "Bit 9 - Result Busy Flag"]
101    #[inline(always)]
102    pub fn rbusy(&self) -> RBUSY_R {
103        RBUSY_R::new(((self.bits >> 9) & 1) != 0)
104    }
105    #[doc = "Bits 16:23 - Panel Argument 1"]
106    #[inline(always)]
107    pub fn panar1(&self) -> PANAR1_R {
108        PANAR1_R::new(((self.bits >> 16) & 0xff) as u8)
109    }
110    #[doc = "Bits 24:31 - Panel Argument 2"]
111    #[inline(always)]
112    pub fn panar2(&self) -> PANAR2_R {
113        PANAR2_R::new(((self.bits >> 24) & 0xff) as u8)
114    }
115}
116impl W {
117    #[doc = "Bits 0:7 - Panel Command"]
118    #[inline(always)]
119    pub fn pancmd(&mut self) -> PANCMD_W<PANCTR_SPEC> {
120        PANCMD_W::new(self, 0)
121    }
122    #[doc = "Bits 16:23 - Panel Argument 1"]
123    #[inline(always)]
124    pub fn panar1(&mut self) -> PANAR1_W<PANCTR_SPEC> {
125        PANAR1_W::new(self, 16)
126    }
127    #[doc = "Bits 24:31 - Panel Argument 2"]
128    #[inline(always)]
129    pub fn panar2(&mut self) -> PANAR2_W<PANCTR_SPEC> {
130        PANAR2_W::new(self, 24)
131    }
132}
133#[doc = "Panel Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`panctr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`panctr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
134pub struct PANCTR_SPEC;
135impl crate::RegisterSpec for PANCTR_SPEC {
136    type Ux = u32;
137}
138#[doc = "`read()` method returns [`panctr::R`](R) reader structure"]
139impl crate::Readable for PANCTR_SPEC {}
140#[doc = "`write(|w| ..)` method takes [`panctr::W`](W) writer structure"]
141impl crate::Writable for PANCTR_SPEC {
142    type Safety = crate::Unsafe;
143    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
144    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
145}
146#[doc = "`reset()` method sets PANCTR to value 0x0301"]
147impl crate::Resettable for PANCTR_SPEC {
148    const RESET_VALUE: u32 = 0x0301;
149}