69 std::vector<uint16_t> gpio_pins;
72 HardwareBackend(
const Options &options,
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;
129 SPIWriterInterface *m_spi_writer;
131 const uint8_t m_output_count;
132 ola::thread::Mutex m_mutex;
133 ola::thread::ConditionVariable m_cond_var;
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) {}
172 SoftwareBackend(
const Options &options,
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(); }
194 SPIWriterInterface *m_spi_writer;
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;
215 explicit FakeSPIBackend(
unsigned int outputs);
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;