0.1.15 MultiSpeedI2CScanner

This commit is contained in:
rob tillaart 2021-12-22 13:02:30 +01:00
parent 65a4d58fb9
commit e764caa61b
10 changed files with 243 additions and 85 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms # Choosing to run compilation tests on 2 different Arduino platforms
platforms: platforms:
- uno - uno
- leonardo
- due - due
- zero - zero
- leonardo
- m4
- esp32
- esp8266
- mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
arduino_ci: runTest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: Arduino-CI/action@master - uses: ruby/setup-ruby@v1
# Arduino-CI/action@v0.1.1 with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2013-2021 Rob Tillaart Copyright (c) 2013-2022 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,19 +1,20 @@
// //
// FILE: MultiSpeedI2CScanner.ino // FILE: MultiSpeedI2CScanner.ino
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.1.13 // VERSION: 0.1.15
// PURPOSE: I2C scanner at different speeds // PURPOSE: I2C scanner at different speeds
// DATE: 2013-11-05 // DATE: 2013-11-05
// URL: https://github.com/RobTillaart/MultiSpeedI2CScanner // URL: https://github.com/RobTillaart/MultiSpeedI2CScanner
// URL: http://forum.arduino.cc/index.php?topic=197360 // URL: http://forum.arduino.cc/index.php?topic=197360
// //
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h> #include <Wire.h>
TwoWire *wi; TwoWire *wire;
const char version[] = "0.1.13"; const char version[] = "0.1.15";
// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY) // INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY)
@ -21,7 +22,7 @@ int wirePortCount = 1;
int selectedWirePort = 0; int selectedWirePort = 0;
// scans devices from 50 to 800KHz I2C speeds. // scans devices from 50 to 800 KHz I2C speeds.
// speed lower than 50 and above 400 can cause problems // speed lower than 50 and above 400 can cause problems
long speed[10] = { 100, 200, 300, 400 }; long speed[10] = { 100, 200, 300, 400 };
int speeds; int speeds;
@ -65,8 +66,8 @@ void setup()
Serial.begin(115200); Serial.begin(115200);
#if defined (ESP8266) || defined(ESP32) #if defined (ESP8266) || defined(ESP32)
uint8_t sda = 21; uint8_t sda = 14; // 21
uint8_t scl = 22; uint8_t scl = 15; // 22
Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed. Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed.
#else #else
Wire.begin(); Wire.begin();
@ -84,8 +85,16 @@ void setup()
Wire3.begin(); Wire3.begin();
wirePortCount++; wirePortCount++;
#endif #endif
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
Wire4.begin();
wirePortCount++;
#endif
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
Wire5.begin();
wirePortCount++;
#endif
wi = &Wire; wire = &Wire;
Serial.println(); Serial.println();
setSpeed('9'); setSpeed('9');
@ -107,21 +116,31 @@ void loop()
switch (selectedWirePort) switch (selectedWirePort)
{ {
case 0: case 0:
wi = &Wire; wire = &Wire;
break; break;
#if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1 #if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1
case 1: case 1:
wi = &Wire1; wire = &Wire1;
break; break;
#endif #endif
#if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2 #if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2
case 2: case 2:
wi = &Wire2; wire = &Wire2;
break; break;
#endif #endif
#if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3 #if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3
case 3: case 3:
wi = &Wire3; wire = &Wire3;
break;
#endif
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
case 4:
wire = &Wire4;
break;
#endif
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
case 5:
wire = &Wire5;
break; break;
#endif #endif
} }
@ -247,11 +266,11 @@ void setSpeed(char sp)
speed[0] = 800; speed[0] = 800;
speeds = 1; speeds = 1;
break; break;
case '9': // limited to 400KHz case '9': // limited to 400 KHz
speeds = 8; speeds = 8;
for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 50; for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 50;
break; break;
case '0': // limited to 800KHz case '0': // limited to 800 KHz
speeds = 8; speeds = 8;
for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 100; for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 100;
break; break;
@ -308,7 +327,7 @@ void displayHelp()
Serial.print(wirePortCount); Serial.print(wirePortCount);
Serial.print(F(" Current: Wire")); Serial.print(F(" Current: Wire"));
Serial.println(selectedWirePort); Serial.println(selectedWirePort);
Serial.println(F("\t@ = toggle Wire - Wire1 - Wire2 [TEENSY 3.5 or Arduino Due]")); Serial.println(F("\t@ = toggle Wire - Wire1 .. Wire5 [e.g. TEENSY or Arduino Due]"));
Serial.println(F("Scan mode:")); Serial.println(F("Scan mode:"));
Serial.println(F("\ts = single scan")); Serial.println(F("\ts = single scan"));
@ -323,18 +342,18 @@ void displayHelp()
Serial.println(F("\ta = toggle address range, 0..127 - 8..119 (default)")); Serial.println(F("\ta = toggle address range, 0..127 - 8..119 (default)"));
Serial.println(F("Speeds:")); Serial.println(F("Speeds:"));
Serial.println(F("\t0 = 100..800 Khz - step 100 (warning - can block!!)")); Serial.println(F("\t0 = 100..800 KHz - step 100 (warning - can block!!)"));
Serial.println(F("\t1 = 100 KHz")); Serial.println(F("\t1 = 100 KHz"));
Serial.println(F("\t2 = 200 KHz")); Serial.println(F("\t2 = 200 KHz"));
Serial.println(F("\t4 = 400 KHz")); Serial.println(F("\t4 = 400 KHz"));
Serial.println(F("\t9 = 50..400 Khz - step 50 < DEFAULT >")); Serial.println(F("\t9 = 50..400 KHz - step 50 < DEFAULT >"));
Serial.println(); Serial.println();
Serial.println(F("\t!! HIGH SPEEDS - WARNING - can block - not applicable for UNO")); Serial.println(F("\t!! HIGH SPEEDS - WARNING - can block - not applicable for UNO"));
Serial.println(F("\t8 = 800 KHz")); Serial.println(F("\t8 = 800 KHz"));
Serial.println(F("\tM = 1000 KHz")); Serial.println(F("\tM = 1000 KHz"));
Serial.println(F("\tN = 3400 KHz")); Serial.println(F("\tN = 3400 KHz"));
Serial.println(F("\tO = 5000 Khz")); Serial.println(F("\tO = 5000 KHz"));
Serial.println(F("\tP = 100 400 1000 3400 5000 Khz (standards)")); Serial.println(F("\tP = 100 400 1000 3400 5000 KHz (standards)"));
Serial.println(F("\n\t? = help - this page")); Serial.println(F("\n\t? = help - this page"));
Serial.println(); Serial.println();
} }
@ -361,6 +380,7 @@ void I2Cscan()
Serial.print(F("--------")); Serial.print(F("--------"));
} }
Serial.println(); Serial.println();
delay(100);
} }
for (uint8_t address = addressStart; address <= addressEnd; address++) for (uint8_t address = addressStart; address <= addressEnd; address++)
@ -371,7 +391,7 @@ void I2Cscan()
for (uint8_t s = 0; s < speeds ; s++) for (uint8_t s = 0; s < speeds ; s++)
{ {
yield(); // keep ESP happy yield(); // keep ESP happy
#if ARDUINO < 158 && defined (TWBR) #if ARDUINO < 158 && defined (TWBR)
uint16_t PREV_TWBR = TWBR; uint16_t PREV_TWBR = TWBR;
@ -380,13 +400,13 @@ void I2Cscan()
{ {
Serial.println("ERROR: not supported speed"); Serial.println("ERROR: not supported speed");
TWBR = PREV_TWBR; TWBR = PREV_TWBR;
return; return;
} }
#else #else
wi->setClock(speed[s] * 1000UL); wire->setClock(speed[s] * 1000UL);
#endif #endif
wi->beginTransmission (address); wire->beginTransmission (address);
found[s] = (wi->endTransmission () == 0); found[s] = (wire->endTransmission () == 0);
fnd |= found[s]; fnd |= found[s];
// give device 5 millis // give device 5 millis
if (fnd && delayFlag) delay(RESTORE_LATENCY); if (fnd && delayFlag) delay(RESTORE_LATENCY);
@ -423,8 +443,10 @@ void I2Cscan()
Serial.print(stopScan - startScan); Serial.print(stopScan - startScan);
Serial.println(F(" milliseconds.")); Serial.println(F(" milliseconds."));
} }
interrupts(); interrupts();
} }
// -- END OF FILE -- // -- END OF FILE --

