s32k144w_pac/dma/
dchpri15.rs

1#[doc = "Register `DCHPRI15` reader"]
2pub struct R(crate::R<DCHPRI15_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<DCHPRI15_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<DCHPRI15_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<DCHPRI15_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `DCHPRI15` writer"]
17pub struct W(crate::W<DCHPRI15_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<DCHPRI15_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<DCHPRI15_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<DCHPRI15_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `CHPRI` reader - Channel n Arbitration Priority"]
38pub struct CHPRI_R(crate::FieldReader<u8, u8>);
39impl CHPRI_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u8) -> Self {
42        CHPRI_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for CHPRI_R {
46    type Target = crate::FieldReader<u8, u8>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `CHPRI` writer - Channel n Arbitration Priority"]
53pub struct CHPRI_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> CHPRI_W<'a> {
57    #[doc = r"Writes raw bits to the field"]
58    #[inline(always)]
59    pub unsafe fn bits(self, value: u8) -> &'a mut W {
60        self.w.bits = (self.w.bits & !0x0f) | (value as u8 & 0x0f);
61        self.w
62    }
63}
64#[doc = "Disable Preempt Ability. This field resets to 0.\n\nValue on reset: 0"]
65#[derive(Clone, Copy, Debug, PartialEq)]
66pub enum DPA_A {
67    #[doc = "0: Channel n can suspend a lower priority channel."]
68    DPA_0 = 0,
69    #[doc = "1: Channel n cannot suspend any channel, regardless of channel priority."]
70    DPA_1 = 1,
71}
72impl From<DPA_A> for bool {
73    #[inline(always)]
74    fn from(variant: DPA_A) -> Self {
75        variant as u8 != 0
76    }
77}
78#[doc = "Field `DPA` reader - Disable Preempt Ability. This field resets to 0."]
79pub struct DPA_R(crate::FieldReader<bool, DPA_A>);
80impl DPA_R {
81    #[inline(always)]
82    pub(crate) fn new(bits: bool) -> Self {
83        DPA_R(crate::FieldReader::new(bits))
84    }
85    #[doc = r"Get enumerated values variant"]
86    #[inline(always)]
87    pub fn variant(&self) -> DPA_A {
88        match self.bits {
89            false => DPA_A::DPA_0,
90            true => DPA_A::DPA_1,
91        }
92    }
93    #[doc = "Checks if the value of the field is `DPA_0`"]
94    #[inline(always)]
95    pub fn is_dpa_0(&self) -> bool {
96        **self == DPA_A::DPA_0
97    }
98    #[doc = "Checks if the value of the field is `DPA_1`"]
99    #[inline(always)]
100    pub fn is_dpa_1(&self) -> bool {
101        **self == DPA_A::DPA_1
102    }
103}
104impl core::ops::Deref for DPA_R {
105    type Target = crate::FieldReader<bool, DPA_A>;
106    #[inline(always)]
107    fn deref(&self) -> &Self::Target {
108        &self.0
109    }
110}
111#[doc = "Field `DPA` writer - Disable Preempt Ability. This field resets to 0."]
112pub struct DPA_W<'a> {
113    w: &'a mut W,
114}
115impl<'a> DPA_W<'a> {
116    #[doc = r"Writes `variant` to the field"]
117    #[inline(always)]
118    pub fn variant(self, variant: DPA_A) -> &'a mut W {
119        self.bit(variant.into())
120    }
121    #[doc = "Channel n can suspend a lower priority channel."]
122    #[inline(always)]
123    pub fn dpa_0(self) -> &'a mut W {
124        self.variant(DPA_A::DPA_0)
125    }
126    #[doc = "Channel n cannot suspend any channel, regardless of channel priority."]
127    #[inline(always)]
128    pub fn dpa_1(self) -> &'a mut W {
129        self.variant(DPA_A::DPA_1)
130    }
131    #[doc = r"Sets the field bit"]
132    #[inline(always)]
133    pub fn set_bit(self) -> &'a mut W {
134        self.bit(true)
135    }
136    #[doc = r"Clears the field bit"]
137    #[inline(always)]
138    pub fn clear_bit(self) -> &'a mut W {
139        self.bit(false)
140    }
141    #[doc = r"Writes raw bits to the field"]
142    #[inline(always)]
143    pub fn bit(self, value: bool) -> &'a mut W {
144        self.w.bits = (self.w.bits & !(0x01 << 6)) | ((value as u8 & 0x01) << 6);
145        self.w
146    }
147}
148#[doc = "Enable Channel Preemption. This field resets to 0.\n\nValue on reset: 0"]
149#[derive(Clone, Copy, Debug, PartialEq)]
150pub enum ECP_A {
151    #[doc = "0: Channel n cannot be suspended by a higher priority channel's service request."]
152    ECP_0 = 0,
153    #[doc = "1: Channel n can be temporarily suspended by the service request of a higher priority channel."]
154    ECP_1 = 1,
155}
156impl From<ECP_A> for bool {
157    #[inline(always)]
158    fn from(variant: ECP_A) -> Self {
159        variant as u8 != 0
160    }
161}
162#[doc = "Field `ECP` reader - Enable Channel Preemption. This field resets to 0."]
163pub struct ECP_R(crate::FieldReader<bool, ECP_A>);
164impl ECP_R {
165    #[inline(always)]
166    pub(crate) fn new(bits: bool) -> Self {
167        ECP_R(crate::FieldReader::new(bits))
168    }
169    #[doc = r"Get enumerated values variant"]
170    #[inline(always)]
171    pub fn variant(&self) -> ECP_A {
172        match self.bits {
173            false => ECP_A::ECP_0,
174            true => ECP_A::ECP_1,
175        }
176    }
177    #[doc = "Checks if the value of the field is `ECP_0`"]
178    #[inline(always)]
179    pub fn is_ecp_0(&self) -> bool {
180        **self == ECP_A::ECP_0
181    }
182    #[doc = "Checks if the value of the field is `ECP_1`"]
183    #[inline(always)]
184    pub fn is_ecp_1(&self) -> bool {
185        **self == ECP_A::ECP_1
186    }
187}
188impl core::ops::Deref for ECP_R {
189    type Target = crate::FieldReader<bool, ECP_A>;
190    #[inline(always)]
191    fn deref(&self) -> &Self::Target {
192        &self.0
193    }
194}
195#[doc = "Field `ECP` writer - Enable Channel Preemption. This field resets to 0."]
196pub struct ECP_W<'a> {
197    w: &'a mut W,
198}
199impl<'a> ECP_W<'a> {
200    #[doc = r"Writes `variant` to the field"]
201    #[inline(always)]
202    pub fn variant(self, variant: ECP_A) -> &'a mut W {
203        self.bit(variant.into())
204    }
205    #[doc = "Channel n cannot be suspended by a higher priority channel's service request."]
206    #[inline(always)]
207    pub fn ecp_0(self) -> &'a mut W {
208        self.variant(ECP_A::ECP_0)
209    }
210    #[doc = "Channel n can be temporarily suspended by the service request of a higher priority channel."]
211    #[inline(always)]
212    pub fn ecp_1(self) -> &'a mut W {
213        self.variant(ECP_A::ECP_1)
214    }
215    #[doc = r"Sets the field bit"]
216    #[inline(always)]
217    pub fn set_bit(self) -> &'a mut W {
218        self.bit(true)
219    }
220    #[doc = r"Clears the field bit"]
221    #[inline(always)]
222    pub fn clear_bit(self) -> &'a mut W {
223        self.bit(false)
224    }
225    #[doc = r"Writes raw bits to the field"]
226    #[inline(always)]
227    pub fn bit(self, value: bool) -> &'a mut W {
228        self.w.bits = (self.w.bits & !(0x01 << 7)) | ((value as u8 & 0x01) << 7);
229        self.w
230    }
231}
232impl R {
233    #[doc = "Bits 0:3 - Channel n Arbitration Priority"]
234    #[inline(always)]
235    pub fn chpri(&self) -> CHPRI_R {
236        CHPRI_R::new((self.bits & 0x0f) as u8)
237    }
238    #[doc = "Bit 6 - Disable Preempt Ability. This field resets to 0."]
239    #[inline(always)]
240    pub fn dpa(&self) -> DPA_R {
241        DPA_R::new(((self.bits >> 6) & 0x01) != 0)
242    }
243    #[doc = "Bit 7 - Enable Channel Preemption. This field resets to 0."]
244    #[inline(always)]
245    pub fn ecp(&self) -> ECP_R {
246        ECP_R::new(((self.bits >> 7) & 0x01) != 0)
247    }
248}
249impl W {
250    #[doc = "Bits 0:3 - Channel n Arbitration Priority"]
251    #[inline(always)]
252    pub fn chpri(&mut self) -> CHPRI_W {
253        CHPRI_W { w: self }
254    }
255    #[doc = "Bit 6 - Disable Preempt Ability. This field resets to 0."]
256    #[inline(always)]
257    pub fn dpa(&mut self) -> DPA_W {
258        DPA_W { w: self }
259    }
260    #[doc = "Bit 7 - Enable Channel Preemption. This field resets to 0."]
261    #[inline(always)]
262    pub fn ecp(&mut self) -> ECP_W {
263        ECP_W { w: self }
264    }
265    #[doc = "Writes raw bits to the register."]
266    #[inline(always)]
267    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
268        self.0.bits(bits);
269        self
270    }
271}
272#[doc = "Channel Priority 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 [dchpri15](index.html) module"]
273pub struct DCHPRI15_SPEC;
274impl crate::RegisterSpec for DCHPRI15_SPEC {
275    type Ux = u8;
276}
277#[doc = "`read()` method returns [dchpri15::R](R) reader structure"]
278impl crate::Readable for DCHPRI15_SPEC {
279    type Reader = R;
280}
281#[doc = "`write(|w| ..)` method takes [dchpri15::W](W) writer structure"]
282impl crate::Writable for DCHPRI15_SPEC {
283    type Writer = W;
284}
285#[doc = "`reset()` method sets DCHPRI15 to value 0x0f"]
286impl crate::Resettable for DCHPRI15_SPEC {
287    #[inline(always)]
288    fn reset_value() -> Self::Ux {
289        0x0f
290    }
291}