ra4m1/sram/
sramprcr.rs

1#[doc = "Register `SRAMPRCR` reader"]
2pub struct R(crate::R<SRAMPRCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SRAMPRCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SRAMPRCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SRAMPRCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SRAMPRCR` writer"]
17pub struct W(crate::W<SRAMPRCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SRAMPRCR_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<SRAMPRCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SRAMPRCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SRAMPRCR` reader - Register Write Control"]
38pub type SRAMPRCR_R = crate::BitReader<SRAMPRCR_A>;
39#[doc = "Register Write Control\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum SRAMPRCR_A {
42    #[doc = "0: Disable writes to protected registers"]
43    _0 = 0,
44    #[doc = "1: Enable writes to protected registers."]
45    _1 = 1,
46}
47impl From<SRAMPRCR_A> for bool {
48    #[inline(always)]
49    fn from(variant: SRAMPRCR_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl SRAMPRCR_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> SRAMPRCR_A {
57        match self.bits {
58            false => SRAMPRCR_A::_0,
59            true => SRAMPRCR_A::_1,
60        }
61    }
62    #[doc = "Checks if the value of the field is `_0`"]
63    #[inline(always)]
64    pub fn is_0(&self) -> bool {
65        *self == SRAMPRCR_A::_0
66    }
67    #[doc = "Checks if the value of the field is `_1`"]
68    #[inline(always)]
69    pub fn is_1(&self) -> bool {
70        *self == SRAMPRCR_A::_1
71    }
72}
73#[doc = "Field `SRAMPRCR` writer - Register Write Control"]
74pub type SRAMPRCR_W<'a, const O: u8> = crate::BitWriter<'a, u8, SRAMPRCR_SPEC, SRAMPRCR_A, O>;
75impl<'a, const O: u8> SRAMPRCR_W<'a, O> {
76    #[doc = "Disable writes to protected registers"]
77    #[inline(always)]
78    pub fn _0(self) -> &'a mut W {
79        self.variant(SRAMPRCR_A::_0)
80    }
81    #[doc = "Enable writes to protected registers."]
82    #[inline(always)]
83    pub fn _1(self) -> &'a mut W {
84        self.variant(SRAMPRCR_A::_1)
85    }
86}
87#[doc = "Write Key Code\n\nValue on reset: 0"]
88#[derive(Clone, Copy, Debug, PartialEq, Eq)]
89#[repr(u8)]
90pub enum KW_AW {
91    #[doc = "120: Writing to the RAMPRCR bit is valid, when the KEY bits are written 1111000b."]
92    _1111000 = 120,
93}
94impl From<KW_AW> for u8 {
95    #[inline(always)]
96    fn from(variant: KW_AW) -> Self {
97        variant as _
98    }
99}
100#[doc = "Field `KW` writer - Write Key Code"]
101pub type KW_W<'a, const O: u8> = crate::FieldWriter<'a, u8, SRAMPRCR_SPEC, u8, KW_AW, 7, O>;
102impl<'a, const O: u8> KW_W<'a, O> {
103    #[doc = "Writing to the RAMPRCR bit is valid, when the KEY bits are written 1111000b."]
104    #[inline(always)]
105    pub fn _1111000(self) -> &'a mut W {
106        self.variant(KW_AW::_1111000)
107    }
108}
109impl R {
110    #[doc = "Bit 0 - Register Write Control"]
111    #[inline(always)]
112    pub fn sramprcr(&self) -> SRAMPRCR_R {
113        SRAMPRCR_R::new((self.bits & 1) != 0)
114    }
115}
116impl W {
117    #[doc = "Bit 0 - Register Write Control"]
118    #[inline(always)]
119    #[must_use]
120    pub fn sramprcr(&mut self) -> SRAMPRCR_W<0> {
121        SRAMPRCR_W::new(self)
122    }
123    #[doc = "Bits 1:7 - Write Key Code"]
124    #[inline(always)]
125    #[must_use]
126    pub fn kw(&mut self) -> KW_W<1> {
127        KW_W::new(self)
128    }
129    #[doc = "Writes raw bits to the register."]
130    #[inline(always)]
131    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
132        self.0.bits(bits);
133        self
134    }
135}
136#[doc = "SRAM Protection 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 [sramprcr](index.html) module"]
137pub struct SRAMPRCR_SPEC;
138impl crate::RegisterSpec for SRAMPRCR_SPEC {
139    type Ux = u8;
140}
141#[doc = "`read()` method returns [sramprcr::R](R) reader structure"]
142impl crate::Readable for SRAMPRCR_SPEC {
143    type Reader = R;
144}
145#[doc = "`write(|w| ..)` method takes [sramprcr::W](W) writer structure"]
146impl crate::Writable for SRAMPRCR_SPEC {
147    type Writer = W;
148    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
149    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
150}
151#[doc = "`reset()` method sets SRAMPRCR to value 0"]
152impl crate::Resettable for SRAMPRCR_SPEC {
153    const RESET_VALUE: Self::Ux = 0;
154}