comparison 1wire.h @ 32:b0cb873c0206

Isolate the bus frobbing parts and the delays into a separate header. This means the user only has to edit a single file to suit their situation and allows the code to work with active drive systems as well as passive pullups (ie 1 vs 2 IO pins)
author darius
date Sun, 23 Apr 2006 22:57:16 +0930
parents 2b0ed085b95b
children 0aa6bf4b98ae
comparison
equal deleted inserted replaced
31:4e417d84365e 32:b0cb873c0206
1 /* 1 /*
2 * 1 wire header code 2 * 1 wire header which defines functions and constants
3 * 3 *
4 * $Id$ 4 * $Id$
5 * 5 *
6 * Copyright (c) 2004 6 * Copyright (c) 2004
7 * Daniel O'Connor <darius@dons.net.au>. All rights reserved. 7 * Daniel O'Connor <darius@dons.net.au>. All rights reserved.
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31 void OWInit(void);
31 uint8_t OWTouchReset(void); 32 uint8_t OWTouchReset(void);
32 void OWWriteBit(uint8_t bit); 33 void OWWriteBit(uint8_t bit);
33 uint8_t OWReadBit(void); 34 uint8_t OWReadBit(void);
34 void OWWriteByte(uint8_t data); 35 void OWWriteByte(uint8_t data);
35 uint8_t OWReadByte(void); 36 uint8_t OWReadByte(void);
37 void OWBlock(uint8_t *data, int len); 38 void OWBlock(uint8_t *data, int len);
38 uint8_t OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only); 39 uint8_t OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
39 uint8_t OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only); 40 uint8_t OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
40 void OWCRC(uint8_t x, uint8_t *crc); 41 void OWCRC(uint8_t x, uint8_t *crc);
41 void OWSendCmd(uint8_t *ROM, uint8_t cmd); 42 void OWSendCmd(uint8_t *ROM, uint8_t cmd);
42
43 #define OWIREOUTPORT PORTD
44 #define OWIREOUTPIN 2
45
46 #define OWIREINPORT PIND
47 #define OWIREDDR DDRD
48 #define OWIREINPIN OWIREOUTPIN
49 43
50 /* Return codes for OWFirst()/OWNext() */ 44 /* Return codes for OWFirst()/OWNext() */
51 #define OW_BADWIRE -3 45 #define OW_BADWIRE -3
52 #define OW_BADCRC -2 46 #define OW_BADCRC -2
53 #define OW_NOPRESENCE -1 47 #define OW_NOPRESENCE -1
68 #define OW_WR_SCR_CMD 0x4e 62 #define OW_WR_SCR_CMD 0x4e
69 #define OW_CPY_SCR_CMD 0x48 63 #define OW_CPY_SCR_CMD 0x48
70 #define OW_RECALL_CMD 0xb8 64 #define OW_RECALL_CMD 0xb8
71 #define OW_RD_PSU_CMD 0xb4 65 #define OW_RD_PSU_CMD 0xb4
72 66
67 /* DS2502 commands */
68 #define OW_READ_MEMORY 0xf0
69 #define OW_READ_STATUS 0xaa
70 #define OW_GEN_CRC 0xc3
71 #define OW_WRITE_MEMORY 0x0f
72 #define OW_WRITE_STATUS 0x55
73
73 /* Family codes */ 74 /* Family codes */
74 #define OW_FAMILY_ROM 0x09 75 #define OW_FAMILY_ROM 0x09
75 #define OW_FAMILY_TEMP 0x10 76 #define OW_FAMILY_TEMP 0x10