Numworks Epsilon  1.4.1
Graphing Calculator Operating System
spi.h
Go to the documentation of this file.
1 #ifndef REGS_SPI_H
2 #define REGS_SPI_H
3 
4 #include "register.h"
5 
6 class SPI {
7 public:
8  class CR1 : Register16 {
9  public:
10  REGS_BOOL_FIELD(MSTR, 2);
11  REGS_BOOL_FIELD(SPE, 6);
12  REGS_BOOL_FIELD(LSBFIRST, 7);
13  REGS_BOOL_FIELD(SSI, 8);
14  REGS_BOOL_FIELD(SSM, 9);
15  REGS_BOOL_FIELD(RXONLY, 10);
16  REGS_BOOL_FIELD(DFF, 11);
17  };
18  class CR2 : Register16 {
19  public:
20  REGS_BOOL_FIELD(RXDMAEN, 0);
21  };
22  class SR : Register16 {
23  public:
24  REGS_BOOL_FIELD(RXNE, 0);
25  REGS_BOOL_FIELD(TXE, 1);
26  };
27  class DR : public Register16 {
28  };
29 
30  constexpr SPI(int i) : m_index(i) {}
31  constexpr operator int() const { return m_index; }
32  REGS_REGISTER_AT(CR1, 0x00);
33  REGS_REGISTER_AT(CR2, 0x04);
34  REGS_REGISTER_AT(SR, 0x08);
35  REGS_REGISTER_AT(DR, 0x0C);
36 private:
37  constexpr uint32_t Base() const {
38  return ((uint32_t []){0x40013000, 0x40003800, 0x40003C00})[m_index-1];
39  };
40  int m_index;
41 };
42 
43 constexpr SPI SPI1(1);
44 
45 #endif
constexpr SPI(int i)
Definition: spi.h:30
Definition: spi.h:18
constexpr SPI SPI1(1)
REGS_BOOL_FIELD(RXNE, 0)
Definition: spi.h:8
REGS_BOOL_FIELD(MSTR, 2)
REGS_REGISTER_AT(CR1, 0x00)
unsigned int uint32_t
Definition: stdint.h:6
Definition: spi.h:6
REGS_BOOL_FIELD(RXDMAEN, 0)
Definition: spi.h:27
Definition: spi.h:22