Blame view

build6/epsilon-master/ion/src/device/regs/cm4.h 1.46 KB
6663b6c9   adorian   projet complet av...
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
  #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);
    };
  
    constexpr CM4() {};
    REGS_REGISTER_AT(VTOR, 0x08);
    REGS_REGISTER_AT(AIRCR, 0x0C);
    REGS_REGISTER_AT(SCR, 0x10);
    REGS_REGISTER_AT(CPACR, 0x88);
  private:
    constexpr uint32_t Base() const {
      return 0xE000ED00;
    }
  };
  
  constexpr CM4 CM4;
  
  #endif