]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/libvbus/include/vbus_gpio
update
[l4.git] / l4 / pkg / libvbus / include / vbus_gpio
index 3af06d062922af68b99eefe30227a54f944ea19f..ded9733a4994dfa574b1226cbdde7bb33b45d764 100644 (file)
 
 namespace L4vbus {
 
+/**
+ * \brief A GPIO pin
+ * \ingroup l4vbus_gpio_module
+ *
+ */
 class Gpio_pin : public Device
 {
 public:
@@ -21,36 +26,74 @@ public:
   : Device(dev), _pin(pin)
   {}
 
+  /**
+   * \copydoc l4vbus_gpio_get()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
   int get() const
   {
     return l4vbus_gpio_get(_bus.cap(), _dev, _pin);
   }
 
+  /**
+   * \copydoc l4vbus_gpio_set()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
   int set(int value) const
   {
     return l4vbus_gpio_set(_bus.cap(), _dev, _pin, value);
   }
 
+  /**
+   * \copydoc l4vbus_gpio_setup()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
   int setup(unsigned mode, unsigned value) const
   {
     return l4vbus_gpio_setup(_bus.cap(), _dev, _pin, mode, value);
   }
 
+  /**
+   * \copydoc l4vbus_gpio_config_pull()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
+  int config_pull(unsigned mode) const
+  {
+    return l4vbus_gpio_config_pull(_bus.cap(), _dev, _pin, mode);
+  }
+
+  /**
+   * \copydoc l4vbus_gpio_config_pad()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
   int config_pad(unsigned func, unsigned value) const
   {
     return l4vbus_gpio_config_pad(_bus.cap(), _dev, _pin, func, value);
   }
 
+  /**
+   * \copydoc l4vbus_gpio_config_get()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
   int config_get(unsigned func, unsigned *value) const
   {
     return l4vbus_gpio_config_get(_bus.cap(), _dev, _pin, func, value);
   }
 
+  /**
+   * \copydoc l4vbus_gpio_to_irq()
+   * \note \a vbus, \a handle and \a pin are implicit
+   */
   int to_irq() const
   {
     return l4vbus_gpio_to_irq(_bus.cap(), _dev, _pin);
   }
 
+  /**
+   * \brief Get pin number
+   *
+   * \return GPIO pin number
+   */
   unsigned pin() const { return _pin; }
 
 protected:
@@ -58,6 +101,10 @@ protected:
   unsigned _pin;
 };
 
+/**
+ * \brief A Gpio_module groups multiple GPIO pins together
+ * \ingroup l4bus_gpio_module
+ */
 class Gpio_module : public Device
 {
 public:
@@ -65,26 +112,63 @@ public:
   : Device(dev)
   {}
 
-  int setup(unsigned mask, unsigned mode, unsigned value) const
+  /**
+   * \brief A slice of the pins provided by this module.
+   *
+   * Data type to specify a selection of pins for the 'multi'
+   * methods.
+   */
+  struct Pin_slice
+  {
+    Pin_slice(unsigned offset, unsigned mask) : offset(offset), mask(mask) {}
+    unsigned offset, mask;
+  };
+
+  /**
+   * \copydoc l4vbus_gpio_multi_setup()
+   * \note \a vbus and \a handle are implicit
+   */
+  int setup(Pin_slice const &mask, unsigned mode, unsigned value) const
   {
-    return l4vbus_gpio_multi_setup(_bus.cap(), _dev, mask, mode, value);
+    return l4vbus_gpio_multi_setup(_bus.cap(), _dev, mask.offset, mask.mask,
+                                   mode, value);
   }
 
-  int config_pad(unsigned mask, unsigned func, unsigned value) const
+  /**
+   * \copydoc l4vbus_gpio_multi_config_pad()
+   * \note \a vbus and \a handle are implicit
+   */
+  int config_pad(Pin_slice const &mask, unsigned func, unsigned value) const
   {
-    return l4vbus_gpio_multi_config_pad(_bus.cap(), _dev, mask, func, value);
+    return l4vbus_gpio_multi_config_pad(_bus.cap(), _dev, mask.offset,
+                                        mask.mask, func, value);
   }
 
-  int get(unsigned *data) const
+  /**
+   * \copydoc l4vbus_gpio_multi_get()
+   * \note \a vbus and \a handle are implicit
+   */
+  int get(unsigned offset, unsigned *data) const
   {
-    return l4vbus_gpio_multi_get(_bus.cap(), _dev, data);
+    return l4vbus_gpio_multi_get(_bus.cap(), _dev, offset, data);
   }
 
-  int set(unsigned mask, unsigned data)
+  /**
+   * \copydoc l4vbus_gpio_multi_set()
+   * \note \a vbus and \a handle are implicit
+   */
+  int set(Pin_slice const &mask, unsigned data)
   {
-    return l4vbus_gpio_multi_set(_bus.cap(), _dev, mask, data);
+    return l4vbus_gpio_multi_set(_bus.cap(), _dev, mask.offset,
+                                 mask.mask, data);
   }
 
+  /**
+   * \brief Get Gpio_pin for a specific pin of this Gpio_module
+   *
+   * \param pin GPIO pin number to get Gpio_pin for.
+   * \return    Gpio_pin
+   */
   Gpio_pin pin(unsigned pin) const
   {
     return Gpio_pin(*this, pin);