Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
ShiftIn.ino
Go to the documentation of this file.
1 #include "GPIO.h"
2 #include "SRPI.h"
3 #include "benchmark.h"
4 
5 #include "Software/Serial.h"
8 #define DATA_PIN 1
9 #define CLOCK_PIN 2
10 
11 void setup()
12 {
13  Serial.begin(57600);
14  while (!Serial);
15 
16  // Set pin mode
17  pinMode(DATA_PIN, INPUT);
18  pinMode(CLOCK_PIN, OUTPUT);
19 
20  // Set benchmark baseline
21  BENCHMARK_BASELINE(1000);
22 }
23 
24 void loop()
25 {
26  uint8_t value;
27 
28  BENCHMARK("1. Arduino core shiftIn", 1000) {
29  value = shiftIn(DATA_PIN, CLOCK_PIN, LSBFIRST);
30  }
31 
32  BENCHMARK("2. SRPI input operator", 1000) {
33  srpi >> value;
34  }
35 
36  Serial.println();
37  delay(2000);
38 }
Definition: SRPI.h:31
void begin(uint32_t baudrate)
Definition: Serial.h:50
Software::Serial< BOARD::D0 > Serial
Definition: ShiftIn.ino:6
SRPI< LSBFIRST, BOARD::D1, BOARD::D2 > srpi
Definition: ShiftIn.ino:7
void loop()
Definition: ShiftIn.ino:24
#define BENCHMARK(msg, scale)
Definition: benchmark.h:52
#define BENCHMARK_BASELINE(scale)
Definition: benchmark.h:34
#define DATA_PIN
Definition: ShiftIn.ino:8
#define CLOCK_PIN
Definition: ShiftIn.ino:9
void setup()
Definition: ShiftIn.ino:11