2013-09-29 13:10:03 -04:00
|
|
|
//
|
|
|
|
// FILE: fastShiftIn.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: test sketch
|
2021-01-29 06:31:58 -05:00
|
|
|
// URL: https://github.com/RobTillaart/FastShiftIn
|
2021-12-17 09:14:55 -05:00
|
|
|
|
2013-09-29 13:10:03 -04:00
|
|
|
|
|
|
|
#include "FastShiftIn.h"
|
|
|
|
|
|
|
|
FastShiftIn FSI(12, 13, LSBFIRST);
|
|
|
|
|
|
|
|
volatile int x = 0;
|
|
|
|
|
2021-12-17 09:14:55 -05:00
|
|
|
|
2013-09-29 13:10:03 -04:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
2021-01-29 06:31:58 -05:00
|
|
|
Serial.println(__FILE__);
|
2013-09-29 13:10:03 -04:00
|
|
|
Serial.println(FASTSHIFTIN_LIB_VERSION);
|
|
|
|
|
|
|
|
digitalWrite(12, HIGH);
|
|
|
|
Serial.println("\n 8 bits HIGH\n");
|
|
|
|
|
|
|
|
Serial.println("\nPerformance - time in us");
|
|
|
|
uint32_t start = micros();
|
2021-01-29 06:31:58 -05:00
|
|
|
for (int i = 0; i < 1000; i++)
|
2013-09-29 13:10:03 -04:00
|
|
|
{
|
|
|
|
x = FSI.read();
|
|
|
|
}
|
2015-03-06 09:09:11 -05:00
|
|
|
uint32_t duration1 = micros() - start;
|
2013-09-29 13:10:03 -04:00
|
|
|
Serial.print("FastShiftIn1: ");
|
2015-03-06 09:09:11 -05:00
|
|
|
Serial.println(duration1 * 0.001);
|
2013-09-29 13:10:03 -04:00
|
|
|
|
|
|
|
start = micros();
|
2021-01-29 06:31:58 -05:00
|
|
|
for (int i = 0; i < 1000; i++)
|
2013-09-29 13:10:03 -04:00
|
|
|
{
|
|
|
|
x = FSI.read();
|
|
|
|
x = FSI.read();
|
|
|
|
}
|
2015-03-06 09:09:11 -05:00
|
|
|
uint32_t duration2 = micros() - start;
|
2013-09-29 13:10:03 -04:00
|
|
|
Serial.print("FastShiftIn2: ");
|
2015-03-06 09:09:11 -05:00
|
|
|
Serial.println(duration2 * 0.001);
|
|
|
|
Serial.print(" Delta: ");
|
2021-01-29 06:31:58 -05:00
|
|
|
Serial.println((duration2 - duration1)* 0.001);
|
2015-03-06 09:09:11 -05:00
|
|
|
Serial.println();
|
2013-09-29 13:10:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
start = micros();
|
2021-01-29 06:31:58 -05:00
|
|
|
for (int i = 0; i < 1000; i++)
|
2013-09-29 13:10:03 -04:00
|
|
|
{
|
|
|
|
x = shiftIn(12, 13, LSBFIRST);
|
|
|
|
}
|
2015-03-06 09:09:11 -05:00
|
|
|
duration1 = micros() - start;
|
2013-09-29 13:10:03 -04:00
|
|
|
Serial.print("Standard shiftIn1: ");
|
2015-03-06 09:09:11 -05:00
|
|
|
Serial.println(duration1* 0.001);
|
2013-09-29 13:10:03 -04:00
|
|
|
|
|
|
|
start = micros();
|
2021-01-29 06:31:58 -05:00
|
|
|
for (int i = 0; i < 1000; i++)
|
2013-09-29 13:10:03 -04:00
|
|
|
{
|
|
|
|
x = shiftIn(12, 13, LSBFIRST);
|
|
|
|
x = shiftIn(12, 13, LSBFIRST);
|
|
|
|
}
|
2015-03-06 09:09:11 -05:00
|
|
|
duration2 = micros() - start;
|
2013-09-29 13:10:03 -04:00
|
|
|
Serial.print("Standard shiftIn2: ");
|
2015-03-06 09:09:11 -05:00
|
|
|
Serial.println(duration2 * 0.001);
|
|
|
|
Serial.print(" Delta: ");
|
2021-01-29 06:31:58 -05:00
|
|
|
Serial.println((duration2 - duration1) * 0.001);
|
2015-03-06 09:09:11 -05:00
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
Serial.println("done...");
|
2013-09-29 13:10:03 -04:00
|
|
|
}
|
|
|
|
|
2021-12-17 09:14:55 -05:00
|
|
|
|
2013-09-29 13:10:03 -04:00
|
|
|
void loop()
|
|
|
|
{
|
2021-12-17 09:14:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|
|
|
|
|