|
DUDS
|
Distributed Update of Data from Something
|
Selects a single chip using a single pin. More...
#include <ChipPinSelectManager.hpp>
Public Types | |
| enum | SelectState { SelectLow, SelectHigh } |
| The list of possible pin states that can be used to select a chip. More... | |
Public Member Functions | |
| ChipPinSelectManager () | |
| Default constructor. More... | |
| ChipPinSelectManager (std::unique_ptr< DigitalPinAccess > &&dpa, SelectState selectState=SelectLow) | |
| Constructs a ChipPinSelectManager with a pin to use for selection. More... | |
| ~ChipPinSelectManager () | |
| Calls shutdown(). More... | |
| void | setSelectPin (std::unique_ptr< DigitalPinAccess > &&dpa, SelectState selectState=SelectLow) |
| Sets the DigitalPinAccess object to use for the chip select line. More... | |
| virtual bool | validChip (int chipId) const noexcept |
| The only valid chip ID for this manager is 1, and it is 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... | |
Protected Attributes | |
| SelectState | selstate |
| True when the chip is selected with a high logic level. More... | |
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... | |
Private Attributes | |
| std::unique_ptr< DigitalPinAccess > | selpin |
| The access object for the select pin. More... | |
Selects a single chip using a single pin.
This is the simplest chip select implementation. It uses a DigitalPinAccess object to operate a single select pin. By using a DigitalPinAccess object, the pin will be flagged as in-use by it's DigitalPort to prevent the select pin from being used for some other purpose.
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 31 of file ChipPinSelectManager.hpp.
The list of possible pin states that can be used to select a chip.
| Enumerator | |
|---|---|
| SelectLow | Indicates the chip is selected when the pin is driven low, or doesn't drive the line if the output type can only drive high. |
| SelectHigh | Indicates the chip is selected when the pin is driven high, or doesn't drive the line if the output type can only drive low. |
Definition at line 40 of file ChipPinSelectManager.hpp.
|
inline |
Default constructor.
Definition at line 65 of file ChipPinSelectManager.hpp.
| duds::hardware::interface::ChipPinSelectManager::~ChipPinSelectManager | ( | ) |
Calls shutdown().
Definition at line 69 of file ChipPinSelectManager.cpp.
Referenced by ChipPinSelectManager().
| duds::hardware::interface::ChipPinSelectManager::ChipPinSelectManager | ( | std::unique_ptr< DigitalPinAccess > && | dpa, |
| SelectState | selectState = SelectLow |
||
| ) |
Constructs a ChipPinSelectManager with a pin to use for selection.
| dpa | The access object for the select pin. |
| selectState | The pin state that selects the device. |
| ChipSelectInUse | A ChipAccess object provided by this manager currently exists. |
| PinUnsupportedOperation | The given pin does not support output. |
| PinDoesNotExist | The DigitalPinAccess object does not provide access to any pin. |
Definition at line 62 of file ChipPinSelectManager.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 ChipPinSelectManager.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 ChipPinSelectManager.cpp.
| void duds::hardware::interface::ChipPinSelectManager::setSelectPin | ( | std::unique_ptr< DigitalPinAccess > && | dpa, |
| SelectState | selectState = SelectLow |
||
| ) |
Sets the DigitalPinAccess object to use for the chip select line.
| dpa | The access object for the select pin. |
| selectState | The pin state that selects the device. |
| ChipSelectInUse | A ChipAccess object provided by this manager currently exists. |
| PinUnsupportedOperation | The given pin does not support output. |
| PinDoesNotExist | The DigitalPinAccess object does not provide access to any pin. |
Definition at line 27 of file ChipPinSelectManager.cpp.
Referenced by ChipPinSelectManager().
|
virtualnoexcept |
The only valid chip ID for this manager is 1, and it is only valid once a DigitalPinAccess object has been provided.
Implements duds::hardware::interface::ChipSelectManager.
Definition at line 15 of file ChipPinSelectManager.cpp.
Referenced by ChipPinSelectManager().
|
private |
The access object for the select pin.
Definition at line 35 of file ChipPinSelectManager.hpp.
Referenced by deselect(), select(), and setSelectPin().
|
protected |
True when the chip is selected with a high logic level.
Definition at line 60 of file ChipPinSelectManager.hpp.
Referenced by deselect(), select(), and setSelectPin().