View File

@ -1,12 +1,16 @@
[![Arduino CI](https://github.com/RobTillaart/MultiSpeedI2CScanner/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino CI](https://github.com/RobTillaart/MultiSpeedI2CScanner/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MultiSpeedI2CScanner/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MultiSpeedI2CScanner/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/MultiSpeedI2CScanner/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MultiSpeedI2CScanner/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MultiSpeedI2CScanner/blob/master/LICENSE) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MultiSpeedI2CScanner/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MultiSpeedI2CScanner.svg?maxAge=3600)](https://github.com/RobTillaart/MultiSpeedI2CScanner/releases) [![GitHub release](https://img.shields.io/github/release/RobTillaart/MultiSpeedI2CScanner.svg?maxAge=3600)](https://github.com/RobTillaart/MultiSpeedI2CScanner/releases)
# Arduino MultiSpeed I2C Scanner # Arduino MultiSpeed I2C Scanner
## Version: 0.1.13
## Version: 0.1.15
## Description ## Description
@ -17,12 +21,13 @@ The scanner provides an overview of which addresses can be found
at which speed. This allows one to optimize the I2C performance of at which speed. This allows one to optimize the I2C performance of
many devices above the standard 100KHz speed. many devices above the standard 100KHz speed.
## Menu dialog ## Menu dialog
``` ```
<speeds = 50 100 150 200 250 300 350 400 > <speeds = 50 100 150 200 250 300 350 400 >
Arduino MultiSpeed I2C Scanner - 0.1.13 Arduino MultiSpeed I2C Scanner - 0.1.15
I2C ports: 1 Current: Wire0 I2C ports: 1 Current: Wire0
@ = toggle Wire - Wire1 - Wire2 [TEENSY 3.5 or Arduino Due] @ = toggle Wire - Wire1 - Wire2 [TEENSY 3.5 or Arduino Due]
@ -37,22 +42,23 @@ Output:
h = toggle header - noHeader. h = toggle header - noHeader.
a = toggle address range, 0..127 - 8..119 (default) a = toggle address range, 0..127 - 8..119 (default)
Speeds: Speeds:
0 = 100..800 Khz - step 100 (warning - can block!!) 0 = 100..800 KHz - step 100 (warning - can block!!)
1 = 100 KHz 1 = 100 KHz
2 = 200 KHz 2 = 200 KHz
4 = 400 KHz 4 = 400 KHz
9 = 50..400 Khz - step 50 < DEFAULT > 9 = 50..400 KHz - step 50 < DEFAULT >
!! HIGH SPEEDS - WARNING - can block - not applicable for UNO !! HIGH SPEEDS - WARNING - can block - not applicable for UNO
8 = 800 KHz 8 = 800 KHz
M = 1000 KHz M = 1000 KHz
N = 3400 KHz N = 3400 KHz
O = 5000 Khz O = 5000 KHz
P = 100 400 1000 3400 5000 Khz (standards) P = 100 400 1000 3400 5000 KHz (standards)
? = help - this page ? = help - this page
``` ```
## Functions ## Functions
### I2C ports ### I2C ports
@ -74,6 +80,7 @@ Only needed sometimes.
**i** toggles disable/enable interrupts, use with care. **i** toggles disable/enable interrupts, use with care.
### Output selection ### Output selection
**p** toggles printAll and printFound. **p** toggles printAll and printFound.
@ -85,6 +92,7 @@ PrintFound will only generate a line if an I2C device is found on that address.
**a** toggles the range of addresses scanned, default the range 8 .. 119 is scanned, **a** toggles the range of addresses scanned, default the range 8 .. 119 is scanned,
but one can extend this range to 0 .. 127. **Note:** some addresses are reserved. but one can extend this range to 0 .. 127. **Note:** some addresses are reserved.
### Speeds ### Speeds
All options here select a single speed or a range of speeds. All options here select a single speed or a range of speeds.
@ -97,3 +105,11 @@ NOTE: not all processors will support these higher speeds.
This can show up as blocking or it can even look like it is working. This can show up as blocking or it can even look like it is working.
Check your datasheet to see which speeds are applicable for the processor in use. Check your datasheet to see which speeds are applicable for the processor in use.
## Future
- add watchdog reset (at least AVR - 8 seconds 0.2.0 )
- create an I2CScanner class
- r = reset (defaults)
- non-AVR command behind a ```#ifdef``` ?

View File

@ -0,0 +1,62 @@
//
// FILE: I2C_bus_counter.ino
// AUTHOR: Rob Tillaart
// PURPOSE: I2C bus counter
// DATE: 2021-11-10
// URL: https://github.com/RobTillaart/MultiSpeedI2CScanner
// URL: http://forum.arduino.cc/index.php?topic=197360
#include <Arduino.h>
#include <Wire.h>
const char version[] = "0.1.0";
int wirePortCount = 1;
///////////////////////////////////////////////////
//
// MAIN CODE
//
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.print(__FILE__);
Serial.print("\t");
Serial.println(version);
delay(1000);
#if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1
Wire1.begin();
wirePortCount++;
#endif
#if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2
Wire2.begin();
wirePortCount++;
#endif
#if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3
Wire3.begin();
wirePortCount++;
#endif
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
Wire4.begin();
wirePortCount++;
#endif
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
Wire5.begin();
wirePortCount++;
#endif
Serial.print("I2C bus count: ");
Serial.println(wirePortCount);
}
void loop()
{
}
// -- END OF FILE --

View File

@ -1,19 +1,20 @@
// //
// FILE: MultiSpeedI2CScanner.ino // FILE: MultiSpeedI2CScanner.ino
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.1.13 // VERSION: 0.1.15
// PURPOSE: I2C scanner at different speeds // PURPOSE: I2C scanner at different speeds
// DATE: 2013-11-05 // DATE: 2013-11-05
// URL: https://github.com/RobTillaart/MultiSpeedI2CScanner // URL: https://github.com/RobTillaart/MultiSpeedI2CScanner
// URL: http://forum.arduino.cc/index.php?topic=197360 // URL: http://forum.arduino.cc/index.php?topic=197360
// //
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h> #include <Wire.h>
TwoWire *wi; TwoWire *wire;
const char version[] = "0.1.13"; const char version[] = "0.1.15";
// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY) // INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY)
@ -21,7 +22,7 @@ int wirePortCount = 1;
int selectedWirePort = 0; int selectedWirePort = 0;
// scans devices from 50 to 800KHz I2C speeds. // scans devices from 50 to 800 KHz I2C speeds.
// speed lower than 50 and above 400 can cause problems // speed lower than 50 and above 400 can cause problems
long speed[10] = { 100, 200, 300, 400 }; long speed[10] = { 100, 200, 300, 400 };
int speeds; int speeds;
@ -65,8 +66,8 @@ void setup()
Serial.begin(115200); Serial.begin(115200);
#if defined (ESP8266) || defined(ESP32) #if defined (ESP8266) || defined(ESP32)
uint8_t sda = 21; uint8_t sda = 14; // 21
uint8_t scl = 22; uint8_t scl = 15; // 22
Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed. Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed.
#else #else
Wire.begin(); Wire.begin();
@ -84,8 +85,16 @@ void setup()
Wire3.begin(); Wire3.begin();
wirePortCount++; wirePortCount++;
#endif #endif
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
Wire4.begin();
wirePortCount++;
#endif
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
Wire5.begin();
wirePortCount++;
#endif
wi = &Wire; wire = &Wire;
Serial.println(); Serial.println();
setSpeed('9'); setSpeed('9');
@ -107,21 +116,31 @@ void loop()
switch (selectedWirePort) switch (selectedWirePort)
{ {
case 0: case 0:
wi = &Wire; wire = &Wire;
break; break;
#if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1 #if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1
case 1: case 1:
wi = &Wire1; wire = &Wire1;
break; break;
#endif #endif
#if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2 #if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2
case 2: case 2:
wi = &Wire2; wire = &Wire2;
break; break;
#endif #endif
#if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3 #if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3
case 3: case 3:
wi = &Wire3; wire = &Wire3;
break;
#endif
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
case 4:
wire = &Wire4;
break;
#endif
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
case 5:
wire = &Wire5;
break; break;
#endif #endif
} }
@ -247,11 +266,11 @@ void setSpeed(char sp)
speed[0] = 800; speed[0] = 800;
speeds = 1; speeds = 1;
break; break;
case '9': // limited to 400KHz case '9': // limited to 400 KHz
speeds = 8; speeds = 8;
for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 50; for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 50;
break; break;
case '0': // limited to 800KHz case '0': // limited to 800 KHz
speeds = 8; speeds = 8;
for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 100; for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 100;
break; break;
@ -308,7 +327,7 @@ void displayHelp()
Serial.print(wirePortCount); Serial.print(wirePortCount);
Serial.print(F(" Current: Wire")); Serial.print(F(" Current: Wire"));
Serial.println(selectedWirePort); Serial.println(selectedWirePort);
Serial.println(F("\t@ = toggle Wire - Wire1 - Wire2 [TEENSY 3.5 or Arduino Due]")); Serial.println(F("\t@ = toggle Wire - Wire1 .. Wire5 [e.g. TEENSY or Arduino Due]"));
Serial.println(F("Scan mode:")); Serial.println(F("Scan mode:"));
Serial.println(F("\ts = single scan")); Serial.println(F("\ts = single scan"));
@ -323,18 +342,18 @@ void displayHelp()
Serial.println(F("\ta = toggle address range, 0..127 - 8..119 (default)")); Serial.println(F("\ta = toggle address range, 0..127 - 8..119 (default)"));
Serial.println(F("Speeds:")); Serial.println(F("Speeds:"));
Serial.println(F("\t0 = 100..800 Khz - step 100 (warning - can block!!)")); Serial.println(F("\t0 = 100..800 KHz - step 100 (warning - can block!!)"));
Serial.println(F("\t1 = 100 KHz")); Serial.println(F("\t1 = 100 KHz"));
Serial.println(F("\t2 = 200 KHz")); Serial.println(F("\t2 = 200 KHz"));
Serial.println(F("\t4 = 400 KHz")); Serial.println(F("\t4 = 400 KHz"));
Serial.println(F("\t9 = 50..400 Khz - step 50 < DEFAULT >")); Serial.println(F("\t9 = 50..400 KHz - step 50 < DEFAULT >"));
Serial.println(); Serial.println();
Serial.println(F("\t!! HIGH SPEEDS - WARNING - can block - not applicable for UNO")); Serial.println(F("\t!! HIGH SPEEDS - WARNING - can block - not applicable for UNO"));
Serial.println(F("\t8 = 800 KHz")); Serial.println(F("\t8 = 800 KHz"));
Serial.println(F("\tM = 1000 KHz")); Serial.println(F("\tM = 1000 KHz"));
Serial.println(F("\tN = 3400 KHz")); Serial.println(F("\tN = 3400 KHz"));
Serial.println(F("\tO = 5000 Khz")); Serial.println(F("\tO = 5000 KHz"));
Serial.println(F("\tP = 100 400 1000 3400 5000 Khz (standards)")); Serial.println(F("\tP = 100 400 1000 3400 5000 KHz (standards)"));
Serial.println(F("\n\t? = help - this page")); Serial.println(F("\n\t? = help - this page"));
Serial.println(); Serial.println();
} }
@ -361,6 +380,7 @@ void I2Cscan()
Serial.print(F("--------")); Serial.print(F("--------"));
} }
Serial.println(); Serial.println();
delay(100);
} }
for (uint8_t address = addressStart; address <= addressEnd; address++) for (uint8_t address = addressStart; address <= addressEnd; address++)
@ -371,7 +391,7 @@ void I2Cscan()
for (uint8_t s = 0; s < speeds ; s++) for (uint8_t s = 0; s < speeds ; s++)
{ {
yield(); // keep ESP happy yield(); // keep ESP happy
#if ARDUINO < 158 && defined (TWBR) #if ARDUINO < 158 && defined (TWBR)
uint16_t PREV_TWBR = TWBR; uint16_t PREV_TWBR = TWBR;
@ -380,13 +400,13 @@ void I2Cscan()
{ {
Serial.println("ERROR: not supported speed"); Serial.println("ERROR: not supported speed");
TWBR = PREV_TWBR; TWBR = PREV_TWBR;
return; return;
} }
#else #else
wi->setClock(speed[s] * 1000UL); wire->setClock(speed[s] * 1000UL);
#endif #endif
wi->beginTransmission (address); wire->beginTransmission (address);
found[s] = (wi->endTransmission () == 0); found[s] = (wire->endTransmission () == 0);
fnd |= found[s]; fnd |= found[s];
// give device 5 millis // give device 5 millis
if (fnd && delayFlag) delay(RESTORE_LATENCY); if (fnd && delayFlag) delay(RESTORE_LATENCY);
@ -423,8 +443,10 @@ void I2Cscan()
Serial.print(stopScan - startScan); Serial.print(stopScan - startScan);
Serial.println(F(" milliseconds.")); Serial.println(F(" milliseconds."));
} }
interrupts(); interrupts();
} }
// -- END OF FILE -- // -- END OF FILE --

