blob: 90a6ddbeaac17497e2426227c7120c9141b0efc6 (
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
|
#ifndef USB_H
#define USB_H
#include <stdint.h>
struct USB_reg_t {
volatile uint32_t GOTGCTL;
volatile uint32_t GOTGINT;
volatile uint32_t GAHBCFG;
volatile uint32_t GUSBCFG;
volatile uint32_t GRSTCTL;
volatile uint32_t GINTSTS;
volatile uint32_t GINTMSK;
volatile uint32_t GRXSTSR;
volatile uint32_t GRXSTSP;
volatile uint32_t GRXFSIZ;
volatile uint32_t DIEPTXF0;
volatile uint32_t HNPTXSTS;
volatile uint32_t GCCFG;
volatile uint32_t CID;
uint32_t _reserved[49];
volatile uint32_t HPTXFSIZ;
volatile uint32_t DIEPTXF1;
volatile uint32_t DIEPTXF2;
volatile uint32_t DIEPTXF3;
};
struct USB_dev_reg_t {
volatile uint32_t DCFG;
volatile uint32_t DCTL;
volatile uint32_t DSTS;
volatile uint32_t DIEPMSK;
volatile uint32_t DOEPMSK;
volatile uint32_t DAINT;
volatile uint32_t DAINTMSK;
volatile uint32_t DVBUSDIS;
volatile uint32_t DVBUSPULSE;
volatile uint32_t DIEPEMPMSK;
};
class USB_t {
public:
USB_reg_t& reg;
USB_dev_reg_t& dev_reg;
USB_t(uint32_t reg_addr) :
reg(*(USB_reg_t*)reg_addr),
dev_reg(*(USB_dev_reg_t*)(reg_addr + 0x800)) {}
};
#if defined(STM32F1)
#elif defined(STM32F4)
static USB_t OTG_FS(0x50000000);
#endif
#endif
|