10 #ifndef DIGITALPINSET_HPP 11 #define DIGITALPINSET_HPP 16 namespace duds {
namespace hardware {
namespace interface {
45 const std::shared_ptr<DigitalPort> &
port,
46 const std::vector<unsigned int> &pvec
63 const std::shared_ptr<DigitalPort> &
port,
64 std::vector<unsigned int> &&pvec
70 std::unique_ptr<DigitalPinSetAccess>
access()
const {
71 return port()->access(pinvec);
81 port()->access(pinvec, acc);
86 const std::vector<unsigned int> &
globalIds()
const {
94 return port()->localIds(pinvec);
100 return (
port() !=
nullptr) && !pinvec.empty();
108 return (pos < pinvec.size()) && (pinvec[pos] != -1);
115 return (
unsigned int)pinvec.size();
122 unsigned int localId(
unsigned int pos)
const {
124 return port()->localId(pinvec.at(pos));
133 return pinvec.at(pos);
140 return port()->capabilities(pinvec.at(pos));
148 return port()->capabilities(pinvec);
164 return port()->configuration(pinvec.at(pos));
181 return port()->configuration(pinvec);
197 return port()->proposeConfig(pinvec.at(pos), conf);
217 return port()->proposeConfig(pinvec.at(pos), proposed, initial);
237 std::vector<DigitalPinConfig> &propConf,
238 std::vector<DigitalPinConfig> &initConf,
242 return port()->proposeConfig(
258 return port()->simultaneousOperations();
265 return port()->independentConfig();
293 #endif // #ifndef DIGITALPINSET_HPP static constexpr Flags OutputDriveMask
A mask of all output flags that involve driving the line.
std::vector< unsigned int > localIds() const
Returns a vector of port-local pin IDs for the pins represented by this object.
unsigned int localId(unsigned int pos) const
Returns the local pin ID of the pin at the given position inside this set of pins.
static constexpr Flags Input
Input operation is supported.
Provides access to multiple pins on a DigitalPort.
std::vector< DigitalPinCap > capabilities() const
Returns the capabilities of all the pins in this set.
const std::vector< unsigned int > & globalIds() const
Provides access to the internal vector of global pin IDs.
Defines the configuration for a digital general purpose I/O pin.
DigitalPinRejectedConfiguration::Reason proposeConfig(unsigned int pos, DigitalPinConfig &proposed, DigitalPinConfig &initial) const
Propose a new configuration for the given pin using a hypothetical given initial configuration.
std::vector< DigitalPinConfig > configuration() const
Returns the current configuration all pins in this set.
std::vector< unsigned int > pinvec
The port global pin IDs this object will represent.
const std::shared_ptr< DigitalPort > & port() const
Returns the port that grants access to the pin(s) referenced by this object.
DigitalPinSet()=default
Constructs DigitalPinSet object with nothing to represent.
DigitalPinCap capabilities(unsigned int pos) const
Returns the capabilities of the specified pin.
void access(DigitalPinSetAccess &acc) const
Obtains an access object for all the pins in this set.
bool canBeInput(unsigned int pos) const
Returns true if the pin can operate as an input.
unsigned int size() const
Returns the number of pins in this object.
Represents a set of pins on a single DigitalPort.
bool exists(unsigned int pos) const
Returns true if the given position is for an existent pin rather than a gap or a position past the en...
std::unique_ptr< DigitalPinSetAccess > access() const
Obtains an access object for all the pins in this set.
bool havePins() const
Returns true if this object has been given any pins to represent.
bool independentConfig() const
Returns true if all pins on the port always have an independent configuration from all other pins...
bool canFloat(unsigned int pos) const
Returns true if the pin can provide a non-input high impedence state (or maybe allow input state...
bool simultaneousOperations() const
True if the port supports operating on multiple pins simultaneously.
A type-safe bit flag storage class.
static constexpr Flags OutputHighImpedance
The pin supports a high impedance state without input.
bool canBeOutput(unsigned int pos) const
Returns true if the pin can operate as an output.
Defines the capabilites of a digital general purpose I/O pin.
DigitalPinRejectedConfiguration::Reason proposeConfig(unsigned int pos, DigitalPinConfig &conf) const
Propose a new configuration for the given pin using the current configuration as the initial configur...
bool proposeConfig(std::vector< DigitalPinConfig > &propConf, std::vector< DigitalPinConfig > &initConf, std::function< void(DigitalPinRejectedConfiguration::Reason)> insertReason=std::function< void(DigitalPinRejectedConfiguration::Reason)>())
Propose a new configuration for the entire pin set using a hypothetical given initial configuration...
A base class for classes that represent one or more pins on a single DigitalPort, but do not provide ...
unsigned int globalId(unsigned int pos) const
Returns the global pin ID of the pin at the given position inside this set of pins.
DigitalPinConfig configuration(unsigned int pos) const
Returns the current configuration of the specified pin.
void retire() noexcept
Relinquish access.