summaryrefslogtreecommitdiff
path: root/ucoolib
diff options
context:
space:
mode:
authorNicolas Schodet2013-03-30 18:14:45 +0100
committerNicolas Schodet2019-10-07 00:01:14 +0200
commitbfc8d8df4f3c406a36d78e94b590c7857d714621 (patch)
tree65c511fdc6ea1936a9a372a98e5e6c3e762f9907 /ucoolib
parent4785817b07b9acd17f4cede289729aa41c6a11b6 (diff)
ucoolib/hal/gpio: add don't care host GPIO
To be used for GPIO without any simulation need.
Diffstat (limited to 'ucoolib')
-rw-r--r--ucoolib/hal/gpio/gpio.host.cc23
-rw-r--r--ucoolib/hal/gpio/gpio.host.hh2
2 files changed, 19 insertions, 6 deletions
diff --git a/ucoolib/hal/gpio/gpio.host.cc b/ucoolib/hal/gpio/gpio.host.cc
index 64ed7cb..e67efcc 100644
--- a/ucoolib/hal/gpio/gpio.host.cc
+++ b/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/ucoolib/hal/gpio/gpio.host.hh b/ucoolib/hal/gpio/gpio.host.hh
index 5e79679..27fd51d 100644
--- a/ucoolib/hal/gpio/gpio.host.hh
+++ b/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.