Mercurial > ~darius > hgwebdir.cgi > avr
diff 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 |
line wrap: on
line diff
--- a/testavr.c Mon Jul 12 17:51:20 2004 +0930 +++ b/testavr.c Mon Jul 12 23:59:00 2004 +0930 @@ -174,9 +174,9 @@ uart_putsP(PSTR("Resetting... ")); if (OWTouchReset() == 1) - uart_putsP(PSTR("No presense\n\r")); + uart_putsP(PSTR("No presense pulse found\n\r")); else - uart_putsP(PSTR("Presense\n\r")); + uart_putsP(PSTR("Presense pulse found\n\r")); } else if (cmdbuf[0] == 'r' && cmdbuf[1] == 'e') { if (OWReadBit()) uart_putsP(PSTR("Read a 1\n\r")); @@ -291,15 +291,34 @@ uart_puts(cmdbuf); } else if (cmdbuf[0] == 's' && cmdbuf[1] == 'r') { memset(ROM, 0, 8); - if (OWTouchReset()) { - uart_putsP(PSTR("No devices on bus\n\r")); - break; - } - if (OWFirst(ROM, 1, 0) == 0) { - uart_putsP(PSTR("No module found\n\r")); - break; - } + + i = OWFirst(ROM, 1, 0); do { + switch (i) { + case OW_BADWIRE: + uart_putsP(PSTR("Presense pulse, but no module found, bad module/cabling?\n\r")); + break; + + case OW_NOPRESENCE: + uart_putsP(PSTR("No presense pulse found\n\r")); + break; + + case OW_BADCRC: + uart_putsP(PSTR("Bad CRC\n\r")); + break; + + case OW_NOMODULES: + case OW_FOUND: + break; + + default: + uart_putsP(PSTR("Unknown error from 1 wire library\n\r")); + break; + } + + if (i != OW_FOUND) + break; + sprintf_P(cmdbuf, PSTR("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n\r"), ROM[0], ROM[1], @@ -310,7 +329,10 @@ ROM[6], ROM[7]); uart_puts(cmdbuf); - } while (OWNext(ROM, 1, 0)); + + i = OWNext(ROM, 1, 0); + } while (1); + #if 0 } else if (cmdbuf[0] == 'l' && cmdbuf[1] == 'e' && cmdbuf[2] == 'd') {