10 #include <boost/property_tree/ptree_fwd.hpp> 11 #include <boost/multi_index_container.hpp> 12 #include <boost/multi_index/ordered_index.hpp> 13 #include <boost/multi_index/sequenced_index.hpp> 14 #include <boost/multi_index/hashed_index.hpp> 15 #include <boost/multi_index/member.hpp> 19 #include <unordered_map> 22 namespace duds {
namespace hardware {
namespace interface {
24 class ChipSelectManager;
115 typedef boost::error_info<struct Info_PortName, std::string>
120 typedef boost::error_info<struct Info_PortId, std::string>
125 typedef boost::error_info<struct Info_PortPinId, unsigned int>
130 typedef boost::error_info<struct Info_SelectManagerName, std::string>
135 typedef boost::error_info<struct Info_SelectName, std::string>
140 typedef boost::error_info<struct Info_SelectBadState, std::string>
145 typedef boost::error_info<struct Info_SelectBadType, std::string>
150 typedef boost::error_info<struct Info_SetName, std::string>
213 static constexpr
unsigned int NoPin = -1;
218 static constexpr
unsigned int NoIdSpecified = -2;
224 const std::pair<const std::string, boost::property_tree::ptree> &item,
234 const std::pair<const std::string, boost::property_tree::ptree> &item,
266 typedef boost::multi_index::multi_index_container<
268 boost::multi_index::indexed_by<
269 boost::multi_index::ordered_non_unique<
270 boost::multi_index::tag<index_gid>,
271 boost::multi_index::member<Pin, unsigned int, &Pin::gid>
273 boost::multi_index::ordered_non_unique<
274 boost::multi_index::tag<index_pid>,
275 boost::multi_index::member<Pin, unsigned int, &Pin::pid>
277 boost::multi_index::hashed_non_unique<
278 boost::multi_index::tag<index_name>,
279 boost::multi_index::member<Pin, std::string, &Pin::name>
281 boost::multi_index::sequenced<
282 boost::multi_index::tag<index_seq>
317 const std::pair<const std::string, boost::property_tree::ptree> &item
323 const PinConfiguration::Pins::index<index_gid>::type &
gidIndex()
const {
330 const PinConfiguration::Pins::index<index_pid>::type &
pidIndex()
const {
337 const PinConfiguration::Pins::index<index_seq>::type &
seqIndex()
const {
341 typedef std::unordered_map<std::string, Port>
PortMap;
350 std::shared_ptr<ChipSelectManager>
csm;
355 std::vector<unsigned int>
pins;
360 std::unordered_map<std::string, unsigned int>
selNames;
407 const std::pair<const std::string, boost::property_tree::ptree> &item,
411 typedef std::unordered_map<std::string, SelMgr>
SelMgrMap;
459 const std::pair<const std::string, boost::property_tree::ptree> &item,
466 const PinConfiguration::Pins::index<index_seq>::type &
seqIndex()
const {
469 PinConfiguration::Pins::index<index_seq>::type::iterator
begin() {
472 PinConfiguration::Pins::index<index_seq>::type::iterator
end() {
476 typedef std::unordered_map<std::string, PinSet>
PinSetMap;
553 void parse(
const boost::property_tree::ptree &pt);
571 const std::shared_ptr<DigitalPort> &dp,
572 const std::string &name =
"default" 582 const Pin &pin(
const std::string &str)
const;
601 const Port &port(
const std::string &name =
"default")
const;
611 const PinSet &pinSet(
const std::string &name)
const;
621 const ChipSel &chipSelect(
const std::string &name)
const;
632 const SelMgr &selectManager(
const std::string &name)
const;
659 void getPinSetAndSelect(
662 const std::string &setName
676 const DigitalPinSet &getPinSet(
const std::string &setName)
const;
690 const ChipSelect &getSelect(
const std::string &selName)
const;
704 DigitalPin getPin(
const std::string &pinName)
const;
715 bool getPin(
DigitalPin &dest,
const std::string &pinName)
const;
722 bool havePin(
const std::string &pinName)
const;
730 return chipSels.count(name) > 0;
736 return ports.cbegin();
748 return selMgrs.cbegin();
754 return selMgrs.cend();
760 return chipSels.cbegin();
766 return chipSels.cend();
772 return pinSets.cbegin();
778 return pinSets.cend();
PinConfiguration::Pins::index< index_seq >::type::iterator end()
PortMap::const_iterator portsEnd() const
Ending iterator to inspect the ports in the configuration.
Pins pins
The pins used by this set.
boost::error_info< struct Info_PortId, std::string > PinBadId
A pin name or number from the configuration that could not be used.
const PinConfiguration::Pins::index< index_gid >::type & gidIndex() const
Convenience function that provides the pin global ID index for the port's pins.
std::unordered_map< std::string, SelMgr > SelMgrMap
PortMap ports
Port configurations stored by name.
Holds configuration data for a single chip select manager.
Not yet set or a bad value.
std::unordered_map< std::string, ChipSel > ChipSelMap
Represents a single pin on a DigitalPort.
boost::error_info< struct Info_PortPinId, unsigned int > PortPinId
The global ID of a pin from a configuration that is involved in the error.
A pin set was defined with pins from more than one port.
A required chip select manager has not yet been created most likely because the port providing its pi...
const PinConfiguration::Pins::index< index_seq >::type & seqIndex() const
Convenience function that provides the sequential index for the sets's pins.
std::uint32_t selStates
Selection state bitmap for pin set manager.
unsigned int idOffset
The pin ID offset for the port; used to translate between global and port pin IDs.
A selection logic state in the configuration could not be parsed.
ChipSelect sel
The chip select object for this configuration.
PinSetMap pinSets
Pin set configurations stored by name.
unsigned int gid
Assigned global ID.
int chipId
The chip ID that is selected by this chip select.
Port * usePort
The port that will provide the pins for this select manager.
SelMgrMap::const_iterator selectManagersEnd() const
Ending iterator to inspect the select managers in the configuration.
Holds configuration data for a single digital port.
boost::error_info< struct Info_SetName, std::string > SetName
The name of a pin set from a configuration.
A required pin set has not yet been created most likely because the port providing its pins has not y...
const PinConfiguration::Pins::index< index_seq >::type & seqIndex() const
Convenience function that provides the sequential index for the port's pins.
Base for all errors directly thrown by PinConfiguration.
bool haveChipSelect(const std::string &name) const
True if the named chip select has been found in the already parsed configuration. ...
ChipSelMap::const_iterator selectsBegin() const
Begining iterator to inspect the chip selects in the configuration.
Use ChipMultiplexerSelectManager.
A given pin ID cannot be used with the port, such as an ID that is less than the port's ID offset...
std::shared_ptr< DigitalPort > dport
The attached DigitalPort.
Port * usePort
The port that will provide the pins for this set.
SelMgrMap selMgrs
Select manager configurations stored by name.
std::unordered_map< std::string, PinSet > PinSetMap
Pins pins
The pins described by the configuration file.
MgrType type
The type of chip select manager requested.
PinConfiguration::Pins::index< index_seq >::type::iterator begin()
boost::multi_index::multi_index_container< Pin, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::tag< index_gid >, boost::multi_index::member< Pin, unsigned int, &Pin::gid > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< index_pid >, boost::multi_index::member< Pin, unsigned int, &Pin::pid > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< index_name >, boost::multi_index::member< Pin, std::string, &Pin::name > >, boost::multi_index::sequenced< boost::multi_index::tag< index_seq > > > > Pins
Holds the configuration data for digital pins indexed by global ID, port ID, arbitrary name...
Index in type Pins that is maintained by parsing order.
MgrType
The type of chip select manager requested.
The configuration gives the same name to more than one chip select.
boost::error_info< struct Info_SelectBadState, std::string > SelectBadState
The string with a select logic state that could not be parsed.
std::string typeval
A hint as to what DigitalPort implementation should be used.
The configuration gives the same name to more than one chip select manager.
An object to wrap together a ChipSelectManager and chip ID to simplify code that needs to repeatedly ...
boost::error_info< struct Info_PortName, std::string > PortName
The name of the port as it appears in the configuration.
bool initSelHigh
True for high selection state with binary manager, or for initially selected state with pin manager...
Index in type Pins that is sorted by the optional pin name.
A chip selection manager was defined with pins from more than one port.
Port * parent
The Port object that supplies the pin.
ChipSelMap chipSels
Chip select configurations stored by name.
Represents a set of pins on a single DigitalPort.
PinSetMap::const_iterator pinSetsBegin() const
Begining iterator to inspect the pin sets in the configuration.
The configuration gives the same name to more than one port.
A select manager was given an unknown type, or no type.
Use ChipPinSelectManager.
std::shared_ptr< ChipSelectManager > csm
The select manager based on this configuration.
Parses configuration data for DigitalPort, DigitalPin, DigitalPinSet, ChipSelectManager, and ChipSelect objects.
DigitalPinSet dpSet
The DigitalPinSet for this configuration.
Index in type Pins that is sorted by pin global ID.
Index in type Pins that is sorted by pin port ID.
std::unordered_map< std::string, Port > PortMap
const PinConfiguration::Pins::index< index_pid >::type & pidIndex() const
Convenience function that provides the pin local ID index for the port's pins.
Use ChipBinarySelectManager.
A chip selection manager was defined without any pins.
The same pin global ID is used for more than one pin.
SelMgr * mgr
The chip select manager configuration for this object.
Holds configuration data for a single digital I/O pin.
PortMap::const_iterator portsBegin() const
Begining iterator to inspect the ports in the configuration.
PinSetMap::const_iterator pinSetsEnd() const
Ending iterator to inspect the pin sets in the configuration.
SelMgrMap::const_iterator selectManagersBegin() const
Begining iterator to inspect the select managers in the configuration.
boost::error_info< struct Info_SelectManagerName, std::string > SelectManagerName
The name of a chip select manager from a configuration.
std::string selName
The name of an optional chip select that has been associated with this pin set.
std::string name
Optional pin name.
std::unordered_map< std::string, unsigned int > selNames
A mapping of a name for a chip select to the chip ID used by the select manager.
The requested chip select does not exist.
The requested chip select manager is not named in the configuration.
unsigned int pinGlobalId(const std::string &str) const
Finds the global ID of the given pin according to this pin configuration.
ChipSelMap::const_iterator selectsEnd() const
Ending iterator to inspect the chip selects in the configuration.
Holds configuration data for a single chip select.
boost::error_info< struct Info_SelectBadType, std::string > SelectBadType
The string with a chip selection manager type that is not valid.
Pins allpins
All pins mentioned in the confiuration across all ports.
Holds configuration data for a single digital pin set.
The configuration gives the same name to more than one pin set.
A given pin ID could not be parsed.
The requested pin set is not defined by the configuration.
boost::error_info< struct Info_SelectName, std::string > SelectName
The name of a chip select from a configuration.
std::vector< unsigned int > pins
The global IDs of the pins that this select manager should use.
The requested port is not named in the configuration.