DUDS
Distributed Update of Data from Something
duds::hardware::interface::MasterSyncSerial Class Referenceabstract

An abstraction for the master side of a simple synchronous serial communication connection to some device. More...

#include <MasterSyncSerial.hpp>

Inheritance diagram for duds::hardware::interface::MasterSyncSerial:
Collaboration diagram for duds::hardware::interface::MasterSyncSerial:

Public Types

typedef duds::general::BitFlags< struct MssFlags > Flags
 Configuration flags for various synchronous serial options. More...
 

Public Member Functions

 MasterSyncSerial ()
 Builds a MasterSyncSerial with an invalid clock period and all configuration flags clear. More...
 
 MasterSyncSerial (Flags flags, int period)
 Builds a MasterSyncSerial object. More...
 
virtual ~MasterSyncSerial ()=0
 Derived class destructors should assure that communication has stopped by calling forceClose(). More...
 
std::unique_ptr< MasterSyncSerialAccessaccess ()
 Obtain access for communication; transitions the object from the ready (MssReady) to the open (MssOpen) state. More...
 
void access (MasterSyncSerialAccess &acc)
 Obtain access for communication; transitions the object from the ready (MssReady) to the open (MssOpen) state. More...
 
std::unique_ptr< MasterSyncSerialAccessaccessStart ()
 Obtain access for communication; transitions the object from the ready (MssReady) to the communicating (MssCommunicating) state. More...
 
void accessStart (MasterSyncSerialAccess &acc)
 Obtain access for communication; transitions the object from the ready (MssReady) to the communicating (MssCommunicating) state. More...
 
unsigned int clockFrequency () const noexcept
 Computes and returns the maximum clock frequency in Hertz. More...
 
unsigned int clockPeriod () const noexcept
 Returns the minimum clock period in nanoseconds. More...
 
Flags configFlags () const noexcept
 Returns the current set of configuration flags. More...
 
virtual void converse (Conversation &conv)
 Has a half-duplex Conversation with the connected device. More...
 
bool inUse () const noexcept
 Returns true when this serial interface is in use by checking for the existence of an access object. More...
 
- Public Member Functions inherited from duds::hardware::interface::Conversationalist
virtual ~Conversationalist ()=0
 Allow proper destruction using a Conversationalist pointer. More...
 

Static Public Attributes

static constexpr Flags MssClockIdleHigh = Flags(2)
 Before communication begins, and after it ends, the clock line should have a high logic level. More...
 
static constexpr Flags MssCommunicating = Flags(128)
 Indicates that communication is underway. More...
 
static constexpr Flags MssConfigMask = Flags(31)
 All the flags that are used for configuration rather than the current state. More...
 
static constexpr Flags MssFirstDerivedClassFlag = Flags(256)
 The first flag that may be defined by a derived class. More...
 
static constexpr Flags MssFullDuplex = Flags(16)
 Communication is full duplex. More...
 
static constexpr Flags MssMSbFirst = Flags(8)
 Send data MSb first, little endian. More...
 
static constexpr Flags MssOpen = Flags(64)
 Indicates that all required resources for communication have been acquired. More...
 
static constexpr Flags MssOutFallInRise = Flags(4)
 Output on the falling edge of the clock and read on the rising edge. More...
 
static constexpr Flags MssReady = Flags(32)
 Indictates that all required resources for communication have been identified and passed a validity check. More...
 
static constexpr Flags MssSpiMode0
 Flags for SPI mode 0. More...
 
static constexpr Flags MssSpiMode0LSb = MssOutFallInRise | MssFullDuplex
 Flags for SPI mode 0 with the LSb transfered first. More...
 
static constexpr Flags MssSpiMode1 = MssMSbFirst | MssFullDuplex
 Flags for SPI mode 1. More...
 
static constexpr Flags MssSpiMode1LSb = MssFullDuplex
 Flags for SPI mode 1 with the LSb transfered first. More...
 
static constexpr Flags MssSpiMode2
 Flags for SPI mode 2. More...
 
static constexpr Flags MssSpiMode2LSb = MssClockIdleHigh | MssFullDuplex
 Flags for SPI mode 2 with the LSb transfered first. More...
 
