stm32l4x2_pac/iwdg/
kr.rs

1#[doc = r" Value to write to the register"]
2pub struct W {
3    bits: u32,
4}
5impl super::KR {
6    #[doc = r" Writes to the register"]
7    #[inline]
8    pub fn write<F>(&self, f: F)
9    where
10        F: FnOnce(&mut W) -> &mut W,
11    {
12        let mut w = W::reset_value();
13        f(&mut w);
14        self.register.set(w.bits);
15    }
16}
17#[doc = "Values that can be written to the field `KEY`"]
18pub enum KEYW {
19    #[doc = "Enable access to PR, RLR and WINR registers (0x5555)"]
20    ENABLE,
21    #[doc = "Reset the watchdog value (0xAAAA)"]
22    RESET,
23    #[doc = "Start the watchdog (0xCCCC)"]
24    START,
25}
26impl KEYW {
27    #[allow(missing_docs)]
28    #[doc(hidden)]
29    #[inline]
30    pub fn _bits(&self) -> u16 {
31        match *self {
32            KEYW::ENABLE => 21845,
33            KEYW::RESET => 43690,
34            KEYW::START => 52428,
35        }
36    }
37}
38#[doc = r" Proxy"]
39pub struct _KEYW<'a> {
40    w: &'a mut W,
41}
42impl<'a> _KEYW<'a> {
43    #[doc = r" Writes `variant` to the field"]
44    #[inline]
45    pub fn variant(self, variant: KEYW) -> &'a mut W {
46        unsafe { self.bits(variant._bits()) }
47    }
48    #[doc = "Enable access to PR, RLR and WINR registers (0x5555)"]
49    #[inline]
50    pub fn enable(self) -> &'a mut W {
51        self.variant(KEYW::ENABLE)
52    }
53    #[doc = "Reset the watchdog value (0xAAAA)"]
54    #[inline]
55    pub fn reset(self) -> &'a mut W {
56        self.variant(KEYW::RESET)
57    }
58    #[doc = "Start the watchdog (0xCCCC)"]
59    #[inline]
60    pub fn start(self) -> &'a mut W {
61        self.variant(KEYW::START)
62    }
63    #[doc = r" Writes raw bits to the field"]
64    #[inline]
65    pub unsafe fn bits(self, value: u16) -> &'a mut W {
66        const MASK: u16 = 65535;
67        const OFFSET: u8 = 0;
68        self.w.bits &= !((MASK as u32) << OFFSET);
69        self.w.bits |= ((value & MASK) as u32) << OFFSET;
70        self.w
71    }
72}
73impl W {
74    #[doc = r" Reset value of the register"]
75    #[inline]
76    pub fn reset_value() -> W {
77        W { bits: 0 }
78    }
79    #[doc = r" Writes raw bits to the register"]
80    #[inline]
81    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
82        self.bits = bits;
83        self
84    }
85    #[doc = "Bits 0:15 - Key value (write only, read 0x0000)"]
86    #[inline]
87    pub fn key(&mut self) -> _KEYW {
88        _KEYW { w: self }
89    }
90}