This source file includes following definitions.
- onewire_bb_reset
- onewire_bb_bit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <sys/param.h>
24 #include <sys/systm.h>
25 #include <sys/device.h>
26
27 #include <dev/onewire/onewirevar.h>
28
29 int
30 onewire_bb_reset(const struct onewire_bbops *ops, void *arg)
31 {
32 int s, rv, i;
33
34 s = splhigh();
35 ops->bb_tx(arg);
36 ops->bb_set(arg, 0);
37 DELAY(480);
38 ops->bb_set(arg, 1);
39 ops->bb_rx(arg);
40 DELAY(30);
41 for (i = 0; i < 6; i++) {
42 if ((rv = ops->bb_get(arg)) == 0)
43 break;
44 DELAY(20);
45 }
46 DELAY(450);
47 splx(s);
48
49 return (rv);
50 }
51
52 int
53 onewire_bb_bit(const struct onewire_bbops *ops, void *arg, int value)
54 {
55 int s, rv, i;
56
57 s = splhigh();
58 ops->bb_tx(arg);
59 ops->bb_set(arg, 0);
60 DELAY(2);
61 if (value) {
62 ops->bb_set(arg, 1);
63 ops->bb_rx(arg);
64 for (i = 0; i < 15; i++) {
65 if ((rv = ops->bb_get(arg)) == 0)
66 break;
67 DELAY(2);
68 }
69 ops->bb_tx(arg);
70 }
71 DELAY(60);
72 ops->bb_set(arg, 1);
73 DELAY(5);
74 splx(s);
75
76 return (rv);
77 }