View File

@ -6,5 +6,5 @@ It is placed here to give Arduino-CI something to compile.
On the long term an I2C scanner class should be made which On the long term an I2C scanner class should be made which
will have this application as an example. will have this application as an example.
As teh application os working rather well this has no urgency As the application is working rather well this has no urgency
or priority. or priority.

View File

@ -1,65 +1,89 @@
# Release Notes # Release Notes
MultiSpeedI2CScanner MultiSpeedI2CScanner
https://github.com/RobTillaart/MultiSpeedI2CScanner
## Version ## Version
0.1.13 0.1.15
### 0.1.15 2021-12-22
- change Khz =>KHz
- update license
### 0.1.14 2021-11-10
- update Arduino-CI build process
- add badges to readme.md
- updated readme.md
- support up to 5 Wire buses
- added an I2C bus counter sketch (very minimal)
- minor edits release notes.
### 0.1.13 2020-12-12 ### 0.1.13 2020-12-12
Add arduino-ci build process. - Add Arduino-CI build process.
Added a dummy examples folder with the same .ino source. - Added a dummy examples folder with the same .ino source.
This shows that the sketch compiles well. - This shows that the sketch compiles well.
### 0.1.12 2020-12-12 ### 0.1.12 2020-12-12
FIx #4, default address range = 08...119 (0-7 and 120-127 are special) - Fix #4, default address range = 08...119 (0-7 and 120-127 are special)
### 0.1.11 2018-07-20 ### 0.1.11 2018-07-20
+ Fix failing TWBR setting - Fix failing TWBR setting
+ added yield() during scan to improve ESP behavior. - added yield() during scan to improve ESP behaviour.
+ added disable interrupts flag - added disable interrupts flag
+ refactor / cleanup - refactor / clean up
### 0.1.10 2018-04-02 ### 0.1.10 2018-04-02
+ Fix #152 - Fix #152
+ improved support for ESP32 - improved support for ESP32
+ changed multispeed ranges a bit (option 0 and 9) - changed multispeed ranges a bit (option 0 and 9)
+ refactor - refactor
+ added experimental high speeds 1000, 3400, 5000 KHz. - added experimental high speeds 1000, 3400, 5000 KHz.
verified on UNO and ESP32, verified on UNO and ESP32,
note the latter one must adjust the pins in the code. note the latter one must adjust the pins in the code.
### 0.1.9 2018-04-02 ### 0.1.9 2018-04-02
+ '9' command to scan up to 400 KHz only to prevent blocking - '9' command to scan up to 400 KHz only to prevent blocking
+ changed "scan up to 400 KHz" as default at startup - changed "scan up to 400 KHz" as default at startup
### 0.1.8 2017-08-03 ### 0.1.8 2017-08-03
+ DUE support - DUE support
### 0.1.7 2017-07-17 ### 0.1.7 2017-07-17
+ TEENSY support - multiple I2C ports - TEENSY support - multiple I2C ports
+ '@' command to select I2C Port - '@' command to select I2C Port
+ changed # speeds steps of 100 - changed # speeds steps of 100
### 0.1.6 2015-03-29 ### 0.1.6 2015-03-29
+ Wire.setClock as more portable way to set I2C clock - Wire.setClock as more portable way to set I2C clock
### 0.1.5 2014-07-06 ### 0.1.5 2014-07-06
+ void setSpeed() - more control about what is scanned - void setSpeed() - more control about what is scanned
+ void setAddress() - address range - void setAddress() - address range
+ extended help - extended help
### older versions not documented ### older versions not documented
(started 2013-11-05 ?)
// END OF FILE // -- END OF FILE --

View File

@ -32,15 +32,19 @@ unittest_setup()
{ {
} }
unittest_teardown() unittest_teardown()
{ {
} }
unittest(test_constructor) unittest(test_constructor)
{ {
assertEqual(1, 1); assertEqual(1, 1);
} }
unittest_main() unittest_main()
// -------- // --------