HWPort Class Reference

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

#include <hwport.h>

Inheritance diagram for HWPort:
Inheritance graph
[legend]
Collaboration diagram for HWPort:
Collaboration graph
[legend]

List of all members.

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.
std::string GetPortString (void)
 returns a string representation of output states
void Reset (void)
std::string GetName (void)
 returns the port name as given in constructor
PinGetPin (unsigned char pinNo)
 returns a pin reference of pin with pin number
int GetPortSize (void)
 returns, how much bits this port controls
void SetPort (unsigned char val)
 setter method for port register
void SetDdr (unsigned char val)
 setter method for data direction register
void SetPin (unsigned char val)
 setter method for PIN register (for new devices with toggle port)
unsigned char GetPort (void)
 getter method for port register
unsigned char GetDdr (void)
 getter method for data direction register
unsigned char GetPin (void)
 getter method for PIN register

Public Attributes

IOReg< HWPortport_reg
IOReg< HWPortpin_reg
IOReg< HWPortddr_reg

Protected Attributes

std::string myName
 the "name" of the port
unsigned char port
 port output register
unsigned char pin
 port input register
unsigned char ddr
 data direction register
unsigned char alternateDdr
 data direction register for special functions
unsigned char useAlternateDdr
 bit mask, which bit in alternateDdr is used
unsigned char alternatePort
 output register for special functions
unsigned char useAlternatePort
 bit mask, which bit in alternatePort is used
unsigned char useAlternatePortIfDdrSet
Pin p [8]
 the port pins, e.g. the final IO stages
int portSize
 how much bits does this port have [1..8]
unsigned char portMask
 mask out unused bits, if necessary
bool portToggleFeature
 controls functionality of SetPin method (write to PIN toggles port register)

Private Member Functions

void CalcPin (void)
 calculating the value for register "pin" from the Pin p[] array

Friends

class PinAtPort

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 ( AvrDevice core,
const std::string &  name,
bool  portToggle = false,
int  size = 8 
)

Definition at line 34 of file hwport.cpp.

References Pin::mask, p, pin, Pin::pinOfPort, portMask, portSize, AvrDevice::RegisterPin(), and Reset().

Here is the call graph for this function:

HWPort::~HWPort (  )  [inline]

Definition at line 72 of file hwport.h.


Member Function Documentation

void HWPort::CalcOutputs ( void   ) 

Calculate the new output value to be transmitted to the environment.

Definition at line 89 of file hwport.cpp.

References alternateDdr, alternatePort, CalcPin(), ddr, Pin::HIGH, Pin::LOW, Pin::outState, p, port, portSize, Pin::PULLUP, Pin::TRISTATE, useAlternateDdr, useAlternatePort, and useAlternatePortIfDdrSet.

Referenced by Reset(), PinAtPort::SetAlternateDdr(), PinAtPort::SetAlternatePort(), PinAtPort::SetDdr(), SetDdr(), SetPin(), PinAtPort::SetPort(), SetPort(), PinAtPort::SetUseAlternateDdr(), PinAtPort::SetUseAlternatePort(), and PinAtPort::SetUseAlternatePortIfDdrSet().

Here is the call graph for this function:

Here is the caller graph for this function:

void HWPort::CalcPin ( void   )  [private]

calculating the value for register "pin" from the Pin p[] array

Definition at line 81 of file hwport.cpp.

References p, pin, and portSize.

Referenced by CalcOutputs().

Here is the caller graph for this function:

unsigned char HWPort::GetDdr ( void   )  [inline]

getter method for data direction register

Definition at line 85 of file hwport.h.

References ddr.

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

returns the port name as given in constructor

Definition at line 77 of file hwport.h.

References myName.

unsigned char HWPort::GetPin ( void   )  [inline]

getter method for PIN register

Definition at line 86 of file hwport.h.

References pin.

Pin & HWPort::GetPin ( unsigned char  pinNo  ) 
unsigned char HWPort::GetPort ( void   )  [inline]

getter method for port register

Definition at line 84 of file hwport.h.

References port.

