Class PinDriver
Defined in File sim_pin.h
Inheritance Relationships
Derived Types
public ArchAVR_SPI::_PinDriver(Class ArchAVR_SPI::_PinDriver)public ArchAVR_TWI::_PinDriver(Class ArchAVR_TWI::_PinDriver)public ArchAVR_USART::_PinDriver(Class ArchAVR_USART::_PinDriver)public ArchAVR_USI::_PinDriver(Class ArchAVR_USI::_PinDriver)public ArchXT_SPI::_PinDriver(Class ArchXT_SPI::_PinDriver)public ArchXT_TWI::_PinDriver(Class ArchXT_TWI::_PinDriver)public ArchXT_TimerA::_PinDriver(Class ArchXT_TimerA::_PinDriver)public ArchXT_TimerB::_PinDriver(Class ArchXT_TimerB::_PinDriver)public ArchXT_USART::_PinDriver(Class ArchXT_USART::_PinDriver)
Class Documentation
-
class PinDriver
MCU pin driver.
PinDriver is an interface that allows to override the controls of a MCU pin. It is usually used as a sub-object of a peripheral that, under some conditions, takes control of a GPIO. The PinDriver does not know which pins it controls. The driver only references pins by a arbitrary integer index (0 to N) that has meaning only for the driver.
To operate, a driver must be registered with the PinManager object during the device initialisation phase. They are referenced by their ID, which must be unique. It is usually the same ID as the corresponding peripheral.
See also
Subclassed by ArchAVR_SPI::_PinDriver, ArchAVR_TWI::_PinDriver, ArchAVR_USART::_PinDriver, ArchAVR_USI::_PinDriver, ArchXT_SPI::_PinDriver, ArchXT_TWI::_PinDriver, ArchXT_TimerA::_PinDriver, ArchXT_TimerB::_PinDriver, ArchXT_USART::_PinDriver
Public Types
-
typedef unsigned int pin_index_t
Public Functions
-
PinDriver(ctl_id_t id, pin_index_t pin_count)
Construct a pin driver.
- Parameters:
id – Driver ID, usually the same ID as the parent peripheral
pin_count – number of pin driven by this driver
-
virtual ~PinDriver()
-
void set_enabled(bool enabled)
Enable/disable the override for all the pins.
- Parameters:
enabled – enable/disable the driver
-
void set_enabled(pin_index_t index, bool enabled)
Enable/disable a pin override.
- Parameters:
pin_index – Index of the pin
enabled – Enable/disable the driver
-
bool enabled(pin_index_t index) const
Returns the enable/disable override state for one pin.
- Parameters:
pin_index – Index of the pin
-
void update_pin_state(pin_index_t pin_index)
Forces a state resolution for one pin. No-op if the driver is disabled for that pin.
- Parameters:
pin_index – Index of the pin to update
-
void update_pin_states()
Forces a state resolution of all the pins. No-op if the driver is disabled for all pins.
-
Wire::state_t pin_state(pin_index_t pin_index) const
Returns the resolved state of a pin.
- Parameters:
pin_index – Index of the pin
-
Pin::controls_t gpio_controls(pin_index_t pin_index) const
Returns the GPIO controls of a pin, as configured by the GPIO port controller.
- Parameters:
pin_index – Index of the pin
-
virtual Pin::controls_t override_gpio(pin_index_t pin_index, const Pin::controls_t &controls) = 0
Stub called when a state resolution is taking place on a pin that the driver is controlling. The reimplementation should make a copy of the controls structure in argument, change its members according to the override state and return the result.
- Parameters:
pin_index – index of the pin
controls – pin controls as configured by the GPIO port controller
- Returns:
the controls to apply to the pin
-
virtual void digital_state_changed(pin_index_t pin_index, bool state)
Stub called when the digital state of a pin has changed after a state resolution.
- Parameters:
pin_index – Index of the pin
state – New digital state of the pin
-
typedef unsigned int pin_index_t