summaryrefslogtreecommitdiffhomepage
path: root/digital
diff options
context:
space:
mode:
Diffstat (limited to 'digital')
-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.