10 #ifndef CHIPSELECTMANAGER_HPP 11 #define CHIPSELECTMANAGER_HPP 14 #include <condition_variable> 16 #include <boost/noncopyable.hpp> 18 namespace duds {
namespace hardware {
namespace interface {
43 public std::enable_shared_from_this<ChipSelectManager> {
117 void baseAccess(std::unique_lock<std::mutex> &lock,
int chipId);
150 virtual bool validChip(
int chipId)
const noexcept = 0;
168 std::unique_ptr<ChipAccess>
access(
int chipId);
208 std::unique_ptr<ChipAccess>
select(
int chipId);
234 #endif // #ifndef CHIPSELECTMANAGER_HPP void changeChip(int chipId)
Changes the chip in use while continuing to use an existing access object.
int waiting
A count of the threads waiting to access chips.
void retire(ChipAccess *ca)
Called by ChipAccess::~ChipAccess() to indicate that the access object is no longer in use...
ChipAccess * curacc
The currently in use access object, or nullptr.
virtual void deselect()=0
Deselects the chip identified by cid.
virtual void select()=0
Selects the chip identified by cid.
std::mutex block
Used to synchonize access.
An object used to provide chip select control to a single user at a time.
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...
int cid
Selected chip ID, or -1 to terminate.
std::unique_ptr< ChipAccess > access(int chipId)
Acquires access to the requested chip and issues a ChipAccess object.
bool inUse() const
Returns true if an access object provided by this manager exists.
std::condition_variable selwait
Used to awaken threads waiting on a chip select.
virtual bool validChip(int chipId) const noexcept=0
Returns true if chipId references a valid chip for this manager.
virtual ~ChipSelectManager()=0
Derived non-abstract classes must call shutdown() in thier destructor.
void shutdown()
Waits on a ChipAccess object if one is in use, then begins forcing any threads waiting on access to w...
The base class for all chip selection managers, the classes that handle the output state to select a ...