static constexpr Flags MssSpiMode3
 Flags for SPI mode 3. More...
 
static constexpr Flags MssSpiMode3LSb
 Flags for SPI mode 3 with the LSb transfered first. More...
 
static constexpr Flags MssUseSelect = Flags(1)
 Use a select line to tell a device to pay attention to the master. More...
 

Protected Member Functions

void clockFrequency (unsigned int freq)
 Changes the maximum clock frequency. More...
 
void clockPeriod (unsigned int nanos)
 Changes the minimum clock period. More...
 
virtual void close ()=0
 Transitions the object from the open (MssOpen) to the ready (MssReady) state. More...
 
void condStart ()
 Calls start() if not currently communicating (clear MssCommunicating flag). More...
 
void condStop ()
 Calls stop() if currently communicating (set MssCommunicating flag). More...
 
void converseAlreadyOpen (Conversation &conv)
 Has a half-duplex Conversation with the connected device. More...
 
void forceClose ()
 Attempts to forcibly cease communications by calling condStop() and close(). More...
 
virtual void open ()=0
 Transitions the object from the ready (MssReady) to the open (MssOpen) state. More...
 
virtual void receive (std::uint8_t *buff, duds::general::Bits bits)
 Receives bits of data. More...
 
virtual void start ()=0
 Denotes the start of a conversation; transitions from the open state to the communicating state. More...
 
virtual void stop ()=0
 Denotes the end of a conversation; transitions from the communicating state to the open state. More...
 
virtual void transfer (const std::uint8_t *__restrict__ out, std::uint8_t *__restrict__ in, duds::general::Bits bits)=0
 Sends and/or receives bits of data. More...
 
virtual void transmit (const std::uint8_t *buff, duds::general::Bits bits)
 Sends bits of data. More...
 

Protected Attributes

Flags flags
 Configuration flags. More...
 
unsigned int minHalfPeriod
 The minimum time between changing the clock edge in nanoseconds. More...
 

Private Member Functions

void retire (MasterSyncSerialAccess *acc)
 Removes the access object from use. More...
 

Private Attributes

MasterSyncSerialAccessmssacc
 A pointer to the current access object or nullptr. More...
 

Friends

class MasterSyncSerialAccess
 The access object calls select(), deselect(), and retire(MasterSyncSerialAccess *). More...
 

Detailed Description

An abstraction for the master side of a simple synchronous serial communication connection to some device.

The abstraction is only for working with a single device; it is expected that multiple such objects will be used for each device on a bus. This abstraction is not intended for use with more complex protocols like I2C.

The abstraction and any similar kind of bus object should not be used for a device if the bus is unimportant to accessing said device. For instance, if an SPI device with Linux kernel support for the device is used, the kernel's device driver should, and likely must, be used to work with the device. However, if the kernel is unaware of the device and the program supplies its own driver, a MasterSyncSerial object can handle the low-level communication.

Single MasterSyncSerial objects do not allow for thread-safe use because they are intended to communicate with a single device and such communication typically does not work well or make sense to implement with multiple threads. However, multiple MasterSyncSerial objects can be thread-safe. Even if resources are shared between MasterSyncSerial objects, they must use those resources in a thread-safe manner. DigitalPinMasterSyncSerial, for instance, must obtain the DigitalPinSetAccess objects for all of its pins in its open() function.

State transitions
When a MasterSyncSerial object is constructed, it is not ready. The transition to the ready (MssReady) state is handled by derived classes in an implementation defined manner. The ready state is checked within this class to prevent misuse. Obtaining an access object (MasterSyncSerialAccess) causes a transition from the ready to the open (MssOpen) state. This is intended to allow the required resources to be locked by this object and be put into a non-communicating idle state. The destruction of the access object will cause a transition back to the ready state. The access object may be used to transition from the open to the communicating (MssCommunicating) state and back multiple times. This allows starting and stoping conversations with the other end, which may entail some kind of start/stop condition or selecting and deselecting a device. By keeping the open and communicating states separate, it is possible to guarantee that several conversations with the device will occur without an interruption for communicating with another device using some of the same resources.
Author
Jeff Jackowski.

