Numworks Epsilon  1.4.1
Graphing Calculator Operating System
rcc.h
Go to the documentation of this file.
1 #ifndef REGS_RCC_H
2 #define REGS_RCC_H
3 
4 #include "register.h"
5 
6 class RCC {
7 public:
8  class CR : public Register32 {
9  public:
10  REGS_BOOL_FIELD(HSION, 0);
11  REGS_BOOL_FIELD(HSEON, 16);
12  REGS_BOOL_FIELD(HSERDY, 17);
13  REGS_BOOL_FIELD(PLLON, 24);
14  REGS_BOOL_FIELD(PLLRDY, 25);
15  };
16 
17  class PLLCFGR : public Register32 {
18  public:
19  REGS_FIELD(PLLM, uint8_t, 5, 0);
20  REGS_FIELD(PLLN, uint16_t, 14, 6);
21  REGS_FIELD(PLLP, uint8_t, 17, 16);
22  enum class PLLSRC {
23  HSI = 0,
24  HSE = 1
25  };
26  void setPLLSRC(PLLSRC s) volatile { setBitRange(22, 22, (uint8_t)s); }
27  REGS_FIELD(PLLQ, uint8_t, 27, 24);
28  REGS_FIELD(PLLR, uint8_t, 30, 28);
29  };
30 
31  class CFGR : public Register32 {
32  public:
33  enum class SW {
34  HSI = 0,
35  HSE = 1,
36  PLL = 2
37  };
38  void setSW(SW s) volatile { setBitRange(1, 0, (uint8_t)s); }
39  SW getSWS() volatile { return (SW)getBitRange(3,2); }
40  enum class AHBRatio {
41  One = 0,
42  DivideBy2 = 4,
43  DivideBy4 = 5,
44  DivideBy8 = 6,
45  DivideBy16 = 7
46  };
47  void setPPRE1(AHBRatio r) volatile { setBitRange(12, 10, (uint32_t)r); }
48  };
49 
50  class AHB1ENR : public Register32 {
51  public:
53  REGS_BOOL_FIELD(GPIOAEN, 0);
54  REGS_BOOL_FIELD(GPIOBEN, 1);
55  REGS_BOOL_FIELD(GPIOCEN, 2);
56  REGS_BOOL_FIELD(GPIODEN, 3);
57  REGS_BOOL_FIELD(GPIOEEN, 4);
58  REGS_BOOL_FIELD(GPIOFEN, 5);
59  REGS_BOOL_FIELD(GPIOGEN, 6);
60  REGS_BOOL_FIELD(GPIOHEN, 7);
61  REGS_BOOL_FIELD(CRCEN, 12);
62  REGS_BOOL_FIELD(DMA1EN, 21);
63  REGS_BOOL_FIELD(DMA2EN, 22);
64  };
65 
66  class AHB2ENR : Register32 {
67  public:
68  REGS_BOOL_FIELD(RNGEN, 6);
69  REGS_BOOL_FIELD(OTGFSEN, 7);
70  };
71 
72  class AHB3ENR : Register32 {
73  public:
74  REGS_BOOL_FIELD(FSMCEN, 0);
75  REGS_BOOL_FIELD(QSPIEN, 1);
76  };
77 
78  class APB1ENR : public Register32 {
79  public:
81  REGS_BOOL_FIELD(TIM3EN, 1);
82  REGS_BOOL_FIELD(SPI3EN, 15);
83  REGS_BOOL_FIELD(USART3EN, 18);
84  REGS_BOOL_FIELD(PWREN, 28);
85  };
86 
87  class APB2ENR : public Register32 {
88  public:
90  REGS_BOOL_FIELD(TIM1EN, 0);
91  REGS_BOOL_FIELD(USART1EN, 4);
92  REGS_BOOL_FIELD(ADC1EN, 8);
93  REGS_BOOL_FIELD(SDIOEN, 11);
94  REGS_BOOL_FIELD(SPI1EN, 12);
95  REGS_BOOL_FIELD(SYSCFGEN, 14);
96  };
97 
98  class DCKCFGR2 : Register32 {
99  public:
100  REGS_BOOL_FIELD(CK48MSEL, 27);
101  REGS_BOOL_FIELD(CKSDIOSEL, 28);
102  };
103 
104  constexpr RCC() {};
105  REGS_REGISTER_AT(CR, 0x00);
106  REGS_REGISTER_AT(PLLCFGR, 0x04);
107  REGS_REGISTER_AT(CFGR, 0x08);
108  REGS_REGISTER_AT(AHB1ENR, 0x30);
109  REGS_REGISTER_AT(AHB2ENR, 0x34);
110  REGS_REGISTER_AT(AHB3ENR, 0x38);
111  REGS_REGISTER_AT(APB1ENR, 0x40);
112  REGS_REGISTER_AT(APB2ENR, 0x44);
113  REGS_REGISTER_AT(DCKCFGR2, 0x94);
114 private:
115  constexpr uint32_t Base() const {
116  return 0x40023800;
117  }
118 };
119 
120 constexpr RCC RCC;
121 
122 #endif
Definition: rcc.h:31
REGS_FIELD(PLLM, uint8_t, 5, 0)
void setPLLSRC(PLLSRC s) volatile
Definition: rcc.h:26
REGS_BOOL_FIELD(FSMCEN, 0)
unsigned short uint16_t
Definition: stdint.h:5
unsigned char uint8_t
Definition: stdint.h:4
REGS_BOOL_FIELD(HSION, 0)
constexpr RCC RCC
Definition: rcc.h:120
Definition: rcc.h:6
constexpr RCC()
Definition: rcc.h:104
SW
Definition: rcc.h:33
unsigned int uint32_t
Definition: stdint.h:6
REGS_BOOL_FIELD(TIM3EN, 1)
REGS_BOOL_FIELD(RNGEN, 6)
Register< uint32_t > Register32
Definition: register.h:49
void setBitRange(uint8_t high, uint8_t low, T value) volatile
Definition: register.h:21
AHBRatio
Definition: rcc.h:40
REGS_BOOL_FIELD(GPIOAEN, 0)
Definition: rcc.h:8
REGS_BOOL_FIELD(TIM1EN, 0)
REGS_BOOL_FIELD(CK48MSEL, 27)
REGS_REGISTER_AT(CR, 0x00)
void setPPRE1(AHBRatio r) volatile
Definition: rcc.h:47
SW getSWS() volatile
Definition: rcc.h:39
void setSW(SW s) volatile
Definition: rcc.h:38
T getBitRange(uint8_t high, uint8_t low) volatile
Definition: register.h:24