atsam4ls4a_pac/spi/
wpcr.rs

1#[doc = "Register `WPCR` reader"]
2pub struct R(crate::R<WPCR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<WPCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<WPCR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<WPCR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `WPCR` writer"]
17pub struct W(crate::W<WPCR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<WPCR_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<WPCR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<WPCR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `WPEN` reader - Write Protection Enable"]
38pub type WPEN_R = crate::BitReader<bool>;
39#[doc = "Field `WPEN` writer - Write Protection Enable"]
40pub type WPEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
41#[doc = "Field `WPKEY` reader - Write Protection Key Password"]
42pub type WPKEY_R = crate::FieldReader<u32, WPKEYSELECT_A>;
43#[doc = "Write Protection Key Password\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u32)]
46pub enum WPKEYSELECT_A {
47    #[doc = "5460041: SPI Write Protection Key Password"]
48    VALUE = 5460041,
49}
50impl From<WPKEYSELECT_A> for u32 {
51    #[inline(always)]
52    fn from(variant: WPKEYSELECT_A) -> Self {
53        variant as _
54    }
55}
56impl WPKEY_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<WPKEYSELECT_A> {
60        match self.bits {
61            5460041 => Some(WPKEYSELECT_A::VALUE),
62            _ => None,
63        }
64    }
65    #[doc = "Checks if the value of the field is `VALUE`"]
66    #[inline(always)]
67    pub fn is_value(&self) -> bool {
68        *self == WPKEYSELECT_A::VALUE
69    }
70}
71#[doc = "Field `WPKEY` writer - Write Protection Key Password"]
72pub type WPKEY_W<'a, const O: u8> =
73    crate::FieldWriter<'a, u32, WPCR_SPEC, u32, WPKEYSELECT_A, 24, O>;
74impl<'a, const O: u8> WPKEY_W<'a, O> {
75    #[doc = "SPI Write Protection Key Password"]
76    #[inline(always)]
77    pub fn value(self) -> &'a mut W {
78        self.variant(WPKEYSELECT_A::VALUE)
79    }
80}
81impl R {
82    #[doc = "Bit 0 - Write Protection Enable"]
83    #[inline(always)]
84    pub fn wpen(&self) -> WPEN_R {
85        WPEN_R::new((self.bits & 1) != 0)
86    }
87    #[doc = "Bits 8:31 - Write Protection Key Password"]
88    #[inline(always)]
89    pub fn wpkey(&self) -> WPKEY_R {
90        WPKEY_R::new((self.bits >> 8) & 0x00ff_ffff)
91    }
92}
93impl W {
94    #[doc = "Bit 0 - Write Protection Enable"]
95    #[inline(always)]
96    #[must_use]
97    pub fn wpen(&mut self) -> WPEN_W<0> {
98        WPEN_W::new(self)
99    }
100    #[doc = "Bits 8:31 - Write Protection Key Password"]
101    #[inline(always)]
102    #[must_use]
103    pub fn wpkey(&mut self) -> WPKEY_W<8> {
104        WPKEY_W::new(self)
105    }
106    #[doc = "Writes raw bits to the register."]
107    #[inline(always)]
108    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
109        self.0.bits(bits);
110        self
111    }
112}
113#[doc = "Write Protection control 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 [wpcr](index.html) module"]
114pub struct WPCR_SPEC;
115impl crate::RegisterSpec for WPCR_SPEC {
116    type Ux = u32;
117}
118#[doc = "`read()` method returns [wpcr::R](R) reader structure"]
119impl crate::Readable for WPCR_SPEC {
120    type Reader = R;
121}
122#[doc = "`write(|w| ..)` method takes [wpcr::W](W) writer structure"]
123impl crate::Writable for WPCR_SPEC {
124    type Writer = W;
125    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
126    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
127}
128#[doc = "`reset()` method sets WPCR to value 0"]
129impl crate::Resettable for WPCR_SPEC {
130    const RESET_VALUE: Self::Ux = 0;
131}