comparison testavr.c @ 10:eb1faf51968e

- Add some useful return values to search functions. - Remove some unecessary trailing \'s in macros - Replace some inline assembly I missed last time with C/macros.
author darius
date Mon, 12 Jul 2004 23:59:00 +0930
parents 7ed10c59ba06
children ccc39c9f320b
comparison
equal deleted inserted replaced
9:7ed10c59ba06 10:eb1faf51968e
172 172
173 if (cmdbuf[0] == 'r' && cmdbuf[1] == 's') { 173 if (cmdbuf[0] == 'r' && cmdbuf[1] == 's') {
174 uart_putsP(PSTR("Resetting... ")); 174 uart_putsP(PSTR("Resetting... "));
175 175
176 if (OWTouchReset() == 1) 176 if (OWTouchReset() == 1)
177 uart_putsP(PSTR("No presense\n\r")); 177 uart_putsP(PSTR("No presense pulse found\n\r"));
178 else 178 else
179 uart_putsP(PSTR("Presense\n\r")); 179 uart_putsP(PSTR("Presense pulse found\n\r"));
180 } else if (cmdbuf[0] == 'r' && cmdbuf[1] == 'e') { 180 } else if (cmdbuf[0] == 'r' && cmdbuf[1] == 'e') {
181 if (OWReadBit()) 181 if (OWReadBit())
182 uart_putsP(PSTR("Read a 1\n\r")); 182 uart_putsP(PSTR("Read a 1\n\r"));
183 else 183 else
184 uart_putsP(PSTR("Read a 0\n\r")); 184 uart_putsP(PSTR("Read a 0\n\r"));
289 sprintf_P(cmdbuf, PSTR("temperature %d.%01d\n\r"), 289 sprintf_P(cmdbuf, PSTR("temperature %d.%01d\n\r"),
290 temp >> 4, (temp << 12) / 6553); 290 temp >> 4, (temp << 12) / 6553);
291 uart_puts(cmdbuf); 291 uart_puts(cmdbuf);
292 } else if (cmdbuf[0] == 's' && cmdbuf[1] == 'r') { 292 } else if (cmdbuf[0] == 's' && cmdbuf[1] == 'r') {
293 memset(ROM, 0, 8); 293 memset(ROM, 0, 8);
294 if (OWTouchReset()) { 294
295 uart_putsP(PSTR("No devices on bus\n\r")); 295 i = OWFirst(ROM, 1, 0);
296 break;
297 }
298 if (OWFirst(ROM, 1, 0) == 0) {
299 uart_putsP(PSTR("No module found\n\r"));
300 break;
301 }
302 do { 296 do {
297 switch (i) {
298 case OW_BADWIRE:
299 uart_putsP(PSTR("Presense pulse, but no module found, bad module/cabling?\n\r"));
300 break;
301
302 case OW_NOPRESENCE:
303 uart_putsP(PSTR("No presense pulse found\n\r"));
304 break;
305
306 case OW_BADCRC:
307 uart_putsP(PSTR("Bad CRC\n\r"));
308 break;
309
310 case OW_NOMODULES:
311 case OW_FOUND:
312 break;
313
314 default:
315 uart_putsP(PSTR("Unknown error from 1 wire library\n\r"));
316 break;
317 }
318
319 if (i != OW_FOUND)
320 break;
321
303 sprintf_P(cmdbuf, PSTR("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n\r"), 322 sprintf_P(cmdbuf, PSTR("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n\r"),
304 ROM[0], 323 ROM[0],
305 ROM[1], 324 ROM[1],
306 ROM[2], 325 ROM[2],
307 ROM[3], 326 ROM[3],
308 ROM[4], 327 ROM[4],
309 ROM[5], 328 ROM[5],
310 ROM[6], 329 ROM[6],
311 ROM[7]); 330 ROM[7]);
312 uart_puts(cmdbuf); 331 uart_puts(cmdbuf);
313 } while (OWNext(ROM, 1, 0)); 332
333 i = OWNext(ROM, 1, 0);
334 } while (1);
335
314 #if 0 336 #if 0
315 337
316 } else if (cmdbuf[0] == 'l' && cmdbuf[1] == 'e' && cmdbuf[2] == 'd') { 338 } else if (cmdbuf[0] == 'l' && cmdbuf[1] == 'e' && cmdbuf[2] == 'd') {
317 if (leds == 0) { 339 if (leds == 0) {
318 leds = 1; 340 leds = 1;