μHAL
spi.h
1#ifndef SPI_H
2#define SPI_H
3
4#include <memory>
5
6#include "controllers.h"
7#include "decoders.h"
8
9namespace spi {
10
11struct spi;
12
13struct Channel {
14 unsigned channel;
15 Channel(unsigned channel):
16 channel(channel)
17 {
18 if (channel > 8)
19 throw std::logic_error("bad spi slave index");
20 }
21};
22
23class Core: public RegisterDecoder {
24 std::unique_ptr<struct spi> regs_storage;
25 struct spi &regs;
26
27 void decode() override;
28
29 public:
30 Core(struct pcie_bars &);
31 ~Core() override;
32};
33
37 std::unique_ptr<struct spi> regs_storage;
38 struct spi &regs;
39
40 Core dec;
41
42 void set_devinfo_callback() override;
43 static int32_t get_divider(int32_t, int32_t);
44
45 public:
46 Controller(struct pcie_bars &);
48
49 void set_defaults();
50
51 bool write_read_data(const unsigned char *, size_t, unsigned char *, size_t, Channel = {0});
52};
53
54} /* namespace spi */
55
56#endif
Definition: controllers.h:35
Definition: decoders.h:97
Definition: spi.h:36
void set_devinfo_callback() override
Definition: spi.cc:100
Definition: spi.h:23
void decode() override
Definition: spi.cc:63
Definition: pcie-defs.h:19
Definition: spi.h:13
Definition: spi.cc:12