pinmap: Defining pindata structures
authorThomas Ingleby <thomas.c.ingleby@intel.com>
Tue, 29 Apr 2014 14:01:24 +0000 (15:01 +0100)
committerThomas Ingleby <thomas.c.ingleby@intel.com>
Wed, 30 Apr 2014 08:30:59 +0000 (09:30 +0100)
* Logic for setting up required multiplexers

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
api/maa.h
src/maa.c

index fe4dd86..67f0248 100644 (file)
--- a/api/maa.h
+++ b/api/maa.h
@@ -49,6 +49,37 @@ typedef enum {
     MAA_ERROR_UNSPECIFIED                    = 99
 } maa_result_t;
 
+typedef unsigned int maa_boolean_t;
+
+typedef union {
+    struct {
+        maa_boolean_t valid:1;
+        maa_boolean_t gpio:1;
+        maa_boolean_t pwm:1;
+        maa_boolean_t fast_gpio:1;
+        maa_boolean_t spi:1;
+        maa_boolean_t i2c:1;
+    };
+    int raw;
+} maa_pincapabilities_t;
+
+typedef struct {
+    unsigned int pin;
+    unsigned int value;
+} maa_mux_t;
+
+typedef struct {
+    char name[8];// do we need this
+    unsigned int pin;
+    int parent_id;
+    maa_pincapabilities_t capabilites;
+    maa_mux_t mux[4];
+    unsigned int mux_total;
+} maa_pininfo;
+
+unsigned int maa_check_gpio(int pin);
+unsigned int maa_check_aio(int pin);
+
 /** Get the version string of maa autogenerated from git tag
  *
  * The version returned may not be what is expected however it is a reliable
index d2c0acd..8301017 100644 (file)
--- a/src/maa.c
+++ b/src/maa.c
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <stddef.h>
+
 #include "maa.h"
+#include "gpio.h"
 #include "version.h"
 
+static maa_pininfo* pindata;
+
 const char *
 maa_get_version()
 {
     return gVERSION;
 }
+
+maa_result_t
+maa_init()
+{
+    return MAA_ERROR_FEATURE_NOT_IMPLEMENTED;
+}
+
+unsigned int
+maa_check_gpio(int pin){
+
+    if(pindata == NULL) {
+        return -1;
+    }
+    //Check in gpio bounds?
+    if(pindata[pin].mux_total > 0) {
+        int mi;
+        for(mi = 0; mi < pindata[pin].mux_total; mi++) {
+            //Do we want to keep the gpio object around
+            //I dont think so
+            maa_gpio_context* mux_i;
+            //TODO CHANGE TO RAW
+            mux_i = maa_gpio_init(pindata[pin].mux[mi].pin);
+            maa_gpio_dir(mux_i, "out");
+            maa_gpio_write(mux_i, pindata[pin].mux[mi].value);
+        }
+    }
+    return pindata[pin].pin
+}
+