Numworks Epsilon  1.4.1
Graphing Calculator Operating System
otg.h
Go to the documentation of this file.
1 #ifndef REGS_OTG_H
2 #define REGS_OTG_H
3 
4 #include "register.h"
5 
6 class OTG {
7 public:
8  class GAHBCFG : public Register32 {
9  public:
11  };
12 
13  class GUSBCFG : public Register32 {
14  public:
15  REGS_BOOL_FIELD(PHYSEL, 6);
16  REGS_FIELD(TRDT, uint8_t, 13, 10);
17  REGS_BOOL_FIELD(FDMOD, 30);
18  };
19 
20  class GRSTCTL : public Register32 {
21  public:
22  REGS_BOOL_FIELD(CSRST, 0);
23  REGS_BOOL_FIELD(RXFFLSH, 4);
24  REGS_BOOL_FIELD(TXFFLSH, 5);
25  REGS_FIELD(TXFNUM, uint8_t, 10, 6);
26  REGS_BOOL_FIELD(AHBIDL, 31);
27  };
28 
29  class GINTSTS : public Register32 {
30  public:
32  REGS_BOOL_FIELD(MMIS, 1);
33  REGS_BOOL_FIELD(SOF, 3);
34  REGS_BOOL_FIELD(RXFLVL, 4);
35  REGS_BOOL_FIELD(USBSUSP, 11);
36  REGS_BOOL_FIELD(USBRST, 12);
37  REGS_BOOL_FIELD(ENUMDNE, 13);
38  REGS_BOOL_FIELD(IEPINT, 18);
39  REGS_BOOL_FIELD(WKUPINT, 31);
40  };
41 
42  class GINTMSK : public Register32 {
43  public:
45  REGS_BOOL_FIELD(RXFLVLM, 4);
46  REGS_BOOL_FIELD(USBSUSPM, 11);
47  REGS_BOOL_FIELD(USBRST, 12);
48  REGS_BOOL_FIELD(ENUMDNEM, 13);
49  REGS_BOOL_FIELD(IEPINT, 18);
50  REGS_BOOL_FIELD(WUIM, 31);
51  };
52 
53  class GRXSTSP : public Register32 {
54  public:
56  enum class PKTSTS {
57  GlobalOutNAK = 1,
58  OutReceived = 2,
59  OutTransferCompleted = 3, // After each Out Transaction
60  SetupTransactionCompleted = 4, // Supposed to be after each SETUP transaction
61  SetupReceived = 6
62  };
63  REGS_FIELD(EPNUM, uint8_t, 3, 0);
64  REGS_FIELD(BCNT, uint16_t, 14, 4);
65  PKTSTS getPKTSTS() volatile { return (PKTSTS)getBitRange(20, 17); }
66  };
67 
68  class GRXFSIZ : public Register32 {
69  public:
70  REGS_FIELD(RXFD, uint16_t, 15, 0);
71  };
72 
73  class DIEPTXF0 : public Register32 {
74  public:
75  REGS_FIELD(TX0FSA, uint16_t, 15, 0);
76  REGS_FIELD(TX0FD, uint16_t, 31, 16);
77  };
78 
79  class GCCFG : public Register32 {
80  public:
81  REGS_BOOL_FIELD(PWRDWN, 16);
82  REGS_BOOL_FIELD(VBDEN, 21);
83  };
84 
85  class DCFG : public Register32 {
86  public:
87  enum class DSPD {
88  FullSpeed = 3,
89  };
90  void setDSPD(DSPD s) volatile { setBitRange(1, 0, (uint8_t)s); }
91  REGS_FIELD(DAD, uint8_t, 10, 4);
92  };
93 
94  class DCTL : public Register32 {
95  public:
96  REGS_BOOL_FIELD(SDIS, 1);
97  };
98 
99  class DIEPMSK : public Register32 {
100  public:
101  REGS_BOOL_FIELD(XFRCM, 0);
102  };
103 
104  class DAINTMSK : public Register32 {
105  public:
106  REGS_FIELD(IEPM, uint16_t, 15, 0);
107  REGS_FIELD(OEPM, uint16_t, 31, 16);
108  };
109 
110  class DIEPCTL0 : public Register32 {
111  public:
112  enum class MPSIZ {
113  Size64 = 0,
114  Size32 = 1,
115  Size16 = 2,
116  Size8 = 3
117  };
119  void setMPSIZ(MPSIZ s) volatile { setBitRange(1, 0, (uint8_t)s); }
120  REGS_BOOL_FIELD(STALL, 21);
121  REGS_FIELD(TXFNUM, uint8_t, 25, 22);
122  REGS_BOOL_FIELD(CNAK, 26);
123  REGS_BOOL_FIELD(SNAK, 27);
124  REGS_BOOL_FIELD(EPENA, 31);
125  };
126 
127  class DOEPCTL0 : public Register32 {
128  public:
129  REGS_BOOL_FIELD(CNAK, 26);
130  REGS_BOOL_FIELD(SNAK, 27);
131  REGS_BOOL_FIELD(EPENA, 31);
132  };
133 
134  class DIEPINT : public Register32 {
135  public:
136  REGS_BOOL_FIELD(XFRC, 0);
137  REGS_BOOL_FIELD(INEPNE, 6);
138  };
139 
140  class DIEPTSIZ0 : public Register32 {
141  public:
143  REGS_FIELD(XFRSIZ, uint8_t, 6, 0);
144  REGS_FIELD(PKTCNT, uint8_t, 20, 19);
145  };
146 
147  class DOEPTSIZ0 : public Register32 {
148  public:
150  REGS_FIELD(XFRSIZ, uint8_t, 6, 0);
151  REGS_BOOL_FIELD(PKTCNT, 19);
152  REGS_FIELD(STUPCNT, uint8_t, 30, 29);
153  };
154 
155  class PCGCCTL : public Register32 {
156  public:
157  REGS_BOOL_FIELD(STPPCLK, 0);
158  REGS_BOOL_FIELD(GATEHCLK, 1);
159  };
160 
161  class DFIFO0 : public Register32 {
162  };
163 
164  constexpr OTG() {};
165  REGS_REGISTER_AT(GAHBCFG, 0x008);
166  REGS_REGISTER_AT(GUSBCFG, 0x00C);
167  REGS_REGISTER_AT(GRSTCTL, 0x010);
168  REGS_REGISTER_AT(GINTSTS, 0x014);
169  REGS_REGISTER_AT(GINTMSK, 0x018);
170  REGS_REGISTER_AT(GRXSTSP, 0x020);
171  REGS_REGISTER_AT(GRXFSIZ, 0x024);
172  REGS_REGISTER_AT(DIEPTXF0, 0x28);
173  REGS_REGISTER_AT(GCCFG, 0x038);
174  REGS_REGISTER_AT(DCFG, 0x800);
175  REGS_REGISTER_AT(DCTL, 0x804);
176  REGS_REGISTER_AT(DIEPMSK, 0x810);
177  REGS_REGISTER_AT(DAINTMSK, 0x81C);
178  REGS_REGISTER_AT(DIEPCTL0, 0x900);
179  REGS_REGISTER_AT(DIEPTSIZ0, 0x910);
180  REGS_REGISTER_AT(DOEPCTL0, 0xB00);
181  REGS_REGISTER_AT(DOEPTSIZ0, 0xB10);
182  REGS_REGISTER_AT(PCGCCTL, 0xE00);
183  REGS_REGISTER_AT(DFIFO0, 0x1000);
184  constexpr volatile DIEPINT * DIEPINT(int i) const {
185  return (class DIEPINT *)(Base() + 0x908 + i*0x20);
186  }
187 private:
188  constexpr uint32_t Base() const {
189  return 0x50000000;
190  }
191 };
192 
193 constexpr OTG OTG;
194 
195 #endif
REGS_FIELD(XFRSIZ, uint8_t, 6, 0)
REGS_BOOL_FIELD(CSRST, 0)
REGS_BOOL_FIELD(XFRCM, 0)
constexpr OTG OTG
Definition: otg.h:193
REGS_BOOL_FIELD(STPPCLK, 0)
REGS_FIELD(DAD, uint8_t, 10, 4)
REGS_BOOL_FIELD(RXFLVLM, 4)
REGS_BOOL_FIELD(CNAK, 26)
unsigned short uint16_t
Definition: stdint.h:5
unsigned char uint8_t
Definition: stdint.h:4
Definition: otg.h:94
REGS_BOOL_FIELD(MMIS, 1)
Definition: otg.h:85
constexpr OTG()
Definition: otg.h:164
REGS_FIELD(TX0FSA, uint16_t, 15, 0)
constexpr volatile DIEPINT * DIEPINT(int i) const
Definition: otg.h:184
void setDSPD(DSPD s) volatile
Definition: otg.h:90
unsigned int uint32_t
Definition: stdint.h:6
REGS_FIELD(RXFD, uint16_t, 15, 0)
void setMPSIZ(MPSIZ s) volatile
Definition: otg.h:119
REGS_BOOL_FIELD(XFRC, 0)
REGS_FIELD(TRDT, uint8_t, 13, 10)
REGS_BOOL_FIELD(STALL, 21)
REGS_FIELD(IEPM, uint16_t, 15, 0)
REGS_BOOL_FIELD(PKTCNT, 19)
REGS_REGISTER_AT(GAHBCFG, 0x008)
REGS_BOOL_FIELD(PHYSEL, 6)
REGS_FIELD(TXFNUM, uint8_t, 10, 6)
REGS_BOOL_FIELD(SDIS, 1)
REGS_FIELD(TXFNUM, uint8_t, 25, 22)
Register< uint32_t > Register32
Definition: register.h:49
Definition: otg.h:79
PKTSTS getPKTSTS() volatile
Definition: otg.h:65
void setBitRange(uint8_t high, uint8_t low, T value) volatile
Definition: register.h:21
DSPD
Definition: otg.h:87
Definition: otg.h:6
REGS_BOOL_FIELD(PWRDWN, 16)
REGS_FIELD(XFRSIZ, uint8_t, 6, 0)
REGS_BOOL_FIELD(GINTMSK, 0)
T getBitRange(uint8_t high, uint8_t low) volatile
Definition: register.h:24
REGS_FIELD(EPNUM, uint8_t, 3, 0)