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

An object used to provide chip select control to a single user at a time. More...

#include <ChipAccess.hpp>

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

Public Member Functions

 ChipAccess ()
 Makes a ChipAccess object that has no access. More...
 
 ~ChipAccess ()
 Relinquishes access. More...
 
void changeChip (int chipId)
 Changes the chip in use while not giving up access to the chip selector. More...
 
void deselect ()
 Deselects the chip. More...
 
void retire ()
 Relinquish access. More...
 
void select ()
 Selects the chip. More...
 

Private Member Functions

 ChipAccess (const std::shared_ptr< ChipSelectManager > &m)
 Constructs a ChipAccess object for use with the given manager. More...
 

Private Attributes

std::shared_ptr< ChipSelectManagermanager
 The manager to which this object is attached. More...
 

Friends

std::unique_ptr< ChipAccessChipSelectManager::access (int)
 ChipSelectManager::access(int) calls the constructor. More...
 
void ChipSelectManager::access (ChipAccess &, int)
 ChipSelectManager::access(ChipAccess &, int) changes manager. More...
 

Detailed Description

An object used to provide chip select control to a single user at a time.

When the object is destroyed, chip select is made available for another user.

Author
Jeff Jackowski

Definition at line 22 of file ChipAccess.hpp.

Constructor & Destructor Documentation

◆ ChipAccess() [1/2]

duds::hardware::interface::ChipAccess::ChipAccess ( const std::shared_ptr< ChipSelectManager > &  m)
inlineprivate

Constructs a ChipAccess object for use with the given manager.

Parameters
mThe manager to access.

Definition at line 39 of file ChipAccess.hpp.

◆ ChipAccess() [2/2]

duds::hardware::interface::ChipAccess::ChipAccess ( )
inline

Makes a ChipAccess object that has no access.

Definition at line 44 of file ChipAccess.hpp.

◆ ~ChipAccess()

duds::hardware::interface::ChipAccess::~ChipAccess ( )
inline

Relinquishes access.

Definition at line 48 of file ChipAccess.hpp.

Member Function Documentation

◆ changeChip()

void duds::hardware::interface::ChipAccess::changeChip ( int  chipId)
inline

Changes the chip in use while not giving up access to the chip selector.

If the chip is the same as the one already in use, nothing happens. If it is different, the validity of the new ID is checked, and if good, deselect() is called to deselect the current chip, then the new ID is recorded.

Postcondition
The previous chip and new chip will be deselected.
Parameters
chipIdThe ID of the chip to use.
Exceptions
ChipSelectInvalidChipThe given chipId is invalid. The exception will include the ChipSelectId attribute with the requested chip ID. No changes will be made to the current chip selection state; ownership of access is not lost.
ChipSelectInvalidAccessThis is an invalid access object.

Definition at line 88 of file ChipAccess.hpp.

◆ deselect()

◆ retire()

void duds::hardware::interface::ChipAccess::retire ( )
inline

Relinquish access.

Definition at line 54 of file ChipAccess.hpp.

Referenced by duds::hardware::interface::DigitalPinMasterSyncSerial::close(), and ~ChipAccess().

◆ select()

Friends And Related Function Documentation

◆ ChipSelectManager::access [1/2]

std::unique_ptr<ChipAccess> ChipSelectManager::access ( int  )
friend

ChipSelectManager::access(int) calls the constructor.

◆ ChipSelectManager::access [2/2]

Member Data Documentation

◆ manager

std::shared_ptr<ChipSelectManager> duds::hardware::interface::ChipAccess::manager
private

The manager to which this object is attached.

Definition at line 34 of file ChipAccess.hpp.

Referenced by duds::hardware::interface::ChipSelectManager::access().


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