mcxa_pac/usb0/
token.rs

1#[doc = "Register `TOKEN` reader"]
2pub type R = crate::R<TokenSpec>;
3#[doc = "Register `TOKEN` writer"]
4pub type W = crate::W<TokenSpec>;
5#[doc = "Field `TOKENENDPT` reader - Token Endpoint Address"]
6pub type TokenendptR = crate::FieldReader;
7#[doc = "Field `TOKENENDPT` writer - Token Endpoint Address"]
8pub type TokenendptW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
9#[doc = "Token Type\n\nValue on reset: 0"]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12#[repr(u8)]
13pub enum Tokenpid {
14    #[doc = "1: OUT token. USBFS performs an OUT (TX) transaction."]
15    EnOutToken = 1,
16    #[doc = "9: IN token. USBFS performs an IN (RX) transaction."]
17    EnInToken = 9,
18    #[doc = "13: SETUP token. USBFS performs a SETUP (TX) transaction"]
19    EnSetupToken = 13,
20}
21impl From<Tokenpid> for u8 {
22    #[inline(always)]
23    fn from(variant: Tokenpid) -> Self {
24        variant as _
25    }
26}
27impl crate::FieldSpec for Tokenpid {
28    type Ux = u8;
29}
30impl crate::IsEnum for Tokenpid {}
31#[doc = "Field `TOKENPID` reader - Token Type"]
32pub type TokenpidR = crate::FieldReader<Tokenpid>;
33impl TokenpidR {
34    #[doc = "Get enumerated values variant"]
35    #[inline(always)]
36    pub const fn variant(&self) -> Option<Tokenpid> {
37        match self.bits {
38            1 => Some(Tokenpid::EnOutToken),
39            9 => Some(Tokenpid::EnInToken),
40            13 => Some(Tokenpid::EnSetupToken),
41            _ => None,
42        }
43    }
44    #[doc = "OUT token. USBFS performs an OUT (TX) transaction."]
45    #[inline(always)]
46    pub fn is_en_out_token(&self) -> bool {
47        *self == Tokenpid::EnOutToken
48    }
49    #[doc = "IN token. USBFS performs an IN (RX) transaction."]
50    #[inline(always)]
51    pub fn is_en_in_token(&self) -> bool {
52        *self == Tokenpid::EnInToken
53    }
54    #[doc = "SETUP token. USBFS performs a SETUP (TX) transaction"]
55    #[inline(always)]
56    pub fn is_en_setup_token(&self) -> bool {
57        *self == Tokenpid::EnSetupToken
58    }
59}
60#[doc = "Field `TOKENPID` writer - Token Type"]
61pub type TokenpidW<'a, REG> = crate::FieldWriter<'a, REG, 4, Tokenpid>;
62impl<'a, REG> TokenpidW<'a, REG>
63where
64    REG: crate::Writable + crate::RegisterSpec,
65    REG::Ux: From<u8>,
66{
67    #[doc = "OUT token. USBFS performs an OUT (TX) transaction."]
68    #[inline(always)]
69    pub fn en_out_token(self) -> &'a mut crate::W<REG> {
70        self.variant(Tokenpid::EnOutToken)
71    }
72    #[doc = "IN token. USBFS performs an IN (RX) transaction."]
73    #[inline(always)]
74    pub fn en_in_token(self) -> &'a mut crate::W<REG> {
75        self.variant(Tokenpid::EnInToken)
76    }
77    #[doc = "SETUP token. USBFS performs a SETUP (TX) transaction"]
78    #[inline(always)]
79    pub fn en_setup_token(self) -> &'a mut crate::W<REG> {
80        self.variant(Tokenpid::EnSetupToken)
81    }
82}
83impl R {
84    #[doc = "Bits 0:3 - Token Endpoint Address"]
85    #[inline(always)]
86    pub fn tokenendpt(&self) -> TokenendptR {
87        TokenendptR::new(self.bits & 0x0f)
88    }
89    #[doc = "Bits 4:7 - Token Type"]
90    #[inline(always)]
91    pub fn tokenpid(&self) -> TokenpidR {
92        TokenpidR::new((self.bits >> 4) & 0x0f)
93    }
94}
95#[cfg(feature = "debug")]
96impl core::fmt::Debug for R {
97    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
98        f.debug_struct("TOKEN")
99            .field("tokenendpt", &self.tokenendpt())
100            .field("tokenpid", &self.tokenpid())
101            .finish()
102    }
103}
104impl W {
105    #[doc = "Bits 0:3 - Token Endpoint Address"]
106    #[inline(always)]
107    pub fn tokenendpt(&mut self) -> TokenendptW<'_, TokenSpec> {
108        TokenendptW::new(self, 0)
109    }
110    #[doc = "Bits 4:7 - Token Type"]
111    #[inline(always)]
112    pub fn tokenpid(&mut self) -> TokenpidW<'_, TokenSpec> {
113        TokenpidW::new(self, 4)
114    }
115}
116#[doc = "Token\n\nYou can [`read`](crate::Reg::read) this register and get [`token::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`token::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
117pub struct TokenSpec;
118impl crate::RegisterSpec for TokenSpec {
119    type Ux = u8;
120}
121#[doc = "`read()` method returns [`token::R`](R) reader structure"]
122impl crate::Readable for TokenSpec {}
123#[doc = "`write(|w| ..)` method takes [`token::W`](W) writer structure"]
124impl crate::Writable for TokenSpec {
125    type Safety = crate::Unsafe;
126}
127#[doc = "`reset()` method sets TOKEN to value 0"]
128impl crate::Resettable for TokenSpec {}