Definition at line 95 of file MasterSyncSerial.hpp.

Member Typedef Documentation

◆ Flags

Configuration flags for various synchronous serial options.

Definition at line 116 of file MasterSyncSerial.hpp.

Constructor & Destructor Documentation

◆ MasterSyncSerial() [1/2]

duds::hardware::interface::MasterSyncSerial::MasterSyncSerial ( )
inline

Builds a MasterSyncSerial with an invalid clock period and all configuration flags clear.

Definition at line 385 of file MasterSyncSerial.hpp.

◆ MasterSyncSerial() [2/2]

duds::hardware::interface::MasterSyncSerial::MasterSyncSerial ( Flags  flags,
int  period 
)

Builds a MasterSyncSerial object.

Parameters
flagsThe initial set of configuration flags.
periodThe minimum clock period in nanoseconds.

Definition at line 36 of file MasterSyncSerial.cpp.

◆ ~MasterSyncSerial()

duds::hardware::interface::MasterSyncSerial::~MasterSyncSerial ( )
pure virtual

Derived class destructors should assure that communication has stopped by calling forceClose().

This may be done unconditionally. forceClose() will call virtual functions. Those functions must be called before the destructor of the class that implements them has finished running; this base class cannot make the call.

Definition at line 40 of file MasterSyncSerial.cpp.

Referenced by MasterSyncSerial().

Member Function Documentation

◆ access() [1/2]

std::unique_ptr< MasterSyncSerialAccess > duds::hardware::interface::MasterSyncSerial::access ( )

Obtain access for communication; transitions the object from the ready (MssReady) to the open (MssOpen) state.

Implementations handle the transition with their implementation of open(). If open() throws an exception, it will not be caught by this function and will prevent the state transition.

Precondition
The object is in the ready state.
Postcondition
The object is in the open state.
Returns
The access object for controlling communications.
Exceptions
SyncSerialNotReadyThe object is not in the ready state.
SyncSerialInUseThe object is already in the open state.

Definition at line 81 of file MasterSyncSerial.cpp.

Referenced by accessStart(), and clockPeriod().

◆ access() [2/2]

void duds::hardware::interface::MasterSyncSerial::access ( MasterSyncSerialAccess acc)

Obtain access for communication; transitions the object from the ready (MssReady) to the open (MssOpen) state.

Implementations handle the transition with their implementation of open(). If open() throws an exception, it will not be caught by this function and will prevent the state transition.

Precondition
The object is in the ready state.
Postcondition
The object is in the open state.
Parameters
accThe access object that will be used for controlling communications. It must not already be providing access.
Exceptions
SyncSerialNotReadyThe object is not in the ready state.
SyncSerialInUseThe object is already in the open state.
SyncSerialAccessInUseThe access object, acc, is providing access to a serial interface.

Definition at line 94 of file MasterSyncSerial.cpp.

◆ accessStart() [1/2]

std::unique_ptr< MasterSyncSerialAccess > duds::hardware::interface::MasterSyncSerial::accessStart ( )

Obtain access for communication; transitions the object from the ready (MssReady) to the communicating (MssCommunicating) state.

Implementations handle the transition with their implementation of open(). If open() throws an exception, it will not be caught by this function and will prevent the state transition.

Precondition
The object is in the ready state.
Postcondition
The object is in the communicating state.
Returns
The access object for controlling communications.
Exceptions
SyncSerialNotReadyThe object is not in the ready state.
SyncSerialInUseThe object is in the open or communicating state.

Definition at line 110 of file MasterSyncSerial.cpp.

Referenced by clockPeriod().

◆ accessStart() [2/2]

void duds::hardware::interface::MasterSyncSerial::accessStart ( MasterSyncSerialAccess acc)

Obtain access for communication; transitions the object from the ready (MssReady) to the communicating (MssCommunicating) state.

Implementations handle the transition with their implementation of open(). If open() throws an exception, it will not be caught by this function and will prevent the state transition.

Precondition
The object is in the ready state.
Postcondition
The object is in the communicating state.
Parameters
accThe access object that will be used for controlling communications. It must not already be providing access.
Exceptions
SyncSerialNotReadyThe object is not in the ready state.
SyncSerialInUseThe object is in the open or communicating state.
SyncSerialAccessInUseThe access object, acc, is providing access to a serial interface.

