simulavr  1.1.0
HWPort Class Reference

Defines a Port, e.g. a hardware device for GPIO. More...

#include <hwport.h>

Inheritance diagram for HWPort:

Public Member Functions

 HWPort (AvrDevice *core, const std::string &name, bool portToggle=false, int size=8)
 
 ~HWPort ()
 
void CalcOutputs (void)
 Calculate the new output value to be transmitted to the environment. More...
 
std::string GetPortString (void)
 returns a string representation of output states More...
 
void Reset (void)
 
std::string GetName (void)
 returns the port name as given in constructor More...
 
PinGetPin (unsigned char pinNo)
 returns a pin reference of pin with pin number More...
 
int GetPortSize (void)
 returns, how much bits this port controls More...
 
void SetPort (unsigned char val)
 setter method for port register More...
 
void SetDdr (unsigned char val)
 setter method for data direction register More...
 
void SetPin (unsigned char val)
 setter method for PIN register (for new devices with toggle port) More...
 
void SetPinBit (bool bit, unsigned int bitaddr)
 
unsigned char GetPort ()
 getter method for port register More...
 
unsigned char GetDdr ()
 getter method for data direction register More...
 
unsigned char GetPin ()
 getter method for PIN register More...
 
unsigned char GetPinBit (unsigned int bitaddr)
 
- Public Member Functions inherited from Hardware
 Hardware (AvrDevice *core)
 
virtual ~Hardware ()
 
virtual unsigned int CpuCycle (void)
 
virtual void ClearIrqFlag (unsigned int vector)
 
virtual bool IsLevelInterrupt (unsigned int vector)
 
virtual bool LevelInterruptPending (unsigned int vector)
 
- Public Member Functions inherited from TraceValueRegister
 TraceValueRegister (TraceValueRegister *parent, const std::string &name)
 Create a TraceValueRegister, with a scope prefix built on parent scope + name. More...
 
 TraceValueRegister ()
 Create a TraceValueRegister, with a empty scope name, single device application. More...
 
virtual ~TraceValueRegister ()
 
const std::string GetTraceValuePrefix (void)
 Returns the scope prefix. More...
 
const std::string GetScopeName (void)
 Returns the scope name. More...
 
void RegisterTraceValue (TraceValue *t)
 Registers a TraceValue for this register. More...
 
void UnregisterTraceValue (TraceValue *t)
 Unregisters a TraceValue, remove it from register. More...
 
TraceValueRegisterGetScopeGroupByName (const std::string &name)
 Get a here registered TraceValueRegister by it's name. More...
 
virtual TraceValueGetTraceValueByName (const std::string &name)
 Get a here registered TraceValue by it's name. More...
 
TraceValueRegisterFindScopeGroupByName (const std::string &name)
 Seek for a TraceValueRegister by it's name. More...
 
TraceValueFindTraceValueByName (const std::string &name)
 Seek for a TraceValue by it's name. More...
 
TraceSetGetAllTraceValues (void)
 Get all here registered TraceValue's only (not with descending values) More...
 
TraceSetGetAllTraceValuesRecursive (void)
 Get all here registered TraceValue's with descending values. More...
 

Public Attributes

IOReg< HWPortport_reg
 
IOReg< HWPortpin_reg
 
IOReg< HWPortddr_reg
 

Protected Attributes

std::string myName
 the "name" of the port More...
 
unsigned char port
 port output register More...
 
unsigned char pin
 port input register More...
 
unsigned char ddr
 data direction register More...
 
PortPin p [8]
 the port pins, e.g. the final IO stages More...
 
TraceValuepintrace [8]
 trace channel to trace output driver state More...
 
unsigned int portSize
 how much bits does this port have [1..8] More...
 
unsigned char portMask
 mask out unused bits, if necessary More...
 
bool portToggleFeature
 controls functionality of SetPin method (write to PIN toggles port register) More...
 

Friends

class PinAtPort
 

Additional Inherited Members

- Protected Member Functions inherited from TraceValueRegister
virtual size_t _tvr_getValuesCount (void)
 Get the count of all TraceValues, that are registered here and descending. More...
 
virtual void _tvr_insertTraceValuesToSet (TraceSet &t)
 Insert all TraceValues into TraceSet, that registered here and descending. More...
 

Detailed Description

Defines a Port, e.g. a hardware device for GPIO.

Example for use alternateDdr and useAlternateDdr: If the UART Tx will be enabled, the UART set alternateDdr to output, useAlternateDdr to 1 and sets port according to Tx Pin value, thats all :-)

useAlternatePortIfDdrSet: special case for the OCR outputs, which only be connected to pin if ddr is set to output!

Definition at line 43 of file hwport.h.

Constructor & Destructor Documentation

◆ HWPort()

HWPort::HWPort ( AvrDevice core,
const std::string &  name,
bool  portToggle = false,
int  size = 8 
)

◆ ~HWPort()

