cm4.h
2 KB
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
#ifndef REGS_CM4_H
#define REGS_CM4_H
#include "register.h"
class CM4 {
public:
// Vector table offset register
// http://www.st.com/content/ccc/resource/technical/document/programming_manual/6c/3a/cb/e7/e4/ea/44/9b/DM00046982.pdf/files/DM00046982.pdf/jcr:content/translations/en.DM00046982.pdf
class VTOR : Register32 {
public:
void setVTOR(void *address) volatile { setBitRange(29, 9, (uint32_t)address); }
};
// Coprocessor Access Control Register
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/BEHBJHIG.html
class CPACR : public Register32 {
public:
enum class Access {
Denied = 0,
PrivilegedOnly = 1,
Full = 3
};
void setAccess(int index, Access a) volatile { setBitRange(2*index+1, 2*index, (uint32_t)a); }
};
// Application Interrupt and Reset Control Register
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihehdge.html
class AIRCR : public Register32 {
public:
void requestReset() volatile {
set(0x5FA<<16 |(1<<2));
}
};
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/Cihhjgdh.html
class SCR : public Register32 {
public:
REGS_BOOL_FIELD(SLEEPDEEP, 2);
};
class STCSR : public Register32 {
public:
enum class CLKSOURCE : uint8_t {
AHB_DIV8 = 0,
AHB = 1
};
REGS_BOOL_FIELD(COUNTFLAG, 16);
REGS_TYPE_FIELD(CLKSOURCE, 2, 2);
REGS_BOOL_FIELD(TICKINT, 1);
REGS_BOOL_FIELD(ENABLE, 0);
};
class STRVR : public Register32 {
public:
REGS_FIELD(RELOAD, uint32_t, 23, 0);
};
class STCVR : public Register32 {
public:
REGS_FIELD(CURRENT, uint32_t, 23, 0);
};
constexpr CM4() {};
REGS_REGISTER_AT(STCSR, 0x10);
REGS_REGISTER_AT(STRVR, 0x14);
REGS_REGISTER_AT(STCVR, 0x18);
REGS_REGISTER_AT(VTOR, 0xD08);
REGS_REGISTER_AT(AIRCR, 0xD0C);
REGS_REGISTER_AT(SCR, 0xD10);
REGS_REGISTER_AT(CPACR, 0xD88);
private:
constexpr uint32_t Base() const {
return 0xE000E000;
}
};
constexpr CM4 CM4;
#endif