summaryrefslogtreecommitdiff
path: root/usb/usb_nrf_def.h
blob: 0d5680780fae39d7486481a5175e2f86b8c8f609 (plain)
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
#ifndef LAKS_USB_USB_NRF_DEF_H
#define LAKS_USB_USB_NRF_DEF_H

#include <stdint.h>

class USB_NRF_t {
	private:
		struct tasks_t {
			uint32_t _reserved;
			volatile uint32_t STARTEPIN[8];
			volatile uint32_t STARTISOIN;
			volatile uint32_t STARTEPOUT[8];
			volatile uint32_t STARTISOOUT;
			volatile uint32_t EP0RCVOUT;
			volatile uint32_t EP0STATUS;
			volatile uint32_t EP0STALL;
			volatile uint32_t DPDMDRIVE;
			volatile uint32_t DPDMNODRIVE;
		};
		
		struct events_t {
			volatile uint32_t USBRESET;
			volatile uint32_t STARTED;
			volatile uint32_t ENDEPIN[8];
			volatile uint32_t EP0DATADONE;
			volatile uint32_t ENDISOIN;
			volatile uint32_t ENDEPOUT[8];
			volatile uint32_t ENDISOOUT;
			volatile uint32_t SOF;
			volatile uint32_t USBEVENT;
			volatile uint32_t EP0SETUP;
			volatile uint32_t EPDATA;
		};
		
		struct reg_t {
			volatile uint32_t SHORTS;
			uint32_t _reserved[63];
			volatile uint32_t INTEN;
			volatile uint32_t INTENSET;
			volatile uint32_t INTENCLR;
			uint32_t _reserved_1[61];
			volatile uint32_t EVENTCAUSE;
			uint32_t _reserved_2[7];
			volatile uint32_t HALTED_EPIN[9];
			volatile uint32_t HALTED_EPOUT[9];
			volatile uint32_t EPSTATUS;
			volatile uint32_t EPDATASTATUS;
			volatile uint32_t USBADDR;
			uint32_t _reserved_3[3];
			volatile uint32_t BMREQUESTTYPE;
			volatile uint32_t BREQUEST;
			volatile uint32_t WVALUEL;
			volatile uint32_t WVALUEH;
			volatile uint32_t WINDEXL;
			volatile uint32_t WINDEXH;
			volatile uint32_t WLENGTHL;
			volatile uint32_t WLENGTHH;
			volatile uint32_t SIZE_EPOUT[8];
			volatile uint32_t SIZE_ISOOUT;
			uint32_t _reserved_4[15];
			volatile uint32_t ENABLE;
			volatile uint32_t USBPULLUP;
			volatile uint32_t DPDMVALUE;
			volatile uint32_t DTOGGLE;
			volatile uint32_t EPINEN;
			volatile uint32_t EPOUTEN;
			volatile uint32_t EPSTALL;
			volatile uint32_t ISOSPLIT;
			volatile uint32_t FRAMECNTR;
			uint32_t _reserved_5[2];
			volatile uint32_t LOWPOWER;
			volatile uint32_t ISOINCONFIG;
		};
		
		struct ep_reg_t {
			volatile uint32_t PTR;
			volatile uint32_t MAXCNT;
			volatile uint32_t AMOUNT;
			uint32_t _reserved[2];
		};
		
	public:
		tasks_t& tasks;
		events_t& events;
		reg_t& reg;
		ep_reg_t* reg_in;
		ep_reg_t* reg_out;
		
		USB_NRF_t(uint32_t reg_addr) :
			tasks(*(tasks_t*)(reg_addr + 0x0)),
			events(*(events_t*)(reg_addr + 0x100)),
			reg(*(reg_t*)(reg_addr + 0x200)),
			reg_in((ep_reg_t*)(reg_addr + 0x600)),
			reg_out((ep_reg_t*)(reg_addr + 0x700)) {}
};

#endif