mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.11 version
This commit is contained in:
parent
d36fddb6f8
commit
2b97b8d4be
21
sketches/MultiSpeedI2CScanner/LICENSE
Normal file
21
sketches/MultiSpeedI2CScanner/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2020 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,20 +1,19 @@
|
||||
//
|
||||
// FILE: MultiSpeedI2CScanner.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.10
|
||||
// VERSION: 0.1.11
|
||||
// PURPOSE: I2C scanner at different speeds
|
||||
// DATE: 2013-11-05
|
||||
// URL: https://github.com/RobTillaart/MultiSpeedI2CScanner
|
||||
// URL: http://forum.arduino.cc/index.php?topic=197360
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
TwoWire *wi;
|
||||
|
||||
const char version[] = "0.1.10";
|
||||
const char version[] = "0.1.11";
|
||||
|
||||
|
||||
// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY)
|
||||
@ -23,8 +22,7 @@ int selectedWirePort = 0;
|
||||
|
||||
|
||||
// scans devices from 50 to 800KHz I2C speeds.
|
||||
// lower than 50 is not possible
|
||||
// DS3231 RTC works on 800 KHz. TWBR = 2; (?)
|
||||
// speed lower than 50 and above 400 can cause problems
|
||||
long speed[10] = { 100, 200, 300, 400 };
|
||||
int speeds;
|
||||
|
||||
@ -42,7 +40,7 @@ bool delayFlag = false;
|
||||
// MINIMIZE OUTPUT
|
||||
bool printAll = true;
|
||||
bool header = true;
|
||||
|
||||
bool disableIRQ = false;
|
||||
|
||||
// STATE MACHINE
|
||||
enum states {
|
||||
@ -61,8 +59,8 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
uint8_t sda = 15;
|
||||
uint8_t scl = 2;
|
||||
uint8_t sda = 21;
|
||||
uint8_t scl = 22;
|
||||
Wire.begin(sda, scl, 100000); // ESP32 - change config pins if needed.
|
||||
#else
|
||||
Wire.begin();
|
||||
@ -90,6 +88,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
yield();
|
||||
char command = getCommand();
|
||||
switch (command)
|
||||
{
|
||||
@ -147,6 +146,11 @@ void loop()
|
||||
Serial.print(F("<print="));
|
||||
Serial.println(printAll ? F("all>") : F("found>"));
|
||||
break;
|
||||
case 'i':
|
||||
disableIRQ = !disableIRQ;
|
||||
Serial.print(F("<irq="));
|
||||
Serial.println(disableIRQ ? F("diabled>") : F("enabled>"));
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
@ -300,6 +304,7 @@ void displayHelp()
|
||||
Serial.println(F("\tc = continuous scan - 1 second delay"));
|
||||
Serial.println(F("\tq = quit continuous scan"));
|
||||
Serial.println(F("\td = toggle latency delay between successful tests. 0 - 5 ms"));
|
||||
Serial.println(F("\ti = toggle enable/disable interrupts"));
|
||||
|
||||
Serial.println(F("Output:"));
|
||||
Serial.println(F("\tp = toggle printAll - printFound."));
|
||||
@ -309,7 +314,7 @@ void displayHelp()
|
||||
Serial.println(F("Speeds:"));
|
||||
Serial.println(F("\t0 = 100..800 Khz - step 100 (warning - can block!!)"));
|
||||
Serial.println(F("\t1 = 100 KHz"));
|
||||
Serial.println(F("\t2 = 200 KH"));
|
||||
Serial.println(F("\t2 = 200 KHz"));
|
||||
Serial.println(F("\t4 = 400 KHz"));
|
||||
Serial.println(F("\t9 = 50..400 Khz - step 50 < DEFAULT >"));
|
||||
Serial.println();
|
||||
@ -328,6 +333,8 @@ void I2Cscan()
|
||||
startScan = millis();
|
||||
uint8_t count = 0;
|
||||
|
||||
if (disableIRQ) noInterrupts();
|
||||
|
||||
if (header)
|
||||
{
|
||||
Serial.print(F("TIME\tDEC\tHEX\t"));
|
||||
@ -344,18 +351,6 @@ void I2Cscan()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
// TEST
|
||||
// 0.1.04: tests only address range 8..120
|
||||
// --------------------------------------------
|
||||
// Address R/W Bit Description
|
||||
// 0000 000 0 General call address
|
||||
// 0000 000 1 START byte
|
||||
// 0000 001 X CBUS address
|
||||
// 0000 010 X reserved - different bus format
|
||||
// 0000 011 X reserved - future purposes
|
||||
// 0000 1XX X High Speed master code
|
||||
// 1111 1XX X reserved - future purposes
|
||||
// 1111 0XX X 10-bit slave addressing
|
||||
for (uint8_t address = addressStart; address <= addressEnd; address++)
|
||||
{
|
||||
bool printLine = printAll;
|
||||
@ -364,12 +359,15 @@ void I2Cscan()
|
||||
|
||||
for (uint8_t s = 0; s < speeds ; s++)
|
||||
{
|
||||
yield(); // keep ESP happy
|
||||
|
||||
#if ARDUINO < 158 && defined (TWBR)
|
||||
uint16_t PREV_TWBR = TWBR;
|
||||
TWBR = (F_CPU / (speed[s] * 1000) - 16) / 2;
|
||||
if (TWBR < 2)
|
||||
{
|
||||
Serial.println("ERROR: not supported speed");
|
||||
TWBR = PREV_TWBR;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
@ -413,4 +411,8 @@ void I2Cscan()
|
||||
Serial.print(stopScan - startScan);
|
||||
Serial.println(F(" milliseconds."));
|
||||
}
|
||||
|
||||
interrupts();
|
||||
}
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
# Arduino MultiSpeed I2C Scanner - 0.1.10
|
||||
# Arduino MultiSpeed I2C Scanner
|
||||
|
||||
## Version: 0.1.11
|
||||
|
||||
## Description
|
||||
|
||||
MultiSpeedI2CScanner is a menu driven I2C scanner, see below.
|
||||
The scanner is tested on an UNO and an ESP32.
|
||||
@ -8,7 +12,7 @@ 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.
|
||||
|
||||
# Menu dialog
|
||||
## Menu dialog
|
||||
|
||||
```
|
||||
<speeds = 50 100 150 200 250 300 350 400 >
|
||||
@ -22,6 +26,7 @@ Scan mode:
|
||||
c = continuous scan - 1 second delay
|
||||
q = quit continuous scan
|
||||
d = toggle latency delay between successful tests. 0 - 5 ms
|
||||
i = toggle enable/disable interrupts
|
||||
Output:
|
||||
p = toggle printAll - printFound.
|
||||
h = toggle header - noHeader.
|
||||
@ -46,11 +51,13 @@ Speeds:
|
||||
## Functions
|
||||
|
||||
### I2C ports
|
||||
|
||||
**@** selects through the different Wire ports.
|
||||
Note that the current Wire port is given after I2C ports: count
|
||||
Wire0 is just Wire but it was easier to program.
|
||||
|
||||
### Scan mode
|
||||
|
||||
**s** selects single scan mode, think of it as manual.
|
||||
|
||||
**c** selects continuous scanning, think of it as automatic.
|
||||
@ -60,7 +67,10 @@ Wire0 is just Wire but it was easier to program.
|
||||
**d** toggles the latency between successful scans.
|
||||
Only needed sometimes.
|
||||
|
||||
**i** toggles disable/enable interrupts, use with care.
|
||||
|
||||
### Output selection
|
||||
|
||||
**p** toggles printAll and printFound.
|
||||
PrintAll will print also the addresses where nothing is found.
|
||||
PrintFound will only generate a line if an I2C device is found on that address.
|
||||
@ -74,13 +84,11 @@ but as some addresses are reserved, one can limit this range to 8 .. 120 .
|
||||
|
||||
All options here select a single speed or a range of speeds.
|
||||
|
||||
Since 0.1.10 experimental speeds of 1000, 3400 and 5000 are added as
|
||||
these are part of the I2C standards.
|
||||
Since 0.1.10 version experimental speeds of 1000, 3400 and 5000 are added as
|
||||
these are part of the I2C standards.
|
||||
http://i2c.info/i2c-bus-specification
|
||||
|
||||
NOTE: not all processors will support these speeds.
|
||||
NOTE: not all processors will support these higher speeds.
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
55
sketches/MultiSpeedI2CScanner/releaseNotes.md
Normal file
55
sketches/MultiSpeedI2CScanner/releaseNotes.md
Normal file
@ -0,0 +1,55 @@
|
||||
# Release Notes
|
||||
|
||||
MultiSpeedI2CScanner
|
||||
|
||||
## Version
|
||||
|
||||
0.1.11
|
||||
|
||||
### 0.1.11 2018-07-20
|
||||
|
||||
+ Fix failing TWBR setting
|
||||
+ added yield() during scan to improve ESP behavior.
|
||||
+ added disable interrupts flag
|
||||
+ refactor / cleanup
|
||||
|
||||
### 0.1.10 2018-04-02
|
||||
|
||||
+ Fix #152
|
||||
+ improved support for ESP32
|
||||
+ changed multispeed ranges a bit (option 0 and 9)
|
||||
+ refactor
|
||||
+ added experimental high speeds 1000, 3400, 5000 KHz.
|
||||
|
||||
verified on UNO and ESP32,
|
||||
note the latter one must adjust the pins in the code.
|
||||
|
||||
### 0.1.9 2018-04-02
|
||||
|
||||
+ '9' command to scan up to 400 KHz only to prevent blocking
|
||||
+ changed "scan up to 400 KHz" as default at startup
|
||||
|
||||
### 0.1.8 2017-08-03
|
||||
|
||||
+ DUE support
|
||||
|
||||
### 0.1.7 2017-07-17
|
||||
|
||||
+ TEENSY support - multiple I2C ports
|
||||
+ '@' command to select I2C Port
|
||||
+ changed # speeds steps of 100
|
||||
|
||||
### 0.1.6 2015-03-29
|
||||
|
||||
+ Wire.setClock as more portable way to set I2C clock
|
||||
|
||||
### 0.1.5 2014-07-06
|
||||
|
||||
+ void setSpeed() - more control about what is scanned
|
||||
+ void setAddress() - address range
|
||||
+ extended help
|
||||
|
||||
### older versions not documented
|
||||
|
||||
|
||||
// END OF FILE
|
@ -1,48 +0,0 @@
|
||||
|
||||
==============================
|
||||
2018-04-02 version 0.1.10
|
||||
==============================
|
||||
|
||||
Fix #152
|
||||
+ improved support for ESP32
|
||||
+ changed multispeed ranges a bit (option 0 and 9)
|
||||
+ refactor
|
||||
+ added experimental high speeds 1000, 3400, 5000 KHz.
|
||||
|
||||
verified on UNO and ESP32, note the latter one must adjust the pins in the code.
|
||||
|
||||
==============================
|
||||
2018-04-02 version 0.1.9
|
||||
==============================
|
||||
+ '9' command to scan up to 400 KHz only to prevent blocking
|
||||
+ changed "scan up to 400 KHz" as default at startup
|
||||
|
||||
==============================
|
||||
2017-08-03 version 0.1.8
|
||||
==============================
|
||||
+ DUE support
|
||||
|
||||
==============================
|
||||
2017-07-17 version 0.1.7
|
||||
==============================
|
||||
+ TEENSY support - multiple I2C ports
|
||||
+ '@' command to select I2C Port
|
||||
+ changed # speeds steps of 100
|
||||
|
||||
==============================
|
||||
2015-03-29 version 0.1.6
|
||||
==============================
|
||||
+ Wire.setClock as more portable way to set I2C clock
|
||||
|
||||
==============================
|
||||
2014-07-06 version 0.1.5
|
||||
==============================
|
||||
+ void setSpeed() - more control about what is scanned
|
||||
+ void setAddress() - address range
|
||||
+ extended help
|
||||
|
||||
==============================
|
||||
older versions not documented
|
||||
==============================
|
||||
|
||||
// END OF FILE
|
Loading…
x
Reference in New Issue
Block a user