rp2040_pac/usbctrl_regs/
usb_pwr.rs

1#[doc = "Register `USB_PWR` reader"]
2pub type R = crate::R<USB_PWR_SPEC>;
3#[doc = "Register `USB_PWR` writer"]
4pub type W = crate::W<USB_PWR_SPEC>;
5#[doc = "Field `VBUS_EN` reader - "]
6pub type VBUS_EN_R = crate::BitReader;
7#[doc = "Field `VBUS_EN` writer - "]
8pub type VBUS_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `VBUS_EN_OVERRIDE_EN` reader - "]
10pub type VBUS_EN_OVERRIDE_EN_R = crate::BitReader;
11#[doc = "Field `VBUS_EN_OVERRIDE_EN` writer - "]
12pub type VBUS_EN_OVERRIDE_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Field `VBUS_DETECT` reader - "]
14pub type VBUS_DETECT_R = crate::BitReader;
15#[doc = "Field `VBUS_DETECT` writer - "]
16pub type VBUS_DETECT_W<'a, REG> = crate::BitWriter<'a, REG>;
17#[doc = "Field `VBUS_DETECT_OVERRIDE_EN` reader - "]
18pub type VBUS_DETECT_OVERRIDE_EN_R = crate::BitReader;
19#[doc = "Field `VBUS_DETECT_OVERRIDE_EN` writer - "]
20pub type VBUS_DETECT_OVERRIDE_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
21#[doc = "Field `OVERCURR_DETECT` reader - "]
22pub type OVERCURR_DETECT_R = crate::BitReader;
23#[doc = "Field `OVERCURR_DETECT` writer - "]
24pub type OVERCURR_DETECT_W<'a, REG> = crate::BitWriter<'a, REG>;
25#[doc = "Field `OVERCURR_DETECT_EN` reader - "]
26pub type OVERCURR_DETECT_EN_R = crate::BitReader;
27#[doc = "Field `OVERCURR_DETECT_EN` writer - "]
28pub type OVERCURR_DETECT_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
29impl R {
30    #[doc = "Bit 0"]
31    #[inline(always)]
32    pub fn vbus_en(&self) -> VBUS_EN_R {
33        VBUS_EN_R::new((self.bits & 1) != 0)
34    }
35    #[doc = "Bit 1"]
36    #[inline(always)]
37    pub fn vbus_en_override_en(&self) -> VBUS_EN_OVERRIDE_EN_R {
38        VBUS_EN_OVERRIDE_EN_R::new(((self.bits >> 1) & 1) != 0)
39    }
40    #[doc = "Bit 2"]
41    #[inline(always)]
42    pub fn vbus_detect(&self) -> VBUS_DETECT_R {
43        VBUS_DETECT_R::new(((self.bits >> 2) & 1) != 0)
44    }
45    #[doc = "Bit 3"]
46    #[inline(always)]
47    pub fn vbus_detect_override_en(&self) -> VBUS_DETECT_OVERRIDE_EN_R {
48        VBUS_DETECT_OVERRIDE_EN_R::new(((self.bits >> 3) & 1) != 0)
49    }
50    #[doc = "Bit 4"]
51    #[inline(always)]
52    pub fn overcurr_detect(&self) -> OVERCURR_DETECT_R {
53        OVERCURR_DETECT_R::new(((self.bits >> 4) & 1) != 0)
54    }
55    #[doc = "Bit 5"]
56    #[inline(always)]
57    pub fn overcurr_detect_en(&self) -> OVERCURR_DETECT_EN_R {
58        OVERCURR_DETECT_EN_R::new(((self.bits >> 5) & 1) != 0)
59    }
60}
61impl W {
62    #[doc = "Bit 0"]
63    #[inline(always)]
64    #[must_use]
65    pub fn vbus_en(&mut self) -> VBUS_EN_W<USB_PWR_SPEC> {
66        VBUS_EN_W::new(self, 0)
67    }
68    #[doc = "Bit 1"]
69    #[inline(always)]
70    #[must_use]
71    pub fn vbus_en_override_en(&mut self) -> VBUS_EN_OVERRIDE_EN_W<USB_PWR_SPEC> {
72        VBUS_EN_OVERRIDE_EN_W::new(self, 1)
73    }
74    #[doc = "Bit 2"]
75    #[inline(always)]
76    #[must_use]
77    pub fn vbus_detect(&mut self) -> VBUS_DETECT_W<USB_PWR_SPEC> {
78        VBUS_DETECT_W::new(self, 2)
79    }
80    #[doc = "Bit 3"]
81    #[inline(always)]
82    #[must_use]
83    pub fn vbus_detect_override_en(&mut self) -> VBUS_DETECT_OVERRIDE_EN_W<USB_PWR_SPEC> {
84        VBUS_DETECT_OVERRIDE_EN_W::new(self, 3)
85    }
86    #[doc = "Bit 4"]
87    #[inline(always)]
88    #[must_use]
89    pub fn overcurr_detect(&mut self) -> OVERCURR_DETECT_W<USB_PWR_SPEC> {
90        OVERCURR_DETECT_W::new(self, 4)
91    }
92    #[doc = "Bit 5"]
93    #[inline(always)]
94    #[must_use]
95    pub fn overcurr_detect_en(&mut self) -> OVERCURR_DETECT_EN_W<USB_PWR_SPEC> {
96        OVERCURR_DETECT_EN_W::new(self, 5)
97    }
98    #[doc = r" Writes raw bits to the register."]
99    #[doc = r""]
100    #[doc = r" # Safety"]
101    #[doc = r""]
102    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
103    #[inline(always)]
104    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
105        self.bits = bits;
106        self
107    }
108}
109#[doc = "Overrides for the power signals in the event that the VBUS signals are not hooked up to GPIO. Set the value of the override and then the override enable to switch over to the override value.  
110
111You can [`read`](crate::generic::Reg::read) this register and get [`usb_pwr::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`usb_pwr::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
112pub struct USB_PWR_SPEC;
113impl crate::RegisterSpec for USB_PWR_SPEC {
114    type Ux = u32;
115}
116#[doc = "`read()` method returns [`usb_pwr::R`](R) reader structure"]
117impl crate::Readable for USB_PWR_SPEC {}
118#[doc = "`write(|w| ..)` method takes [`usb_pwr::W`](W) writer structure"]
119impl crate::Writable for USB_PWR_SPEC {
120    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
121    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
122}
123#[doc = "`reset()` method sets USB_PWR to value 0"]
124impl crate::Resettable for USB_PWR_SPEC {
125    const RESET_VALUE: u32 = 0;
126}