|
DUDS
|
Distributed Update of Data from Something
|
Provides access to multiple pins on a DigitalPort. More...
#include <DigitalPinSetAccess.hpp>
Public Member Functions | |
| DigitalPinSetAccess ()=default | |
| Constructs an access object with nothing to access. More... | |
| ~DigitalPinSetAccess () | |
| Relinquish access on destruction. More... | |
| bool | canBeInput (unsigned int pos) const |
| Returns true if the pin can operate as an input. More... | |
| bool | canBeOutput (unsigned int pos) const |
| Returns true if the pin can operate as an output. More... | |
| bool | canFloat (unsigned int pos) const |
| Returns true if the pin can provide a non-input high impedence state (or maybe allow input state?). More... | |
| DigitalPinCap | capabilities (unsigned int pos) const |
| Returns the capabilities of the specified pin. More... | |
| std::vector< DigitalPinCap > | capabilities () const |
| Returns the capabilities of all the pins in this set. More... | |
| DigitalPinConfig | configuration (unsigned int pos) const |
| Returns the current configuration of the specified pin. More... | |
| std::vector< DigitalPinConfig > | configuration () const |
| Returns the current configuration all pins in this set. More... | |
| 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 end. More... | |
| unsigned int | globalId (unsigned int pos) const |
| Returns the global pin ID of the pin at the given position inside this set of pins. More... | |
| std::vector< unsigned int > | globalIds () const |
| Returns a vector of global pin IDs for the pins accessed by this object. More... | |
| bool | havePins () const |
| Returns true if this object has been given any pins to access. More... | |
| bool | independentConfig () const |
| Returns true if all pins on the port always have an independent configuration from all other pins. More... | |
| bool | input (unsigned int pos) const |
| Samples the input state of a pin. More... | |
| std::vector< bool > | input () const |
| Samples the input state of all the pins. More... | |
| std::vector< bool > | input (const std::vector< unsigned int > &pos) const |
| Samples the input state of a subset of the pins. More... | |
| bool | isInput (unsigned int pos) const |
| Returns true if the pin is configured as an input. More... | |
| bool | isOutput (unsigned int pos) const |
| Returns true if the pin is configured as an output. More... | |
| unsigned int | localId (unsigned int pos) const |
| Returns the local pin ID of the pin at the given position inside this set of pins. More... | |
| const std::vector< unsigned int > & | localIds () const |
| Provides access to the internal vector of local pin IDs. More... | |
| DigitalPinConfig | modifyConfig (unsigned int pos, const DigitalPinConfig &conf) const |
| Modifies the configuration of a pin. More... | |
| void | modifyConfig (const DigitalPinConfig &conf) const |
| Sets the configuration for all the pins. More... | |
| void | modifyConfig (std::vector< DigitalPinConfig > &conf) const |
| Sets the configuration for all the pins. More... | |
| void | modifyConfig (const std::vector< unsigned int > &pos, std::vector< DigitalPinConfig > &conf) const |
| Sets the configuration for a subset of the pins. More... | |
| DigitalPinSetAccess & | operator= (DigitalPinSetAccess &&old) noexcept |
| A move assignment. More... | |
| void | output (unsigned int pos, bool state) const |
| Changes the output state of a pin. More... | |
| void | output (const std::vector< bool > &state) const |
| Changes the output state of all the pins. More... | |
| void | output (bool state) const |
| Changes the output state of all the pins. More... | |
| void | output (const std::vector< unsigned int > &pos, const std::vector< bool > &state) const |
| Changes the output state of a subset of the pins. More... | |
| DigitalPinRejectedConfiguration::Reason | proposeConfig (unsigned int pos, DigitalPinConfig &conf) const |
| Propose a new configuration for the given pin using the current configuration as the initial configuration. More... | |
| 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. More... | |
| 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. More... | |
| void | retire () noexcept |
| Relinquish access. More... | |
| void | retire (unsigned int pos) |
| Relinquish access to a single pin. More... | |
| bool | simultaneousOperations () const |
| True if the port supports operating on multiple pins simultaneously. More... | |
| unsigned int | size () const |
| Returns the number of pins in this access object. More... | |
| std::vector< unsigned int > | subset (const std::vector< unsigned int > &pos) const |
| Produces a vector with port local pin IDs that are a subset of the pins in this access object. More... | |
| template<typename Int > | |
| void | write (Int val, int bits) const |
| Writes out a number in binary to the pins. More... | |
| template<typename Int > | |
| void | write (Int val) const |
| Writes out a number in binary to the pins. More... | |
Public Member Functions inherited from duds::hardware::interface::DigitalPinAccessBase | |
| DigitalPort * | port () const |
| Returns a pointer to the port that controls the pin(s) that are operated through this object. More... | |
Private Member Functions | |
| DigitalPinSetAccess (DigitalPort *port, std::vector< unsigned int > &&pids) | |
| Used by DigitalPort. More... | |
| void | reserveAdditional (unsigned int len) |
| Reserves additional space in pins so that upcoming pushes onto the vector will not cause multiple memory reallocations. More... | |
Private Attributes | |
| friend | DigitalPort |
| std::vector< unsigned int > | pinvec |
| The port local pin IDs this object may use. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from duds::hardware::interface::DigitalPinAccessBase | |
| DigitalPinAccessBase () | |
| Cannot be constructed using this base class, but allows the construction of a useless access object without a DigitalPort. More... | |
| DigitalPinAccessBase (DigitalPort *port) | |
| Initializes the port pointer. More... | |
| ~DigitalPinAccessBase ()=default | |
| Cannot be destructed using this base class to avoid the need for a virtual destructor. More... | |
| DigitalPinAccessBase & | operator= (DigitalPinAccessBase &&old) noexcept |
| Allows moving access objects. More... | |
| void | reset () |
| Loses the pointer to the DigitalPort rendering the access object useless. More... | |
Protected Attributes inherited from duds::hardware::interface::DigitalPinAccessBase | |
| PortData | portdata |
| Port specific information. More... | |
Provides access to multiple pins on a DigitalPort.
This allows using multiple pins in a single operation.
Definition at line 31 of file DigitalPinSetAccess.hpp.
|
inlineprivate |
Used by DigitalPort.
Definition at line 39 of file DigitalPinSetAccess.hpp.
|
default |
Constructs an access object with nothing to access.
|
inline |
Relinquish access on destruction.
Definition at line 56 of file DigitalPinSetAccess.hpp.
|
inline |
Returns true if the pin can operate as an input.
| pos | The position of the pin in this set. |
Definition at line 419 of file DigitalPinSetAccess.hpp.
|
inline |
Returns true if the pin can operate as an output.
| pos | The position of the pin in this set. |
Definition at line 426 of file DigitalPinSetAccess.hpp.
|
inline |
Returns true if the pin can provide a non-input high impedence state (or maybe allow input state?).
| pos | The position of the pin in this set. |
Definition at line 438 of file DigitalPinSetAccess.hpp.
|
inline |
Returns the capabilities of the specified pin.
| pos | The position of the pin in this set. |
Definition at line 137 of file DigitalPinSetAccess.hpp.
|
inline |
Returns the capabilities of all the pins in this set.
Any gaps in the set (ID is -1) will have a value of DigitalPinCap::Nonexistent.
Definition at line 145 of file DigitalPinSetAccess.hpp.
Referenced by canBeInput(), canBeOutput(), and canFloat().
|
inline |
Returns the current configuration of the specified pin.
| pos | The position of the pin in this set. |
Definition at line 152 of file DigitalPinSetAccess.hpp.
|
inline |
Returns the current configuration all pins in this set.
Any gaps in the set (ID is -1) will have a configuration of DigitalPinConfig::OperationNoChange.
Definition at line 160 of file DigitalPinSetAccess.hpp.
Referenced by isInput(), and isOutput().
|
inline |
Returns true if the given position is for an existent pin rather than a gap or a position past the end.
| pos | The position to check. |
Definition at line 105 of file DigitalPinSetAccess.hpp.
|
inline |
Returns the global pin ID of the pin at the given position inside this set of pins.
| pos | The position of the pin in this set. |
Definition at line 129 of file DigitalPinSetAccess.hpp.
Referenced by capabilities(), configuration(), input(), modifyConfig(), output(), proposeConfig(), and subset().
|
inline |
Returns a vector of global pin IDs for the pins accessed by this object.
Definition at line 91 of file DigitalPinSetAccess.hpp.
|
inline |
Returns true if this object has been given any pins to access.
Definition at line 97 of file DigitalPinSetAccess.hpp.
Referenced by retire().
|
inline |
Returns true if all pins on the port always have an independent configuration from all other pins.
Definition at line 398 of file DigitalPinSetAccess.hpp.
|
inline |
Samples the input state of a pin.
| pos | The position of the pin in this set. |
| PinWrongDirection | This pin is not configured as an input. |
Definition at line 315 of file DigitalPinSetAccess.hpp.
|
inline |
Samples the input state of all the pins.
| PinWrongDirection | Not all the pins are not configured as an input. |
Definition at line 323 of file DigitalPinSetAccess.hpp.
|
inline |
Samples the input state of a subset of the pins.
| pos | A vector of the pins to sample specified by their position in this pin set. |
| PinWrongDirection | A pin in pos is not configured as an input. |
Definition at line 333 of file DigitalPinSetAccess.hpp.
|
inline |
Returns true if the pin is configured as an input.
| pos | The position of the pin in this set. |
Definition at line 405 of file DigitalPinSetAccess.hpp.
|
inline |
Returns true if the pin is configured as an output.
| pos | The position of the pin in this set. |
Definition at line 412 of file DigitalPinSetAccess.hpp.
|
inline |
Returns the local pin ID of the pin at the given position inside this set of pins.
| pos | The position of the pin in this set. |
Definition at line 120 of file DigitalPinSetAccess.hpp.
|
inline |
Provides access to the internal vector of local pin IDs.
Definition at line 84 of file DigitalPinSetAccess.hpp.
Referenced by duds::hardware::interface::linux::GpioDevPort::madeAccess().
|
inline |
Modifies the configuration of a pin.
If the port implementation is a derivative of DigitalPortDependentPins, the change may affect multiple pins, and the configuration of other pins may prevent the requested change.
| pos | The position of the pin in this set. |
| conf | The requested new configuration. |
Definition at line 265 of file DigitalPinSetAccess.hpp.
Referenced by duds::hardware::devices::displays::HD44780::preparePins(), and duds::hardware::devices::displays::ST7920::preparePins().
| void duds::hardware::interface::DigitalPinSetAccess::modifyConfig | ( | const DigitalPinConfig & | conf | ) | const |
Sets the configuration for all the pins.
| conf | The configuration to set for all pins. |
| DigitalPinConfigError |
Definition at line 61 of file DigitalPinSetAccess.cpp.
|
inline |
Sets the configuration for all the pins.
| conf | The new configuration. The vector makes a parallel data structure with the pins stroed in this object. If a gap exists (ID is -1), the configuration must be set to DigitalPinConfig::OperationNoChange. |
| DigitalPinConfigRangeError | The size of conf is not the same as size(). |
| DigitalPinConfigError |
Definition at line 289 of file DigitalPinSetAccess.hpp.
|
inline |
Sets the configuration for a subset of the pins.
| pos | A vector of the pins to use specified by their position in this pin set. |
| conf | The new configuration. The vector makes a parallel data structure with the specified subset of pins. If a gap exists (ID is -1), the configuration must be set to DigitalPinConfig::OperationNoChange. |
| DigitalPinConfigRangeError | The size of conf is not the same as the size of pos. |
| DigitalPinConfigError |
Definition at line 304 of file DigitalPinSetAccess.hpp.
|
noexcept |
A move assignment.
This requires a call to DigitalPort::updateAccess(), which needs to synchronize on its internal data. As a result, move assignments are not speedy. However, they assure pin access is transfered without being lost.
Definition at line 21 of file DigitalPinSetAccess.cpp.
Referenced by ~DigitalPinSetAccess().
|
inline |
Changes the output state of a pin.
If the pin is not currently configured to output, the configuration will not change, but the new output state will be used when the pin becomes an output in the future.
| pos | The position of the pin in this set. |
| state | The new output state. |
Definition at line 343 of file DigitalPinSetAccess.hpp.
Referenced by duds::hardware::devices::displays::HD44780::initialize(), duds::hardware::devices::displays::ST7920::initialize(), and output().
|
inline |
Changes the output state of all the pins.
If a pin is not currently configured to output, the configuration will not change, but the new output state will be used when the pin becomes an output in the future.
| state | The new output states. The vector makes a parallel data structure with the pins in this set (pinvec). Gaps (ID of -1) are not presently supported. |
Definition at line 354 of file DigitalPinSetAccess.hpp.
| void duds::hardware::interface::DigitalPinSetAccess::output | ( | bool | state | ) | const |
Changes the output state of all the pins.
If a pin is not currently configured to output, the configuration will not change, but the new output state will be used when the pin becomes an output in the future.
| state | The new output state for all pins. |
Definition at line 66 of file DigitalPinSetAccess.cpp.
|
inline |
Changes the output state of a subset of the pins.
If a pin is not currently configured to output, the configuration will not change, but the new output state will be used when the pin becomes an output in the future.
| pos | A vector of the pins to use specified by their position in this pin set. |
| state | The new output states. The vector makes a parallel data structure with the specified subset of pins. Gaps (ID of -1) are not presently supported. |
Definition at line 377 of file DigitalPinSetAccess.hpp.
|
inline |
Propose a new configuration for the given pin using the current configuration as the initial configuration.
The pin's configuration is not changed; this only checks for a valid supported change.
| conf | The proposed configuration. |
| pos | The position of the pin in this set. |
Definition at line 185 of file DigitalPinSetAccess.hpp.
|
inline |
Propose a new configuration for the given pin using a hypothetical given initial configuration.
The pin's configuration is not changed; this only checks for a valid supported change.
| proposed | The proposed configuration. |
| initial | The initial configuration. It should be a valid configuration for the pin and port, but it doesn't need to be the current configuration. |
| pos | The position of the pin in this set. |
Definition at line 204 of file DigitalPinSetAccess.hpp.
|
inline |
Propose a new configuration for the entire pin set using a hypothetical given initial configuration.
The configuration is not changed; this only checks for a valid supported change.
| propConf | The proposed configuration. |
| initConf | The initial configuration. It should be a valid configuration for the pins and port, but it doesn't need to be the current configuration. |
| insertReason | A function that, if specified, will be called for each pin, in the order specified by this set, with the rejection reason for that pin. The reason will be DigitalPinRejectedConfiguration::NotRejected if the pin's proposed configuration is good. The function is optional. |
Definition at line 228 of file DigitalPinSetAccess.hpp.
|
private |
Reserves additional space in pins so that upcoming pushes onto the vector will not cause multiple memory reallocations.
| len | The anticipated number of items about to be added. |
Definition at line 14 of file DigitalPinSetAccess.cpp.
Referenced by duds::hardware::interface::DigitalPort::access(), and DigitalPinSetAccess().
|
noexcept |
Relinquish access.
Definition at line 36 of file DigitalPinSetAccess.cpp.
Referenced by duds::hardware::interface::DigitalPinSet::access(), duds::hardware::interface::DigitalPinMasterSyncSerial::close(), operator=(), and ~DigitalPinSetAccess().
| void duds::hardware::interface::DigitalPinSetAccess::retire | ( | unsigned int | pos | ) |
Relinquish access to a single pin.
Good idea? Leave -1 in its spot, unless at end which can be removed.
| pos | The pin's position within the access object. |
|
inline |
True if the port supports operating on multiple pins simultaneously.
If false, the pins may be modified on over a period of time in an implementation defined order.
Definition at line 391 of file DigitalPinSetAccess.hpp.
|
inline |
Returns the number of pins in this access object.
The count includes pins set as -1; gaps in the pins to access.
Definition at line 112 of file DigitalPinSetAccess.hpp.
| std::vector< unsigned int > duds::hardware::interface::DigitalPinSetAccess::subset | ( | const std::vector< unsigned int > & | pos | ) | const |
Produces a vector with port local pin IDs that are a subset of the pins in this access object.
| pos | The pins to find specified by their position in this pin set. Values of -1 are copied into the result to maintain any gaps. |
| PinDoesNotExist | A specified position is outside the bounds of this set. |
Definition at line 44 of file DigitalPinSetAccess.cpp.
Referenced by configuration(), input(), modifyConfig(), and output().
|
inline |
Writes out a number in binary to the pins.
The LSb is given to the pin at position 0, the next bit to position 1, and so on. As with the other output functions, the pin configuration will not be changed.
| Int | The integer type used to hold the number. |
| val | The number to write. |
| bits | The number of bits to write. This may not exceed the number of pins in this set. If it exceeds the number of bits in Int, the more significant bits will be zero. |
| PinRangeError | The number of bits to write is less than 1 or greater than the number of pins in this set. |
| DigitalPinNumericRangeError | The given value is too large to fit in the requested number of bits. |
Definition at line 456 of file DigitalPinSetAccess.hpp.
Referenced by duds::hardware::devices::displays::HD44780::sendByte(), duds::hardware::devices::displays::ST7920::sendByte(), and write().
|
inline |
Writes out a number in binary to the pins.
The LSb is given to the pin at position 0, the next bit to position 1, and so on. All the pins in this set will be used. As with the other output functions, the pin configuration will not be changed.
| Int | The integer type used to hold the number. |
| val | The number to write. |
Definition at line 499 of file DigitalPinSetAccess.hpp.
|
private |
Definition at line 47 of file DigitalPinSetAccess.hpp.
|
private |
The port local pin IDs this object may use.
Definition at line 35 of file DigitalPinSetAccess.hpp.
Referenced by duds::hardware::interface::DigitalPort::access(), localIds(), modifyConfig(), operator=(), output(), reserveAdditional(), retire(), subset(), and duds::hardware::interface::DigitalPort::updateAccess().