From d8e9ffba072ce61bdf527d3a1ab51a69bf13cd03 Mon Sep 17 00:00:00 2001 From: joerg65 Date: Fri, 21 Feb 2020 18:10:42 +0100 Subject: [PATCH] Added i2C support C1/C2 for mainline kernel --- wiringPi/wiringPiI2C.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wiringPi/wiringPiI2C.c b/wiringPi/wiringPiI2C.c index 312e13e..44d183d 100755 --- a/wiringPi/wiringPiI2C.c +++ b/wiringPi/wiringPiI2C.c @@ -53,7 +53,7 @@ #include #include #include - +#include #include "wiringPi.h" #include "wiringPiI2C.h" @@ -224,12 +224,17 @@ int wiringPiI2CSetup (const int devId) { int model, rev, mem, maker, overVolted ; const char *device = NULL; + struct stat buffer; piBoardId (&model, &rev, &mem, &maker, &overVolted) ; switch(model) { case MODEL_ODROID_C1: case MODEL_ODROID_C2: - device = "/dev/i2c-1"; + if (stat ("/dev/i2c-0", &buffer) == 0) { + device = "/dev/i2c-0"; + } else { + device = "/dev/i2c-1"; + } break; case MODEL_ODROID_XU3: case MODEL_ODROID_N1: