From f5c61232ee55fe7900b4af74b18f2904546cedee Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 30 Mar 2013 18:14:45 +0100 Subject: digital/ucoolib/ucoolib/hal/gpio: add don't care host GPIO To be used for GPIO without any simulation need. --- digital/ucoolib/ucoolib/hal/gpio/gpio.host.cc | 23 +++++++++++++++++------ digital/ucoolib/ucoolib/hal/gpio/gpio.host.hh | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'digital/ucoolib') 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. -- cgit v1.2.3