nuc5: Add i2c support for intel 5th generation NUC
[contrib/mraa.git] / src / x86 / x86.c
index 55de9d5..7c524c1 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "mraa_internal.h"
 #include "x86/intel_galileo_rev_d.h"
 #include "x86/intel_edison_fab_c.h"
 #include "x86/intel_de3815.h"
 #include "x86/intel_minnow_max.h"
+#include "x86/intel_nuc5.h"
 
 mraa_platform_t
 mraa_x86_platform()
 {
     mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
-    char *line = NULL;
+    charline = NULL;
     // let getline allocate memory for *line
     size_t len = 0;
-    FILE *fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
+    FILEfh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
     if (fh != NULL) {
         if (getline(&line, &len, fh) != -1) {
             if (strncmp(line, "GalileoGen2", 11) == 0) {
@@ -53,16 +55,21 @@ mraa_x86_platform()
             } else if (strncmp(line, "DE3815", 6) == 0) {
                 platform_type = MRAA_INTEL_DE3815;
                 plat = mraa_intel_de3815();
+            } else if (strncmp(line, "NUC5i5MYBE", 10) == 0 || strncmp(line, "NUC5i3MYBE", 10) == 0) {
+                platform_type = MRAA_INTEL_NUC5;
+                plat = mraa_intel_nuc5();
             } else if (strncmp(line, "NOTEBOOK", 8) == 0) {
                 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
                 plat = mraa_intel_minnow_max();
             } else if (strncasecmp(line, "MinnowBoard MAX", 15) == 0) {
                 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
                 plat = mraa_intel_minnow_max();
-            } else {
-                syslog(LOG_ERR, "Platform not supported, initialising as MRAA_INTEL_GALILEO_GEN1");
+            } else if (strncasecmp(line, "Galileo", 7) == 0) {
                 platform_type = MRAA_INTEL_GALILEO_GEN1;
                 plat = mraa_intel_galileo_rev_d();
+            } else {
+                syslog(LOG_ERR, "Platform not supported, not initialising");
+                platform_type = MRAA_UNKNOWN_PLATFORM;
             }
             free(line);
         }