mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
97 lines
1.5 KiB
C++
97 lines
1.5 KiB
C++
//
|
|
// FILE: DS28CM00_perf.ino
|
|
// AUTHOR: Rob Tillaart
|
|
// VERSION: 0.1.0
|
|
// PURPOSE: performance test DS28CM00 lib
|
|
// DATE: 2017-07-24
|
|
// URL:
|
|
//
|
|
// Released to the public domain
|
|
//
|
|
|
|
#include <Wire.h>
|
|
#include <DS28CM00.h>
|
|
|
|
uint8_t uid[8];
|
|
|
|
DS28CM00 DS28;
|
|
|
|
uint32_t start;
|
|
uint32_t stop;
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
Serial.print(F("DS28CM00 library: "));
|
|
Serial.println(DS28CM00_LIB_VERSION);
|
|
|
|
Wire.begin();
|
|
Wire.setClock(100000);
|
|
DS28.begin();
|
|
|
|
Serial.println();
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
if (DS28.getUID(uid))
|
|
{
|
|
perf_test();
|
|
Serial.println();
|
|
}
|
|
else
|
|
{
|
|
Serial.println("Could not connect to DS28CM00...");
|
|
}
|
|
delay(1000);
|
|
}
|
|
|
|
void perf_test()
|
|
{
|
|
Serial.println(F("DS28CM00 performance. Times in milliseconds,"));
|
|
|
|
Serial.print(F("1000x getUID :\t"));
|
|
start = millis();
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
DS28.getUID(uid);
|
|
}
|
|
stop = millis();
|
|
Serial.println(stop - start);
|
|
|
|
|
|
Serial.print(F("1000x setI2C :\t"));
|
|
start = millis();
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
DS28.setI2CMode();
|
|
}
|
|
stop = millis();
|
|
Serial.println(stop - start);
|
|
|
|
|
|
Serial.print(F("1000x setSMB :\t"));
|
|
start = millis();
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
DS28.setSMBusMode();
|
|
}
|
|
stop = millis();
|
|
Serial.println(stop - start);
|
|
|
|
|
|
Serial.print(F("1000x getMode:\t"));
|
|
uint8_t mode;
|
|
start = millis();
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
DS28.getMode(mode);
|
|
}
|
|
stop = millis();
|
|
Serial.println(stop - start);
|
|
}
|
|
|
|
// END OF FILE
|