HWPort::~HWPort ( )

Definition at line 71 of file hwport.cpp.

References pintrace, portSize, and TraceValueRegister::UnregisterTraceValue().

Member Function Documentation

◆ CalcOutputs()

◆ GetDdr()

unsigned char HWPort::GetDdr ( )
inline

getter method for data direction register

Definition at line 75 of file hwport.h.

References ddr.

◆ GetName()

std::string HWPort::GetName ( void  )
inline

returns the port name as given in constructor

Definition at line 65 of file hwport.h.

References GetPin(), and myName.

◆ GetPin() [1/2]

◆ GetPin() [2/2]

unsigned char HWPort::GetPin ( )
inline

getter method for PIN register

Definition at line 76 of file hwport.h.

References pin.

Referenced by GetName().

◆ GetPinBit()

unsigned char HWPort::GetPinBit ( unsigned int  bitaddr)
inline

Definition at line 79 of file hwport.h.

◆ GetPort()

unsigned char HWPort::GetPort ( )
inline

getter method for port register

Definition at line 74 of file hwport.h.

References port.

◆ GetPortSize()

int HWPort::GetPortSize ( void  )
inline

returns, how much bits this port controls

Definition at line 67 of file hwport.h.

References portSize, SetDdr(), SetPin(), SetPinBit(), and SetPort().

Referenced by ExternalIRQPort::ExternalIRQPort().

◆ GetPortString()

string HWPort::GetPortString ( void  )

returns a string representation of output states

Definition at line 108 of file hwport.cpp.

References p, and portSize.

◆ Reset()

void HWPort::Reset ( void  )
virtual

Implement the hardware's reset functionality here. The default is no action on reset.

Reimplemented from Hardware.

Definition at line 77 of file hwport.cpp.

References CalcOutputs(), ddr, p, pin, port, and portSize.

Referenced by HWPort().

◆ SetDdr()

void HWPort::SetDdr ( unsigned char  val)

setter method for data direction register

Definition at line 123 of file hwport.cpp.

References CalcOutputs(), ddr, ddr_reg, IOReg< P >::hardwareChange(), and portMask.

Referenced by GetPortSize().

◆ SetPin()

void HWPort::SetPin ( unsigned char  val)

setter method for PIN register (for new devices with toggle port)

Definition at line 129 of file hwport.cpp.

References avr_warning, CalcOutputs(), IOReg< P >::hardwareChange(), myName, port, port_reg, and portToggleFeature.

Referenced by GetPortSize().

◆ SetPinBit()

void HWPort::SetPinBit ( bool  bit,
unsigned int  bitaddr 
)

◆ SetPort()

void HWPort::SetPort ( unsigned char  val)

setter method for port register

Definition at line 117 of file hwport.cpp.

References CalcOutputs(), IOReg< P >::hardwareChange(), port, port_reg, and portMask.

Referenced by GetPortSize().

Friends And Related Function Documentation

◆ PinAtPort

friend class PinAtPort
friend

Definition at line 81 of file hwport.h.

Member Data Documentation

◆ ddr

unsigned char HWPort::ddr
protected

data direction register

Definition at line 50 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetDdr(), GetDdr(), Reset(), PinAtPort::SetDdr(), SetDdr(), and SetPinBit().

◆ ddr_reg

◆ myName

std::string HWPort::myName
protected

the "name" of the port

Definition at line 46 of file hwport.h.

Referenced by GetName(), SetPin(), and SetPinBit().

◆ p

◆ pin

unsigned char HWPort::pin
protected

port input register

Definition at line 49 of file hwport.h.

Referenced by CalcOutputs(), GetPin(), HWPort(), Reset(), and SetPinBit().

◆ pin_reg

◆ pintrace

TraceValue* HWPort::pintrace[8]
protected

trace channel to trace output driver state

Definition at line 53 of file hwport.h.

Referenced by CalcOutputs(), HWPort(), SetPinBit(), and ~HWPort().

◆ port

unsigned char HWPort::port
protected

port output register

Definition at line 48 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetPort(), GetPort(), Reset(), SetPin(), SetPinBit(), PinAtPort::SetPort(), and SetPort().

◆ port_reg

◆ portMask

unsigned char HWPort::portMask
protected

mask out unused bits, if necessary

Definition at line 55 of file hwport.h.

Referenced by HWPort(), SetDdr(), and SetPort().

◆ portSize

unsigned int HWPort::portSize
protected

how much bits does this port have [1..8]

Definition at line 54 of file hwport.h.

Referenced by CalcOutputs(), GetPortSize(), GetPortString(), HWPort(), Reset(), and ~HWPort().

◆ portToggleFeature

bool HWPort::portToggleFeature
protected

controls functionality of SetPin method (write to PIN toggles port register)

Definition at line 56 of file hwport.h.

Referenced by SetPin(), and SetPinBit().


The documentation for this class was generated from the following files: