GY-63_MS5611/libraries/FastShiftIn/examples/fastShiftIn_readLSBFIRST/fastShiftIn_readLSBFIRST.ino

80 lines
1.6 KiB
Arduino
Raw Normal View History

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