Numworks Epsilon  1.4.1
Graphing Calculator Operating System
sdio.h
Go to the documentation of this file.
1 #ifndef REGS_SDIO_H
2 #define REGS_SDIO_H
3 
4 #include "register.h"
5 
6 class SDIO {
7 public:
8  class POWER : Register32 {
9  public:
10  enum class PWRCTRL : uint8_t {
11  Off = 0,
12  On = 3
13  };
14  REGS_TYPE_FIELD(PWRCTRL, 1, 0);
15  };
16 
17  class CLKCR : Register32 {
18  public:
19  enum class WIDBUS : uint8_t {
20  Default = 0,
21  FourBits = 1,
22  EightBits = 2
23  };
24  REGS_FIELD(CLKDIV, uint8_t, 7, 0);
25  REGS_BOOL_FIELD(CLKEN, 8);
26  REGS_BOOL_FIELD(PWRSAV, 9);
27  REGS_BOOL_FIELD(BYPASS, 10);
28  REGS_TYPE_FIELD(WIDBUS, 12, 11);
29  REGS_BOOL_FIELD(NEGEDGE, 13);
30  REGS_BOOL_FIELD(HWFC_EN, 14);
31  };
32 
33  class ARG : public Register32 {
34  };
35 
36  class CMD : public Register32 {
37  public:
39  enum class WAITRESP : uint8_t {
40  None = 0,
41  Short = 1,
42  Long = 3
43  };
44  REGS_FIELD(CMDINDEX, uint8_t, 5, 0);
46  REGS_BOOL_FIELD(WAITINT, 8);
47  REGS_BOOL_FIELD(WAITPEND, 9);
48  REGS_BOOL_FIELD(CPSMEN, 10);
49  };
50 
51  class RESP : public Register32 {
52  };
53 
54  class STA : Register32 {
55  public:
56  REGS_BOOL_FIELD_R(CCRCFAIL, 0);
57  REGS_BOOL_FIELD_R(DCRCFAIL, 1);
58  REGS_BOOL_FIELD_R(CTIMEOUT, 2);
59  REGS_BOOL_FIELD_R(DTIMEOUT, 3);
60  REGS_BOOL_FIELD_R(TXUNDERR, 4);
61  REGS_BOOL_FIELD_R(RXOVERR, 5);
62  REGS_BOOL_FIELD_R(CMDREND, 6);
63  REGS_BOOL_FIELD_R(CMDSENT, 7);
64  REGS_BOOL_FIELD_R(DATAEND, 8);
65  REGS_BOOL_FIELD_R(DBCKEND, 10);
66  REGS_BOOL_FIELD_R(CMDACT, 11);
67  REGS_BOOL_FIELD_R(TXACT, 12);
68  REGS_BOOL_FIELD_R(RXACT, 13);
69  REGS_BOOL_FIELD_R(TXFIFOHE, 14);
70  REGS_BOOL_FIELD_R(RXFIFOHF, 15);
71  REGS_BOOL_FIELD_R(TXFIFOF, 16);
72  REGS_BOOL_FIELD_R(RXFIFOF, 17);
73  REGS_BOOL_FIELD_R(TXFIFOE, 18);
74  REGS_BOOL_FIELD_R(RXFIFOE, 19);
75  REGS_BOOL_FIELD_R(TXDAVL, 20);
76  REGS_BOOL_FIELD_R(RXDAVL, 21);
77  REGS_BOOL_FIELD_R(SDIOIT, 22);
78  };
79 
80  class ICR : public Register32 {
81  public:
83  REGS_BOOL_FIELD_W(CCRCFAILC, 0);
84  REGS_BOOL_FIELD_W(DCRCFAILC, 1);
85  REGS_BOOL_FIELD_W(CTIMEOUTC, 2);
86  REGS_BOOL_FIELD_W(DTIMEOUTC, 3);
87  REGS_BOOL_FIELD_W(TXUNDERRC, 4);
88  REGS_BOOL_FIELD_W(RXOVERRC, 5);
89  REGS_BOOL_FIELD_W(CMDRENDC, 6);
90  REGS_BOOL_FIELD_W(CMDSENTC, 7);
91  REGS_BOOL_FIELD_W(DATAENDC, 8);
92  REGS_BOOL_FIELD_W(DBCKENDC, 10);
93  REGS_BOOL_FIELD_W(SDIOITC, 22);
94  };
95 
96  constexpr SDIO() {};
97  REGS_REGISTER_AT(POWER, 0x00);
98  REGS_REGISTER_AT(CLKCR, 0x04);
99  REGS_REGISTER_AT(ARG, 0x08);
100  REGS_REGISTER_AT(CMD, 0x0C);
101  volatile RESP * RESP(int i ) const { return (class RESP *)(Base() + 0x10+4*i); };
102  REGS_REGISTER_AT(STA, 0x34);
103  REGS_REGISTER_AT(ICR, 0x38);
104 private:
105  constexpr uint32_t Base() const {
106  return 0x40012C00;
107  }
108 };
109 
110 constexpr SDIO SDIO;
111 
112 #endif
Definition: sdio.h:33
REGS_BOOL_FIELD(WAITINT, 8)
Definition: sdio.h:6
Definition: sdio.h:36
unsigned char uint8_t
Definition: stdint.h:4
REGS_BOOL_FIELD_W(CCRCFAILC, 0)
REGS_FIELD(CLKDIV, uint8_t, 7, 0)
REGS_TYPE_FIELD(PWRCTRL, 1, 0)
constexpr SDIO SDIO
Definition: sdio.h:110
unsigned int uint32_t
Definition: stdint.h:6
REGS_BOOL_FIELD_R(CCRCFAIL, 0)
WAITRESP
Definition: sdio.h:39
Register< uint32_t > Register32
Definition: register.h:49
REGS_FIELD(CMDINDEX, uint8_t, 5, 0)
REGS_TYPE_FIELD(WAITRESP, 7, 6)
volatile RESP * RESP(int i) const
Definition: sdio.h:101
constexpr SDIO()
Definition: sdio.h:96
REGS_REGISTER_AT(POWER, 0x00)
REGS_TYPE_FIELD(WIDBUS, 12, 11)
Definition: sdio.h:80
REGS_BOOL_FIELD(CLKEN, 8)
Definition: sdio.h:54