Definition at line 116 of file MasterSyncSerial.cpp.

◆ clockFrequency() [1/2]

void duds::hardware::interface::MasterSyncSerial::clockFrequency ( unsigned int  freq)
protected

Changes the maximum clock frequency.

This is an internal function to allow implementations control over the stored clock speed.

Precondition
No communication must current be active; selected must be false.
Postcondition
minHalfPeriod has half the period of the clock in nanoseconds.
Parameters
freqThe requested maximum clock frequency in hertz.

Definition at line 69 of file MasterSyncSerial.cpp.

◆ clockFrequency() [2/2]

unsigned int duds::hardware::interface::MasterSyncSerial::clockFrequency ( ) const
noexcept

◆ clockPeriod() [1/2]

void duds::hardware::interface::MasterSyncSerial::clockPeriod ( unsigned int  nanos)
protected

Changes the minimum clock period.

This is an internal function to allow implementations control over the clock speed.

Precondition
No communication must current be active; selected must be false.
Postcondition
minHalfPeriod has half the period of the clock in nanoseconds.
Parameters
nanosThe requested minimum clock period in nanoseconds.

Definition at line 73 of file MasterSyncSerial.cpp.

◆ clockPeriod() [2/2]

unsigned int duds::hardware::interface::MasterSyncSerial::clockPeriod ( ) const
inlinenoexcept

◆ close()

virtual void duds::hardware::interface::MasterSyncSerial::close ( )
protectedpure virtual

Transitions the object from the open (MssOpen) to the ready (MssReady) state.

This should relinquish access to any required shared resources.

Precondition
This function will only be called when in the open state.
Postcondition
The object will be ready, but the flag MssOpen is still set. The caller of this function will clear the flag.

Implemented in duds::hardware::interface::DigitalPinMasterSyncSerial, and duds::hardware::interface::linux::SpiMasterSyncSerial.

Referenced by converse(), forceClose(), and retire().

◆ condStart()

void duds::hardware::interface::MasterSyncSerial::condStart ( )
protected

Calls start() if not currently communicating (clear MssCommunicating flag).

Precondition
The object is in the ready state (MssReady).
Postcondition
The object is in the communicating state (MssCommunicating).
Exceptions
SyncSerialNotReadyThe object is not in the ready state (MssReady).
Bug:
Exception changed to SyncSerialNotOpen

Definition at line 121 of file MasterSyncSerial.cpp.

Referenced by accessStart(), and converseAlreadyOpen().

◆ condStop()

void duds::hardware::interface::MasterSyncSerial::condStop ( )
protected

Calls stop() if currently communicating (set MssCommunicating flag).

Postcondition
The object is not in the communicating state (MssCommunicating).
Exceptions
SyncSerialNotReadyThe object is not in the ready state (MssReady).
Bug:
Exception changed to SyncSerialNotOpen

Definition at line 136 of file MasterSyncSerial.cpp.

Referenced by converseAlreadyOpen(), forceClose(), and retire().

◆ configFlags()

Flags duds::hardware::interface::MasterSyncSerial::configFlags ( ) const
inlinenoexcept

Returns the current set of configuration flags.

Todo:
Change name to flags; change name of member flags.

Definition at line 404 of file MasterSyncSerial.hpp.

◆ converse()

void duds::hardware::interface::MasterSyncSerial::converse ( Conversation conv)
virtual

Has a half-duplex Conversation with the connected device.

An access object is not used to call this function, but one is acquired and released internally. The Conversation object defines all input and output parameters. On the ConversationPart objects, the MpfBreak flag is honored, but the MpfVarlen flag is ignored. The transmit() and receive() functions are called to move the data.

Precondition
The object is in the ready state, but not the open state. There must not be an access object to use this object.
Postcondition
The object is in the ready state and not the open state.
Parameters
convThe conversation to have with the device on the other end.
Exceptions
SyncSerialInUseThe object is already in the open state.
SyncSerialIoErrorAn error prevented the communication.

Implements duds::hardware::interface::Conversationalist.

Definition at line 185 of file MasterSyncSerial.cpp.

