diff --git a/.arduino-ci.yml b/.arduino-ci.yml index 3e49662..fd05073 100644 --- a/.arduino-ci.yml +++ b/.arduino-ci.yml @@ -1,3 +1,18 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: @@ -9,3 +24,4 @@ compile: - esp32 - esp8266 - mega2560 + - rpipico diff --git a/MultiSpeedI2CScanner.ino b/MultiSpeedI2CScanner.ino index fb0e631..b417d20 100644 --- a/MultiSpeedI2CScanner.ino +++ b/MultiSpeedI2CScanner.ino @@ -1,7 +1,7 @@ // // FILE: MultiSpeedI2CScanner.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.15 +// VERSION: 0.1.16 // PURPOSE: I2C scanner at different speeds // DATE: 2013-11-05 // URL: https://github.com/RobTillaart/MultiSpeedI2CScanner @@ -12,18 +12,22 @@ #include #include +// FOR INTERNAL I2C BUS NANO 33 BLE +// #define WIRE_IMPLEMENT_WIRE1 1 +// extern TwoWire Wire1; + TwoWire *wire; -const char version[] = "0.1.15"; +const char version[] = "0.1.16"; -// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY) +// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY) int wirePortCount = 1; int selectedWirePort = 0; -// scans devices from 50 to 800 KHz I2C speeds. -// speed lower than 50 and above 400 can cause problems +// scans devices from 50 to 800 KHz I2C speeds. +// speed lower than 50 and above 400 can cause problems long speed[10] = { 100, 200, 300, 400 }; int speeds; @@ -31,44 +35,46 @@ int addressStart = 8; int addressEnd = 119; -// DELAY BETWEEN TESTS +// DELAY BETWEEN TESTS +// for delay between tests of found devices. #ifndef RESTORE_LATENCY -#define RESTORE_LATENCY 5 // for delay between tests of found devices. +#define RESTORE_LATENCY 5 #endif bool delayFlag = false; -// MINIMIZE OUTPUT +// MINIMIZE OUTPUT bool printAll = true; bool header = true; bool disableIRQ = false; -// STATE MACHINE +// STATE MACHINE enum states { STOP, ONCE, CONT, HELP }; states state = STOP; -// TIMING +// TIMING uint32_t startScan; uint32_t stopScan; -/////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// // // MAIN CODE // void setup() { Serial.begin(115200); + while (!Serial); #if defined (ESP8266) || defined(ESP32) - uint8_t sda = 14; // 21 - uint8_t scl = 15; // 22 - Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed. + uint8_t sda = 14; // 21 + uint8_t scl = 15; // 22 + Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed. #else Wire.begin(); #endif @@ -97,8 +103,7 @@ void setup() wire = &Wire; Serial.println(); - setSpeed('9'); - displayHelp(); + reset(); } @@ -191,6 +196,10 @@ void loop() setSpeed(command); break; + case 'r': + reset(); + break; + case 'a': setAddress(); break; @@ -224,6 +233,25 @@ void loop() } } +////////////////////////////////////////////////////////////////////// + +void reset() +{ + setSpeed('9'); + selectedWirePort = 0; + addressStart = 8; + addressEnd = 119; + + delayFlag = false; + printAll = true; + header = true; + disableIRQ = false; + + state = STOP; + + displayHelp(); +} + void setAddress() { @@ -354,7 +382,8 @@ void displayHelp() Serial.println(F("\tN = 3400 KHz")); Serial.println(F("\tO = 5000 KHz")); Serial.println(F("\tP = 100 400 1000 3400 5000 KHz (standards)")); - Serial.println(F("\n\t? = help - this page")); + Serial.println(F("\n\tr = reset to startup defaults.")); + Serial.println(F("\t? = help - this page")); Serial.println(); } @@ -434,6 +463,26 @@ void I2Cscan() } } +/* + // FOOTER + if (header) + { + for (uint8_t s = 0; s < speeds + 5; s++) + { + Serial.print(F("--------")); + } + Serial.println(); + + Serial.print(F("TIME\tDEC\tHEX\t")); + for (uint8_t s = 0; s < speeds; s++) + { + Serial.print(F("\t")); + Serial.print(speed[s]); + } + Serial.println(F("\t[KHz]")); + } +*/ + stopScan = millis(); if (header) { diff --git a/README.md b/README.md index 38d928b..5cebf65 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,11 @@ The scanner provides an overview of which addresses can be found at which speed. This allows one to optimize the I2C performance of many devices above the standard 100KHz speed. +#### Related + +build your own I2C scanner with: +- https://github.com/RobTillaart/I2C_SCANNER + ## Menu dialog @@ -108,8 +113,14 @@ Check your datasheet to see which speeds are applicable for the processor in use ## Future +#### Must + +#### Should + +#### Could + - add watchdog reset (at least AVR - 8 seconds 0.2.0 ) -- create an I2CScanner class -- r = reset (defaults) - non-AVR command behind a ```#ifdef``` ? +- rename releaseNotes.md to changelog.md (in line with libraries) +- I2C GENERIC RESET address 0x00 CMD 0x06 diff --git a/examples/MultiSpeedI2CScanner/MultiSpeedI2CScanner.ino b/examples/MultiSpeedI2CScanner/MultiSpeedI2CScanner.ino index fb0e631..b417d20 100644 --- a/examples/MultiSpeedI2CScanner/MultiSpeedI2CScanner.ino +++ b/examples/MultiSpeedI2CScanner/MultiSpeedI2CScanner.ino @@ -1,7 +1,7 @@ // // FILE: MultiSpeedI2CScanner.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.15 +// VERSION: 0.1.16 // PURPOSE: I2C scanner at different speeds // DATE: 2013-11-05 // URL: https://github.com/RobTillaart/MultiSpeedI2CScanner @@ -12,18 +12,22 @@ #include #include +// FOR INTERNAL I2C BUS NANO 33 BLE +// #define WIRE_IMPLEMENT_WIRE1 1 +// extern TwoWire Wire1; + TwoWire *wire; -const char version[] = "0.1.15"; +const char version[] = "0.1.16"; -// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY) +// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY) int wirePortCount = 1; int selectedWirePort = 0; -// scans devices from 50 to 800 KHz I2C speeds. -// speed lower than 50 and above 400 can cause problems +// scans devices from 50 to 800 KHz I2C speeds. +// speed lower than 50 and above 400 can cause problems long speed[10] = { 100, 200, 300, 400 }; int speeds; @@ -31,44 +35,46 @@ int addressStart = 8; int addressEnd = 119; -// DELAY BETWEEN TESTS +// DELAY BETWEEN TESTS +// for delay between tests of found devices. #ifndef RESTORE_LATENCY -#define RESTORE_LATENCY 5 // for delay between tests of found devices. +#define RESTORE_LATENCY 5 #endif bool delayFlag = false; -// MINIMIZE OUTPUT +// MINIMIZE OUTPUT bool printAll = true; bool header = true; bool disableIRQ = false; -// STATE MACHINE +// STATE MACHINE enum states { STOP, ONCE, CONT, HELP }; states state = STOP; -// TIMING +// TIMING uint32_t startScan; uint32_t stopScan; -/////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// // // MAIN CODE // void setup() { Serial.begin(115200); + while (!Serial); #if defined (ESP8266) || defined(ESP32) - uint8_t sda = 14; // 21 - uint8_t scl = 15; // 22 - Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed. + uint8_t sda = 14; // 21 + uint8_t scl = 15; // 22 + Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed. #else Wire.begin(); #endif @@ -97,8 +103,7 @@ void setup() wire = &Wire; Serial.println(); - setSpeed('9'); - displayHelp(); + reset(); } @@ -191,6 +196,10 @@ void loop() setSpeed(command); break; + case 'r': + reset(); + break; + case 'a': setAddress(); break; @@ -224,6 +233,25 @@ void loop() } } +////////////////////////////////////////////////////////////////////// + +void reset() +{ + setSpeed('9'); + selectedWirePort = 0; + addressStart = 8; + addressEnd = 119; + + delayFlag = false; + printAll = true; + header = true; + disableIRQ = false; + + state = STOP; + + displayHelp(); +} + void setAddress() { @@ -354,7 +382,8 @@ void displayHelp() Serial.println(F("\tN = 3400 KHz")); Serial.println(F("\tO = 5000 KHz")); Serial.println(F("\tP = 100 400 1000 3400 5000 KHz (standards)")); - Serial.println(F("\n\t? = help - this page")); + Serial.println(F("\n\tr = reset to startup defaults.")); + Serial.println(F("\t? = help - this page")); Serial.println(); } @@ -434,6 +463,26 @@ void I2Cscan() } } +/* + // FOOTER + if (header) + { + for (uint8_t s = 0; s < speeds + 5; s++) + { + Serial.print(F("--------")); + } + Serial.println(); + + Serial.print(F("TIME\tDEC\tHEX\t")); + for (uint8_t s = 0; s < speeds; s++) + { + Serial.print(F("\t")); + Serial.print(speed[s]); + } + Serial.println(F("\t[KHz]")); + } +*/ + stopScan = millis(); if (header) { diff --git a/releaseNotes.md b/releaseNotes.md index e07813e..d4a176d 100644 --- a/releaseNotes.md +++ b/releaseNotes.md @@ -8,7 +8,13 @@ https://github.com/RobTillaart/MultiSpeedI2CScanner ## Version -0.1.15 +0.1.16 + + +### 0.1.16 2023-01-20 + +- update build-ci +- add link to I2C scanner class in readme.md ### 0.1.15 2021-12-22