summaryrefslogtreecommitdiff
path: root/digital/ucoolib
diff options
context:
space:
mode:
authorNicolas Schodet2013-03-30 18:14:45 +0100
committerNicolas Schodet2013-03-30 18:14:45 +0100
commitf5c61232ee55fe7900b4af74b18f2904546cedee (patch)
treee71f84f66ae29bab53ad0f41913f75a6efa6f919 /digital/ucoolib
parentcbbc2f88c13ab4f49be0640afc2723b8927f821d (diff)
digital/ucoolib/ucoolib/hal/gpio: add don't care host GPIO
To be used for GPIO without any simulation need.
Diffstat (limited to 'digital/ucoolib')
-rw-r--r--digital/ucoolib/ucoolib/hal/gpio/gpio.host.cc23
-rw-r--r--digital/ucoolib/ucoolib/hal/gpio/gpio.host.hh2
2 files changed, 19 insertions, 6 deletions
diff --git a/digital/ucoolib/ucoolib/hal/gpio/gpio.host.cc b/digital/ucoolib/ucoolib/hal/gpio/gpio.host.cc
index 64ed7cb8..e67efcc8 100644
--- a/digital/ucoolib/ucoolib/hal/gpio/gpio.host.cc
+++ b/digital/ucoolib/ucoolib/hal/gpio/gpio.host.cc
@@ -125,28 +125,37 @@ Gpio::Gpio (Host &host, const char *name)
shared_->register_instance (host, *this);
}
+Gpio::Gpio ()
+ : name_ (0), input_ (false), output_ (false), direction_output_ (false)
+{
+}
+
void
Gpio::set ()
{
- shared_->set (*this, true);
+ if (name_)
+ shared_->set (*this, true);
}
void
Gpio::reset ()
{
- shared_->set (*this, false);
+ if (name_)
+ shared_->set (*this, false);
}
void
Gpio::set (bool state)
{
- shared_->set (*this, state);
+ if (name_)
+ shared_->set (*this, state);
}
void
Gpio::toggle ()
{
- shared_->set (*this, !output_);
+ if (name_)
+ shared_->set (*this, !output_);
}
bool
@@ -158,13 +167,15 @@ Gpio::get () const
void
Gpio::input ()
{
- shared_->output (*this, false);
+ if (name_)
+ shared_->output (*this, false);
}
void
Gpio::output ()
{
- shared_->output (*this, true);
+ if (name_)
+ shared_->output (*this, true);
}
} // namespace ucoo
diff --git a/digital/ucoolib/ucoolib/hal/gpio/gpio.host.hh b/digital/ucoolib/ucoolib/hal/gpio/gpio.host.hh
index 5e796797..27fd51d8 100644
--- a/digital/ucoolib/ucoolib/hal/gpio/gpio.host.hh
+++ b/digital/ucoolib/ucoolib/hal/gpio/gpio.host.hh
@@ -36,6 +36,8 @@ class Gpio : public Io
public:
/// Initialise GPIO.
Gpio (Host &host, const char *name);
+ /// Initialise GPIO, with no mex support.
+ Gpio ();
/// See Io::set.
void set ();
/// See Io::reset.