|
DUDS
|
Distributed Update of Data from Something
|
Defines the configuration for a digital general purpose I/O pin. More...
#include <DigitalPinConfig.hpp>
Classes | |
| struct | ClearAll |
| Construction option for initializing all fields to defaul values. More... | |
Public Types | |
| typedef duds::general::BitFlags< struct DigitalPinConfigFlags, std::uint32_t > | Flags |
| A container of flags that control the operation of a digital pin. More... | |
Public Member Functions | |
| DigitalPinConfig ()=default | |
| Construct uninitialized. More... | |
| constexpr | DigitalPinConfig (const Flags opt, const std::uint16_t minOut=0, const std::uint16_t maxOut=0) |
| Construct with initial flags and current values. More... | |
| constexpr | DigitalPinConfig (const ClearAll) |
| Construct with all values initialized to zero. More... | |
| void | checkValidity () const |
| Checks for the use of obviously invalid data, such as the use of mutually exclusive options. More... | |
| void | combine (const DigitalPinConfig &newCfg) |
| Combines this configuration with a newer configuration taking into account requests to not change certain options. More... | |
| DigitalPinRejectedConfiguration::Reason | compatible (const DigitalPinCap &cap) const |
| Returns a set of flags that indicate certain incompatible conditions in the given pin configuration irrespective of any other pin. More... | |
| void | reverseCombine (const DigitalPinConfig &oldCfg) |
| Combines an old (initial) configuration with a new configuration in this object and stores the result in this object. More... | |
Static Public Member Functions | |
| static DigitalPinConfig | combine (const DigitalPinConfig &oldCfg, const DigitalPinConfig &newCfg) |
| Combines a configuration with a newer configuration taking into account requests to not change certain options, and produces a new configuration object. More... | |
Public Attributes | |
| std::uint16_t | maxOutputCurrent |
| The selected maximum output current in milliamps (?) for the pin, or zero for no change and immaterial. More... | |
| std::uint16_t | minOutputCurrent |
| The selected minimum output current in milliamps (?) for the pin, or zero for no change and immaterial. More... | |
| Flags | options |
| The control options requested for a digital pin. More... | |
Static Public Attributes | |
| static constexpr Flags | DirImmaterial = Flags::Bit(2) |
| Do not care about the pin's direction. More... | |
| static constexpr Flags | DirInput = Flags::Bit(0) |
| Configure the pin for input. More... | |
| static constexpr Flags | DirMask |
| A bit mask for all direction flags. More... | |
| static constexpr Flags | DirNoChange = Flags::Zero() |
| Do not change the pin's direction. More... | |
| static constexpr Flags | DirOutput = Flags::Bit(1) |
| Configure the pin for output. More... | |
| static constexpr Flags | EventEdge = EventEdgeFalling | EventEdgeRising |
| Configure the pin to flag an event on any edge. More... | |
| static constexpr Flags | EventEdgeFalling = Flags::Bit(8) |
| Configure the pin to flag an event on the falling edge. More... | |
| static constexpr Flags | EventEdgeRising = Flags::Bit(9) |
| Configure the pin to flag an event on the rising edge. More... | |
| static constexpr Flags | EventImmaterial = Flags::Bit(12) |
| Do not care about the pin's event configuration. More... | |
| static constexpr Flags | EventLevelHigh = Flags::Bit(11) |
| Configure the pin to flag an event on a high level input. More... | |
| static constexpr Flags | EventLevelLow = Flags::Bit(10) |
| Configure the pin to flag an event on a low level input. More... | |
| static constexpr Flags | EventMask |
| A bit mask for the event configuration flags. More... | |
| static constexpr Flags | EventNoChange = Flags::Zero() |
| Do not change the pin's event configuration. More... | |
| static constexpr Flags | EventNone = Flags::Bit(7) |
| Configure the pin to not flag an event when the input state changes. More... | |
| static constexpr Flags | InputNoPull = Flags::Bit(3) |
| Configure the pin to not use a pull-up or pull-down resistor. More... | |
| static constexpr Flags | InputPulldown = Flags::Bit(4) |
| Configure the pin to have a pull-down resistor. More... | |
| static constexpr Flags | InputPullImmaterial = Flags::Bit(6) |
| Do not care about the pin's use of a pull-up or pull-down resistor. More... | |
| static constexpr Flags | InputPullMask |
| A bit mask for the pull-up and pull-down resistor flags. More... | |
| static constexpr Flags | InputPullNoChange = Flags::Zero() |
| Do not change the use or non-use of a pull-up or pull-down resistor. More... | |
| static constexpr Flags | InputPullup = Flags::Bit(5) |
| Configure the pin to have a pull-up resistor. More... | |
| static constexpr Flags | InputState = Flags::Bit(20) |
| The last known input state from the pin. More... | |
| static constexpr Flags | InterruptImmaterial = Flags::Bit(15) |
| Do not care about the pin's interrupt configuration. More... | |
| static constexpr Flags | InterruptMask = InterruptNone | InterruptOnEvent |
| A bit mask for the interrupt configuration flags. More... | |
| static constexpr Flags | InterruptNoChange = Flags::Zero() |
| Do not change the pin's interrupt configuration. More... | |
| static constexpr Flags | InterruptNone = Flags::Bit(13) |
| Configure the pin to not trigger an interrupt. More... | |
| static constexpr Flags | InterruptOnEvent = Flags::Bit(14) |
| Configure the pin to trigger an interrupt when an event occurs. More... | |
| static constexpr Flags | OperationNoChange = Flags::Zero() |
| No change to any pin operation. More... | |
| static constexpr Flags | OutputDriveHigh = Flags::Bit(17) |
| Configure the pin to be able to drive the output high. More... | |
| static constexpr Flags | OutputDriveLow = Flags::Bit(16) |
| Configure the pin to be able to drive the output low. More... | |
| static constexpr Flags | OutputHighImpedance = Flags::Bit(18) |
| Configure the pin to have a high impedance or floating output. More... | |
| static constexpr Flags | OutputImmaterial = Flags::Bit(19) |
| Do not care about the pin's output configuration. More... | |
| static constexpr Flags | OutputMask |
| A bit mask for the output options. More... | |
| static constexpr Flags | OutputNoChange = Flags::Zero() |
| Do not change the pin's output configuration. More... | |
| static constexpr Flags | OutputPushPull = OutputDriveLow | OutputDriveHigh |
| Configure the pin to drive output both high and low. More... | |
| static constexpr Flags | OutputState = Flags::Bit(21) |
| The set output state for the pin. More... | |
Defines the configuration for a digital general purpose I/O pin.
Definition at line 22 of file DigitalPinConfig.hpp.
| typedef duds::general::BitFlags<struct DigitalPinConfigFlags, std::uint32_t> duds::hardware::interface::DigitalPinConfig::Flags |
A container of flags that control the operation of a digital pin.
The flags are intended to cover a wide range of hardware, so not all options may be available on specific hardware.
Definition at line 29 of file DigitalPinConfig.hpp.
|
default |
Construct uninitialized.
|
inline |
Construct with initial flags and current values.
| opt | The initial configuration flags. |
| minOut | The initial minimum output current. The default value 0 indicates that a minimum value is not set. |
| maxOut | The initial maximum output current. The default value 0 indicates that a maximum value is not set. |
Definition at line 259 of file DigitalPinConfig.hpp.
|
inline |
Construct with all values initialized to zero.
Definition at line 275 of file DigitalPinConfig.hpp.
| void duds::hardware::interface::DigitalPinConfig::checkValidity | ( | ) | const |
Checks for the use of obviously invalid data, such as the use of mutually exclusive options.
This is intended as a debugging check. Any invalid data found is a programming error, so the error is reported as an exception.
| DigitalPinConfigurationError | An exception indicating the first problem found. The actual object will be derived from this class. |
Definition at line 50 of file DigitalPinConfig.cpp.
Referenced by duds::hardware::interface::DigitalPinCap::compatible(), and DigitalPinConfig().
| void duds::hardware::interface::DigitalPinConfig::combine | ( | const DigitalPinConfig & | newCfg | ) |
Combines this configuration with a newer configuration taking into account requests to not change certain options.
If an immaterial flag is set in newCfg, the corresponding configuration flags will be taken from this object and the immaterial flag will be set.
| newCfg | The new configuration. Anything set to a value indicating no change will result in the current configuration (this object) being used for that option. |
Definition at line 95 of file DigitalPinConfig.cpp.
Referenced by combine(), DigitalPinConfig(), duds::hardware::interface::DigitalPort::modifyConfig(), and reverseCombine().
|
static |
Combines a configuration with a newer configuration taking into account requests to not change certain options, and produces a new configuration object.
If an immaterial flag is set in newCfg, the corresponding configuration flags will be taken from oldCfg and the immaterial flag will be set.
| oldCfg | The starting configuration. |
| newCfg | The new configuration. Anything set to a value indicating no change will result in the starting configuration, oldCfg, being used for that option. |
Definition at line 134 of file DigitalPinConfig.cpp.
| DigitalPinRejectedConfiguration::Reason duds::hardware::interface::DigitalPinConfig::compatible | ( | const DigitalPinCap & | cap | ) | const |
Returns a set of flags that indicate certain incompatible conditions in the given pin configuration irrespective of any other pin.
The only condition currently checked is whether or not the configuration is supported by the hardware.
| cap | The capabilities to check against. |
| DigitalPinConfigurationError | The configuration disagrees with itself from either having mutually exclusive flags set, or a minimum greater than a maximum. This is a programming mistake that has nothing to do with the pin capabilities. |
Definition at line 143 of file DigitalPinConfig.cpp.
Referenced by reverseCombine().
|
inline |
Combines an old (initial) configuration with a new configuration in this object and stores the result in this object.
Definition at line 324 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::DigitalPortIndependentPins::proposeConfigImpl(), and duds::hardware::interface::DigitalPortDependentPins::proposeConfigImpl().
|
static |
Do not care about the pin's direction.
This allows the direction to be changed if a request to alter the configuration of several pins must change this pin's direction to succeed with the given hardware. If the request can be honored without changing the pin's direction, then the direction will not change.
Definition at line 55 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and combine().
|
static |
Configure the pin for input.
The output flags, masked by OutputMask, must be clear to use input.
Definition at line 35 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), duds::hardware::interface::DigitalPinCap::compatible(), duds::hardware::interface::test::VirtualPort::configurePort(), duds::hardware::interface::linux::SysFsPort::configurePort(), duds::hardware::interface::linux::GpioDevPort::configurePort(), duds::hardware::interface::test::VirtualPort::initPin(), duds::hardware::interface::linux::GpioDevPort::initPin(), duds::hardware::interface::DigitalPort::input(), duds::hardware::interface::DigitalPinAccess::isInput(), duds::hardware::interface::DigitalPinSetAccess::isInput(), duds::hardware::interface::linux::GpioDevPort::madeAccess(), and duds::hardware::interface::linux::SysFsPort::FsPin::open().
|
static |
A bit mask for all direction flags.
Definition at line 63 of file DigitalPinConfig.hpp.
Referenced by combine(), duds::hardware::interface::test::VirtualPort::configurePort(), duds::hardware::interface::linux::GpioDevPort::configurePort(), and duds::hardware::interface::linux::GpioDevPort::madeAccess().
|
static |
Do not change the pin's direction.
Definition at line 59 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Configure the pin for output.
The input pull flags, masked by InputPullMask, must be clear to use output, save for InputNoPull. The InputNoPull flag is set for output, and included in this flag to simplify program logic.
The event settings are independent of the direction setting. However, this flag implies the EventNone flag unless another event flag is specified. This is for ease of use as it is the most common use-case.
Definition at line 47 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), duds::hardware::interface::DigitalPinCap::compatible(), duds::hardware::interface::test::VirtualPort::configurePort(), duds::hardware::interface::linux::SysFsPort::configurePort(), duds::hardware::interface::linux::GpioDevPort::configurePort(), duds::hardware::interface::DigitalPinCap::firstOutputDriveConfigFlags(), duds::hardware::interface::linux::GpioDevPort::initPin(), duds::hardware::interface::DigitalPinAccess::isOutput(), duds::hardware::interface::DigitalPinSetAccess::isOutput(), duds::hardware::interface::linux::GpioDevPort::madeAccess(), duds::hardware::interface::linux::SysFsPort::FsPin::open(), duds::hardware::interface::linux::GpioDevPort::outputImpl(), and duds::hardware::interface::ChipBinarySelectManager::setSelectPin().
|
static |
Configure the pin to flag an event on any edge.
Definition at line 112 of file DigitalPinConfig.hpp.
Referenced by checkValidity().
|
static |
Configure the pin to flag an event on the falling edge.
Definition at line 104 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::DigitalPinCap::compatible().
|
static |
Configure the pin to flag an event on the rising edge.
Definition at line 108 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::DigitalPinCap::compatible().
|
static |
Do not care about the pin's event configuration.
This allows the event configuration to be changed if a request to alter the configuration of several pins must change this pin's event configuration to succeed with the given hardware. If the request can be honored without making such a change, then the event configuration will not be changed.
Definition at line 129 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and combine().
|
static |
Configure the pin to flag an event on a high level input.
Definition at line 120 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
|
static |
Configure the pin to flag an event on a low level input.
Definition at line 116 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
|
static |
A bit mask for the event configuration flags.
Definition at line 137 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Do not change the pin's event configuration.
Definition at line 133 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Configure the pin to not flag an event when the input state changes.
Definition at line 100 of file DigitalPinConfig.hpp.
Referenced by checkValidity().
|
static |
Configure the pin to not use a pull-up or pull-down resistor.
Definition at line 69 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
|
static |
Configure the pin to have a pull-down resistor.
Definition at line 73 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
|
static |
Do not care about the pin's use of a pull-up or pull-down resistor.
This allows the pull-up or pull-down to be changed if a request to alter the configuration of several pins must change this pin's pull-up or pull-down resistor useage to succeed with the given hardware. If the request can be honored without making such a change, then it will not be changed.
Definition at line 86 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and combine().
|
static |
A bit mask for the pull-up and pull-down resistor flags.
Definition at line 94 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Do not change the use or non-use of a pull-up or pull-down resistor.
Definition at line 90 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Configure the pin to have a pull-up resistor.
Definition at line 77 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
|
static |
The last known input state from the pin.
This flag is updated on any single pin read operation for the pin. It is handled independently of the output state.
Definition at line 220 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::test::VirtualPort::inputImpl(), and duds::hardware::interface::linux::GpioDevPort::inputImpl().
|
static |
Do not care about the pin's interrupt configuration.
This allows the interrupt configuration to be changed if a request to alter the configuration of several pins must change this pin's interrupt configuration to succeed with the given hardware. If the request can be honored without making such a change, then the interrupt configuration will not be changed.
Definition at line 157 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and combine().
|
static |
A bit mask for the interrupt configuration flags.
Definition at line 165 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Do not change the pin's interrupt configuration.
Definition at line 161 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Configure the pin to not trigger an interrupt.
Definition at line 144 of file DigitalPinConfig.hpp.
Referenced by checkValidity().
|
static |
Configure the pin to trigger an interrupt when an event occurs.
Definition at line 148 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
| std::uint16_t duds::hardware::interface::DigitalPinConfig::maxOutputCurrent |
The selected maximum output current in milliamps (?) for the pin, or zero for no change and immaterial.
This will have no effect for inputs. If the pin capabilities ommits an output current limit, this value will not be used.
Definition at line 246 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), combine(), and duds::hardware::interface::operator<<().
| std::uint16_t duds::hardware::interface::DigitalPinConfig::minOutputCurrent |
The selected minimum output current in milliamps (?) for the pin, or zero for no change and immaterial.
This will have no effect for inputs. If the pin capabilities ommits an output current limit, this value will not be used.
Definition at line 238 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), combine(), duds::hardware::interface::DigitalPinCap::compatible(), and duds::hardware::interface::operator<<().
|
static |
No change to any pin operation.
Definition at line 213 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::DigitalPort::configuration(), duds::hardware::interface::DigitalPort::proposeConfig(), duds::hardware::interface::DigitalPortIndependentPins::proposeConfigImpl(), duds::hardware::interface::DigitalPortDependentPins::proposeConfigImpl(), duds::hardware::interface::DigitalPortIndependentPins::proposeFullConfigImpl(), and duds::hardware::interface::DigitalPortDependentPins::proposeFullConfigImpl().
| Flags duds::hardware::interface::DigitalPinConfig::options |
The control options requested for a digital pin.
Definition at line 231 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), combine(), duds::hardware::interface::DigitalPinCap::compatible(), duds::hardware::interface::test::VirtualPort::configurePort(), duds::hardware::interface::linux::GpioDevPort::madeAccess(), duds::hardware::interface::linux::SysFsPort::FsPin::open(), duds::hardware::interface::operator!=(), duds::hardware::interface::operator&(), duds::hardware::interface::operator<<(), duds::hardware::interface::operator==(), duds::hardware::interface::operator^(), duds::hardware::interface::operator|(), and duds::hardware::interface::linux::GpioDevPort::outputImpl().
|
static |
Configure the pin to be able to drive the output high.
If not configured to also drive the output low, then operation like an open emitter is requested, and may be emulated by configuring the pin as an input when the output state is changed to low. Emulation using input will only be done if no other pin can be affected.
Definition at line 182 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::DigitalPinCap::compatible(), duds::hardware::interface::DigitalPinCap::firstOutputDriveConfigFlags(), duds::hardware::interface::linux::GpioDevPort::initPin(), and duds::hardware::interface::ChipBinarySelectManager::setSelectPin().
|
static |
Configure the pin to be able to drive the output low.
If not configured to also drive the output high, then operation like an open collector or open drain output is requested, and may be emulated by configuring the pin as an input when the output state is changed to high. Emulation using input will only be done if no other pin can be affected.
Definition at line 174 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::DigitalPinCap::compatible(), duds::hardware::interface::DigitalPinCap::firstOutputDriveConfigFlags(), duds::hardware::interface::linux::GpioDevPort::initPin(), and duds::hardware::interface::ChipBinarySelectManager::setSelectPin().
|
static |
Configure the pin to have a high impedance or floating output.
Definition at line 190 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and duds::hardware::interface::DigitalPinCap::compatible().
|
static |
Do not care about the pin's output configuration.
This allows the output configuration to be changed if a request to alter the configuration of several pins must change this pin's output configuration to succeed with the given hardware. If the request can be honored without making such a change, then the output configuration will not be changed.
Definition at line 199 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), and combine().
|
static |
A bit mask for the output options.
Definition at line 207 of file DigitalPinConfig.hpp.
Referenced by combine().
|
static |
Do not change the pin's output configuration.
Definition at line 203 of file DigitalPinConfig.hpp.
Referenced by combine(), and duds::hardware::interface::DigitalPinCap::firstOutputDriveConfigFlags().
|
static |
Configure the pin to drive output both high and low.
Definition at line 186 of file DigitalPinConfig.hpp.
Referenced by checkValidity(), duds::hardware::interface::DigitalPinCap::compatible(), duds::hardware::interface::DigitalPinCap::firstOutputDriveConfigFlags(), duds::hardware::interface::linux::GpioDevPort::initPin(), duds::hardware::interface::linux::SysFsPort::FsPin::open(), and duds::hardware::interface::ChipBinarySelectManager::setSelectPin().
|
static |
The set output state for the pin.
This flag is updated on any single pin write operation for the pin. It is handled independently of the input state.
Definition at line 227 of file DigitalPinConfig.hpp.
Referenced by duds::hardware::interface::linux::GpioDevPort::configurePort(), duds::hardware::interface::linux::GpioDevPort::madeAccess(), duds::hardware::interface::test::VirtualPort::outputImpl(), and duds::hardware::interface::linux::GpioDevPort::outputImpl().