Mercurial > ~darius > hgwebdir.cgi > avr
annotate 1wire-delay.h @ 14:a9d493261c6c
- Add $Id$
- Rearrange slightly.
author | darius |
---|---|
date | Sat, 17 Sep 2005 18:02:28 +0930 |
parents | eb1faf51968e |
children | 8dc98a293e43 |
rev | line source |
---|---|
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
1 /* |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
2 * Delay routines for the 1 wire bus |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
3 * Search routine is copied from the Dallas owpd library with mods. |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
4 * |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
5 * $Id$ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
6 * |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
7 * Copyright (c) 2004 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
8 * Daniel O'Connor <darius@dons.net.au>. All rights reserved. |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
9 * |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
10 * Redistribution and use in source and binary forms, with or without |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
11 * modification, are permitted provided that the following conditions |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
12 * are met: |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
13 * 1. Redistributions of source code must retain the above copyright |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
14 * notice, this list of conditions and the following disclaimer. |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
15 * 2. Redistributions in binary form must reproduce the above copyright |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
16 * notice, this list of conditions and the following disclaimer in the |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
17 * documentation and/or other materials provided with the distribution. |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
18 * |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
19 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
22 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
29 * SUCH DAMAGE. |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
30 */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
31 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
32 /* |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
33 * Note that all these routines are clock speed sensitive! |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
34 * (4Mhz AT908515) |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
35 */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
36 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
37 #if (XTAL_CPU == 4000000) |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
38 /* 6 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
39 #define DELAY_A asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
40 "ldi r21, 6\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
41 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
42 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
43 "brne L_%=\n\t" \ |
10 | 44 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
45 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
46 /* 64 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
47 #define DELAY_B asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
48 "ldi r21, 32\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
49 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
50 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
51 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
52 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
53 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
54 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
55 "brne L_%=\n\t" \ |
10 | 56 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
57 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
58 /* 60 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
59 #define DELAY_C asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
60 "ldi r21, 30\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
61 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
62 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
63 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
64 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
65 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
66 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
67 "brne L_%=\n\t" \ |
10 | 68 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
69 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
70 /* 10 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
71 #define DELAY_D asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
72 "ldi r21, 9\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
73 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
74 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
75 "brne L_%=\n\t" \ |
10 | 76 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
77 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
78 /* 9 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
79 #define DELAY_E asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
80 "ldi r21, 8\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
81 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
82 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
83 "brne L_%=\n\t" \ |
10 | 84 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
85 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
86 /* 55 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
87 #define DELAY_F asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
88 "ldi r21, 27\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
89 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
90 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
91 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
92 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
93 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
94 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
95 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
96 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
97 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
98 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
99 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
100 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
101 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
102 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
103 "brne L_%=\n\t" \ |
10 | 104 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
105 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
106 /* 0 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
107 #define DELAY_G |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
108 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
109 /* 480 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
110 #define DELAY_H asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
111 "ldi r21, 120\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
112 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
113 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
114 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
115 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
116 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
117 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
118 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
119 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
120 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
121 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
122 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
123 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
124 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
125 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
126 "brne L_%=\n\t" \ |
10 | 127 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
128 |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
129 /* 70 usec */ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
130 #define DELAY_I asm volatile( \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
131 "ldi r21, 35\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
132 "L_%=: nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
133 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
134 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
135 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
136 "nop\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
137 "dec r21\n\t" \ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
138 "brne L_%=\n\t" \ |
10 | 139 ::: "r21") |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
140 #else |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
141 #error No 1 wire delay routines for selected clock speed |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
142 #endif |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
diff
changeset
|
143 |