Arduino-OWI
One-Wire Interface (OWI) library for Arduino
Benchmark.ino
Go to the documentation of this file.
1 #include "GPIO.h"
2 #include "OWI.h"
3 #include "Software/OWI.h"
4 #include "benchmark.h"
5 
7 
8 void setup()
9 {
10  Serial.begin(57600);
11  while (!Serial);
12  BENCHMARK_BASELINE(1);
13 }
14 
15 void loop()
16 {
17  // Measure the standard 1-wire bus manager functions
18  // All measurements are in micro-seconds
19 
20  uint8_t rom[owi.ROM_MAX];
21  uint8_t dir = 0;
22 
23  // Cyclic Redundancy Check per byte
24  MEASURE(owi.crc_update(0,0));
25 
26  // Reset pulse and presence check
27  MEASURE(owi.reset());
28 
29  // Write bit and byte
30  MEASURE(owi.write(0,1));
31  MEASURE(owi.write(1,1));
32  MEASURE(owi.write(0x00));
33  MEASURE(owi.write(0xff));
34 
35  // Read bit and byte
36  MEASURE(owi.read(1));
37  MEASURE(owi.read());
38 
39  // Triplet; read two bits and write one
40  MEASURE(owi.triplet(dir));
41 
42  // Standard rom functions
43  MEASURE(owi.read_rom(rom));
44  MEASURE(owi.skip_rom());
45  MEASURE(owi.match_rom(rom));
46  MEASURE(owi.search_rom(0, rom));
47  MEASURE(owi.alarm_search(rom));
48 
49  Serial.println();
50  delay(2000);
51 }
virtual uint8_t read(uint8_t bits=CHARBITS)
Definition: OWI.h:72
int8_t alarm_search(uint8_t *code, int8_t last=FIRST)
Definition: OWI.h:261
virtual void write(uint8_t value, uint8_t bits=CHARBITS)
Definition: OWI.h:98
bool skip_rom()
Definition: OWI.h:248
static uint8_t crc_update(uint8_t crc, uint8_t data)
Definition: OWI.h:146
virtual bool reset()
Definition: OWI.h:48
virtual int8_t triplet(uint8_t &dir)
Definition: OWI.h:106
int8_t search_rom(uint8_t family, uint8_t *code, int8_t last=FIRST)
Definition: OWI.h:204
Software::Serial< BOARD::D0 > Serial
Definition: Alarm.ino:8
void loop()
Definition: Benchmark.ino:15
Software::OWI< BOARD::D7 > owi
Definition: Benchmark.ino:6
bool read_rom(uint8_t *code)
Definition: OWI.h:222
bool match_rom(uint8_t *code)
Definition: OWI.h:236
void setup()
Definition: Benchmark.ino:8
static const size_t ROM_MAX
Definition: OWI.h:32