From 157bb65054442bc0a72b0ffbb61ae20c96a6f97e Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Fri, 17 Mar 2017 10:01:35 +0800 Subject: [PATCH 1/2] Added support to secondary I2C interfaces --- i2cdetect.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/i2cdetect.h b/i2cdetect.h index 6bd99f6..fe96dd8 100644 --- a/i2cdetect.h +++ b/i2cdetect.h @@ -1,8 +1,12 @@ +/* +i2cdetect.h - Arduino library for scanning I2C bus for devices +*/ #ifndef __I2CDETECT_H_ #define __I2CDETECT_H_ -void i2cdetect(uint8_t first, uint8_t last); -void i2cdetect(); +#include + +void i2cdetect(TwoWire &wire = Wire, uint8_t first = 0x03, uint8_t last = 0x77); #endif From ec9d1c45ab80d84c140201949a3cead2aa49d63d Mon Sep 17 00:00:00 2001 From: Maxthon Chan Date: Fri, 17 Mar 2017 10:03:02 +0800 Subject: [PATCH 2/2] Added support for secondary I2C interfaces --- i2cdetect.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i2cdetect.cpp b/i2cdetect.cpp index a933781..43def84 100644 --- a/i2cdetect.cpp +++ b/i2cdetect.cpp @@ -21,7 +21,7 @@ void _printf(const char *format, ...) va_end(ap); } -void i2cdetect(uint8_t first, uint8_t last) { +void i2cdetect(TwoWire &wire, uint8_t first, uint8_t last) { uint8_t i, j, address, error; // header @@ -36,8 +36,8 @@ void i2cdetect(uint8_t first, uint8_t last) { for (i = 0; i < 16; i++) { address = i + j*16; if (address >= first && address <= last) { - Wire.beginTransmission(address); - error = Wire.endTransmission(); + wire.beginTransmission(address); + error = wire.endTransmission(); if (error) { Serial.print(" --"); } else {