|
DUDS
|
Distributed Update of Data from Something
|
Selects one of two chips using a single pin. More...
#include <ChipBinarySelectManager.hpp>
Public Member Functions | |
| ChipBinarySelectManager () | |
| Default constructor. More... | |
| ChipBinarySelectManager (std::unique_ptr< DigitalPinAccess > &&dpa, int initSel=0) | |
| Constructs a ChipBinarySelectManager with a pin for selection. More... | |
| ~ChipBinarySelectManager () | |
| Calls shutdown(). More... | |
| void | setSelectPin (std::unique_ptr< DigitalPinAccess > &&dpa, int initSel=0) |
| Sets the DigitalPinAccess object to use for the chip select line. More... | |
| virtual bool | validChip (int chipId) const noexcept |
| The only valid chip IDs for this manager are 0 and 1, and they are only valid once a DigitalPinAccess object has been provided. 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< ChipAccess > | access (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< ChipAccess > | select (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< DigitalPinAccess > | selpin |
| The access object for the select 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... | |
Selects one of two chips using a single pin.
This means one of the chips will always be selected. Not all chips will function properly using this scheme. At least some EEPROM's have no problem with it. The hardware implementation may require an inverter. Chip ID 0 is selected with a logic low, and ID 1 with a logic high.
Even though a chip is always selected, an access object should always be requested prior to using either chip. This will ensure the correct chip is selected by a multi-threaded program, and will work properly if the chip selection implementation is changed.
The pin used for chip selection must support output. This class allows any output type, but will select the first output type supported in this order:
Definition at line 39 of file ChipBinarySelectManager.hpp.
| duds::hardware::interface::ChipBinarySelectManager::ChipBinarySelectManager | ( | ) |
Default constructor.
Definition at line 73 of file ChipBinarySelectManager.cpp.
| duds::hardware::interface::ChipBinarySelectManager::ChipBinarySelectManager | ( | std::unique_ptr< DigitalPinAccess > && | dpa, |
| int | initSel = 0 |
||
| ) |
Constructs a ChipBinarySelectManager with a pin for selection.
| dpa | The access object for the select pin. |
| initSel | Non-zero to initially select ID 1 (logic high), or zero for ID 0 (logic low). |
| ChipSelectInUse | A ChipAccess object provided by this manager currently exists. |
| PinDoesNotExist | The DigitalPinAccess object does not provide access to any pin. |
| DigitalPinCannotOutputError | The pin cannot output. |
Definition at line 75 of file ChipBinarySelectManager.cpp.
| duds::hardware::interface::ChipBinarySelectManager::~ChipBinarySelectManager | ( | ) |
Calls shutdown().
Definition at line 81 of file ChipBinarySelectManager.cpp.
|
protectedvirtual |
Deselects the chip identified by cid.
If the chip is already deselected, it must remain deselected.
Implements duds::hardware::interface::ChipSelectManager.
Definition at line 23 of file ChipBinarySelectManager.cpp.
|
protectedvirtual |
Selects the chip identified by cid.
If the chip is already selected, it must remain selected.
Implements duds::hardware::interface::ChipSelectManager.
Definition at line 19 of file ChipBinarySelectManager.cpp.
| void duds::hardware::interface::ChipBinarySelectManager::setSelectPin | ( | std::unique_ptr< DigitalPinAccess > && | dpa, |
| int | initSel = 0 |
||
| ) |
Sets the DigitalPinAccess object to use for the chip select line.
| dpa | The access object for the select pin. |
| initSel | The initially selected chip ID. Must be 0 or 1. |
| ChipSelectInUse | A ChipAccess object provided by this manager currently exists. |
| PinDoesNotExist | The DigitalPinAccess object does not provide access to any pin. |
| DigitalPinCannotOutputError | The pin cannot output. |
Definition at line 27 of file ChipBinarySelectManager.cpp.
Referenced by ChipBinarySelectManager().
|
virtualnoexcept |
The only valid chip IDs for this manager are 0 and 1, and they are only valid once a DigitalPinAccess object has been provided.
Implements duds::hardware::interface::ChipSelectManager.
Definition at line 15 of file ChipBinarySelectManager.cpp.
|
private |
The access object for the select pin.
Definition at line 43 of file ChipBinarySelectManager.hpp.
Referenced by deselect(), select(), and setSelectPin().