1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#[doc = "Reader of register TOKEN"]
pub type R = crate::R<u8, super::TOKEN>;
#[doc = "Writer for register TOKEN"]
pub type W = crate::W<u8, super::TOKEN>;
#[doc = "Register TOKEN `reset()`'s with value 0"]
impl crate::ResetValue for super::TOKEN {
    type Type = u8;
    #[inline(always)]
    fn reset_value() -> Self::Type {
        0
    }
}
#[doc = "Reader of field `TOKENENDPT`"]
pub type TOKENENDPT_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `TOKENENDPT`"]
pub struct TOKENENDPT_W<'a> {
    w: &'a mut W,
}
impl<'a> TOKENENDPT_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x0f) | ((value as u8) & 0x0f);
        self.w
    }
}
#[doc = "Possible values of the field `TOKENPID`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TOKENPID_A {
    #[doc = "OUT Token. USB Module performs an OUT (TX) transaction."]
    _0001,
    #[doc = "IN Token. USB Module performs an In (RX) transaction."]
    _1001,
    #[doc = "SETUP Token. USB Module performs a SETUP (TX) transaction"]
    _1101,
}
impl crate::ToBits<u8> for TOKENPID_A {
    #[inline(always)]
    fn _bits(&self) -> u8 {
        match *self {
            TOKENPID_A::_0001 => 1,
            TOKENPID_A::_1001 => 9,
            TOKENPID_A::_1101 => 13,
        }
    }
}
#[doc = "Reader of field `TOKENPID`"]
pub type TOKENPID_R = crate::R<u8, TOKENPID_A>;
impl TOKENPID_R {
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> crate::Variant<u8, TOKENPID_A> {
        use crate::Variant::*;
        match self.bits {
            1 => Val(TOKENPID_A::_0001),
            9 => Val(TOKENPID_A::_1001),
            13 => Val(TOKENPID_A::_1101),
            i => Res(i),
        }
    }
    #[doc = "Checks if the value of the field is `_0001`"]
    #[inline(always)]
    pub fn is_0001(&self) -> bool {
        *self == TOKENPID_A::_0001
    }
    #[doc = "Checks if the value of the field is `_1001`"]
    #[inline(always)]
    pub fn is_1001(&self) -> bool {
        *self == TOKENPID_A::_1001
    }
    #[doc = "Checks if the value of the field is `_1101`"]
    #[inline(always)]
    pub fn is_1101(&self) -> bool {
        *self == TOKENPID_A::_1101
    }
}
#[doc = "Write proxy for field `TOKENPID`"]
pub struct TOKENPID_W<'a> {
    w: &'a mut W,
}
impl<'a> TOKENPID_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: TOKENPID_A) -> &'a mut W {
        use crate::ToBits;
        unsafe { self.bits(variant._bits()) }
    }
    #[doc = "OUT Token. USB Module performs an OUT (TX) transaction."]
    #[inline(always)]
    pub fn _0001(self) -> &'a mut W {
        self.variant(TOKENPID_A::_0001)
    }
    #[doc = "IN Token. USB Module performs an In (RX) transaction."]
    #[inline(always)]
    pub fn _1001(self) -> &'a mut W {
        self.variant(TOKENPID_A::_1001)
    }
    #[doc = "SETUP Token. USB Module performs a SETUP (TX) transaction"]
    #[inline(always)]
    pub fn _1101(self) -> &'a mut W {
        self.variant(TOKENPID_A::_1101)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x0f << 4)) | (((value as u8) & 0x0f) << 4);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:3 - Holds the Endpoint address for the token command"]
    #[inline(always)]
    pub fn tokenendpt(&self) -> TOKENENDPT_R {
        TOKENENDPT_R::new((self.bits & 0x0f) as u8)
    }
    #[doc = "Bits 4:7 - Contains the token type executed by the USB module."]
    #[inline(always)]
    pub fn tokenpid(&self) -> TOKENPID_R {
        TOKENPID_R::new(((self.bits >> 4) & 0x0f) as u8)
    }
}
impl W {
    #[doc = "Bits 0:3 - Holds the Endpoint address for the token command"]
    #[inline(always)]
    pub fn tokenendpt(&mut self) -> TOKENENDPT_W {
        TOKENENDPT_W { w: self }
    }
    #[doc = "Bits 4:7 - Contains the token type executed by the USB module."]
    #[inline(always)]
    pub fn tokenpid(&mut self) -> TOKENPID_W {
        TOKENPID_W { w: self }
    }
}