Referenced by clockPeriod().

◆ converseAlreadyOpen()

void duds::hardware::interface::MasterSyncSerial::converseAlreadyOpen ( Conversation conv)
protected

Has a half-duplex Conversation with the connected device.

The Conversation object defines all input and output parameters. On the ConversationPart objects, the MpfBreak flag is honored, but the MpfVarlen flag is ignored. The transmit() and receive() functions are called to move the data.

Precondition
The object is in the open state or the communicating state.
Postcondition
The object is in the open state, but not the communicating state.
Parameters
convThe conversation to have with the device on the other end.
Exceptions
SyncSerialIoErrorAn error prevented the communication.

Definition at line 162 of file MasterSyncSerial.cpp.

Referenced by converse().

◆ forceClose()

void duds::hardware::interface::MasterSyncSerial::forceClose ( )
protected

Attempts to forcibly cease communications by calling condStop() and close().

It is intended to be called in the destructor of derived classes. This base class cannot make the call in its destructor because the calls invoke virtual functions. The destructor may call this function unconditionally.

Definition at line 42 of file MasterSyncSerial.cpp.

Referenced by converse(), duds::hardware::interface::DigitalPinMasterSyncSerial::~DigitalPinMasterSyncSerial(), and duds::hardware::interface::linux::SpiMasterSyncSerial::~SpiMasterSyncSerial().

◆ inUse()

bool duds::hardware::interface::MasterSyncSerial::inUse ( ) const
inlinenoexcept

Returns true when this serial interface is in use by checking for the existence of an access object.

Definition at line 411 of file MasterSyncSerial.hpp.

◆ open()

virtual void duds::hardware::interface::MasterSyncSerial::open ( )
protectedpure virtual

Transitions the object from the ready (MssReady) to the open (MssOpen) state.

This should acquire access to any required shared resources.

Precondition
This function will only be called when in the ready state.
Postcondition
The object will be open, but the flag MssOpen is not set. The caller of this function will set the flag.
Exceptions
boost::exceptionBadness; state transision did not occur.

Implemented in duds::hardware::interface::DigitalPinMasterSyncSerial, and duds::hardware::interface::linux::SpiMasterSyncSerial.

Referenced by access(), and converse().

◆ receive()

void duds::hardware::interface::MasterSyncSerial::receive ( std::uint8_t *  buff,
duds::general::Bits  bits 
)
protectedvirtual

Receives bits of data.

If full duplex communication is used, transmitted data is undefined unless an implementation cares to have a definition. The implementation in this base class is:

transfer(nullptr, buff, bits);
Precondition
This object is in the communicating state from a prior call to condStart().
Parameters
buffThe buffer that will receive the data.
bitsThe number of bits to send. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 158 of file MasterSyncSerial.cpp.

Referenced by converseAlreadyOpen().

◆ retire()

void duds::hardware::interface::MasterSyncSerial::retire ( MasterSyncSerialAccess acc)
private

Removes the access object from use.

Exceptions
SyncSerialInvalidAccessacc is not the current access object.
Todo:
Maybe only throw in debug builds.

Definition at line 49 of file MasterSyncSerial.cpp.

◆ start()

virtual void duds::hardware::interface::MasterSyncSerial::start ( )
protectedpure virtual

Denotes the start of a conversation; transitions from the open state to the communicating state.

Precondition
This object is in the ready state (MssReady) and not in the communicating state (MssCommunicating). These conditions are checked by condStart().
Postcondition
Communication may commence. If the other end needs to be selected, the selection has occured. The MssCommunicating flag does not need to be set; that is handled by condStart().

Implemented in duds::hardware::interface::DigitalPinMasterSyncSerial, and duds::hardware::interface::linux::SpiMasterSyncSerial.

Referenced by condStart().

◆ stop()

virtual void duds::hardware::interface::MasterSyncSerial::stop ( )
protectedpure virtual

Denotes the end of a conversation; transitions from the communicating state to the open state.

Precondition
This object is in the communicating state (MssCommunicating) and not in the open state (MssOpen). These conditions are checked by condStop().
Postcondition
The chip is deselected if the MssUseSelect flag is set. The clock is in the idle state.

