Skip to main content

mcxa_pac/edma_0_tcd0/tcd/
ch_pri.rs

1#[doc = "Register `CH_PRI` reader"]
2pub type R = crate::R<ChPriSpec>;
3#[doc = "Register `CH_PRI` writer"]
4pub type W = crate::W<ChPriSpec>;
5#[doc = "Field `APL` reader - Arbitration Priority Level"]
6pub type AplR = crate::FieldReader;
7#[doc = "Field `APL` writer - Arbitration Priority Level"]
8pub type AplW<'a, REG> = crate::FieldWriter<'a, REG, 3>;
9#[doc = "Disable Preempt Ability\n\nValue on reset: 0"]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum Dpa {
13    #[doc = "0: Channel can suspend a lower-priority channel"]
14    Suspend = 0,
15    #[doc = "1: Channel cannot suspend any other channel, regardless of channel priority"]
16    CannotSuspend = 1,
17}
18impl From<Dpa> for bool {
19    #[inline(always)]
20    fn from(variant: Dpa) -> Self {
21        variant as u8 != 0
22    }
23}
24#[doc = "Field `DPA` reader - Disable Preempt Ability"]
25pub type DpaR = crate::BitReader<Dpa>;
26impl DpaR {
27    #[doc = "Get enumerated values variant"]
28    #[inline(always)]
29    pub const fn variant(&self) -> Dpa {
30        match self.bits {
31            false => Dpa::Suspend,
32            true => Dpa::CannotSuspend,
33        }
34    }
35    #[doc = "Channel can suspend a lower-priority channel"]
36    #[inline(always)]
37    pub fn is_suspend(&self) -> bool {
38        *self == Dpa::Suspend
39    }
40    #[doc = "Channel cannot suspend any other channel, regardless of channel priority"]
41    #[inline(always)]
42    pub fn is_cannot_suspend(&self) -> bool {
43        *self == Dpa::CannotSuspend
44    }
45}
46#[doc = "Field `DPA` writer - Disable Preempt Ability"]
47pub type DpaW<'a, REG> = crate::BitWriter<'a, REG, Dpa>;
48impl<'a, REG> DpaW<'a, REG>
49where
50    REG: crate::Writable + crate::RegisterSpec,
51{
52    #[doc = "Channel can suspend a lower-priority channel"]
53    #[inline(always)]
54    pub fn suspend(self) -> &'a mut crate::W<REG> {
55        self.variant(Dpa::Suspend)
56    }
57    #[doc = "Channel cannot suspend any other channel, regardless of channel priority"]
58    #[inline(always)]
59    pub fn cannot_suspend(self) -> &'a mut crate::W<REG> {
60        self.variant(Dpa::CannotSuspend)
61    }
62}
63#[doc = "Enable Channel Preemption\n\nValue on reset: 0"]
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum Ecp {
67    #[doc = "0: Channel cannot be suspended by a higher-priority channel's service request"]
68    CannotSuspend = 0,
69    #[doc = "1: Channel can be temporarily suspended by a higher-priority channel's service request"]
70    Suspend = 1,
71}
72impl From<Ecp> for bool {
73    #[inline(always)]
74    fn from(variant: Ecp) -> Self {
75        variant as u8 != 0
76    }
77}
78#[doc = "Field `ECP` reader - Enable Channel Preemption"]
79pub type EcpR = crate::BitReader<Ecp>;
80impl EcpR {
81    #[doc = "Get enumerated values variant"]
82    #[inline(always)]
83    pub const fn variant(&self) -> Ecp {
84        match self.bits {
85            false => Ecp::CannotSuspend,
86            true => Ecp::Suspend,
87        }
88    }
89    #[doc = "Channel cannot be suspended by a higher-priority channel's service request"]
90    #[inline(always)]
91    pub fn is_cannot_suspend(&self) -> bool {
92        *self == Ecp::CannotSuspend
93    }
94    #[doc = "Channel can be temporarily suspended by a higher-priority channel's service request"]
95    #[inline(always)]
96    pub fn is_suspend(&self) -> bool {
97        *self == Ecp::Suspend
98    }
99}
100#[doc = "Field `ECP` writer - Enable Channel Preemption"]
101pub type EcpW<'a, REG> = crate::BitWriter<'a, REG, Ecp>;
102impl<'a, REG> EcpW<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    #[doc = "Channel cannot be suspended by a higher-priority channel's service request"]
107    #[inline(always)]
108    pub fn cannot_suspend(self) -> &'a mut crate::W<REG> {
109        self.variant(Ecp::CannotSuspend)
110    }
111    #[doc = "Channel can be temporarily suspended by a higher-priority channel's service request"]
112    #[inline(always)]
113    pub fn suspend(self) -> &'a mut crate::W<REG> {
114        self.variant(Ecp::Suspend)
115    }
116}
117impl R {
118    #[doc = "Bits 0:2 - Arbitration Priority Level"]
119    #[inline(always)]
120    pub fn apl(&self) -> AplR {
121        AplR::new((self.bits & 7) as u8)
122    }
123    #[doc = "Bit 30 - Disable Preempt Ability"]
124    #[inline(always)]
125    pub fn dpa(&self) -> DpaR {
126        DpaR::new(((self.bits >> 30) & 1) != 0)
127    }
128    #[doc = "Bit 31 - Enable Channel Preemption"]
129    #[inline(always)]
130    pub fn ecp(&self) -> EcpR {
131        EcpR::new(((self.bits >> 31) & 1) != 0)
132    }
133}
134#[cfg(feature = "debug")]
135impl core::fmt::Debug for R {
136    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
137        f.debug_struct("CH_PRI")
138            .field("apl", &self.apl())
139            .field("dpa", &self.dpa())
140            .field("ecp", &self.ecp())
141            .finish()
142    }
143}
144impl W {
145    #[doc = "Bits 0:2 - Arbitration Priority Level"]
146    #[inline(always)]
147    pub fn apl(&mut self) -> AplW<'_, ChPriSpec> {
148        AplW::new(self, 0)
149    }
150    #[doc = "Bit 30 - Disable Preempt Ability"]
151    #[inline(always)]
152    pub fn dpa(&mut self) -> DpaW<'_, ChPriSpec> {
153        DpaW::new(self, 30)
154    }
155    #[doc = "Bit 31 - Enable Channel Preemption"]
156    #[inline(always)]
157    pub fn ecp(&mut self) -> EcpW<'_, ChPriSpec> {
158        EcpW::new(self, 31)
159    }
160}
161#[doc = "Channel Priority\n\nYou can [`read`](crate::Reg::read) this register and get [`ch_pri::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ch_pri::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
162pub struct ChPriSpec;
163impl crate::RegisterSpec for ChPriSpec {
164    type Ux = u32;
165}
166#[doc = "`read()` method returns [`ch_pri::R`](R) reader structure"]
167impl crate::Readable for ChPriSpec {}
168#[doc = "`write(|w| ..)` method takes [`ch_pri::W`](W) writer structure"]
169impl crate::Writable for ChPriSpec {
170    type Safety = crate::Unsafe;
171}
172#[doc = "`reset()` method sets CH_PRI to value 0"]
173impl crate::Resettable for ChPriSpec {}