From 02143ffd97cf0918e3d16dcb4e56f89bc39991ea Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 15 Nov 2018 19:21:39 -0500 Subject: [PATCH] i2c bus detection --- cw/cw_main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cw/cw_main.c b/cw/cw_main.c index e67ffd78..98ec7522 100644 --- a/cw/cw_main.c +++ b/cw/cw_main.c @@ -16,6 +16,9 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include //Needed for I2C port +#include //Needed for I2C port +#include //Needed for I2C port #include #include @@ -86,7 +89,18 @@ int main(void) tlm[i][j] = 0; } } - tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); + int file_i2c; + char *filenam1e = (char*)"/dev/i2c-3"; + if ((file_i2c = open(filenam1e, O_RDWR)) < 0) + { + printf("ERROR: /dev/ic2-3 bus not present\n"); + tempSensor = -1; + } else + { + tempSensor = wiringPiI2CSetupInterface("/dev/i2c-3", 0x48); + } + + printf("tempSensor: %d \n",tempSensor); // Configure SPI bus to AX5043 setSpiChannel(SPI_CHANNEL);