DUDS
Distributed Update of Data from Something
duds::hardware::interface::ChipPinSetSelectManager Class Reference

Selects a single chip at a time using one pin from a set. More...

#include <ChipPinSetSelectManager.hpp>

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

Public Member Functions

 ChipPinSetSelectManager ()
 Default constructor. More...
 
 ChipPinSetSelectManager (std::unique_ptr< DigitalPinSetAccess > &&dpsa, std::uint32_t selectStates=0)
 Constructs a ChipPinSetSelectManager with a pin set to use for selection. More...
 
 ~ChipPinSetSelectManager ()
 Calls shutdown(). More...
 
void setSelectPins (std::unique_ptr< DigitalPinSetAccess > &&dpsa, std::uint32_t selectStates=0)
 Sets the DigitalPinSetAccess object to use for the chip select lines, and the selection states for each chip. More...
 
virtual bool validChip (int chipId) const noexcept
 Valid IDs are those with a pin in the DigitalPinSetAccess object given to this manager. More...
 
- Public Member Functions inherited from duds::hardware::interface::ChipSelectManager
 ChipSelectManager ()
 
virtual ~ChipSelectManager ()=0
 Derived non-abstract classes must call shutdown() in thier destructor. More...
 
std::unique_ptr< ChipAccessaccess (int chipId)
 Acquires access to the requested chip and issues a ChipAccess object. More...
 
void access (ChipAccess &acc, int chipId)
 Acquires access to the requested chip and modifies an existing ChipAccess object to provide that access. More...
 
bool inUse () const
 Returns true if an access object provided by this manager exists. More...
 
std::unique_ptr< ChipAccessselect (int chipId)
 Selects the requested chip and issues a ChipAccess object. More...
 
void select (ChipAccess &acc, int chipId)
 Selects the requested chip and modifies a ChipAccess object to further control chip selection. More...
 

Protected Member Functions

virtual void deselect ()
 Deselects the chip identified by cid. More...
 
virtual void select ()
 Selects the chip identified by cid. More...
 
- Protected Member Functions inherited from duds::hardware::interface::ChipSelectManager
void baseAccess (std::unique_lock< std::mutex > &lock, int chipId)
 Obtains the resources for providing an access object, but does not make an access object. More...
 
void changeChip (int chipId)
 Changes the chip in use while continuing to use an existing access object. More...
 
void shutdown ()
 Waits on a ChipAccess object if one is in use, then begins forcing any threads waiting on access to wake up and throw exceptions. More...
 

Private Attributes

std::unique_ptr< DigitalPinSetAccessselpins
 The access object for the select pin. More...
 
std::uint32_t selstates
 The select logic states for each pin. More...
 

Additional Inherited Members

- Protected Attributes inherited from duds::hardware::interface::ChipSelectManager
std::mutex block
 Used to synchonize access. More...
 
int cid
 Selected chip ID, or -1 to terminate. More...
 

Detailed Description

Selects a single chip at a time using one pin from a set.

It uses a DigitalPinSetAccess object to operate the select pins. By using a DigitalPinSetAccess object, the pins will be flagged as in-use by it's DigitalPort to prevent the pins from being used for some other purpose.

The pins used must support output. This class allows any output type, but will select the first output type supported in this order:

  1. Push-pull
  2. Drive low
  3. Drive high
Author
Jeff Jackowski

Definition at line 31 of file ChipPinSetSelectManager.hpp.

Constructor & Destructor Documentation

◆ ChipPinSetSelectManager() [1/2]

duds::hardware::interface::ChipPinSetSelectManager::ChipPinSetSelectManager ( )
inline

Default constructor.

Definition at line 47 of file ChipPinSetSelectManager.hpp.

◆ ~ChipPinSetSelectManager()

duds::hardware::interface::ChipPinSetSelectManager::~ChipPinSetSelectManager ( )

Calls shutdown().

Definition at line 83 of file ChipPinSetSelectManager.cpp.

Referenced by ChipPinSetSelectManager().

◆ ChipPinSetSelectManager() [2/2]

duds::hardware::interface::ChipPinSetSelectManager::ChipPinSetSelectManager ( std::unique_ptr< DigitalPinSetAccess > &&  dpsa,
std::uint32_t  selectStates = 0 
)

Constructs a ChipPinSetSelectManager with a pin set to use for selection.

Parameters
dpsaThe access object for the select pins. Up to 32 pins may be used.
selectStatesThe pin states that selects each device. The bit position corresponds to the index in dpsa. (1 << index)
Exceptions
ChipSelectInUseA ChipAccess object provided by this manager currently exists.
PinDoesNotExistThe DigitalPinAccess object does not provide access to any pin.
ChipSelectTooManyPinsMore than 32 pins are in the access object.
DigitalPinCannotOutputErrorAt least one pin cannot output.

Definition at line 76 of file ChipPinSetSelectManager.cpp.

Member Function Documentation

◆ deselect()

void duds::hardware::interface::ChipPinSetSelectManager::deselect ( )
protectedvirtual

Deselects the chip identified by cid.

If the chip is already deselected, it must remain deselected.

Note
There is no need for thread synchronization in this function.

Implements duds::hardware::interface::ChipSelectManager.

Definition at line 23 of file ChipPinSetSelectManager.cpp.

◆ select()

void duds::hardware::interface::ChipPinSetSelectManager::select ( )
protectedvirtual

Selects the chip identified by cid.

If the chip is already selected, it must remain selected.

Note
There is no need for thread synchronization in this function.

Implements duds::hardware::interface::ChipSelectManager.

Definition at line 19 of file ChipPinSetSelectManager.cpp.

◆ setSelectPins()

void duds::hardware::interface::ChipPinSetSelectManager::setSelectPins ( std::unique_ptr< DigitalPinSetAccess > &&  dpsa,
std::uint32_t  selectStates = 0 
)

Sets the DigitalPinSetAccess object to use for the chip select lines, and the selection states for each chip.

Parameters
dpsaThe access object for the select pins. Up to 32 pins may be used.
selectStatesThe pin states that selects each device. The bit position corresponds to the index in dpsa. (1 << index)
Exceptions
ChipSelectInUseA ChipAccess object provided by this manager currently exists.
PinDoesNotExistThe DigitalPinAccess object does not provide access to any pin.
ChipSelectTooManyPinsMore than 32 pins are in the access object.
DigitalPinCannotOutputErrorAt least one pin cannot output.

Definition at line 27 of file ChipPinSetSelectManager.cpp.

Referenced by ChipPinSetSelectManager().

◆ validChip()

bool duds::hardware::interface::ChipPinSetSelectManager::validChip ( int  chipId) const
virtualnoexcept

Valid IDs are those with a pin in the DigitalPinSetAccess object given to this manager.

Implements duds::hardware::interface::ChipSelectManager.

Definition at line 15 of file ChipPinSetSelectManager.cpp.

Referenced by ChipPinSetSelectManager().

Member Data Documentation

◆ selpins

std::unique_ptr<DigitalPinSetAccess> duds::hardware::interface::ChipPinSetSelectManager::selpins
private

The access object for the select pin.

Definition at line 35 of file ChipPinSetSelectManager.hpp.

Referenced by deselect(), select(), and setSelectPins().

◆ selstates

std::uint32_t duds::hardware::interface::ChipPinSetSelectManager::selstates
private

The select logic states for each pin.

Definition at line 39 of file ChipPinSetSelectManager.hpp.

Referenced by deselect(), select(), and setSelectPins().


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