Open RTS
Full implementation of the Somfy RTS protocol
Loading...
Searching...
No Matches
RTSRadio.hpp
Go to the documentation of this file.
1#ifndef RTS_RADIO_HPP
2#define RTS_RADIO_HPP
3
4#include <openrts/rts_radio.h>
5
15class SPIModule : public spi_module
16{
17 public:
18 SPIModule()
19 {
20 clock = 1000000;
21 mode = 0;
22 }
23
24 virtual void begin() = 0;
25};
26
27#if defined(ARDUINO)
28class ArduinoSPI : public SPIModule
29{
30 public:
31 ArduinoSPI(SPIClass *spiClass=&SPI) :
32 spiClass(spiClass)
33 {
34 }
35
36 void begin()
37 {
38 spi_module_init_arduino(this, spiClass);
39 }
40
41 private:
42 SPIClass *spiClass;
43};
44
45ArduinoSPI DEFAULT_SPI_MODULE;
46#endif
47
48#if defined(__linux__)
49class LinuxSPI : public SPIModule
50{
51 public:
52 LinuxSPI(const char *spiDevice) :
53 spiDevice(spiDevice)
54 {
55 }
56
57 void begin()
58 {
59 spi_module_init_linux(this, spiDevice);
60 }
61
62 private:
63 const char *spiDevice;
64};
65#endif
66
70class RTSRadio : protected rts_radio
71{
72 public:
78 void setMode(enum rts_radio_mode mode)
79 {
80 rts_radio_set_mode(this, mode);
81 }
82
83 protected:
84 RTSRadio(SPIModule *spiModule) :
85 spiModule(spiModule)
86 {
87 }
88
89 RTSRadio(uint8_t chipSelect)
90 {
91 this->spiModule = &DEFAULT_SPI_MODULE;
92 this->spiModule->cs_pin = chipSelect;
93 }
94
95 void begin()
96 {
97 spiModule->begin();
98 }
99
100 SPIModule *spiModule;
101};
102
107#endif // RTS_RADIO_HPP
Abstraction layer which configures radio modules for RTS.
Definition RTSRadio.hpp:71
void setMode(enum rts_radio_mode mode)
Set the radio mode for this module, eg.
Definition RTSRadio.hpp:78
rts_radio_mode
The transceiver mode to enter.
Definition rts_radio.h:22
void rts_radio_set_mode(struct rts_radio *radio, enum rts_radio_mode mode)
Set the radio mode for the specified rts_radio module, eg.
Definition rts_radio.c:79
Abstraction layer which configures radio modules for RTS.
Definition rts_radio.h:31
Hardware abstraction layer for userland SPI drivers.
Definition spi_module.h:22
uint8_t mode
The SPI mode to use for transfers.
Definition spi_module.h:36
uint32_t clock
The SPI clock speed (in Hz) to use for transfers.
Definition spi_module.h:31