Skip to main content

atsame70q21/usbhs/
usbhs_sr.rs

1#[doc = "Register `USBHS_SR` reader"]
2pub struct R(crate::R<USBHS_SR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<USBHS_SR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<USBHS_SR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<USBHS_SR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Field `RDERRI` reader - Remote Device Connection Error Interrupt (Host mode only)"]
17pub struct RDERRI_R(crate::FieldReader<bool, bool>);
18impl RDERRI_R {
19    #[inline(always)]
20    pub(crate) fn new(bits: bool) -> Self {
21        RDERRI_R(crate::FieldReader::new(bits))
22    }
23}
24impl core::ops::Deref for RDERRI_R {
25    type Target = crate::FieldReader<bool, bool>;
26    #[inline(always)]
27    fn deref(&self) -> &Self::Target {
28        &self.0
29    }
30}
31#[doc = "Speed Status (Device mode only)\n\nValue on reset: 0"]
32#[derive(Clone, Copy, Debug, PartialEq)]
33#[repr(u8)]
34pub enum SPEED_A {
35    #[doc = "0: Full-Speed mode"]
36    FULL_SPEED = 0,
37    #[doc = "1: High-Speed mode"]
38    HIGH_SPEED = 1,
39    #[doc = "2: Low-Speed mode"]
40    LOW_SPEED = 2,
41}
42impl From<SPEED_A> for u8 {
43    #[inline(always)]
44    fn from(variant: SPEED_A) -> Self {
45        variant as _
46    }
47}
48#[doc = "Field `SPEED` reader - Speed Status (Device mode only)"]
49pub struct SPEED_R(crate::FieldReader<u8, SPEED_A>);
50impl SPEED_R {
51    #[inline(always)]
52    pub(crate) fn new(bits: u8) -> Self {
53        SPEED_R(crate::FieldReader::new(bits))
54    }
55    #[doc = r"Get enumerated values variant"]
56    #[inline(always)]
57    pub fn variant(&self) -> Option<SPEED_A> {
58        match self.bits {
59            0 => Some(SPEED_A::FULL_SPEED),
60            1 => Some(SPEED_A::HIGH_SPEED),
61            2 => Some(SPEED_A::LOW_SPEED),
62            _ => None,
63        }
64    }
65    #[doc = "Checks if the value of the field is `FULL_SPEED`"]
66    #[inline(always)]
67    pub fn is_full_speed(&self) -> bool {
68        **self == SPEED_A::FULL_SPEED
69    }
70    #[doc = "Checks if the value of the field is `HIGH_SPEED`"]
71    #[inline(always)]
72    pub fn is_high_speed(&self) -> bool {
73        **self == SPEED_A::HIGH_SPEED
74    }
75    #[doc = "Checks if the value of the field is `LOW_SPEED`"]
76    #[inline(always)]
77    pub fn is_low_speed(&self) -> bool {
78        **self == SPEED_A::LOW_SPEED
79    }
80}
81impl core::ops::Deref for SPEED_R {
82    type Target = crate::FieldReader<u8, SPEED_A>;
83    #[inline(always)]
84    fn deref(&self) -> &Self::Target {
85        &self.0
86    }
87}
88#[doc = "Field `CLKUSABLE` reader - UTMI Clock Usable"]
89pub struct CLKUSABLE_R(crate::FieldReader<bool, bool>);
90impl CLKUSABLE_R {
91    #[inline(always)]
92    pub(crate) fn new(bits: bool) -> Self {
93        CLKUSABLE_R(crate::FieldReader::new(bits))
94    }
95}
96impl core::ops::Deref for CLKUSABLE_R {
97    type Target = crate::FieldReader<bool, bool>;
98    #[inline(always)]
99    fn deref(&self) -> &Self::Target {
100        &self.0
101    }
102}
103impl R {
104    #[doc = "Bit 4 - Remote Device Connection Error Interrupt (Host mode only)"]
105    #[inline(always)]
106    pub fn rderri(&self) -> RDERRI_R {
107        RDERRI_R::new(((self.bits >> 4) & 0x01) != 0)
108    }
109    #[doc = "Bits 12:13 - Speed Status (Device mode only)"]
110    #[inline(always)]
111    pub fn speed(&self) -> SPEED_R {
112        SPEED_R::new(((self.bits >> 12) & 0x03) as u8)
113    }
114    #[doc = "Bit 14 - UTMI Clock Usable"]
115    #[inline(always)]
116    pub fn clkusable(&self) -> CLKUSABLE_R {
117        CLKUSABLE_R::new(((self.bits >> 14) & 0x01) != 0)
118    }
119}
120#[doc = "General 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 [usbhs_sr](index.html) module"]
121pub struct USBHS_SR_SPEC;
122impl crate::RegisterSpec for USBHS_SR_SPEC {
123    type Ux = u32;
124}
125#[doc = "`read()` method returns [usbhs_sr::R](R) reader structure"]
126impl crate::Readable for USBHS_SR_SPEC {
127    type Reader = R;
128}
129#[doc = "`reset()` method sets USBHS_SR to value 0"]
130impl crate::Resettable for USBHS_SR_SPEC {
131    #[inline(always)]
132    fn reset_value() -> Self::Ux {
133        0
134    }
135}