comparison 1wire-config-stm32.h @ 15:a50a054d060c

- Make OWREADBUS work properly. - Fix debug commands.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 08 Feb 2012 10:36:26 +1030
parents 6f8f7b87d2f1
children
comparison
equal deleted inserted replaced
14:d8002c716678 15:a50a054d060c
35 */ 35 */
36 36
37 #include "stm32f10x.h" /* GPIO* */ 37 #include "stm32f10x.h" /* GPIO* */
38 #include "hw.h" /* For _usleep16() */ 38 #include "hw.h" /* For _usleep16() */
39 39
40 /* No need for this on 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)
44 44
45 /* Init bus */ 45 /* Init bus */
46 #define OWBUSINIT() 46 #define OWBUSINIT()
47 47
48 /* Set the port up to allow reading from the 1 wire bus */ 48 /* Set the port up to allow reading from the 1 wire bus */
49 #define OWSETREAD() do { \ 49 #define OWSETREAD() do { \
50 GPIO_InitTypeDef GPIO_InitStructure; \ 50 GPIO_InitTypeDef GPIO_InitStructure; \
51 \
51 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; \ 52 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; \
52 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \ 53 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; \
53 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; \ 54 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; \
54 GPIO_Init(GPIOE, &GPIO_InitStructure); \ 55 GPIO_Init(GPIOE, &GPIO_InitStructure); \
55 } while (0) 56 } while (0)
56 57
57 58
58 /* Read the 1-wire bus, non-inverting logic */ 59 /* Read the 1-wire bus, non-inverting logic */
59 #define OWREADBUS() (GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_3)) 60 #define OWREADBUS() (GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_3) ? 1 : 0)
60 61
61 /* Set the 1-wire bus to 0 62 /* Set the 1-wire bus to 0
62 */ 63 */
63 #define OWSETBUSLOW() do { \ 64 #define OWSETBUSLOW() do { \
64 GPIO_InitTypeDef GPIO_InitStructure; \ 65 GPIO_InitTypeDef GPIO_InitStructure; \
87 #define OWDELAY_E _usleep16(9) /* 9 usec */ 88 #define OWDELAY_E _usleep16(9) /* 9 usec */
88 #define OWDELAY_F _usleep16(55) /* 55 usec */ 89 #define OWDELAY_F _usleep16(55) /* 55 usec */
89 #define OWDELAY_G /* 0 usec */ 90 #define OWDELAY_G /* 0 usec */
90 #define OWDELAY_H _usleep16(480) /* 480 usec */ 91 #define OWDELAY_H _usleep16(480) /* 480 usec */
91 #define OWDELAY_I _usleep16(70) /* 70 usec */ 92 #define OWDELAY_I _usleep16(70) /* 70 usec */
93 #define OWDELAY_J _usleep16(410) /* 410 usec */
92 94
93 #ifdef OW_DEBUG 95 #ifdef OW_DEBUG
94 #define OWPUTS(x) puts_P(x) 96 #define OWPUTS(x) puts(x)
95 #define OWPUTSP(x) puts_P(x) 97 #define OWPUTSP(x) puts(x)
96 #define OWPRINTFP(fmt, ...) printf_P(fmt, ## __VA_ARGS__) 98 #define OWPRINTFP(fmt, ...) printf(fmt, ## __VA_ARGS__)
97 #else 99 #else
98 #define OWPUTS(x) 100 #define OWPUTS(x)
99 #define OWPUTSP(x) 101 #define OWPUTSP(x)
100 #define OWPRINTFP(fmt, ...) 102 #define OWPRINTFP(fmt, ...)
101 #endif 103 #endif