PinManager Class Reference

yasimavr: PinManager Class Reference
yasimavr
Loading...
Searching...
No Matches

MCU pin manager. More...

#include <sim_pin.h>

Classes

struct  drv_entry_t
 
struct  pin_entry_t
 

Public Types

typedef sim_id_t mux_id_t
 

Public Member Functions

 PinManager (const std::vector< pin_id_t > &pin_ids)
 
 ~PinManager ()
 
bool register_driver (PinDriver &drv)
 
bool add_mux_config (ctl_id_t drv, const std::vector< pin_id_t > &pins, mux_id_t mux_id=default_mux_id)
 
void set_current_mux (ctl_id_t drv, mux_id_t index)
 
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
 
std::vector< pin_id_tcurrent_mux_pins (ctl_id_t drv) const
 
Pinpin (pin_id_t pin_id) const
 
 PinManager (const PinManager &)=delete
 
PinManageroperator= (const PinManager &)=delete
 

Static Public Attributes

static constexpr mux_id_t default_mux_id = "DEFAULT"
 

Friends

class Pin
 
class PinDriver
 

Detailed Description

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.

See also
Pin, PinDriver

Member Typedef Documentation

◆ mux_id_t

Constructor & Destructor Documentation

◆ PinManager() [1/2]

PinManager::PinManager ( const std::vector< pin_id_t > &  pin_ids)
explicit

Construct a pin manager.

Parameters
pin_idsarray of the pin IDs managed by this. A Pin object is constructed for each of these IDs.

◆ ~PinManager()

PinManager::~PinManager ( )

◆ PinManager() [2/2]

PinManager::PinManager ( const PinManager )
delete

Member Function Documentation

◆ add_mux_config()

bool PinManager::add_mux_config ( ctl_id_t  drv_id,
const std::vector< pin_id_t > &  pin_ids,
mux_id_t  mux_id = default_mux_id 
)

Add a mux configuration for a pin driver.

Parameters
drv_idID of the driver
pin_idsArray of the pin IDs corresponding to the indexes used by the driver
mux_idID for the mux config (unique for the driver), must be > 0
Returns
true if the operation succeeded
Note
the first mux config is automatically activated.

◆ current_mux()

PinManager::mux_id_t PinManager::current_mux ( ctl_id_t  drv_id,
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_idID of the driver

◆ current_mux_pins()

std::vector< pin_id_t > PinManager::current_mux_pins ( ctl_id_t  drv_id) 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_idID of the driver

◆ operator=()

PinManager & PinManager::operator= ( const PinManager )
delete

◆ pin()

Pin * PinManager::pin ( pin_id_t  pin_id) const

Return a pointer to a Pin object

Parameters
drv_idID of the pin

◆ register_driver()

bool PinManager::register_driver ( PinDriver drv)

Register a pin driver with this manager.

Parameters
drvdriver to register

◆ set_current_mux() [1/2]

void PinManager::set_current_mux ( ctl_id_t  drv_id,
mux_id_t  mux_id 
)

Activate a mux configuration for all pins of a pin driver.

Parameters
drv_idID of the driver
mux_indexindex of the new configuration to activate. May be 0 i.e. no mux is activated.

◆ set_current_mux() [2/2]

void PinManager::set_current_mux ( ctl_id_t  drv_id,
PinDriver::pin_index_t  pin_index,
mux_id_t  mux_id 
)

Activate a mux configuration for one pin of a pin driver.

Parameters
drv_idID of the driver
pin_indexIndex of the pin
mux_indexindex of the new configuration to activate. May be 0 i.e. no mux is activated.

Friends And Related Symbol Documentation

◆ Pin

friend class Pin
friend

◆ PinDriver

friend class PinDriver
friend

Member Data Documentation

◆ default_mux_id

constexpr mux_id_t PinManager::default_mux_id = "DEFAULT"
staticconstexpr

The documentation for this class was generated from the following files: