Class PinManager
Defined in File sim_pin.h
Nested Relationships
Nested Types
Class Documentation
-
class PinManager
MCU pin manager.
Class managing a set of pins and the mux configurations between the pin drivers and the pins.
The mux configuration are identified by a ID, with 0 a reserved value. This ID must be unique for a particular driver. A default mux ID is provided by the static constant default_mux_id which can be used for drivers that have only one mux config.
Public Functions
-
explicit PinManager(const std::vector<pin_id_t> &pin_ids)
Construct a pin manager.
- Parameters:
pin_ids – array of the pin IDs managed by this. A Pin object is constructed for each of these IDs.
-
~PinManager()
-
bool register_driver(PinDriver &drv)
Register a pin driver with this manager.
- Parameters:
drv – driver to register
-
bool add_mux_config(ctl_id_t drv, const std::vector<pin_id_t> &pins, mux_id_t mux_id = default_mux_id)
Add a mux configuration for a pin driver.
Note
the first mux config is automatically activated.
- Parameters:
drv_id – ID of the driver
pin_ids – Array of the pin IDs corresponding to the indexes used by the driver
mux_id – ID for the mux config (unique for the driver), must be > 0
- Returns:
true if the operation succeeded
-
void set_current_mux(ctl_id_t drv, mux_id_t index)
Activate a mux configuration for a pin driver.
- Parameters:
drv_id – ID of the driver
mux_index – index of the new configuration to activate. May be 0 i.e. no mux is activated.
-
void set_current_mux(ctl_id_t drv, PinDriver::pin_index_t, mux_id_t index)
-
mux_id_t current_mux(ctl_id_t drv, PinDriver::pin_index_t pin_index) const
Returns the ID of the currently activated mux config for a pin driver. If no mux is activated, returns 0.
- Parameters:
drv_id – ID of the driver
-
std::vector<pin_id_t> current_mux_pins(ctl_id_t drv) const
Returns the pin IDs to which a driver is attached according to its currently activated mux config. If no mux config is activated for this driver, an array filled with zeros is returned.
- Parameters:
drv_id – ID of the driver
-
Pin *pin(pin_id_t pin_id) const
Return a pointer to a Pin object
- Parameters:
drv_id – ID of the pin
-
PinManager(const PinManager&) = delete
-
PinManager &operator=(const PinManager&) = delete
-
struct drv_entry_t
Public Functions
-
inline ~drv_entry_t()
-
inline pin_id_t pin_id(PinDriver::pin_index_t pin_index, mux_id_t mux_id) const
-
inline pin_id_t pin_id(PinDriver::pin_index_t pin_index) const
-
inline PinDriver::pin_index_t pin_count() const
-
inline ~drv_entry_t()
-
explicit PinManager(const std::vector<pin_id_t> &pin_ids)