int HWPort::GetPortSize ( void   )  [inline]

returns, how much bits this port controls

Definition at line 79 of file hwport.h.

References portSize.

Referenced by ExternalIRQPort::ExternalIRQPort().

Here is the caller graph for this function:

string HWPort::GetPortString ( void   ) 

returns a string representation of output states

Definition at line 129 of file hwport.cpp.

References p, and portSize.

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 61 of file hwport.cpp.

References alternateDdr, alternatePort, CalcOutputs(), ddr, pin, port, useAlternateDdr, useAlternatePort, and useAlternatePortIfDdrSet.

Referenced by HWPort().

Here is the call graph for this function:

Here is the caller graph for this function:

void HWPort::SetDdr ( unsigned char  val  )  [inline]

setter method for data direction register

Definition at line 82 of file hwport.h.

References CalcOutputs(), ddr, and portMask.

Referenced by AvrDevice_at90s8515::AvrDevice_at90s8515().

Here is the call graph for this function:

Here is the caller graph for this function:

void HWPort::SetPin ( unsigned char  val  ) 

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

Definition at line 139 of file hwport.cpp.

References avr_warning, CalcOutputs(), myName, port, and portToggleFeature.

Here is the call graph for this function:

void HWPort::SetPort ( unsigned char  val  )  [inline]

setter method for port register

Definition at line 81 of file hwport.h.

References CalcOutputs(), port, and portMask.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class PinAtPort [friend]

Definition at line 88 of file hwport.h.


Member Data Documentation

unsigned char HWPort::alternateDdr [protected]

data direction register for special functions

Definition at line 55 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetAlternateDdr(), Reset(), and PinAtPort::SetAlternateDdr().

unsigned char HWPort::alternatePort [protected]

output register for special functions

Definition at line 58 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetAlternatePort(), Reset(), and PinAtPort::SetAlternatePort().

unsigned char HWPort::ddr [protected]

data direction register

Definition at line 53 of file hwport.h.

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

std::string HWPort::myName [protected]

the "name" of the port

Definition at line 49 of file hwport.h.

Referenced by GetName(), and SetPin().

Pin HWPort::p[8] [protected]

the port pins, e.g. the final IO stages

Definition at line 65 of file hwport.h.

Referenced by CalcOutputs(), CalcPin(), PinAtPort::GetAnalog(), GetPin(), GetPortString(), and HWPort().

unsigned char HWPort::pin [protected]

port input register

Definition at line 52 of file hwport.h.

Referenced by CalcPin(), GetPin(), HWPort(), and Reset().

unsigned char HWPort::port [protected]

port output register

Definition at line 51 of file hwport.h.

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

unsigned char HWPort::portMask [protected]

mask out unused bits, if necessary

Definition at line 67 of file hwport.h.

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

int HWPort::portSize [protected]

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

Definition at line 66 of file hwport.h.

Referenced by CalcOutputs(), CalcPin(), GetPortSize(), GetPortString(), and HWPort().

bool HWPort::portToggleFeature [protected]

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

Definition at line 68 of file hwport.h.

Referenced by SetPin().

unsigned char HWPort::useAlternateDdr [protected]

bit mask, which bit in alternateDdr is used

Definition at line 56 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetUseAlterateDdr(), Reset(), and PinAtPort::SetUseAlternateDdr().

unsigned char HWPort::useAlternatePort [protected]

bit mask, which bit in alternatePort is used

Definition at line 59 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetUseAlternatePort(), Reset(), and PinAtPort::SetUseAlternatePort().

unsigned char HWPort::useAlternatePortIfDdrSet [protected]

special case for the ocr1a&b is selected on pin, which only be send to pin if ddr is set to output

Definition at line 63 of file hwport.h.

Referenced by CalcOutputs(), PinAtPort::GetUseAlternatePortIfDdrSet(), Reset(), and PinAtPort::SetUseAlternatePortIfDdrSet().


The documentation for this class was generated from the following files:
Generated on Sun Feb 12 16:51:43 2012 for Simulavr by  doxygen 1.6.3