1 //---------------------------------------------------------------------------
2 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
18 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
22 // Except as contained in this notice, the name of Dallas Semiconductor
23 // shall not be used except as stated in the Dallas Semiconductor
25 //---------------------------------------------------------------------------
27 // DS2480.H - This file contains the DS2480 constants
31 // History: 1.02 -> 1.03 Make sure uchar is not defined twice.
36 #define MODE_DATA 0xE1
37 #define MODE_COMMAND 0xE3
38 #define MODE_STOP_PULSE 0xF1
41 #define RB_CHIPID_MASK 0x1C
42 #define RB_RESET_MASK 0x03
43 #define RB_1WIRESHORT 0x00
44 #define RB_PRESENCE 0x01
45 #define RB_ALARMPRESENCE 0x02
46 #define RB_NOPRESENCE 0x03
48 #define RB_BIT_MASK 0x03
49 #define RB_BIT_ONE 0x03
50 #define RB_BIT_ZERO 0x00
52 // Masks for all bit ranges
54 #define FUNCTSEL_MASK 0x60
55 #define BITPOL_MASK 0x10
56 #define SPEEDSEL_MASK 0x0C
57 #define MODSEL_MASK 0x02
58 #define PARMSEL_MASK 0x70
59 #define PARMSET_MASK 0x0E
61 // Command or config bit
63 #define CMD_CONFIG 0x01
65 // Function select bits
66 #define FUNCTSEL_BIT 0x00
67 #define FUNCTSEL_SEARCHON 0x30
68 #define FUNCTSEL_SEARCHOFF 0x20
69 #define FUNCTSEL_RESET 0x40
70 #define FUNCTSEL_CHMOD 0x60
72 // Bit polarity/Pulse voltage bits
73 #define BITPOL_ONE 0x10
74 #define BITPOL_ZERO 0x00
75 #define BITPOL_5V 0x00
76 #define BITPOL_12V 0x10
78 // One Wire speed bits
79 #define SPEEDSEL_STD 0x00
80 #define SPEEDSEL_FLEX 0x04
81 #define SPEEDSEL_OD 0x08
82 #define SPEEDSEL_PULSE 0x0C
84 // Data/Command mode select bits
85 #define MODSEL_DATA 0x00
86 #define MODSEL_COMMAND 0x02
88 // 5V Follow Pulse select bits (If 5V pulse
89 // will be following the next byte or bit.)
90 #define PRIME5V_TRUE 0x02
91 #define PRIME5V_FALSE 0x00
93 // Parameter select bits
94 #define PARMSEL_PARMREAD 0x00
95 #define PARMSEL_SLEW 0x10
96 #define PARMSEL_12VPULSE 0x20
97 #define PARMSEL_5VPULSE 0x30
98 #define PARMSEL_WRITE1LOW 0x40
99 #define PARMSEL_SAMPLEOFFSET 0x50
100 #define PARMSEL_ACTIVEPULLUPTIME 0x60
101 #define PARMSEL_BAUDRATE 0x70
103 // Pull down slew rate.
104 #define PARMSET_Slew15Vus 0x00
105 #define PARMSET_Slew2p2Vus 0x02
106 #define PARMSET_Slew1p65Vus 0x04
107 #define PARMSET_Slew1p37Vus 0x06
108 #define PARMSET_Slew1p1Vus 0x08
109 #define PARMSET_Slew0p83Vus 0x0A
110 #define PARMSET_Slew0p7Vus 0x0C
111 #define PARMSET_Slew0p55Vus 0x0E
113 // 12V programming pulse time table
114 #define PARMSET_32us 0x00
115 #define PARMSET_64us 0x02
116 #define PARMSET_128us 0x04
117 #define PARMSET_256us 0x06
118 #define PARMSET_512us 0x08
119 #define PARMSET_1024us 0x0A
120 #define PARMSET_2048us 0x0C
121 #define PARMSET_infinite 0x0E
123 // 5V strong pull up pulse time table
124 #define PARMSET_16p4ms 0x00
125 #define PARMSET_65p5ms 0x02
126 #define PARMSET_131ms 0x04
127 #define PARMSET_262ms 0x06
128 #define PARMSET_524ms 0x08
129 #define PARMSET_1p05s 0x0A
130 #define PARMSET_2p10s 0x0C
131 #define PARMSET_infinite 0x0E
134 #define PARMSET_Write8us 0x00
135 #define PARMSET_Write9us 0x02
136 #define PARMSET_Write10us 0x04
137 #define PARMSET_Write11us 0x06
138 #define PARMSET_Write12us 0x08
139 #define PARMSET_Write13us 0x0A
140 #define PARMSET_Write14us 0x0C
141 #define PARMSET_Write15us 0x0E
143 // Data sample offset and Write 0 recovery time
144 #define PARMSET_SampOff3us 0x00
145 #define PARMSET_SampOff4us 0x02
146 #define PARMSET_SampOff5us 0x04
147 #define PARMSET_SampOff6us 0x06
148 #define PARMSET_SampOff7us 0x08
149 #define PARMSET_SampOff8us 0x0A
150 #define PARMSET_SampOff9us 0x0C
151 #define PARMSET_SampOff10us 0x0E
153 // Active pull up on time
154 #define PARMSET_PullUp0p0us 0x00
155 #define PARMSET_PullUp0p5us 0x02
156 #define PARMSET_PullUp1p0us 0x04
157 #define PARMSET_PullUp1p5us 0x06
158 #define PARMSET_PullUp2p0us 0x08
159 #define PARMSET_PullUp2p5us 0x0A
160 #define PARMSET_PullUp3p0us 0x0C
161 #define PARMSET_PullUp3p5us 0x0E
164 #define PARMSET_9600 0x00
165 #define PARMSET_19200 0x02
166 #define PARMSET_57600 0x04
167 #define PARMSET_115200 0x06
169 // DS2480 program voltage available
170 #define DS2480PROG_MASK 0x20
173 #define MODE_NORMAL 0x00
174 #define MODE_OVERDRIVE 0x01
175 #define MODE_STRONG5 0x02
176 #define MODE_PROGRAM 0x04
177 #define MODE_BREAK 0x08
179 extern int DS2480Detect(int);
180 extern int DS2480ChangeBaud(int, uchar);
182 // global DS2480 state
183 extern int ULevel[MAX_PORTNUM]; // current DS2480 1-Wire Net level
184 extern int UBaud[MAX_PORTNUM]; // current DS2480 baud rate
185 extern int UMode[MAX_PORTNUM]; // current DS2480 command or data mode state
186 extern int USpeed[MAX_PORTNUM]; // current DS2480 1-Wire Net comm speed