changeset 45:efd44dc40934

Add macros for number system used for temperatures. Add error strings and improve comments for ROM programming.
author darius@Inchoate
date Mon, 20 Oct 2008 22:11:18 +1030
parents f219538d6ea7
children fb272cb82bcb
files 1wire.c 1wire.h
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/1wire.c	Sun Jul 06 22:42:42 2008 +0930
+++ b/1wire.c	Mon Oct 20 22:11:18 2008 +1030
@@ -48,6 +48,13 @@
 static uint8_t OW_LastDiscrepancy = 0;
 static uint8_t OW_LastFamilyDiscrepancy = 0;
 
+const PROGMEM char *OWProgROM_Status[] = {
+    "OK",
+    "not possible (no HW support)",
+    "Invalid parameters",
+    "module doesn't exist or didn't respond properly"
+};
+
 /*-----------------------------------------------------------------------------
  * Configure the IO port as we need
  */
@@ -414,7 +421,7 @@
  *
  * Returns..
  *  0 if all is OK
- *  1 if the programming was unsuccessful
+ *  1 if the programming is not possible
  *  2 if the parameters were invalid
  *  3 if the DS2502 didn't respond appropriately (also happens if the
  *  module doesn't exist)
@@ -426,7 +433,7 @@
     
     /* Stupid programmer detection */
     if (status) {
-	if (start  + len > 3)
+	if (start + len > 3)
 	    return(2);
     } else {
 	if (start  + len > 127)
--- a/1wire.h	Sun Jul 06 22:42:42 2008 +0930
+++ b/1wire.h	Mon Oct 20 22:11:18 2008 +1030
@@ -82,3 +82,10 @@
 #define OW_TEMP_WRONG_FAM	-1000
 #define OW_TEMP_CRC_ERR		-1001
 #define OW_TEMP_NO_ROM		-1002
+
+/* Helpers for OWGetTemp's number system */
+#define GETWHOLE(x)	((x) / 100)
+#define GETFRAC(x)	((x) - (GETWHOLE(x) * 100))
+
+extern const PROGMEM char *OWProgROM_Status[];
+