13 #include <epicsTypes.h>
14 #include <epicsMutex.h>
26 virtual void select(
unsigned id) =0;
30 virtual epicsUInt8
cycle(epicsUInt8 in) =0;
38 virtual void cycles(
size_t nops,
39 const Operation *ops);
42 double timeout()
const;
43 void setTimeout(
double t);
46 mutable epicsMutex mutex;
51 class epicsShareClass SPIDevice
56 SPIDevice() :spi(0), id(0) {}
57 SPIDevice(SPIInterface *spi,
unsigned id) :spi(spi), id(id) {}
59 inline SPIInterface* interface()
const {
return spi; }
60 inline unsigned selector()
const {
return id; }
65 explicit Selector(SPIDevice& dev) :dev(dev)
66 { dev.spi->select(dev.id); }
68 { dev.spi->select(0u); }
71 static bool lookupDev(
const std::string& name, SPIDevice*);
72 static void registerDev(
const std::string& name,
const SPIDevice& );
73 static void unregisterDev(
const std::string& name);
76 class TimeoutCalculator
84 TimeoutCalculator(
double total,
double factor=2.0,
double initial=0.01)
85 :total(total), factor(factor), initial(initial), accumulated(0.0), next(0.0)
87 bool ok()
const {
return accumulated<total; }
97 double sofar()
const {
return accumulated; }
Interface for SPI Master.
Definition: spi.h:21
virtual epicsUInt8 cycle(epicsUInt8 in)=0