nrf52840_pac/power/
usbregstatus.rs
1#[doc = "Register `USBREGSTATUS` reader"]
2pub struct R(crate::R<USBREGSTATUS_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<USBREGSTATUS_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<USBREGSTATUS_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<USBREGSTATUS_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Field `VBUSDETECT` reader - VBUS input detection status (USBDETECTED and USBREMOVED events are derived from this information)"]
17pub type VBUSDETECT_R = crate::BitReader<VBUSDETECT_A>;
18#[doc = "VBUS input detection status (USBDETECTED and USBREMOVED events are derived from this information)\n\nValue on reset: 0"]
19#[derive(Clone, Copy, Debug, PartialEq)]
20pub enum VBUSDETECT_A {
21 #[doc = "0: VBUS voltage below valid threshold"]
22 NO_VBUS = 0,
23 #[doc = "1: VBUS voltage above valid threshold"]
24 VBUS_PRESENT = 1,
25}
26impl From<VBUSDETECT_A> for bool {
27 #[inline(always)]
28 fn from(variant: VBUSDETECT_A) -> Self {
29 variant as u8 != 0
30 }
31}
32impl VBUSDETECT_R {
33 #[doc = "Get enumerated values variant"]
34 #[inline(always)]
35 pub fn variant(&self) -> VBUSDETECT_A {
36 match self.bits {
37 false => VBUSDETECT_A::NO_VBUS,
38 true => VBUSDETECT_A::VBUS_PRESENT,
39 }
40 }
41 #[doc = "Checks if the value of the field is `NO_VBUS`"]
42 #[inline(always)]
43 pub fn is_no_vbus(&self) -> bool {
44 *self == VBUSDETECT_A::NO_VBUS
45 }
46 #[doc = "Checks if the value of the field is `VBUS_PRESENT`"]
47 #[inline(always)]
48 pub fn is_vbus_present(&self) -> bool {
49 *self == VBUSDETECT_A::VBUS_PRESENT
50 }
51}
52#[doc = "Field `OUTPUTRDY` reader - USB supply output settling time elapsed"]
53pub type OUTPUTRDY_R = crate::BitReader<OUTPUTRDY_A>;
54#[doc = "USB supply output settling time elapsed\n\nValue on reset: 0"]
55#[derive(Clone, Copy, Debug, PartialEq)]
56pub enum OUTPUTRDY_A {
57 #[doc = "0: USBREG output settling time not elapsed"]
58 NOT_READY = 0,
59 #[doc = "1: USBREG output settling time elapsed (same information as USBPWRRDY event)"]
60 READY = 1,
61}
62impl From<OUTPUTRDY_A> for bool {
63 #[inline(always)]
64 fn from(variant: OUTPUTRDY_A) -> Self {
65 variant as u8 != 0
66 }
67}
68impl OUTPUTRDY_R {
69 #[doc = "Get enumerated values variant"]
70 #[inline(always)]
71 pub fn variant(&self) -> OUTPUTRDY_A {
72 match self.bits {
73 false => OUTPUTRDY_A::NOT_READY,
74 true => OUTPUTRDY_A::READY,
75 }
76 }
77 #[doc = "Checks if the value of the field is `NOT_READY`"]
78 #[inline(always)]
79 pub fn is_not_ready(&self) -> bool {
80 *self == OUTPUTRDY_A::NOT_READY
81 }
82 #[doc = "Checks if the value of the field is `READY`"]
83 #[inline(always)]
84 pub fn is_ready(&self) -> bool {
85 *self == OUTPUTRDY_A::READY
86 }
87}
88impl R {
89 #[doc = "Bit 0 - VBUS input detection status (USBDETECTED and USBREMOVED events are derived from this information)"]
90 #[inline(always)]
91 pub fn vbusdetect(&self) -> VBUSDETECT_R {
92 VBUSDETECT_R::new((self.bits & 1) != 0)
93 }
94 #[doc = "Bit 1 - USB supply output settling time elapsed"]
95 #[inline(always)]
96 pub fn outputrdy(&self) -> OUTPUTRDY_R {
97 OUTPUTRDY_R::new(((self.bits >> 1) & 1) != 0)
98 }
99}
100#[doc = "USB supply status\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 [usbregstatus](index.html) module"]
101pub struct USBREGSTATUS_SPEC;
102impl crate::RegisterSpec for USBREGSTATUS_SPEC {
103 type Ux = u32;
104}
105#[doc = "`read()` method returns [usbregstatus::R](R) reader structure"]
106impl crate::Readable for USBREGSTATUS_SPEC {
107 type Reader = R;
108}
109#[doc = "`reset()` method sets USBREGSTATUS to value 0"]
110impl crate::Resettable for USBREGSTATUS_SPEC {
111 #[inline(always)]
112 fn reset_value() -> Self::Ux {
113 0
114 }
115}