changeset 15:b12881051261

Use corrected delay() routine. Add note about timing oddities (but it works, so..)
author Daniel O'Connor <darius@dons.net.au>
date Wed, 14 Nov 2012 12:24:44 +1030
parents 891841f5f785
children db6011aa94d6
files 1wire-config.h
diffstat 1 files changed, 30 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/1wire-config.h	Wed Nov 14 12:24:21 2012 +1030
+++ b/1wire-config.h	Wed Nov 14 12:24:44 2012 +1030
@@ -35,7 +35,7 @@
  */
 
 #include "stm32f10x.h" /* GPIO* */
-#include "hw.h" /* For _usleep16() */
+#include "delay.h"
 
 /* Fudge AVR stuff for ARM */
 #define PROGMEM
@@ -81,17 +81,35 @@
     GPIO_Init(GPIOE, &GPIO_InitStructure);		\
 } while (0)
 
-#define OWDELAY_A _usleep16(6)						/* 6 usec */
-#define OWDELAY_B _usleep16(64)						/* 64 usec */
-#define OWDELAY_C _usleep16(60)						/* 60 usec */
-#define OWDELAY_D _usleep16(10)						/* 10 usec */
-#define OWDELAY_E _usleep16(9)						/* 9 usec */
-#define OWDELAY_F _usleep16(55)						/* 55 usec */
-#define OWDELAY_G							/* 0 usec */
-#define OWDELAY_H _usleep16(480)					/* 480 usec */
-#define OWDELAY_I _usleep16(70)						/* 70 usec */
-#define OWDELAY_J _usleep16(410)					/* 410 usec */
-
+#if 0
+#define OWDELAY_A delay(6)					/* 6 usec */
+#define OWDELAY_B delay(64)					/* 64 usec */
+#define OWDELAY_C delay(60)					/* 60 usec */
+#define OWDELAY_D delay(10)					/* 10 usec */
+#define OWDELAY_E delay(9)					/* 9 usec */
+#define OWDELAY_F delay(55)					/* 55 usec */
+#define OWDELAY_G						/* 0 usec */
+#define OWDELAY_H delay(480)					/* 480 usec */
+#define OWDELAY_I delay(70)					/* 70 usec */
+#define OWDELAY_J delay(410)					/* 410 usec */
+#else
+/* As measured by the cro delay() is correct, but the code does not work and I don't understand why.
+ * We need to use delays 2/3 the expected amount.
+ * Possibly due to use of GPIO_Init(), however the STM32 lib doesn't seem to have a function to 
+ * just set the GPIO mode.
+ */
+#define OWDELAY_A delay(4)					/* 6 usec */
+#define OWDELAY_B delay(43)					/* 64 usec */
+#define OWDELAY_C delay(40)					/* 60 usec */
+#define OWDELAY_D delay(7)					/* 10 usec */
+#define OWDELAY_E delay(6)					/* 9 usec */
+#define OWDELAY_F delay(37)					/* 55 usec */
+#define OWDELAY_G						/* 0 usec */
+#define OWDELAY_H delay(320)					/* 480 usec */
+#define OWDELAY_I delay(47)					/* 70 usec */
+#define OWDELAY_J delay(273)					/* 410 usec */
+#endif
+//#define OW_DEBUG
 #ifdef OW_DEBUG
 #define OWPUTS(x)		puts(x)
 #define OWPUTSP(x)		puts(x)