summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/io/gpio_asserv.cc
diff options
context:
space:
mode:
Diffstat (limited to '2004/i/nono/src/io/gpio_asserv.cc')
-rw-r--r--2004/i/nono/src/io/gpio_asserv.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/2004/i/nono/src/io/gpio_asserv.cc b/2004/i/nono/src/io/gpio_asserv.cc
index de2256d..0438001 100644
--- a/2004/i/nono/src/io/gpio_asserv.cc
+++ b/2004/i/nono/src/io/gpio_asserv.cc
@@ -32,6 +32,17 @@ GpioAsserv::GpioAsserv (Asserv &asserv)
: outputs_ (0), asserv_ (asserv)
{
asserv_.setGpiDelay (3);
+ names_["b1"] = 1;
+ names_["b2"] = 2;
+ names_["b3"] = 3;
+ names_["b5"] = 5;
+ names_["b6"] = 6;
+ names_["d2"] = 2 + nbOutputs_;
+ names_["d3"] = 3 + nbOutputs_;
+ names_["d4"] = 4 + nbOutputs_;
+ names_["d5"] = 5 + nbOutputs_;
+ names_["d6"] = 6 + nbOutputs_;
+ names_["d7"] = 7 + nbOutputs_;
}
/// Destructeur.
@@ -50,8 +61,7 @@ GpioAsserv::set (int n, unsigned int bits, int nb)
mask <<= n;
bits <<= n;
outputs_ = (outputs_ & ~mask) | (bits & mask);
- unsigned int toSend = (outputs_ & 0x07) << 1 | (outputs_ & 0x18) << 2;
- asserv_.sendGpo (toSend);
+ asserv_.sendGpo (outputs_);
}
/// Lit plusieurs entrées.
@@ -60,9 +70,8 @@ GpioAsserv::get (int n, int nb)
{
if (n < nbOutputs_ || n + nb > nbOutputs_ + nbInputs_)
throw std::out_of_range ("GpioServoPp::get: Out of range.");
- unsigned int mask = 1 << (nb) - 1;
+ unsigned int mask = (1 << nb) - 1;
unsigned int recv = asserv_.getGpi ();
- recv = recv >> 2;
unsigned int bits = (recv >> (n - nbOutputs_)) & mask;
return bits;
}
@@ -74,3 +83,14 @@ GpioAsserv::getNbIo (void)
return nbOutputs_ + nbInputs_;
}
+/// Récupère une entrée/sortie par son nom.
+int
+GpioAsserv::getByName (const std::string &name) const
+{
+ Names::const_iterator i = names_.find (name);
+ if (i != names_.end ())
+ return i->second;
+ else
+ return -1;
+}
+