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 | |
Pin (const Pin &p) | |
copy constructor, copy values but no refs to Net or HWPort | |
Pin (const OpenDrain &od) | |
copy constructor, if we take values from OpenDrain pin | |
Pin (T_Pinstate ps) | |
copy constructor from pin state | |
Pin (unsigned char *parentPin, unsigned char mask) | |
constructor for a port pin | |
virtual | ~Pin () |
pin destructor, breaks save connection to other pins, if necessary | |
operator char () const | |
virtual Pin & | operator= (char) |
virtual | operator bool () const |
virtual Pin | operator+ (const Pin &p) |
virtual Pin | operator+= (const Pin &p) |
virtual void | SetInState (const Pin &p) |
handles the input value from net | |
virtual void | RegisterNet (Net *n) |
registers Net instance on pin | |
virtual void | UnRegisterNet (Net *n) |
deletes Net instance registration for pin | |
virtual Pin | GetPin (void) |
"cast method" to get back a Pin instance | |
int | GetAnalog (void) const |
Returns analog input value of pin. | |
Pin & | SetAnalog (int value) |
Sets the pin to an analog value. | |
void | RegisterCallback (HasPinNotifyFunction *) |
bool | CalcPin (void) |
Update input values from output values. | |
bool | isPortPin (void) |
True, if it's a port pin. | |
bool | isConnected (void) |
True, if it's connected to other pins. | |
bool | hasListener (void) |
True, if there change listeners. | |
Public Attributes | |
T_Pinstate | outState |
discret value of output stage | |
std::vector < HasPinNotifyFunction * > | notifyList |
listeners for change of input value | |
Protected Attributes | |
unsigned char * | pinOfPort |
points to HWPort::pin or NULL | |
unsigned char | mask |
byte mask for HWPort::pin | |
int | analogValue |
analog input value, from 0 to INT_MAX | |
Net * | connectedTo |
the connection to other pins (NULL, if not connected) | |
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.
Definition at line 47 of file pin.h.
enum Pin::T_Pinstate |
Possible PIN states.
This are the discret states of output stage and input value.
Pin::Pin | ( | void | ) |
common constructor, initial output state is tristate
Definition at line 126 of file pin.cpp.
References analogValue, connectedTo, outState, pinOfPort, TRISTATE, and TRISTATE_ANALOG_VALUE.
Referenced by OpenDrain::GetPin(), OpenDrain::operator+(), and operator+().
Pin::Pin | ( | const Pin & | p | ) |
copy constructor, copy values but no refs to Net or HWPort
Definition at line 148 of file pin.cpp.
References analogValue, connectedTo, outState, and pinOfPort.
Pin::Pin | ( | const OpenDrain & | od | ) |
copy constructor, if we take values from OpenDrain pin
Definition at line 259 of file pin.cpp.
References analogValue, LOW, outState, TRISTATE, and TRISTATE_ANALOG_VALUE.
Pin::Pin | ( | T_Pinstate | ps | ) |
copy constructor from pin state
Definition at line 99 of file pin.cpp.
References analogValue, connectedTo, HIGH, LOW, outState, pinOfPort, PULLDOWN, PULLUP, TRISTATE, and TRISTATE_ANALOG_VALUE.
Pin::Pin | ( | unsigned char * | parentPin, | |
unsigned char | mask | |||
) |
constructor for a port pin
Definition at line 139 of file pin.cpp.
References analogValue, connectedTo, mask, outState, pinOfPort, TRISTATE, and TRISTATE_ANALOG_VALUE.
Pin::~Pin | ( | ) | [virtual] |
pin destructor, breaks save connection to other pins, if necessary
Definition at line 134 of file pin.cpp.
References connectedTo, and UnRegisterNet().
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
Definition at line 89 of file pin.cpp.
References Net::CalcNet(), connectedTo, and SetInState().
Referenced by operator=(), and SetAnalog().
int Pin::GetAnalog | ( | void | ) | const |
Returns analog input value of pin.
Definition at line 45 of file pin.cpp.
References ANALOG, analogValue, HIGH, LOW, outState, PULLDOWN, PULLUP, and TRISTATE.
Referenced by HWAd::CpuCycle(), PinAtPort::GetAnalog(), HWAdmux::GetMuxOutput(), and Scope::SetInStateForChannel().
virtual Pin Pin::GetPin | ( | void | ) | [inline, virtual] |
"cast method" to get back a Pin instance
Reimplemented in OpenDrain, and SwigDirector_Pin.
bool Pin::hasListener | ( | void | ) | [inline] |
bool Pin::isConnected | ( | void | ) | [inline] |
True, if it's connected to other pins.
Definition at line 107 of file pin.h.
References connectedTo.
bool Pin::isPortPin | ( | void | ) | [inline] |
Pin::operator bool | ( | ) | const [virtual] |
Pin::operator char | ( | ) | const |
Pin & Pin::operator= | ( | char | c | ) | [virtual] |
Definition at line 196 of file pin.cpp.
References ANALOG, ANALOG_SHORTED, analogValue, CalcPin(), HIGH, LOW, outState, PULLDOWN, PULLUP, SHORTED, TRISTATE, and TRISTATE_ANALOG_VALUE.
void Pin::RegisterCallback | ( | HasPinNotifyFunction * | h | ) |
register a listener for input value change
Definition at line 66 of file pin.cpp.
References notifyList.
Referenced by ExternalIRQPort::ExternalIRQPort(), ExternalIRQSingle::ExternalIRQSingle(), HWAcomp::HWAcomp(), PinMonitor::PinMonitor(), SerialRx::SerialRx(), and SerialRxBasic::SerialRxBasic().
void Pin::RegisterNet | ( | Net * | n | ) | [virtual] |
registers Net instance on pin
Reimplemented in OpenDrain, and SwigDirector_Pin.
Definition at line 156 of file pin.cpp.
References connectedTo, and UnRegisterNet().
Referenced by Net::Add(), and OpenDrain::RegisterNet().
Pin & Pin::SetAnalog | ( | int | value | ) |
Sets the pin to an analog value.
Definition at line 244 of file pin.cpp.
References analogValue, and CalcPin().
void Pin::SetInState | ( | const Pin & | p | ) | [virtual] |
handles the input value from net
Reimplemented in SwigDirector_Pin, ExtPin, ExtAnalogPin, and ScopePin.
Definition at line 70 of file pin.cpp.
References analogValue, mask, notifyList, and pinOfPort.
Referenced by avr_set_pin_tf(), Net::CalcNet(), and CalcPin().
void Pin::UnRegisterNet | ( | Net * | n | ) | [virtual] |
deletes Net instance registration for pin
Reimplemented in SwigDirector_Pin.
Definition at line 161 of file pin.cpp.
References connectedTo, and Net::Delete().
Referenced by RegisterNet(), and ~Pin().
int Pin::analogValue [protected] |
analog input value, from 0 to INT_MAX
Definition at line 52 of file pin.h.
Referenced by GetAnalog(), operator bool(), operator=(), Pin(), SetAnalog(), AdcAnalogPin::setAnalogValue(), SetInState(), and ExtAnalogPin::SetNewValueFromUi().
Net* Pin::connectedTo [protected] |
the connection to other pins (NULL, if not connected)
Definition at line 54 of file pin.h.
Referenced by CalcPin(), isConnected(), Pin(), RegisterNet(), AdcAnalogPin::setAnalogValue(), ExtAnalogPin::SetNewValueFromUi(), ExtPin::SetNewValueFromUi(), UnRegisterNet(), and ~Pin().
unsigned char Pin::mask [protected] |
byte mask for HWPort::pin
Definition at line 51 of file pin.h.
Referenced by HWPort::HWPort(), Pin(), and SetInState().
std::vector<HasPinNotifyFunction*> Pin::notifyList |
listeners for change of input value
Definition at line 75 of file pin.h.
Referenced by hasListener(), RegisterCallback(), and SetInState().
discret value of output stage
Definition at line 74 of file pin.h.
Referenced by avr_get_pin_tf(), HWPort::CalcOutputs(), ExtPin::ExtPin(), GetAnalog(), operator bool(), operator char(), operator+(), operator=(), Pin(), ExtAnalogPin::SetNewValueFromUi(), ExtPin::SetNewValueFromUi(), and HWSpi::SetSPCR().
unsigned char* Pin::pinOfPort [protected] |
points to HWPort::pin or NULL
Definition at line 50 of file pin.h.
Referenced by HWPort::HWPort(), isPortPin(), Pin(), and SetInState().