22 #ifndef PLUGINS_SPI_SPIBACKEND_H_ 23 #define PLUGINS_SPI_SPIBACKEND_H_ 26 #include <ola/thread/Mutex.h> 27 #include <ola/thread/Thread.h> 31 #include "plugins/spi/SPIWriter.h" 44 virtual uint8_t *Checkout(uint8_t output,
unsigned int length) = 0;
45 virtual uint8_t *Checkout(uint8_t output,
47 unsigned int latch_bytes) = 0;
48 virtual void Commit(uint8_t output) = 0;
50 virtual std::string DevicePath()
const = 0;
52 virtual bool Init() = 0;
55 static const char SPI_DROP_VAR[];
56 static const char SPI_DROP_VAR_KEY[];
69 std::vector<uint16_t> gpio_pins;
79 uint8_t *Checkout(uint8_t output,
unsigned int length) {
80 return Checkout(output, length, 0);
83 uint8_t *Checkout(uint8_t output,
85 unsigned int latch_bytes);
86 void Commit(uint8_t output);
88 std::string DevicePath()
const {
return m_spi_writer->DevicePath(); }
98 m_write_pending(
false),
104 ~OutputData() {
delete[] m_data; }
106 uint8_t *Resize(
unsigned int length);
107 void SetLatchBytes(
unsigned int latch_bytes);
109 bool IsPending()
const {
return m_write_pending; }
110 void ResetPending() { m_write_pending =
false; }
111 const uint8_t *GetData()
const {
return m_data; }
112 unsigned int Size()
const {
return m_size; }
114 OutputData& operator=(
const OutputData &other);
118 bool m_write_pending;
120 unsigned int m_actual_size;
121 unsigned int m_latch_bytes;
123 OutputData(
const OutputData&);
126 typedef std::vector<int> GPIOFds;
127 typedef std::vector<OutputData*> Outputs;
131 const uint8_t m_output_count;
136 Outputs m_output_data;
140 const std::vector<uint16_t> m_gpio_pins;
141 std::vector<bool> m_gpio_pin_state;
143 void SetupOutputs(Outputs *outputs);
144 void WriteOutput(uint8_t output_id, OutputData *output);
169 Options() : outputs(1), sync_output(0) {}
179 uint8_t *Checkout(uint8_t output,
unsigned int length) {
180 return Checkout(output, length, 0);
183 uint8_t *Checkout(uint8_t output,
185 unsigned int latch_bytes);
186 void Commit(uint8_t output);
188 std::string DevicePath()
const {
return m_spi_writer->DevicePath(); }
198 bool m_write_pending;
201 const int16_t m_sync_output;
202 std::vector<unsigned int> m_output_sizes;
203 std::vector<unsigned int> m_latch_bytes;
205 unsigned int m_length;
218 uint8_t *Checkout(uint8_t output,
unsigned int length) {
219 return Checkout(output, length, 0);
222 uint8_t *Checkout(uint8_t output,
224 unsigned int latch_bytes);
226 void Commit(uint8_t output);
227 const uint8_t *GetData(uint8_t output,
unsigned int *length);
229 std::string DevicePath()
const {
return "/dev/test"; }
231 bool Init() {
return true; }
233 unsigned int Writes(uint8_t output)
const;
238 Output() : data(NULL), length(0), writes(0) {}
239 ~Output() {
delete[] data; }
246 typedef std::vector<Output*> Outputs;
252 #endif // PLUGINS_SPI_SPIBACKEND_H_ Definition: SPIBackend.h:63
A container for the exported variables.
Definition: ExportMap.h:324
Definition: SPIBackend.h:157
Definition: ExportMap.h:242
Definition: SPIWriter.h:36
Definition: SPIBackend.h:40
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: SPIBackend.h:213
Definition: SPIBackend.h:66
Definition: SPIBackend.h:154