stm32f1_staging/stm32f103/bkp/
cr.rs

1///Register `CR` reader
2pub type R = crate::R<CRrs>;
3///Register `CR` writer
4pub type W = crate::W<CRrs>;
5/**Tamper pin enable
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum TPE {
11    ///0: The TAMPER pin is free for general purpose I/O
12    General = 0,
13    ///1: Tamper alternate I/O function is activated
14    Alternate = 1,
15}
16impl From<TPE> for bool {
17    #[inline(always)]
18    fn from(variant: TPE) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `TPE` reader - Tamper pin enable
23pub type TPE_R = crate::BitReader<TPE>;
24impl TPE_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> TPE {
28        match self.bits {
29            false => TPE::General,
30            true => TPE::Alternate,
31        }
32    }
33    ///The TAMPER pin is free for general purpose I/O
34    #[inline(always)]
35    pub fn is_general(&self) -> bool {
36        *self == TPE::General
37    }
38    ///Tamper alternate I/O function is activated
39    #[inline(always)]
40    pub fn is_alternate(&self) -> bool {
41        *self == TPE::Alternate
42    }
43}
44///Field `TPE` writer - Tamper pin enable
45pub type TPE_W<'a, REG> = crate::BitWriter<'a, REG, TPE>;
46impl<'a, REG> TPE_W<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    ///The TAMPER pin is free for general purpose I/O
51    #[inline(always)]
52    pub fn general(self) -> &'a mut crate::W<REG> {
53        self.variant(TPE::General)
54    }
55    ///Tamper alternate I/O function is activated
56    #[inline(always)]
57    pub fn alternate(self) -> &'a mut crate::W<REG> {
58        self.variant(TPE::Alternate)
59    }
60}
61/**Tamper pin active level
62
63Value on reset: 0*/
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum TPAL {
67    ///0: A high level on the TAMPER pin resets all data backup registers (if TPE bit is set)
68    High = 0,
69    ///1: A low level on the TAMPER pin resets all data backup registers (if TPE bit is set)
70    Low = 1,
71}
72impl From<TPAL> for bool {
73    #[inline(always)]
74    fn from(variant: TPAL) -> Self {
75        variant as u8 != 0
76    }
77}
78///Field `TPAL` reader - Tamper pin active level
79pub type TPAL_R = crate::BitReader<TPAL>;
80impl TPAL_R {
81    ///Get enumerated values variant
82    #[inline(always)]
83    pub const fn variant(&self) -> TPAL {
84        match self.bits {
85            false => TPAL::High,
86            true => TPAL::Low,
87        }
88    }
89    ///A high level on the TAMPER pin resets all data backup registers (if TPE bit is set)
90    #[inline(always)]
91    pub fn is_high(&self) -> bool {
92        *self == TPAL::High
93    }
94    ///A low level on the TAMPER pin resets all data backup registers (if TPE bit is set)
95    #[inline(always)]
96    pub fn is_low(&self) -> bool {
97        *self == TPAL::Low
98    }
99}
100///Field `TPAL` writer - Tamper pin active level
101pub type TPAL_W<'a, REG> = crate::BitWriter<'a, REG, TPAL>;
102impl<'a, REG> TPAL_W<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    ///A high level on the TAMPER pin resets all data backup registers (if TPE bit is set)
107    #[inline(always)]
108    pub fn high(self) -> &'a mut crate::W<REG> {
109        self.variant(TPAL::High)
110    }
111    ///A low level on the TAMPER pin resets all data backup registers (if TPE bit is set)
112    #[inline(always)]
113    pub fn low(self) -> &'a mut crate::W<REG> {
114        self.variant(TPAL::Low)
115    }
116}
117impl R {
118    ///Bit 0 - Tamper pin enable
119    #[inline(always)]
120    pub fn tpe(&self) -> TPE_R {
121        TPE_R::new((self.bits & 1) != 0)
122    }
123    ///Bit 1 - Tamper pin active level
124    #[inline(always)]
125    pub fn tpal(&self) -> TPAL_R {
126        TPAL_R::new(((self.bits >> 1) & 1) != 0)
127    }
128}
129impl core::fmt::Debug for R {
130    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
131        f.debug_struct("CR")
132            .field("tpe", &self.tpe())
133            .field("tpal", &self.tpal())
134            .finish()
135    }
136}
137impl W {
138    ///Bit 0 - Tamper pin enable
139    #[inline(always)]
140    pub fn tpe(&mut self) -> TPE_W<CRrs> {
141        TPE_W::new(self, 0)
142    }
143    ///Bit 1 - Tamper pin active level
144    #[inline(always)]
145    pub fn tpal(&mut self) -> TPAL_W<CRrs> {
146        TPAL_W::new(self, 1)
147    }
148}
149/**Backup control register (BKP_CR)
150
151You can [`read`](crate::Reg::read) this register and get [`cr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
152
153See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F103.html#BKP:CR)*/
154pub struct CRrs;
155impl crate::RegisterSpec for CRrs {
156    type Ux = u32;
157}
158///`read()` method returns [`cr::R`](R) reader structure
159impl crate::Readable for CRrs {}
160///`write(|w| ..)` method takes [`cr::W`](W) writer structure
161impl crate::Writable for CRrs {
162    type Safety = crate::Unsafe;
163}
164///`reset()` method sets CR to value 0
165impl crate::Resettable for CRrs {}