changeset 15:0940abdf2b9d

- Add LED commands. - Fix backspace/delete.
author darius
date Sat, 17 Sep 2005 18:10:33 +0930
parents a9d493261c6c
children 026dc24d85e0
files testavr.c
diffstat 1 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/testavr.c	Sat Sep 17 18:02:28 2005 +0930
+++ b/testavr.c	Sat Sep 17 18:10:33 2005 +0930
@@ -53,11 +53,15 @@
     uint8_t	ROM[8];
     char	cmdbuf[40];
     int8_t	i, arg;
-    
+    uint8_t	crc, buf[9];;
+    int8_t	temp;
+    uint16_t	tfrac;
+
     cli();
 
     outp(0xfc, DDRC);
     outp(0x00, PORTC);
+    DDRA = 0xff;
 
     /* Init UART */
     outp(UART_BAUD_SELECT(UART_BAUD_RATE,XTAL_CPU), UBRR);
@@ -76,8 +80,8 @@
 	    if (cmdbuf[i] == '\n' || cmdbuf[i] == '\r')
 		break;
 	    
-	    /* Backspace */
-	    if (cmdbuf[i] == 010) {
+	    /* Backspace/Delete */
+	    if (cmdbuf[i] == 0x08) {
 		if (i > 0) {
 		    uart_putsP(PSTR("\010\040\010"));
 		    i--;
@@ -110,7 +114,8 @@
 			    "wr bit           Write a bit\n\r"
 			    "wb byte          Write a byte (hex)\n\r"
 			    "wc cmd [ROMID]   Write command\n\r"
-			    "te ROMID         Read the temperature from a DS1820\n\r"));
+			    "te ROMID         Read the temperature from a DS1820\n\r"
+			    "le byte	      Set the LED port\n\r"));
 	    
 	    continue;
 	}
@@ -172,10 +177,6 @@
 
 	    OWSendCmd(ROM, arg);
 	} else if (cmdbuf[0] == 't' && cmdbuf[1] == 'e') {
-	    uint8_t	crc, buf[9];;
-	    int8_t	temp;
-	    uint16_t	tfrac;
-	    
 	    if (strlen(cmdbuf) < 26) {
 		uart_putsP(PSTR("Unable to parse ROM ID\n\r"));
 		continue;
@@ -294,6 +295,14 @@
 
 		i = OWNext(ROM, 1, 0);
 	    } while (1);
+	} else if (cmdbuf[0] == 'l' && cmdbuf[1] == 'e') {
+	    crc = (uint8_t)strtol(cmdbuf + 3, (char **)NULL, 16);
+	    PORTA = crc;
+#if 1
+	    uart_putsP(PSTR("LEDs set to 0x"));
+	    uart_puts_hex(crc);
+	    uart_putsP(PSTR("\n\r"));
+#endif
 	} else {
 	  badcmd:
 	    uart_putsP(PSTR("Unknown command, ? for a list\n\r"));