Implemented in duds::hardware::interface::DigitalPinMasterSyncSerial, and duds::hardware::interface::linux::SpiMasterSyncSerial.

Referenced by condStop().

◆ transfer()

virtual void duds::hardware::interface::MasterSyncSerial::transfer ( const std::uint8_t *__restrict__  out,
std::uint8_t *__restrict__  in,
duds::general::Bits  bits 
)
protectedpure virtual

Sends and/or receives bits of data.

If full duplex communication is not supported, one of the buffers should be given a nullptr pointer. The buffers must not overlap.

Precondition
This object is in the communicating state from a prior call to condStart().
Parameters
outThe data to transmit, or nullptr to not transmit.
inThe buffer that will receive data, or nullptr if nothing will be received.
bitsThe number of bits to transfer. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotFullDuplexNeither out and in are nullptr, and the serial interface is half-duplex.
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Implemented in duds::hardware::interface::linux::SpiMasterSyncSerial.

Referenced by receive(), and transmit().

◆ transmit()

void duds::hardware::interface::MasterSyncSerial::transmit ( const std::uint8_t *  buff,
duds::general::Bits  bits 
)
protectedvirtual

Sends bits of data.

If full duplex communication is used, received data is lost. The implementation in this base class is:

transfer(buff, nullptr, bits);
Precondition
This object is in the communicating state from a prior call to condStart().
Parameters
buffThe data to transmit.
bitsThe number of bits to send. Implementations may impose limitations on this value, like requiring a multiple of 8.
Exceptions
SyncSerialNotCommunicatingThis object is not in the communicating state.
SyncSerialUnsupportedAn operation unsupported by the implementation was attempted. This may happen if (bits % 8) is non-zero.
SyncSerialIoErrorAn error prevented the communication.

Definition at line 151 of file MasterSyncSerial.cpp.

Referenced by converseAlreadyOpen().

Friends And Related Function Documentation

◆ MasterSyncSerialAccess

friend class MasterSyncSerialAccess
friend

The access object calls select(), deselect(), and retire(MasterSyncSerialAccess *).

Definition at line 101 of file MasterSyncSerial.hpp.

Referenced by access().

Member Data Documentation

◆ flags

◆ minHalfPeriod

unsigned int duds::hardware::interface::MasterSyncSerial::minHalfPeriod
protected

The minimum time between changing the clock edge in nanoseconds.

This is a period instead of a frequency because software implementations need to sleep for half a period very often, whereas implementations that require a frequency are typically using hardware support and need the frequency just once.

Definition at line 218 of file MasterSyncSerial.hpp.

Referenced by clockFrequency(), clockPeriod(), duds::hardware::interface::linux::SpiMasterSyncSerial::setClockPeriod(), duds::hardware::interface::DigitalPinMasterSyncSerial::start(), duds::hardware::interface::DigitalPinMasterSyncSerial::stop(), and duds::hardware::interface::DigitalPinMasterSyncSerial::transfer().

◆ mssacc

MasterSyncSerialAccess* duds::hardware::interface::MasterSyncSerial::mssacc
private

A pointer to the current access object or nullptr.

Definition at line 105 of file MasterSyncSerial.hpp.

Referenced by access(), converse(), and retire().

◆ MssClockIdleHigh

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssClockIdleHigh = Flags(2)
static

Before communication begins, and after it ends, the clock line should have a high logic level.

Definition at line 125 of file MasterSyncSerial.hpp.

Referenced by duds::hardware::interface::linux::SpiMasterSyncSerial::open(), duds::hardware::interface::DigitalPinMasterSyncSerial::open(), and duds::hardware::interface::DigitalPinMasterSyncSerial::stop().

◆ MssCommunicating

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssCommunicating = Flags(128)
static

◆ MssConfigMask

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssConfigMask = Flags(31)
static

All the flags that are used for configuration rather than the current state.

Definition at line 142 of file MasterSyncSerial.hpp.

Referenced by configFlags(), and MasterSyncSerial().

◆ MssFirstDerivedClassFlag

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssFirstDerivedClassFlag = Flags(256)
static

The first flag that may be defined by a derived class.

