39 portToggleFeature(portToggle),
40 port_reg(this,
"PORT",
53 for(
unsigned int tt = 0; tt <
portSize; tt++) {
55 string dummy = name + (char)(
'0' + tt);
72 for(
int tt =
portSize - 1; tt >= 0; tt--) {
82 for(
int tt =
portSize - 1; tt >= 0; tt--)
83 p[tt].ResetOverride();
88 assert(pinNo <
sizeof(
p)/
sizeof(
p[0]));
93 unsigned char tmpPin = 0;
95 for(
unsigned int actualBitNo = 0; actualBitNo <
portSize; actualBitNo++) {
96 unsigned char actualBit = 1 << actualBitNo;
97 bool regPort = (bool)(
port & actualBit);
98 bool regDDR = (bool)(
ddr & actualBit);
100 if(
p[actualBitNo].CalcPinOverride(regDDR, regPort,
false))
111 for(
unsigned int tt = 0; tt <
portSize; tt++)
112 dummy[portSize - 1 - tt] =
p[tt];
135 avr_warning(
"Writing of 'PORT%s.PIN' (with %d) is not supported.",
myName.c_str(), val);
141 unsigned char tmpPin =
pin;
143 unsigned char actualBit = 1 << bitaddr;
144 tmpPin &= ~actualBit;
148 bool regPort = (bool)(
port & actualBit);
149 bool regDDR = (bool)(
ddr & actualBit);
151 if(
p[bitaddr].CalcPinOverride(regDDR, regPort,
false)) {
159 avr_warning(
"Writing of 'PORT%s.PIN' (with %d) is not supported.",
myName.c_str(), val);
std::string myName
the "name" of the port
unsigned char GetPin()
getter method for PIN register
Basic AVR device, contains the core functionality.
unsigned char * pinOfPort
points to HWPort::pin or nullptr
TraceValue * pintrace[8]
trace channel to trace output driver state
Pin class, handles input and output to external parts.
unsigned char pin
port input register
Defines a Port, e.g. a hardware device for GPIO.
void RegisterPin(const std::string &name, Pin *p)
void CalcOutputs(void)
Calculate the new output value to be transmitted to the environment.
HWPort(AvrDevice *core, const std::string &name, bool portToggle=false, int size=8)
unsigned char portMask
mask out unused bits, if necessary
unsigned char ddr
data direction register
unsigned char mask
byte mask for HWPort::pin
Build a register for TraceValue's.
void RegisterTraceValue(TraceValue *t)
Registers a TraceValue for this register.
void SetPinBit(bool bit, unsigned int bitaddr)
std::string GetPortString(void)
returns a string representation of output states
unsigned char port
port output register
bool portToggleFeature
controls functionality of SetPin method (write to PIN toggles port register)
void SetDdr(unsigned char val)
setter method for data direction register
void SetPort(unsigned char val)
setter method for port register
PortPin p[8]
the port pins, e.g. the final IO stages
void hardwareChange(unsigned char val)
const std::string GetTraceValuePrefix(void)
Returns the scope prefix.
void SetPin(unsigned char val)
setter method for PIN register (for new devices with toggle port)
void UnregisterTraceValue(TraceValue *t)
Unregisters a TraceValue, remove it from register.
IOReg< HWPort > * pinRegOfPort
points to PIN io register of port or nullptr
void change(unsigned val)
Log a change on this value.
unsigned int portSize
how much bits does this port have [1..8]