[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Simulavr-devel] [PATCH 07/13] Allow for data direction register (DDR) d
From: |
Onno Kortmann |
Subject: |
[Simulavr-devel] [PATCH 07/13] Allow for data direction register (DDR) default on HWPorts |
Date: |
Tue, 3 Mar 2009 23:46:14 +0100 |
Some devices have DDR!=0x00 after reset (e.g. mega103).
This allows an optional third 'default_ddr' argument
to the constructor of HWPort.
Signed-off-by: Onno Kortmann <address@hidden>
---
src/hwport.cpp | 6 ++++--
src/hwport.h | 8 +++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/hwport.cpp b/src/hwport.cpp
index 883d714..25c94d7 100644
--- a/src/hwport.cpp
+++ b/src/hwport.cpp
@@ -29,7 +29,9 @@ using namespace std;
#include "trace.h"
-HWPort::HWPort(AvrDevice *core, const string
&name):Hardware(core),myName(name) {
+HWPort::HWPort(AvrDevice *core,
+ const string &name,
+ const unsigned char def_ddr):Hardware(core),myName(name),
default_ddr(def_ddr) {
Reset();
for (int tt=0; tt<8; tt++) {
string dummy=name+(char)('0'+tt);
@@ -43,7 +45,7 @@ HWPort::HWPort(AvrDevice *core, const string
&name):Hardware(core),myName(name)
void HWPort::Reset() {
port=0;
pin=0;
- ddr=0;
+ default_ddr=0;
alternateDdr=0;
useAlternateDdr=0;
diff --git a/src/hwport.h b/src/hwport.h
index c555eac..f00aab7 100644
--- a/src/hwport.h
+++ b/src/hwport.h
@@ -50,6 +50,8 @@ class HWPort: public Hardware {
//which only be send to pin if ddr is set to output
Pin p[8];
+ unsigned char default_ddr;
+
public:
void CalcOutputs(); //Calculate the new output value to be
transmitted to the environment
string GetPortString();
@@ -61,7 +63,11 @@ class HWPort: public Hardware {
public:
- HWPort(AvrDevice *core, const string &name);
+ //! Create port hardware.
+ /*! \param def_ddr: defines the default value of DDR after
+ initialization. Used to support output-only ports such as on the
+ ATMEGA103 (PORTC). */
+ HWPort(AvrDevice *core, const string &name, unsigned char
def_ddr=0x00);
void Reset();
void SetPort(unsigned char val) { port=val; CalcOutputs();}
void SetDdr(unsigned char val) { ddr=val;CalcOutputs();}
--
1.5.6.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Simulavr-devel] [PATCH 07/13] Allow for data direction register (DDR) default on HWPorts,
Onno Kortmann <=