simulavr
1.1.0
|
Pin class, handles input and output to external parts. More...
#include <pin.h>
Public Types | |
enum | T_Pinstate { LOW, HIGH, SHORTED, PULLUP, TRISTATE, PULLDOWN, ANALOG, ANALOG_SHORTED } |
Possible PIN states. More... | |
Public Member Functions | |
Pin (void) | |
common constructor, initial output state is tristate More... | |
Pin (const Pin &p) | |
copy constructor, copy values but no refs to Net or HWPort More... | |
Pin (T_Pinstate ps) | |
copy constructor from pin state More... | |
Pin (unsigned char *parentPin, unsigned char mask) | |
constructor for a port pin, only used in UI part! More... | |
Pin (float analog) | |
constructor for analog pin More... | |
virtual | ~Pin () |
pin destructor, breaks save connection to other pins, if necessary More... | |
operator char () const | |
return char representation for output stage More... | |
virtual Pin & | operator= (char) |
set output stage to (digital) state, set value for ANALOG state separately More... | |
virtual | operator bool () const |
return boolean state of output stage More... | |
virtual Pin | operator+ (const Pin &p) |
calculate common state from 2 connected pins More... | |
virtual Pin | operator+= (const Pin &p) |
calculate common state from connected other pin to this pin More... | |
virtual void | SetInState (const Pin &p) |
handles the input value from net More... | |
virtual void | RegisterNet (Net *n) |
registers Net instance on pin More... | |
virtual void | UnRegisterNet (Net *n) |
deletes Net instance registration for pin More... | |
virtual Pin | GetPin (void) |
"cast method" to get back a Pin instance More... | |
int | GetAnalog (void) |
Get analog value as integer from 0 to INT_MAX (for backward compatibility, will be deprecated later) More... | |
float | GetRawAnalog (void) const |
get back raw analog value (just variable content!) More... | |
float | GetAnalogValue (float vcc) |
Returns real analog input value of pin. More... | |
Pin & | SetAnalogValue (float value) |
Sets the pin to an real analog value. More... | |
void | SetRawAnalog (float value) |
void | RegisterCallback (HasPinNotifyFunction *) |
bool | CalcPin (void) |
Update input values from output values. More... | |
bool | isPortPin (void) |
True, if it's a port pin. More... | |
bool | isConnected (void) |
True, if it's connected to other pins. More... | |
bool | hasListener (void) |
True, if there change listeners. More... | |
Public Attributes | |
T_Pinstate | outState |
discrete value of output stage More... | |
std::vector< HasPinNotifyFunction * > | notifyList |
listeners for change of input value More... | |
Protected Attributes | |
unsigned char * | pinOfPort |
points to HWPort::pin or nullptr More... | |
IOReg< HWPort > * | pinRegOfPort |
points to PIN io register of port or nullptr More... | |
unsigned char | mask |
byte mask for HWPort::pin More... | |
AnalogValue | analogVal |
"real" analog voltage value More... | |
Net * | connectedTo |
the connection to other pins (nullptr, if not connected) More... | |
Friends | |
class | HWPort |
class | Net |
Pin class, handles input and output to external parts.
This isn't a simple electrical point with a electrical potential. Pin class simulates mostly complete Input/Output circuit. So you have a output stage and a input state. Such a pin is connected by a net (see Net class) with other pins. Attention! The variable outState isn't the electrical state of a pin, it's only the state of the output stage. Only in case of no connected Net instance (aka no physical connection to other sink / source) it's also the real pin state!
enum Pin::T_Pinstate |
Possible PIN states.
This are the discrete states of output stage and input value.
Enumerator | |
---|---|
LOW | |
HIGH | |
SHORTED | |
PULLUP | |
TRISTATE | |
PULLDOWN | |
ANALOG | |
ANALOG_SHORTED |
Pin::Pin | ( | void | ) |
Pin::Pin | ( | const Pin & | p | ) |
Pin::Pin | ( | T_Pinstate | ps | ) |
copy constructor from pin state
Definition at line 95 of file pin.cpp.
References AnalogValue::ST_FLOATING, AnalogValue::ST_GND, and AnalogValue::ST_VCC.
Pin::Pin | ( | unsigned char * | parentPin, |
unsigned char | mask | ||
) |
|
virtual |
bool Pin::CalcPin | ( | void | ) |
Update input values from output values.
If there is no connection to other pins, then it will reflect the own output value to own input value. Otherwise it calls Net::CalcNet method
int Pin::GetAnalog | ( | void | ) |
|
inline |
Returns real analog input value of pin.
Definition at line 150 of file pin.h.
References AnalogValue::getA().
Referenced by PinAtPort::GetAnalogValue(), HWARefPin::GetRefValue(), HWARef4::GetRefValue(), HWARef8::GetRefValue(), HWAdmux6::GetValue(), HWAdmuxM8::GetValue(), HWAdmuxM16::GetValue(), HWAdmuxT25::GetValue(), HWAdmuxM2560::GetValue(), and HWAdmuxM8::GetValueAComp().
|
inlinevirtual |
"cast method" to get back a Pin instance
Reimplemented in OpenDrain.
Definition at line 147 of file pin.h.
Referenced by PinMonitor::PinMonitor().
|
inline |
get back raw analog value (just variable content!)
Definition at line 149 of file pin.h.
References AnalogValue::getRaw().
Referenced by HWAd::CpuCycle(), HWAcomp::GetIn0(), HWAcomp::GetIn1(), HWARef4::GetRefValue(), HWARef8::GetRefValue(), HWAdmuxM8::GetValue(), HWAdmuxM16::GetValue(), HWAdmuxT25::GetValue(), and HWAdmuxM2560::GetValue().
|
inline |
|
inline |
|
virtual |
return boolean state of output stage
Definition at line 193 of file pin.cpp.
References AnalogValue::ST_FLOATING, AnalogValue::ST_GND, and AnalogValue::ST_VCC.
Pin::operator char | ( | ) | const |
|
virtual |
set output stage to (digital) state, set value for ANALOG state separately
Definition at line 219 of file pin.cpp.
References AnalogValue::ST_FLOATING, AnalogValue::ST_GND, and AnalogValue::ST_VCC.
void Pin::RegisterCallback | ( | HasPinNotifyFunction * | h | ) |
register a listener for input value change
Definition at line 60 of file pin.cpp.
Referenced by ExternalIRQPort::ExternalIRQPort(), ExternalIRQSingle::ExternalIRQSingle(), HWAcomp::HWAcomp(), HWAdmux6::HWAdmux6(), HWAdmuxM2560::HWAdmuxM2560(), HWAdmuxM8::HWAdmuxM8(), PinMonitor::PinMonitor(), and HWUSI::registerDIandSCK().
|
virtual |
Pin & Pin::SetAnalogValue | ( | float | value | ) |
Sets the pin to an real analog value.
Definition at line 267 of file pin.cpp.
Referenced by AdcAnalogPin::setAnalogValue().
|
virtual |
handles the input value from net
Reimplemented in ExtAnalogPin, and ExtPin.
Definition at line 64 of file pin.cpp.
References analogVal.
Referenced by avr_set_pin_tf(), and Net::CalcNet().
|
inline |
Definition at line 152 of file pin.h.
References AnalogValue::setA().
|
virtual |
|
protected |
"real" analog voltage value
Definition at line 104 of file pin.h.
Referenced by Pin(), and SetInState().
|
protected |
|
protected |
std::vector<HasPinNotifyFunction*> Pin::notifyList |
T_Pinstate Pin::outState |
discrete value of output stage
Definition at line 126 of file pin.h.
Referenced by avr_get_pin_tf(), operator+(), and Pin().
|
protected |
points to HWPort::pin or nullptr
Definition at line 101 of file pin.h.
Referenced by HWPort::HWPort().
points to PIN io register of port or nullptr
Definition at line 102 of file pin.h.
Referenced by HWPort::HWPort().