1-Wire and ENS210 driver stack
one_wire.h
Go to the documentation of this file.
1 /*!
2  * @file one_wire.h
3  * @brief General 1-Wire API using the DS2485 1-Wire master.
4  */
5 
6 /*******************************************************************************
7 * Copyright (C) Maxim Integrated Products, Inc., All rights Reserved.
8 *
9 * This software is protected by copyright laws of the United States and
10 * of foreign countries. This material may also be protected by patent laws
11 * and technology transfer regulations of the United States and of foreign
12 * countries. This software is furnished under a license agreement and/or a
13 * nondisclosure agreement and may only be used or reproduced in accordance
14 * with the terms of those agreements. Dissemination of this information to
15 * any party or parties not specified in the license agreement and/or
16 * nondisclosure agreement is expressly prohibited.
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
25 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * Except as contained in this notice, the name of Maxim Integrated
30 * Products, Inc. shall not be used except as stated in the Maxim Integrated
31 * Products, Inc. Branding Policy.
32 *
33 * The mere transfer of this software does not imply any licenses
34 * of trade secrets, proprietary technology, copyrights, patents,
35 * trademarks, maskwork rights, or any other form of intellectual
36 * property whatsoever. Maxim Integrated Products, Inc. retains all
37 * ownership rights.
38 *******************************************************************************
39 */
40 
41  /* Define to prevent redundant inclusion */
42 #ifndef ONE_WIRE_H_INCLUDED
43 #define ONE_WIRE_H_INCLUDED
44 
45 /* **** Includes **** */
46 #include <stdint.h>
47 #include <stdbool.h>
48 #include "one_wire_address.h" // OneWire_ROM_ID_T type stores a 1-Wire address
49 
50 #ifdef __cplusplus
51  extern "C" {
52 #endif
53 
54 #define OneWire_Release_Byte_xAA 0xAA
55 
56 /* **** Definitions **** */
57 
58 /* Primitive Commands for use in DS2485 Scripts*/
59 #define PC_OW_RESET 0x00
60 #define PC_OW_WRITE_BIT 0x01
61 #define PC_OW_READ_BIT 0x02
62 #define PC_OW_WRITE_BYTE 0x03
63 #define PC_OW_READ_BYTE 0x04
64 #define PC_OW_TRIPLET 0x05
65 #define PC_OW_OV_SKIP 0x06
66 #define PC_OW_SKIP 0x07
67 #define PC_OW_READ_BLOCK 0x08
68 #define PC_OW_WRITE_BLOCK 0x09
69 #define PC_DELAY 0x0A
70 #define PC_PRIME_SPU 0x0B
71 #define PC_SPU_OFF 0x0C
72 #define PC_SPEED 0x0D
73 #define PC_VERIFY_TOGGLE 0x0E
74 #define PC_VERIFY_BYTE 0x0F
75 #define PC_CRC16_START 0x10
76 #define PC_VERIFY_CRC16 0x11
77 #define PC_SET_GPIO 0x12
78 #define PC_READ_GPIO 0x13
79 #define PC_VERIFY_GPIO 0x14
80 #define PC_CONFIG_RPUP_BUF 0x15
81 
82 /* 1-Wire Preset Timings [us] */
83 //tRSTL - Standard Speed
84 #define tRSTL_STANDARD_PRESET_0 440
85 #define tRSTL_STANDARD_PRESET_1 460
86 #define tRSTL_STANDARD_PRESET_2 480
87 #define tRSTL_STANDARD_PRESET_3 500
88 #define tRSTL_STANDARD_PRESET_4 520
89 #define tRSTL_STANDARD_PRESET_5 540
90 #define tRSTL_STANDARD_PRESET_6 560
91 #define tRSTL_STANDARD_PRESET_7 580
92 #define tRSTL_STANDARD_PRESET_8 600
93 #define tRSTL_STANDARD_PRESET_9 620
94 #define tRSTL_STANDARD_PRESET_A 640
95 #define tRSTL_STANDARD_PRESET_B 660
96 #define tRSTL_STANDARD_PRESET_C 680
97 #define tRSTL_STANDARD_PRESET_D 720
98 #define tRSTL_STANDARD_PRESET_E 800
99 #define tRSTL_STANDARD_PRESET_F 960
100 
101 //tRSTL - Overdrive Speed
102 #define tRSTL_OVERDRIVE_PRESET_0 44
103 #define tRSTL_OVERDRIVE_PRESET_1 46
104 #define tRSTL_OVERDRIVE_PRESET_2 48
105 #define tRSTL_OVERDRIVE_PRESET_3 50
106 #define tRSTL_OVERDRIVE_PRESET_4 52
107 #define tRSTL_OVERDRIVE_PRESET_5 54
108 #define tRSTL_OVERDRIVE_PRESET_6 56
109 #define tRSTL_OVERDRIVE_PRESET_7 58
110 #define tRSTL_OVERDRIVE_PRESET_8 60
111 #define tRSTL_OVERDRIVE_PRESET_9 62
112 #define tRSTL_OVERDRIVE_PRESET_A 64
113 #define tRSTL_OVERDRIVE_PRESET_B 66
114 #define tRSTL_OVERDRIVE_PRESET_C 68
115 #define tRSTL_OVERDRIVE_PRESET_D 72
116 #define tRSTL_OVERDRIVE_PRESET_E 74
117 #define tRSTL_OVERDRIVE_PRESET_F 80
118 
119 //tRSTH - Standard Speed
120 #define tRSTH_STANDARD_PRESET_0 440
121 #define tRSTH_STANDARD_PRESET_1 460
122 #define tRSTH_STANDARD_PRESET_2 480
123 #define tRSTH_STANDARD_PRESET_3 500
124 #define tRSTH_STANDARD_PRESET_4 520
125 #define tRSTH_STANDARD_PRESET_5 540
126 #define tRSTH_STANDARD_PRESET_6 560
127 #define tRSTH_STANDARD_PRESET_7 580
128 #define tRSTH_STANDARD_PRESET_8 600
129 #define tRSTH_STANDARD_PRESET_9 620
130 #define tRSTH_STANDARD_PRESET_A 640
131 #define tRSTH_STANDARD_PRESET_B 660
132 #define tRSTH_STANDARD_PRESET_C 680
133 #define tRSTH_STANDARD_PRESET_D 700
134 #define tRSTH_STANDARD_PRESET_E 720
135 #define tRSTH_STANDARD_PRESET_F 740
136 
137 //tRSTH - Overdrive Speed
138 #define tRSTH_OVERDRIVE_PRESET_0 44
139 #define tRSTH_OVERDRIVE_PRESET_1 46
140 #define tRSTH_OVERDRIVE_PRESET_2 48
141 #define tRSTH_OVERDRIVE_PRESET_3 50
142 #define tRSTH_OVERDRIVE_PRESET_4 52
143 #define tRSTH_OVERDRIVE_PRESET_5 54
144 #define tRSTH_OVERDRIVE_PRESET_6 56
145 #define tRSTH_OVERDRIVE_PRESET_7 58
146 #define tRSTH_OVERDRIVE_PRESET_8 60
147 #define tRSTH_OVERDRIVE_PRESET_9 62
148 #define tRSTH_OVERDRIVE_PRESET_A 64
149 #define tRSTH_OVERDRIVE_PRESET_B 66
150 #define tRSTH_OVERDRIVE_PRESET_C 68
151 #define tRSTH_OVERDRIVE_PRESET_D 70
152 #define tRSTH_OVERDRIVE_PRESET_E 72
153 #define tRSTH_OVERDRIVE_PRESET_F 74
154 
155 //tW0L - Standard Speed
156 #define tW0L_STANDARD_PRESET_0 52
157 #define tW0L_STANDARD_PRESET_1 56
158 #define tW0L_STANDARD_PRESET_2 60
159 #define tW0L_STANDARD_PRESET_3 62
160 #define tW0L_STANDARD_PRESET_4 64
161 #define tW0L_STANDARD_PRESET_5 66
162 #define tW0L_STANDARD_PRESET_6 68
163 #define tW0L_STANDARD_PRESET_7 70
164 #define tW0L_STANDARD_PRESET_8 72
165 #define tW0L_STANDARD_PRESET_9 74
166 #define tW0L_STANDARD_PRESET_A 76
167 #define tW0L_STANDARD_PRESET_B 80
168 #define tW0L_STANDARD_PRESET_C 90
169 #define tW0L_STANDARD_PRESET_D 100
170 #define tW0L_STANDARD_PRESET_E 110
171 #define tW0L_STANDARD_PRESET_F 120
172 
173 //tW0L - Overdrive Speed
174 #define tW0L_OVERDRIVE_PRESET_0 5
175 #define tW0L_OVERDRIVE_PRESET_1 5.5
176 #define tW0L_OVERDRIVE_PRESET_2 6
177 #define tW0L_OVERDRIVE_PRESET_3 6.5
178 #define tW0L_OVERDRIVE_PRESET_4 7
179 #define tW0L_OVERDRIVE_PRESET_5 7.5
180 #define tW0L_OVERDRIVE_PRESET_6 8
181 #define tW0L_OVERDRIVE_PRESET_7 8.5
182 #define tW0L_OVERDRIVE_PRESET_8 9
183 #define tW0L_OVERDRIVE_PRESET_9 9.5
184 #define tW0L_OVERDRIVE_PRESET_A 10
185 #define tW0L_OVERDRIVE_PRESET_B 11
186 #define tW0L_OVERDRIVE_PRESET_C 12
187 #define tW0L_OVERDRIVE_PRESET_D 13
188 #define tW0L_OVERDRIVE_PRESET_E 14
189 #define tW0L_OVERDRIVE_PRESET_F 15.5
190 
191 //tREC - Standard Speed
192 #define tREC_STANDARD_PRESET_0 0.5
193 #define tREC_STANDARD_PRESET_1 1.5
194 #define tREC_STANDARD_PRESET_2 2
195 #define tREC_STANDARD_PRESET_3 3
196 #define tREC_STANDARD_PRESET_4 4
197 #define tREC_STANDARD_PRESET_5 5
198 #define tREC_STANDARD_PRESET_6 6
199 #define tREC_STANDARD_PRESET_7 7.5
200 #define tREC_STANDARD_PRESET_8 12
201 #define tREC_STANDARD_PRESET_9 17.5
202 #define tREC_STANDARD_PRESET_A 28.5
203 #define tREC_STANDARD_PRESET_B 34
204 #define tREC_STANDARD_PRESET_C 45
205 #define tREC_STANDARD_PRESET_D 56.5
206 #define tREC_STANDARD_PRESET_E 112
207 #define tREC_STANDARD_PRESET_F 223
208 
209 //tREC - Overdrive Speed
210 #define tREC_OVERDRIVE_PRESET_0 0.5
211 #define tREC_OVERDRIVE_PRESET_1 1.5
212 #define tREC_OVERDRIVE_PRESET_2 2
213 #define tREC_OVERDRIVE_PRESET_3 3
214 #define tREC_OVERDRIVE_PRESET_4 4
215 #define tREC_OVERDRIVE_PRESET_5 5
216 #define tREC_OVERDRIVE_PRESET_6 6
217 #define tREC_OVERDRIVE_PRESET_7 7.5
218 #define tREC_OVERDRIVE_PRESET_8 12
219 #define tREC_OVERDRIVE_PRESET_9 17.5
220 #define tREC_OVERDRIVE_PRESET_A 28.5
221 #define tREC_OVERDRIVE_PRESET_B 34
222 #define tREC_OVERDRIVE_PRESET_C 45
223 #define tREC_OVERDRIVE_PRESET_D 56.5
224 #define tREC_OVERDRIVE_PRESET_E 112
225 #define tREC_OVERDRIVE_PRESET_F 223
226 
227 //tMSI - Standard Speed
228 #define tMSI_STANDARD_PRESET_0 3
229 #define tMSI_STANDARD_PRESET_1 3
230 #define tMSI_STANDARD_PRESET_2 3
231 #define tMSI_STANDARD_PRESET_3 5
232 #define tMSI_STANDARD_PRESET_4 6
233 #define tMSI_STANDARD_PRESET_5 7
234 #define tMSI_STANDARD_PRESET_6 7.5
235 #define tMSI_STANDARD_PRESET_7 8
236 #define tMSI_STANDARD_PRESET_8 8.5
237 #define tMSI_STANDARD_PRESET_9 9
238 #define tMSI_STANDARD_PRESET_A 10
239 #define tMSI_STANDARD_PRESET_B 11
240 #define tMSI_STANDARD_PRESET_C 12
241 #define tMSI_STANDARD_PRESET_D 13
242 #define tMSI_STANDARD_PRESET_E 14
243 #define tMSI_STANDARD_PRESET_F 15
244 
245 //tMSI - Overdrive Speed
246 #define tMSI_OVERDRIVE_PRESET_0 0.75
247 #define tMSI_OVERDRIVE_PRESET_1 0.75
248 #define tMSI_OVERDRIVE_PRESET_2 0.75
249 #define tMSI_OVERDRIVE_PRESET_3 0.75
250 #define tMSI_OVERDRIVE_PRESET_4 1
251 #define tMSI_OVERDRIVE_PRESET_5 1.25
252 #define tMSI_OVERDRIVE_PRESET_6 1.5
253 #define tMSI_OVERDRIVE_PRESET_7 1.625
254 #define tMSI_OVERDRIVE_PRESET_8 1.75
255 #define tMSI_OVERDRIVE_PRESET_9 1.875
256 #define tMSI_OVERDRIVE_PRESET_A 2
257 #define tMSI_OVERDRIVE_PRESET_B 2.125
258 #define tMSI_OVERDRIVE_PRESET_C 2.25
259 #define tMSI_OVERDRIVE_PRESET_D 2.375
260 #define tMSI_OVERDRIVE_PRESET_E 2.5
261 #define tMSI_OVERDRIVE_PRESET_F 2.625
262 
263 //tMSP - Standard Speed
264 #define tMSP_STANDARD_PRESET_0 58
265 #define tMSP_STANDARD_PRESET_1 60
266 #define tMSP_STANDARD_PRESET_2 62
267 #define tMSP_STANDARD_PRESET_3 64
268 #define tMSP_STANDARD_PRESET_4 66
269 #define tMSP_STANDARD_PRESET_5 67
270 #define tMSP_STANDARD_PRESET_6 68
271 #define tMSP_STANDARD_PRESET_7 69
272 #define tMSP_STANDARD_PRESET_8 70
273 #define tMSP_STANDARD_PRESET_9 71
274 #define tMSP_STANDARD_PRESET_A 72
275 #define tMSP_STANDARD_PRESET_B 74
276 #define tMSP_STANDARD_PRESET_C 76
277 #define tMSP_STANDARD_PRESET_D 78
278 #define tMSP_STANDARD_PRESET_E 80
279 #define tMSP_STANDARD_PRESET_F 82
280 
281 //tMSP - Overdrive Speed
282 #define tMSP_OVERDRIVE_PRESET_0 5
283 #define tMSP_OVERDRIVE_PRESET_1 5.5
284 #define tMSP_OVERDRIVE_PRESET_2 6
285 #define tMSP_OVERDRIVE_PRESET_3 6.5
286 #define tMSP_OVERDRIVE_PRESET_4 7
287 #define tMSP_OVERDRIVE_PRESET_5 7.5
288 #define tMSP_OVERDRIVE_PRESET_6 8
289 #define tMSP_OVERDRIVE_PRESET_7 8.5
290 #define tMSP_OVERDRIVE_PRESET_8 9
291 #define tMSP_OVERDRIVE_PRESET_9 9.5
292 #define tMSP_OVERDRIVE_PRESET_A 10
293 #define tMSP_OVERDRIVE_PRESET_B 10.5
294 #define tMSP_OVERDRIVE_PRESET_C 11
295 #define tMSP_OVERDRIVE_PRESET_D 12
296 #define tMSP_OVERDRIVE_PRESET_E 13
297 #define tMSP_OVERDRIVE_PRESET_F 14
298 
299 //tW1L - Standard Speed
300 #define tW1L_STANDARD_PRESET_0 1
301 #define tW1L_STANDARD_PRESET_1 3
302 #define tW1L_STANDARD_PRESET_2 5
303 #define tW1L_STANDARD_PRESET_3 6.5
304 #define tW1L_STANDARD_PRESET_4 7
305 #define tW1L_STANDARD_PRESET_5 7.5
306 #define tW1L_STANDARD_PRESET_6 8
307 #define tW1L_STANDARD_PRESET_7 9
308 #define tW1L_STANDARD_PRESET_8 10
309 #define tW1L_STANDARD_PRESET_9 11
310 #define tW1L_STANDARD_PRESET_A 12
311 #define tW1L_STANDARD_PRESET_B 13
312 #define tW1L_STANDARD_PRESET_C 14
313 #define tW1L_STANDARD_PRESET_D 15
314 #define tW1L_STANDARD_PRESET_E 15.5
315 #define tW1L_STANDARD_PRESET_F 16
316 
317 //tW1L - Overdrive Speed
318 #define tW1L_OVERDRIVE_PRESET_0 0.0625
319 #define tW1L_OVERDRIVE_PRESET_1 0.125
320 #define tW1L_OVERDRIVE_PRESET_2 0.25
321 #define tW1L_OVERDRIVE_PRESET_3 0.375
322 #define tW1L_OVERDRIVE_PRESET_4 0.5
323 #define tW1L_OVERDRIVE_PRESET_5 0.625
324 #define tW1L_OVERDRIVE_PRESET_6 0.75
325 #define tW1L_OVERDRIVE_PRESET_7 0.875
326 #define tW1L_OVERDRIVE_PRESET_8 1
327 #define tW1L_OVERDRIVE_PRESET_9 1.125
328 #define tW1L_OVERDRIVE_PRESET_A 1.25
329 #define tW1L_OVERDRIVE_PRESET_B 1.375
330 #define tW1L_OVERDRIVE_PRESET_C 1.5
331 #define tW1L_OVERDRIVE_PRESET_D 1.625
332 #define tW1L_OVERDRIVE_PRESET_E 1.75
333 #define tW1L_OVERDRIVE_PRESET_F 1.875
334 
335 //tMSR - Standard Speed
336 #define tMSR_STANDARD_PRESET_0 5
337 #define tMSR_STANDARD_PRESET_1 7
338 #define tMSR_STANDARD_PRESET_2 9
339 #define tMSR_STANDARD_PRESET_3 10.5
340 #define tMSR_STANDARD_PRESET_4 11
341 #define tMSR_STANDARD_PRESET_5 11.5
342 #define tMSR_STANDARD_PRESET_6 12
343 #define tMSR_STANDARD_PRESET_7 13
344 #define tMSR_STANDARD_PRESET_8 14
345 #define tMSR_STANDARD_PRESET_9 15
346 #define tMSR_STANDARD_PRESET_A 16
347 #define tMSR_STANDARD_PRESET_B 17
348 #define tMSR_STANDARD_PRESET_C 18
349 #define tMSR_STANDARD_PRESET_D 19
350 #define tMSR_STANDARD_PRESET_E 19.5
351 #define tMSR_STANDARD_PRESET_F 20
352 
353 //tMSR - Overdrive Speed
354 #define tMSR_OVERDRIVE_PRESET_0 1
355 #define tMSR_OVERDRIVE_PRESET_1 1.125
356 #define tMSR_OVERDRIVE_PRESET_2 1.25
357 #define tMSR_OVERDRIVE_PRESET_3 1.375
358 #define tMSR_OVERDRIVE_PRESET_4 1.5
359 #define tMSR_OVERDRIVE_PRESET_5 1.625
360 #define tMSR_OVERDRIVE_PRESET_6 1.75
361 #define tMSR_OVERDRIVE_PRESET_7 1.875
362 #define tMSR_OVERDRIVE_PRESET_8 2
363 #define tMSR_OVERDRIVE_PRESET_9 2.125
364 #define tMSR_OVERDRIVE_PRESET_A 2.25
365 #define tMSR_OVERDRIVE_PRESET_B 2.375
366 #define tMSR_OVERDRIVE_PRESET_C 2.5
367 #define tMSR_OVERDRIVE_PRESET_D 2.625
368 #define tMSR_OVERDRIVE_PRESET_E 2.75
369 #define tMSR_OVERDRIVE_PRESET_F 2.875
370 
371 /* 1-Wire Speeds */
372 typedef enum {
373  STANDARD,
374  OVERDRIVE,
375 } one_wire_speeds;
376 
377 /* One Wire Timing Presets */
378 typedef enum {
379  PRESET_0,
380  PRESET_1,
381  PRESET_2,
382  PRESET_3,
383  PRESET_4,
384  PRESET_5,
385  PRESET_6,
386  PRESET_7,
387  PRESET_8,
388  PRESET_9,
389  PRESET_A,
390  PRESET_B,
391  PRESET_C,
392  PRESET_D,
393  PRESET_E,
394  PRESET_F,
395 } one_wire_timing_presets;
396 
397 /* VTH Values */
398 typedef enum {
399  VTH_LOW,
400  VTH_MEDIUM,
401  VTH_HIGH,
402  VTH_OFF
403 } vth_values;
404 
405 /* VIAPO Values */
406 typedef enum {
407  VIAPO_LOW,
408  VIAPO_MEDIUM,
409  VIAPO_HIGH,
410  VIAPO_OFF
411 } viapo_values;
412 
413 /* RWPU Values */
414 typedef enum {
415  RWPU_EXTERNAL,
416  RWPU_500,
417  RWPU_1000,
418  RWPU_333,
419 } rwpu_values;
420 
421 /* GPIO Settings */
422 typedef enum {
423  CONDUCTING = 0xAA,
424  NON_CONDUCTING = 0x55,
425  CONDUCTING_NO_LEVEL_READ = 0xA5,
426  NON_CONDUCTING_NO_LEVEL_READ = 0x5A,
427 } gpio_settings;
428 
429 /* GPIO Verify Level Detection */
430 typedef enum {
431  LOW = 0xAA,
432  HIGH = 0x55,
433 } gpio_verify_level_detection;
434 
435 
436 /* **** Globals **** */
437 
438 extern uint8_t oneWireScript[126];
439 extern uint8_t oneWireScript_length;
440 extern double oneWireScript_accumulativeOneWireTime;
441 extern uint8_t oneWireScript_commandsCount;
442 extern uint8_t oneWireScriptResponse[126];
443 extern uint8_t oneWireScriptResponse_length;
444 
445 /***** Low Level Functions *****/
446 int OneWire_ResetPulse(void);
447 int OneWire_WriteByte(uint8_t byte);
448 int OneWire_WriteBlock(uint8_t *data, int data_length);
449 uint8_t OneWire_ReadByte(void);
450 void OneWire_ReadBlock(uint8_t *data, int data_length);
451 int OneWire_Search(OneWire_ROM_ID_T *romid, bool search_reset, bool *last_device_found);
452 int OneWire_WriteBytePower(int send_byte);
453 
454 /***** High Level Functions *****/
455 int OneWire_Enable_APU(bool apu);
456 int OneWire_Enable_SPU(bool spu);
457 int OneWire_Enable_OneWirePowerDown(bool pdn);
458 int OneWire_Set_OneWireMasterSpeed(one_wire_speeds spd);
459 int OneWire_Get_OneWireMasterSpeed(one_wire_speeds *spd);
460 
461 //RPUP/BUF
462 int OneWire_Set_Custom_RPUP_BUF(vth_values vth, viapo_values viapo, rwpu_values rwpu);
463 int OneWire_Get_Custom_RPUP_BUF(vth_values *vth, viapo_values *viapo, rwpu_values *rwpu); //overwrites vth, viapo, and rwpu with value read from DS2485
464 
465 //tRSTL
466 int OneWire_Set_tRSTL_Standard_Predefined(one_wire_timing_presets trstl);
467 int OneWire_Set_tRSTL_Overdrive_Predefined(one_wire_timing_presets trstl);
468 int OneWire_Set_tRSTL_Standard_Custom(double trstl); // Max = 1020 us
469 int OneWire_Set_tRSTL_Overdrive_Custom(double trstl); // Max = 126 us
470 int OneWire_Get_tRSTL(double *trstl, one_wire_speeds spd); //overwrites trstl in us
471 
472 //tRSTH
473 int OneWire_Set_tRSTH_Standard_Predefined(one_wire_timing_presets trsth);
474 int OneWire_Set_tRSTH_Overdrive_Predefined(one_wire_timing_presets trsth);
475 int OneWire_Set_tRSTH_Standard_Custom(double trsth); // Max = 1020 us
476 int OneWire_Set_tRSTH_Overdrive_Custom(double trsth); // Max = 126 us
477 int OneWire_Get_tRSTH(double *trsth, one_wire_speeds spd); //overwrites trsth in us
478 
479 //tRSTH
480 int OneWire_Set_tW0L_Standard_Predefined(one_wire_timing_presets tw0l);
481 int OneWire_Set_tW0L_Overdrive_Predefined(one_wire_timing_presets tw0l);
482 int OneWire_Set_tW0L_Standard_Custom(double tw0l); // Max = 126 us
483 int OneWire_Set_tW0L_Overdrive_Custom(double tw0l); // Max = 31.5 us
484 int OneWire_Get_tW0L(double *tw0l, one_wire_speeds spd); //overwrites tw0l in us
485 
486 //tREC
487 int OneWire_Set_tREC_Standard_Predefined(one_wire_timing_presets trec);
488 int OneWire_Set_tREC_Overdrive_Predefined(one_wire_timing_presets trec);
489 int OneWire_Set_tREC_Standard_Custom(double trec); // Max = 255.5 us
490 int OneWire_Set_tREC_Overdrive_Custom(double trec); // Max = 255.5 us
491 int OneWire_Get_tREC(double *trec, one_wire_speeds spd); //overwrites trec in us
492 
493 //tMSI
494 int OneWire_Set_tMSI_Standard_Predefined(one_wire_timing_presets tmsi);
495 int OneWire_Set_tMSI_Overdrive_Predefined(one_wire_timing_presets tmsi);
496 int OneWire_Set_tMSI_Standard_Custom(double tmsi); // Max = 15.5 us
497 int OneWire_Set_tMSI_Overdrive_Custom(double tmsi); // Max = 3.875 us
498 int OneWire_Get_tMSI(double *tmsi, one_wire_speeds spd); //overwrites tmsi in us
499 
500 //tMSP
501 int OneWire_Set_tMSP_Standard_Predefined(one_wire_timing_presets tmsp);
502 int OneWire_Set_tMSP_Overdrive_Predefined(one_wire_timing_presets tmsp);
503 int OneWire_Set_tMSP_Standard_Custom(double tmsp); // Max = 127 us
504 int OneWire_Set_tMSP_Overdrive_Custom(double tmsp); // Max = 15.5 us
505 int OneWire_Get_tMSP(double *tmsp, one_wire_speeds spd); //overwrites tmsp in us
506 
507 //tW1L
508 int OneWire_Set_tW1L_Standard_Predefined(one_wire_timing_presets tw1l);
509 int OneWire_Set_tW1L_Overdrive_Predefined(one_wire_timing_presets tw1l);
510 int OneWire_Set_tW1L_Standard_Custom(double tw1l); // Max = 31.5 us
511 int OneWire_Set_tW1L_Overdrive_Custom(double tw1l); // Max = 1.9375 us
512 int OneWire_Get_tW1L(double *tw1l, one_wire_speeds spd); //overwrites tw1l in us
513 
514 //tMSR
515 int OneWire_Set_tMSR_Standard_Predefined(one_wire_timing_presets tmsr);
516 int OneWire_Set_tMSR_Overdrive_Predefined(one_wire_timing_presets tmsr);
517 int OneWire_Set_tMSR_Standard_Custom(double tmsr); // Max = 31.5 us
518 int OneWire_Set_tMSR_Overdrive_Custom(double tmsr); // Max = 3.875 us
519 int OneWire_Get_tMSR(double *tmsr, one_wire_speeds spd); //overwrites tmsr in us
520 
521 /* Primitive Script Commands */
522 extern void OneWire_Script_Clear(void);
523 extern int OneWire_Script_Execute(void);
524 extern int OneWire_Script_Add_OW_RESET(uint8_t *response_index, one_wire_speeds spd, bool ignore);
525 extern int OneWire_Script_Add_OW_WRITE_BIT(uint8_t *response_index, bool bit_value);
526 extern int OneWire_Script_Add_OW_READ_BIT(uint8_t *response_index);
527 extern int OneWire_Script_Add_OW_WRITE_BYTE(uint8_t *response_index, uint8_t txByte);
528 extern int OneWire_Script_Add_OW_READ_BYTE(uint8_t *response_index);
529 extern int OneWire_Script_Add_OW_TRIPLET(uint8_t *response_index, bool t_value);
530 extern int OneWire_Script_Add_OV_SKIP(uint8_t *response_index);
531 extern int OneWire_Script_Add_SKIP(uint8_t *response_index);
532 extern int OneWire_Script_Add_OW_READ_BLOCK(uint8_t *response_index, uint8_t rxBytes);
533 extern int OneWire_Script_Add_OW_WRITE_BLOCK(uint8_t *response_index, const uint8_t *txData, uint8_t txData_length);
534 extern void OneWire_Script_Add_DELAY(uint8_t ms);
535 extern void OneWire_Script_Add_PRIME_SPU(void);
536 extern void OneWire_Script_Add_SPU_OFF(void);
537 extern int OneWire_Script_Add_SPEED(one_wire_speeds spd, bool ignore);
538 extern int OneWire_Script_Add_VERIFY_TOGGLE(uint8_t *response_index);
539 extern int OneWire_Script_Add_VERIFY_BYTE(uint8_t *response_index, uint8_t byte);
540 extern void OneWire_Script_Add_CRC16_START(void);
541 extern void OneWire_Script_Add_VERIFY_CRC16(uint8_t *response_index, unsigned short hex_value);
542 extern void OneWire_Script_Add_SET_GPIO(uint8_t *response_index, gpio_settings pioac);
543 extern void OneWire_Script_Add_READ_GPIO(uint8_t *response_index);
544 extern void OneWire_Script_Add_VERIFY_GPIO(uint8_t *response_index, gpio_verify_level_detection pioal);
545 extern void OneWire_Script_Add_CONFIG_RPUP_BUF(unsigned short hex_value);
546 
547 int OneWire_Init(void);
548 
549 
550 #ifdef __cplusplus
551 }
552 #endif
553 
554 #endif /* _ONE_WIRE_TEST_H_ */
Address of a device on a 1-Wire bus. Separate file to allow inclusion by high-level functions without...
OneWire_ROM_ID_T type stores a 1-Wire address.
Definition: one_wire_address.h:15
int OneWire_Search(OneWire_ROM_ID_T *romid, bool search_reset, bool *last_device_found)
Definition: one_wire.c:164