Defines a Port, e.g. a hardware device for GPIO. More...
#include <hwport.h>
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 | |
Pin & | GetPin (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< HWPort > | port_reg |
IOReg< HWPort > | pin_reg |
IOReg< HWPort > | ddr_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 |
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.
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().
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().
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().
unsigned char HWPort::GetDdr | ( | void | ) | [inline] |
std::string HWPort::GetName | ( | void | ) | [inline] |
unsigned char HWPort::GetPin | ( | void | ) | [inline] |
Pin & HWPort::GetPin | ( | unsigned char | pinNo | ) |
returns a pin reference of pin with pin number
Definition at line 77 of file hwport.cpp.
References p.
Referenced by AvrDevice_at90s4433::AvrDevice_at90s4433(), AvrDevice_atmega128::AvrDevice_atmega128(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega8::AvrDevice_atmega8(), ExternalIRQPort::ExternalIRQPort(), PinAtPort::GetPin(), and PinAtPort::operator bool().
unsigned char HWPort::GetPort | ( | void | ) | [inline] |
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().
string HWPort::GetPortString | ( | void | ) |
returns a string representation of output states
Definition at line 129 of file hwport.cpp.
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().
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().
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.
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.
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().
Definition at line 91 of file hwport.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_at90s4433::AvrDevice_at90s4433(), AvrDevice_at90s8515::AvrDevice_at90s8515(), AvrDevice_atmega128::AvrDevice_atmega128(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega668base::AvrDevice_atmega668base(), AvrDevice_atmega8::AvrDevice_atmega8(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
std::string HWPort::myName [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] |
Definition at line 91 of file hwport.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_at90s4433::AvrDevice_at90s4433(), AvrDevice_at90s8515::AvrDevice_at90s8515(), AvrDevice_atmega128::AvrDevice_atmega128(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega668base::AvrDevice_atmega668base(), AvrDevice_atmega8::AvrDevice_atmega8(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
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().
Definition at line 91 of file hwport.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_at90s4433::AvrDevice_at90s4433(), AvrDevice_at90s8515::AvrDevice_at90s8515(), AvrDevice_atmega128::AvrDevice_atmega128(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega668base::AvrDevice_atmega668base(), AvrDevice_atmega8::AvrDevice_atmega8(), AvrDevice_attiny2313::AvrDevice_attiny2313(), and PinAtPort::SetAlternatePort().
unsigned char HWPort::portMask [protected] |
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] |
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().