Mercurial > ~darius > hgwebdir.cgi > avr
diff 1wire.h @ 0:ffeab3c04e83
Initial revision
author | darius |
---|---|
date | Sun, 11 Jul 2004 00:45:50 +0930 |
parents | |
children | f9a085a0ba93 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1wire.h Sun Jul 11 00:45:50 2004 +0930 @@ -0,0 +1,63 @@ +/* Copyright (c) 2004 + * Daniel O'Connor <darius@dons.net.au>. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +int OWTouchReset(void); +void OWWriteBit(int bit); +int OWReadBit(void); +void OWWriteByte(uint8_t data); +int OWReadByte(void); +int OWTouchByte(uint8_t data); +void OWBlock(uint8_t *data, int len); +int OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only); +int OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only); +void OWCRC(uint8_t x, uint8_t *crc); +void OWSendCmd(uint8_t *ROM, uint8_t cmd); + +#define OWIREOUTPORT PORTC +#define OWIREOUTPIN 0 + +#define OWIREINPORT PINC +#define OWIREDDR DDRC +#define OWIREINPIN OWIREOUTPIN + +/* General 1 wire commands */ +#define OW_OVRDRV_SKIP_CMD 0x3c +#define OW_SEARCH_ALRM_CMD 0xec +#define OW_SEARCH_ROM_CMD 0xf0 +#define OW_READ_ROM_CMD 0x33 +#define OW_MATCH_ROM_CMD 0x55 +#define OW_SKIP_ROM_CMD 0xcc + +/* DS1820 commands */ +#define OW_CONVERTT_CMD 0x44 +#define OW_RD_SCR_CMD 0xbe +#define OW_WR_SCR_CMD 0x4e +#define OW_CPY_SCR_CMD 0x48 +#define OW_RECALL_CMD 0xb8 +#define OW_RD_PSU_CMD 0xb4 + +/* Family codes */ +#define OW_FAMILY_ROM 0x09 +#define OW_FAMILY_TEMP 0x10