Class Pin
Defined in File sim_pin.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public SignalHook(Class SignalHook)
Class Documentation
-
class Pin : public SignalHook
MCU pin model.
Pin represents a external pad of the MCU used for GPIO. The pin has two electrical states given by the external circuit and the internal circuit (the GPIO port), which are resolved into a single electrical state. In case of conflict, the SHORTED state is set. Analog voltage levels are relative to VCC, hence limited to the range [0.0, 1.0].
Public Types
-
enum State
Pin state enum. All the possible logical/analog electrical states that the pin can take.
Values:
-
enumerator State_Floating
-
enumerator State_PullUp
-
enumerator State_PullDown
-
enumerator State_Analog
-
enumerator State_High
-
enumerator State_Low
-
enumerator State_Shorted
-
enumerator State_Floating
-
enum SignalId
Signal IDs raised by the pin. For all signals, the index is set to the pin ID.
Values:
-
enumerator Signal_StateChange
Signal raised for any change of the resolved state. data is set to the new state (one of State enum values)
-
enumerator Signal_StateChange
Public Functions
-
explicit Pin(pin_id_t id)
Build a pin.
- Parameters:
id – Identifier for the pin which should be unique
-
void set_external_state(State state, double voltage = 0.0)
Set the external electrical state of the pin.
Note
The voltage value is used only when state is Analog, and contrained to the range [0.0; 1.0].
- Parameters:
state – new external electrical state
voltage – new voltage value, relative to VCC.
-
void set_gpio_state(State state)
Set the electrical state of the pin as controlled by the GPIO port.
- Parameters:
state – new internal electrical state
-
bool digital_state() const
Returns the electrical state expressed as a boolean state. If the state is digital, it returns true if the state is high or false if it’s low. In other states, true is returned if the voltage is greater than 0.5.
- Returns:
the resolved state
-
inline double voltage() const
- Returns:
the pin voltage value
-
inline DataSignal &signal()
- Returns:
the signal raising the state/value changes
-
virtual void raised(const signal_data_t &sigdata, int hooktag) override
Callback override for receiving signal changes
Public Static Functions
-
struct state_t
-
enum State