Warning
The bit position may change.

Definition at line 165 of file MasterSyncSerial.hpp.

◆ MssFullDuplex

◆ MssMSbFirst

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssMSbFirst = Flags(8)
static

◆ MssOpen

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssOpen = Flags(64)
static

Indicates that all required resources for communication have been acquired.

These are initally put into a non-communicating state.

Definition at line 155 of file MasterSyncSerial.hpp.

Referenced by access(), condStart(), condStop(), converse(), forceClose(), duds::hardware::interface::linux::SpiMasterSyncSerial::open(), retire(), duds::hardware::interface::DigitalPinMasterSyncSerial::setChipSelect(), and duds::hardware::interface::DigitalPinMasterSyncSerial::setPins().

◆ MssOutFallInRise

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssOutFallInRise = Flags(4)
static

Output on the falling edge of the clock and read on the rising edge.

Definition at line 129 of file MasterSyncSerial.hpp.

Referenced by duds::hardware::interface::linux::SpiMasterSyncSerial::open(), and duds::hardware::interface::DigitalPinMasterSyncSerial::transfer().

◆ MssReady

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssReady = Flags(32)
static

Indictates that all required resources for communication have been identified and passed a validity check.

The MasterSyncSerial class clears this flag when constructed; after that, the flag is only changed by derived classes. Several functions in this base class use this flag to check for improper usage.

Definition at line 150 of file MasterSyncSerial.hpp.

Referenced by access(), converse(), duds::hardware::interface::linux::SpiMasterSyncSerial::open(), duds::hardware::interface::DigitalPinMasterSyncSerial::setChipSelect(), and duds::hardware::interface::DigitalPinMasterSyncSerial::setPins().

◆ MssSpiMode0

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode0
static
Initial value:

Flags for SPI mode 0.

This does not include MssUseSelect; this should be set if needed.

Definition at line 170 of file MasterSyncSerial.hpp.

◆ MssSpiMode0LSb

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode0LSb = MssOutFallInRise | MssFullDuplex
static

Flags for SPI mode 0 with the LSb transfered first.

This does not include MssUseSelect; this should be set if needed.

Definition at line 193 of file MasterSyncSerial.hpp.

◆ MssSpiMode1

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode1 = MssMSbFirst | MssFullDuplex
static

Flags for SPI mode 1.

This does not include MssUseSelect; this should be set if needed.

Definition at line 176 of file MasterSyncSerial.hpp.

◆ MssSpiMode1LSb

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode1LSb = MssFullDuplex
static

Flags for SPI mode 1 with the LSb transfered first.

This does not include MssUseSelect; this should be set if needed.

Definition at line 198 of file MasterSyncSerial.hpp.

◆ MssSpiMode2

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode2
static
Initial value:

Flags for SPI mode 2.

This does not include MssUseSelect; this should be set if needed.

Definition at line 181 of file MasterSyncSerial.hpp.

◆ MssSpiMode2LSb

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode2LSb = MssClockIdleHigh | MssFullDuplex
static

Flags for SPI mode 2 with the LSb transfered first.

This does not include MssUseSelect; this should be set if needed.

Definition at line 203 of file MasterSyncSerial.hpp.

◆ MssSpiMode3

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode3
static
Initial value:

Flags for SPI mode 3.

This does not include MssUseSelect; this should be set if needed.

Definition at line 187 of file MasterSyncSerial.hpp.

◆ MssSpiMode3LSb

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssSpiMode3LSb
static
Initial value:

Flags for SPI mode 3 with the LSb transfered first.

This does not include MssUseSelect; this should be set if needed.

Definition at line 208 of file MasterSyncSerial.hpp.

◆ MssUseSelect

constexpr MasterSyncSerial::Flags duds::hardware::interface::MasterSyncSerial::MssUseSelect = Flags(1)
static

Use a select line to tell a device to pay attention to the master.

Definition at line 120 of file MasterSyncSerial.hpp.

Referenced by duds::hardware::interface::DigitalPinMasterSyncSerial::setChipSelect(), and duds::hardware::interface::DigitalPinMasterSyncSerial::setPins().


The documentation for this class was generated from the following files: