d1_pac/plic/
ctrl.rs

1#[doc = "Register `ctrl` reader"]
2pub type R = crate::R<CTRL_SPEC>;
3#[doc = "Register `ctrl` writer"]
4pub type W = crate::W<CTRL_SPEC>;
5#[doc = "Field `ctrl` reader - PLIC Control"]
6pub type CTRL_R = crate::BitReader<CTRL_A>;
7#[doc = "PLIC Control\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum CTRL_A {
10    #[doc = "0: Only the machine mode can access to all registers in PLIC. Supervisor mode can only access the interrupt threshold register and the interrupt response/completion register."]
11    M = 0,
12    #[doc = "1: The machine mode and the supervisor mode can access all registers. CTRL is accessible only in the machine mode."]
13    MS = 1,
14}
15impl From<CTRL_A> for bool {
16    #[inline(always)]
17    fn from(variant: CTRL_A) -> Self {
18        variant as u8 != 0
19    }
20}
21impl CTRL_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> CTRL_A {
25        match self.bits {
26            false => CTRL_A::M,
27            true => CTRL_A::MS,
28        }
29    }
30    #[doc = "Only the machine mode can access to all registers in PLIC. Supervisor mode can only access the interrupt threshold register and the interrupt response/completion register."]
31    #[inline(always)]
32    pub fn is_m(&self) -> bool {
33        *self == CTRL_A::M
34    }
35    #[doc = "The machine mode and the supervisor mode can access all registers. CTRL is accessible only in the machine mode."]
36    #[inline(always)]
37    pub fn is_ms(&self) -> bool {
38        *self == CTRL_A::MS
39    }
40}
41#[doc = "Field `ctrl` writer - PLIC Control"]
42pub type CTRL_W<'a, REG> = crate::BitWriter<'a, REG, CTRL_A>;
43impl<'a, REG> CTRL_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "Only the machine mode can access to all registers in PLIC. Supervisor mode can only access the interrupt threshold register and the interrupt response/completion register."]
48    #[inline(always)]
49    pub fn m(self) -> &'a mut crate::W<REG> {
50        self.variant(CTRL_A::M)
51    }
52    #[doc = "The machine mode and the supervisor mode can access all registers. CTRL is accessible only in the machine mode."]
53    #[inline(always)]
54    pub fn ms(self) -> &'a mut crate::W<REG> {
55        self.variant(CTRL_A::MS)
56    }
57}
58impl R {
59    #[doc = "Bit 0 - PLIC Control"]
60    #[inline(always)]
61    pub fn ctrl(&self) -> CTRL_R {
62        CTRL_R::new((self.bits & 1) != 0)
63    }
64}
65impl W {
66    #[doc = "Bit 0 - PLIC Control"]
67    #[inline(always)]
68    #[must_use]
69    pub fn ctrl(&mut self) -> CTRL_W<CTRL_SPEC> {
70        CTRL_W::new(self, 0)
71    }
72    #[doc = r" Writes raw bits to the register."]
73    #[doc = r""]
74    #[doc = r" # Safety"]
75    #[doc = r""]
76    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
77    #[inline(always)]
78    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
79        self.bits = bits;
80        self
81    }
82}
83#[doc = "Control Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`ctrl::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
84pub struct CTRL_SPEC;
85impl crate::RegisterSpec for CTRL_SPEC {
86    type Ux = u32;
87}
88#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
89impl crate::Readable for CTRL_SPEC {}
90#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
91impl crate::Writable for CTRL_SPEC {
92    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
93    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
94}
95#[doc = "`reset()` method sets ctrl to value 0"]
96impl crate::Resettable for CTRL_SPEC {
97    const RESET_VALUE: Self::Ux = 0;
98}