comparison 1wire.c @ 13:6f8f7b87d2f1

- Rename 1wire config example to note it's for AVR. - Add STM32 config. - Rework a little to remove AVR depedencies. - Re-do OWProgROM in the no VPP case so it doesn't generate warnings.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 07 Feb 2012 13:53:21 +1030
parents 3879f487b661
children d8002c716678
comparison
equal deleted inserted replaced
12:4e10d1eef9a5 13:6f8f7b87d2f1
35 * 35 *
36 * Modify 1wire-config.h 36 * Modify 1wire-config.h
37 */ 37 */
38 38
39 #include <stdio.h> 39 #include <stdio.h>
40 #include <avr/io.h> 40 #include <stdint.h>
41 #include <avr/pgmspace.h> 41 #include "1wire-config.h"
42 #include <util/delay.h>
43 #include "1wire.h" 42 #include "1wire.h"
44 #include "1wire-config.h"
45 #include "cons.h"
46 43
47 static uint8_t OW_LastDevice = 0; 44 static uint8_t OW_LastDevice = 0;
48 static uint8_t OW_LastDiscrepancy = 0; 45 static uint8_t OW_LastDiscrepancy = 0;
49 static uint8_t OW_LastFamilyDiscrepancy = 0; 46 static uint8_t OW_LastFamilyDiscrepancy = 0;
50 47
76 73
77 /* Check the bus isn't being held low (ie it's broken) Do it after 74 /* Check the bus isn't being held low (ie it's broken) Do it after
78 * the delay so we guarantee we don't see a slave from a previous 75 * the delay so we guarantee we don't see a slave from a previous
79 * comms attempt 76 * comms attempt
80 */ 77 */
81 #if 0
82 OWSETREAD(); 78 OWSETREAD();
83 if(OWREADBUS() == 0) 79 if(OWREADBUS() == 0)
84 return 2; 80 return 2;
85 #endif
86 81
87 OWSETBUSLOW(); 82 OWSETBUSLOW();
88 OWDELAY_H; 83 OWDELAY_H;
89 OWSETBUSHIGH(); 84 OWSETBUSHIGH();
90 OWDELAY_I; 85 OWDELAY_I;
429 * 1 if the programming is not possible 424 * 1 if the programming is not possible
430 * 2 if the parameters were invalid 425 * 2 if the parameters were invalid
431 * 3 if the DS2502 didn't respond appropriately (also happens if the 426 * 3 if the DS2502 didn't respond appropriately (also happens if the
432 * module doesn't exist) 427 * module doesn't exist)
433 */ 428 */
429 #if defined(OWSETVPPON) && defined(OWSETVPPOFF)
434 uint8_t 430 uint8_t
435 OWProgROM(uint8_t *ROM, uint8_t start, uint8_t len, uint8_t *data, uint8_t exact, uint8_t status) { 431 OWProgROM(uint8_t *ROM, uint8_t start, uint8_t len, uint8_t *data, uint8_t exact, uint8_t status) {
436 #if defined(OWSETVPPON) && defined(OWSETVPPOFF)
437 uint8_t crc, i, tmp; 432 uint8_t crc, i, tmp;
438 433
439 /* Stupid programmer detection */ 434 /* Stupid programmer detection */
440 if (status) { 435 if (status) {
441 if (start + len > 3) 436 if (start + len > 3)
525 crc = 0; 520 crc = 0;
526 OWCRC(start + i + 1, &crc); 521 OWCRC(start + i + 1, &crc);
527 } 522 }
528 523
529 return(0); 524 return(0);
525 }
530 #else 526 #else
527 uint8_t
528 OWProgROM(uint8_t *ROM __attribute((unused)), uint8_t start __attribute((unused)), uint8_t len __attribute((unused)), uint8_t *data __attribute((unused)), uint8_t exact __attribute((unused)), uint8_t status __attribute((unused))) {
531 return(1); 529 return(1);
530 }
532 #endif 531 #endif
533 }
534 532
535 /* 533 /*
536 * OWGetTemp 534 * OWGetTemp
537 * 535 *
538 * Get the temperature from a 1wire bus module 536 * Get the temperature from a 1wire bus module