atsam4s2c_pac/rstc/
sr.rs

1#[doc = "Register `SR` reader"]
2pub struct R(crate::R<SR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Field `URSTS` reader - User Reset Status"]
17pub type URSTS_R = crate::BitReader<bool>;
18#[doc = "Field `RSTTYP` reader - Reset Type"]
19pub type RSTTYP_R = crate::FieldReader<u8, RSTTYP_A>;
20#[doc = "Reset Type\n\nValue on reset: 0"]
21#[derive(Clone, Copy, Debug, PartialEq, Eq)]
22#[repr(u8)]
23pub enum RSTTYP_A {
24    #[doc = "0: First power-up Reset"]
25    GENERAL_RST = 0,
26    #[doc = "1: Return from Backup Mode"]
27    BACKUP_RST = 1,
28    #[doc = "2: Watchdog fault occurred"]
29    WDT_RST = 2,
30    #[doc = "3: Processor reset required by the software"]
31    SOFT_RST = 3,
32    #[doc = "4: NRST pin detected low"]
33    USER_RST = 4,
34}
35impl From<RSTTYP_A> for u8 {
36    #[inline(always)]
37    fn from(variant: RSTTYP_A) -> Self {
38        variant as _
39    }
40}
41impl RSTTYP_R {
42    #[doc = "Get enumerated values variant"]
43    #[inline(always)]
44    pub fn variant(&self) -> Option<RSTTYP_A> {
45        match self.bits {
46            0 => Some(RSTTYP_A::GENERAL_RST),
47            1 => Some(RSTTYP_A::BACKUP_RST),
48            2 => Some(RSTTYP_A::WDT_RST),
49            3 => Some(RSTTYP_A::SOFT_RST),
50            4 => Some(RSTTYP_A::USER_RST),
51            _ => None,
52        }
53    }
54    #[doc = "Checks if the value of the field is `GENERAL_RST`"]
55    #[inline(always)]
56    pub fn is_general_rst(&self) -> bool {
57        *self == RSTTYP_A::GENERAL_RST
58    }
59    #[doc = "Checks if the value of the field is `BACKUP_RST`"]
60    #[inline(always)]
61    pub fn is_backup_rst(&self) -> bool {
62        *self == RSTTYP_A::BACKUP_RST
63    }
64    #[doc = "Checks if the value of the field is `WDT_RST`"]
65    #[inline(always)]
66    pub fn is_wdt_rst(&self) -> bool {
67        *self == RSTTYP_A::WDT_RST
68    }
69    #[doc = "Checks if the value of the field is `SOFT_RST`"]
70    #[inline(always)]
71    pub fn is_soft_rst(&self) -> bool {
72        *self == RSTTYP_A::SOFT_RST
73    }
74    #[doc = "Checks if the value of the field is `USER_RST`"]
75    #[inline(always)]
76    pub fn is_user_rst(&self) -> bool {
77        *self == RSTTYP_A::USER_RST
78    }
79}
80#[doc = "Field `NRSTL` reader - NRST Pin Level"]
81pub type NRSTL_R = crate::BitReader<bool>;
82#[doc = "Field `SRCMP` reader - Software Reset Command in Progress"]
83pub type SRCMP_R = crate::BitReader<bool>;
84impl R {
85    #[doc = "Bit 0 - User Reset Status"]
86    #[inline(always)]
87    pub fn ursts(&self) -> URSTS_R {
88        URSTS_R::new((self.bits & 1) != 0)
89    }
90    #[doc = "Bits 8:10 - Reset Type"]
91    #[inline(always)]
92    pub fn rsttyp(&self) -> RSTTYP_R {
93        RSTTYP_R::new(((self.bits >> 8) & 7) as u8)
94    }
95    #[doc = "Bit 16 - NRST Pin Level"]
96    #[inline(always)]
97    pub fn nrstl(&self) -> NRSTL_R {
98        NRSTL_R::new(((self.bits >> 16) & 1) != 0)
99    }
100    #[doc = "Bit 17 - Software Reset Command in Progress"]
101    #[inline(always)]
102    pub fn srcmp(&self) -> SRCMP_R {
103        SRCMP_R::new(((self.bits >> 17) & 1) != 0)
104    }
105}
106#[doc = "Status Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sr](index.html) module"]
107pub struct SR_SPEC;
108impl crate::RegisterSpec for SR_SPEC {
109    type Ux = u32;
110}
111#[doc = "`read()` method returns [sr::R](R) reader structure"]
112impl crate::Readable for SR_SPEC {
113    type Reader = R;
114}
115#[doc = "`reset()` method sets SR to value 0"]
116impl crate::Resettable for SR_SPEC {
117    const RESET_VALUE: Self::Ux = 0;
118}