DUDS
Distributed Update of Data from Something
SpiMasterSyncSerial.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
12 #include <linux/spi/spidev.h>
13 
14 // /!@?!#?!#?
15 #undef linux
16 
17 namespace duds { namespace hardware { namespace interface { namespace linux {
18 
52  spi_ioc_transfer xfer;
56  int spifd;
57 protected:
58  virtual void open();
59  virtual void close();
60  virtual void start();
61  virtual void stop();
66  virtual void transfer(
67  const std::uint8_t * __restrict__ out,
68  std::uint8_t * __restrict__ in,
70  );
71 public:
84  const std::string &path,
86  int freq = 100000
87  );
114  void open(
115  const std::string &path,
117  int freq = 100000
118  );
127  void setClockFrequency(unsigned int freq);
136  void setClockPeriod(unsigned int nanos);
137 };
138 
139 } } } } // namespaces
140 
A synchronous serial implementation using the SPI userspace interface provided by the Linux kernel...
virtual void transfer(const std::uint8_t *__restrict__ out, std::uint8_t *__restrict__ in, duds::general::Bits bits)
Moves data about.
virtual void close()
Transitions the object from the open (MssOpen) to the ready (MssReady) state.
void setClockFrequency(unsigned int freq)
Changes the maximum clock frequency.
SpiMasterSyncSerial()
Creates the object without a SPI device to use.
static constexpr Flags MssSpiMode0
Flags for SPI mode 0.
spi_ioc_transfer xfer
Data for telling the kernel what to send and receive.
An abstraction for the master side of a simple synchronous serial communication connection to some de...
virtual void stop()
Denotes the end of a conversation; transitions from the communicating state to the open state...
A class to assist with specifiying the sizes of data with scaling units, much like std::chrono::durat...
Definition: DataSize.hpp:106
virtual void open()
Transitions the object from the ready (MssReady) to the open (MssOpen) state.
void setClockPeriod(unsigned int nanos)
Changes the minimum clock period.
virtual void start()
Denotes the start of a conversation; transitions from the open state to the communicating state...