esp32c6_lp/lp_tee/
m_mode_ctrl.rs

1#[doc = "Register `M%s_MODE_CTRL` reader"]
2pub type R = crate::R<M_MODE_CTRL_SPEC>;
3#[doc = "Register `M%s_MODE_CTRL` writer"]
4pub type W = crate::W<M_MODE_CTRL_SPEC>;
5#[doc = "M0 security level mode: 2'd3: ree_mode2. 2'd2: ree_mode1. 2'd1: ree_mode0. 2'd0: tee_mode\n\nValue on reset: 3"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum SECURITY_MODE {
10    #[doc = "0: Tee mode"]
11    Tee = 0,
12    #[doc = "1: Ree0 mode"]
13    Ree0 = 1,
14    #[doc = "2: Ree1 mode"]
15    Ree1 = 2,
16    #[doc = "3: Ree2 mode"]
17    Ree2 = 3,
18}
19impl From<SECURITY_MODE> for u8 {
20    #[inline(always)]
21    fn from(variant: SECURITY_MODE) -> Self {
22        variant as _
23    }
24}
25impl crate::FieldSpec for SECURITY_MODE {
26    type Ux = u8;
27}
28impl crate::IsEnum for SECURITY_MODE {}
29#[doc = "Field `MODE` reader - M0 security level mode: 2'd3: ree_mode2. 2'd2: ree_mode1. 2'd1: ree_mode0. 2'd0: tee_mode"]
30pub type MODE_R = crate::FieldReader<SECURITY_MODE>;
31impl MODE_R {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> SECURITY_MODE {
35        match self.bits {
36            0 => SECURITY_MODE::Tee,
37            1 => SECURITY_MODE::Ree0,
38            2 => SECURITY_MODE::Ree1,
39            3 => SECURITY_MODE::Ree2,
40            _ => unreachable!(),
41        }
42    }
43    #[doc = "Tee mode"]
44    #[inline(always)]
45    pub fn is_tee(&self) -> bool {
46        *self == SECURITY_MODE::Tee
47    }
48    #[doc = "Ree0 mode"]
49    #[inline(always)]
50    pub fn is_ree0(&self) -> bool {
51        *self == SECURITY_MODE::Ree0
52    }
53    #[doc = "Ree1 mode"]
54    #[inline(always)]
55    pub fn is_ree1(&self) -> bool {
56        *self == SECURITY_MODE::Ree1
57    }
58    #[doc = "Ree2 mode"]
59    #[inline(always)]
60    pub fn is_ree2(&self) -> bool {
61        *self == SECURITY_MODE::Ree2
62    }
63}
64#[doc = "Field `MODE` writer - M0 security level mode: 2'd3: ree_mode2. 2'd2: ree_mode1. 2'd1: ree_mode0. 2'd0: tee_mode"]
65pub type MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, SECURITY_MODE, crate::Safe>;
66impl<'a, REG> MODE_W<'a, REG>
67where
68    REG: crate::Writable + crate::RegisterSpec,
69    REG::Ux: From<u8>,
70{
71    #[doc = "Tee mode"]
72    #[inline(always)]
73    pub fn tee(self) -> &'a mut crate::W<REG> {
74        self.variant(SECURITY_MODE::Tee)
75    }
76    #[doc = "Ree0 mode"]
77    #[inline(always)]
78    pub fn ree0(self) -> &'a mut crate::W<REG> {
79        self.variant(SECURITY_MODE::Ree0)
80    }
81    #[doc = "Ree1 mode"]
82    #[inline(always)]
83    pub fn ree1(self) -> &'a mut crate::W<REG> {
84        self.variant(SECURITY_MODE::Ree1)
85    }
86    #[doc = "Ree2 mode"]
87    #[inline(always)]
88    pub fn ree2(self) -> &'a mut crate::W<REG> {
89        self.variant(SECURITY_MODE::Ree2)
90    }
91}
92impl R {
93    #[doc = "Bits 0:1 - M0 security level mode: 2'd3: ree_mode2. 2'd2: ree_mode1. 2'd1: ree_mode0. 2'd0: tee_mode"]
94    #[inline(always)]
95    pub fn mode(&self) -> MODE_R {
96        MODE_R::new((self.bits & 3) as u8)
97    }
98}
99#[cfg(feature = "impl-register-debug")]
100impl core::fmt::Debug for R {
101    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
102        f.debug_struct("M_MODE_CTRL")
103            .field("mode", &self.mode())
104            .finish()
105    }
106}
107impl W {
108    #[doc = "Bits 0:1 - M0 security level mode: 2'd3: ree_mode2. 2'd2: ree_mode1. 2'd1: ree_mode0. 2'd0: tee_mode"]
109    #[inline(always)]
110    #[must_use]
111    pub fn mode(&mut self) -> MODE_W<M_MODE_CTRL_SPEC> {
112        MODE_W::new(self, 0)
113    }
114}
115#[doc = "Tee mode control register\n\nYou can [`read`](crate::Reg::read) this register and get [`m_mode_ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`m_mode_ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
116pub struct M_MODE_CTRL_SPEC;
117impl crate::RegisterSpec for M_MODE_CTRL_SPEC {
118    type Ux = u32;
119}
120#[doc = "`read()` method returns [`m_mode_ctrl::R`](R) reader structure"]
121impl crate::Readable for M_MODE_CTRL_SPEC {}
122#[doc = "`write(|w| ..)` method takes [`m_mode_ctrl::W`](W) writer structure"]
123impl crate::Writable for M_MODE_CTRL_SPEC {
124    type Safety = crate::Unsafe;
125    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
126    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
127}
128#[doc = "`reset()` method sets M%s_MODE_CTRL to value 0x03"]
129impl crate::Resettable for M_MODE_CTRL_SPEC {
130    const RESET_VALUE: u32 = 0x03;
131}