Mercurial > ~darius > hgwebdir.cgi > tempctrl
comparison 1wire.c @ 22:bd792ebf813d
Report the bus being held low back to the caller from OWFirst/Next.
author | darius |
---|---|
date | Mon, 12 Dec 2005 23:27:40 +1030 |
parents | e82d15fa9a1a |
children | 02b67e09ca12 |
comparison
equal
deleted
inserted
replaced
21:e82d15fa9a1a | 22:bd792ebf813d |
---|---|
52 OWdelay(void) { | 52 OWdelay(void) { |
53 DELAY_I; | 53 DELAY_I; |
54 } | 54 } |
55 | 55 |
56 /*----------------------------------------------------------------------------- | 56 /*----------------------------------------------------------------------------- |
57 * Generate a 1-Wire reset, return 0 if presence pulse was found, | 57 * Generate a 1-Wire reset, return 0 if presence pulse was found, 1 if it |
58 * return 1 otherwise. | 58 * wasn't, or 2 if the line appears to be being held low. |
59 * | |
59 * | 60 * |
60 * (NOTE: Does not handle alarm presence from DS2404/DS1994) | 61 * (NOTE: Does not handle alarm presence from DS2404/DS1994) |
61 */ | 62 */ |
62 uint8_t | 63 uint8_t |
63 OWTouchReset(void) { | 64 OWTouchReset(void) { |
64 DELAY_G; | 65 DELAY_G; |
66 | |
67 if (!(OWIREINPORT & _BV(OWIREINPIN))) | |
68 return 2; | |
69 | |
65 OWIREOUTPORT &= ~(_BV(OWIREOUTPIN)); | 70 OWIREOUTPORT &= ~(_BV(OWIREOUTPIN)); |
66 OWIREDDR |= _BV(OWIREOUTPIN); | 71 OWIREDDR |= _BV(OWIREOUTPIN); |
67 DELAY_H; | 72 DELAY_H; |
68 OWIREDDR &= ~(_BV(OWIREOUTPIN)); | 73 OWIREDDR &= ~(_BV(OWIREOUTPIN)); |
69 DELAY_I; | 74 DELAY_I; |
237 /* reset the 1-wire | 242 /* reset the 1-wire |
238 * if there are no parts on 1-wire, return 0 */ | 243 * if there are no parts on 1-wire, return 0 */ |
239 #if OW_DEBUG | 244 #if OW_DEBUG |
240 uart_putsP(PSTR("Resetting\n\r")); | 245 uart_putsP(PSTR("Resetting\n\r")); |
241 #endif | 246 #endif |
242 if (OWTouchReset()) { | 247 switch (OWTouchReset()) { |
243 /* reset the search */ | 248 case 0: |
244 OW_LastDiscrepancy = 0; | 249 break; |
245 OW_LastFamilyDiscrepancy = 0; | 250 |
246 #if OW_DEBUG | 251 case 1: |
247 uart_putsP(PSTR("No devices on bus\n\r")); | 252 /* reset the search */ |
248 #endif | 253 OW_LastDiscrepancy = 0; |
249 return OW_NOPRESENCE; | 254 OW_LastFamilyDiscrepancy = 0; |
255 #if OW_DEBUG | |
256 uart_putsP(PSTR("No devices on bus\n\r")); | |
257 #endif | |
258 return OW_NOPRESENCE; | |
259 break; | |
260 | |
261 case 2: | |
262 /* reset the search */ | |
263 OW_LastDiscrepancy = 0; | |
264 OW_LastFamilyDiscrepancy = 0; | |
265 #if OW_DEBUG | |
266 uart_putsP(PSTR("Bus appears to be being held low\n\r")); | |
267 #endif | |
268 return OW_BADWIRE; | |
269 break; | |
270 | |
250 } | 271 } |
251 } | 272 } |
252 | 273 |
253 /* If finding alarming devices issue a different command */ | 274 /* If finding alarming devices issue a different command */ |
254 if (alarm_only) | 275 if (alarm_only) |