comparison 1wire-config.h @ 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 96c345d304af
children 38869c474104
comparison
equal deleted inserted replaced
14:891841f5f785 15:b12881051261
33 * The configuration described here has the 1-wire IO on GPIOE3, 33 * The configuration described here has the 1-wire IO on GPIOE3,
34 * with no pull down, nor VPP 34 * with no pull down, nor VPP
35 */ 35 */
36 36
37 #include "stm32f10x.h" /* GPIO* */ 37 #include "stm32f10x.h" /* GPIO* */
38 #include "hw.h" /* For _usleep16() */ 38 #include "delay.h"
39 39
40 /* Fudge AVR stuff for ARM */ 40 /* Fudge AVR stuff for ARM */
41 #define PROGMEM 41 #define PROGMEM
42 #define PSTR(x) x 42 #define PSTR(x) x
43 #define pgm_read_byte(x) *(x) 43 #define pgm_read_byte(x) *(x)
79 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \ 79 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \
80 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; \ 80 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; \
81 GPIO_Init(GPIOE, &GPIO_InitStructure); \ 81 GPIO_Init(GPIOE, &GPIO_InitStructure); \
82 } while (0) 82 } while (0)
83 83
84 #define OWDELAY_A _usleep16(6) /* 6 usec */ 84 #if 0
85 #define OWDELAY_B _usleep16(64) /* 64 usec */ 85 #define OWDELAY_A delay(6) /* 6 usec */
86 #define OWDELAY_C _usleep16(60) /* 60 usec */ 86 #define OWDELAY_B delay(64) /* 64 usec */
87 #define OWDELAY_D _usleep16(10) /* 10 usec */ 87 #define OWDELAY_C delay(60) /* 60 usec */
88 #define OWDELAY_E _usleep16(9) /* 9 usec */ 88 #define OWDELAY_D delay(10) /* 10 usec */
89 #define OWDELAY_F _usleep16(55) /* 55 usec */ 89 #define OWDELAY_E delay(9) /* 9 usec */
90 #define OWDELAY_G /* 0 usec */ 90 #define OWDELAY_F delay(55) /* 55 usec */
91 #define OWDELAY_H _usleep16(480) /* 480 usec */ 91 #define OWDELAY_G /* 0 usec */
92 #define OWDELAY_I _usleep16(70) /* 70 usec */ 92 #define OWDELAY_H delay(480) /* 480 usec */
93 #define OWDELAY_J _usleep16(410) /* 410 usec */ 93 #define OWDELAY_I delay(70) /* 70 usec */
94 94 #define OWDELAY_J delay(410) /* 410 usec */
95 #else
96 /* As measured by the cro delay() is correct, but the code does not work and I don't understand why.
97 * We need to use delays 2/3 the expected amount.
98 * Possibly due to use of GPIO_Init(), however the STM32 lib doesn't seem to have a function to
99 * just set the GPIO mode.
100 */
101 #define OWDELAY_A delay(4) /* 6 usec */
102 #define OWDELAY_B delay(43) /* 64 usec */
103 #define OWDELAY_C delay(40) /* 60 usec */
104 #define OWDELAY_D delay(7) /* 10 usec */
105 #define OWDELAY_E delay(6) /* 9 usec */
106 #define OWDELAY_F delay(37) /* 55 usec */
107 #define OWDELAY_G /* 0 usec */
108 #define OWDELAY_H delay(320) /* 480 usec */
109 #define OWDELAY_I delay(47) /* 70 usec */
110 #define OWDELAY_J delay(273) /* 410 usec */
111 #endif
112 //#define OW_DEBUG
95 #ifdef OW_DEBUG 113 #ifdef OW_DEBUG
96 #define OWPUTS(x) puts(x) 114 #define OWPUTS(x) puts(x)
97 #define OWPUTSP(x) puts(x) 115 #define OWPUTSP(x) puts(x)
98 #define OWPRINTFP(fmt, ...) printf(fmt, ## __VA_ARGS__) 116 #define OWPRINTFP(fmt, ...) printf(fmt, ## __VA_ARGS__)
99 #else 117 #else