Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | /*! \file ds2482.h \brief Dallas DS2482 I2C-to-Dallas1Wire Master Library. */ |
2 | //***************************************************************************** |
||
3 | // |
||
4 | // File Name : 'ds2482.h' |
||
5 | // Title : Dallas DS2482 I2C-to-Dallas1Wire Master Library |
||
6 | // Author : Pascal Stang - Copyright (C) 2004 |
||
7 | // Created : 2004.09.27 |
||
8 | // Revised : 2004.09.27 |
||
9 | // Version : 0.1 |
||
10 | // Target MCU : Atmel AVR Series |
||
11 | // Editor Tabs : 4 |
||
12 | // |
||
13 | // NOTE: This code is currently below version 1.0, and therefore is considered |
||
14 | // to be lacking in some functionality or documentation, or may not be fully |
||
15 | // tested. Nonetheless, you can expect most functions to work. |
||
16 | // |
||
17 | // This code is distributed under the GNU Public License |
||
18 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
19 | // |
||
20 | //***************************************************************************** |
||
21 | |||
22 | #ifndef DS2482_H |
||
23 | #define DS2482_H |
||
24 | |||
25 | #include "global.h" |
||
26 | |||
27 | // constants/macros/typdefs |
||
28 | #define DS2482_I2C_ADDR 0x30 //< Base I2C address of DS2482 devices |
||
29 | |||
30 | // DS2482 command defines |
||
31 | #define DS2482_CMD_DRST 0xF0 //< DS2482 Device Reset |
||
32 | #define DS2482_CMD_WCFG 0xD2 //< DS2482 Write Configuration |
||
33 | #define DS2482_CMD_CHSL 0xC3 //< DS2482 Channel Select |
||
34 | #define DS2482_CMD_SRP 0xE1 //< DS2482 Set Read Pointer |
||
35 | #define DS2482_CMD_1WRS 0xB4 //< DS2482 1-Wire Reset |
||
36 | #define DS2482_CMD_1WWB 0xA5 //< DS2482 1-Wire Write Byte |
||
37 | #define DS2482_CMD_1WRB 0x96 //< DS2482 1-Wire Read Byte |
||
38 | #define DS2482_CMD_1WSB 0x87 //< DS2482 1-Wire Single Bit |
||
39 | #define DS2482_CMD_1WT 0x78 //< DS2482 1-Wire Triplet |
||
40 | |||
41 | // DS2482 status register bit defines |
||
42 | #define DS2482_STATUS_1WB 0x01 //< DS2482 Status 1-Wire Busy |
||
43 | #define DS2482_STATUS_PPD 0x02 //< DS2482 Status Presence Pulse Detect |
||
44 | #define DS2482_STATUS_SD 0x04 //< DS2482 Status Short Detected |
||
45 | #define DS2482_STATUS_LL 0x08 //< DS2482 Status 1-Wire Logic Level |
||
46 | #define DS2482_STATUS_RST 0x10 //< DS2482 Status Device Reset |
||
47 | #define DS2482_STATUS_SBR 0x20 //< DS2482 Status Single Bit Result |
||
48 | #define DS2482_STATUS_TSB 0x40 //< DS2482 Status Triplet Second Bit |
||
49 | #define DS2482_STATUS_DIR 0x80 //< DS2482 Status Branch Direction Taken |
||
50 | |||
51 | // DS2482 configuration register bit defines |
||
52 | #define DS2482_CFG_APU 0x01 //< DS2482 Config Active Pull-Up |
||
53 | #define DS2482_CFG_PPM 0x02 //< DS2482 Config Presence Pulse Masking |
||
54 | #define DS2482_CFG_SPU 0x04 //< DS2482 Config Strong Pull-Up |
||
55 | #define DS2482_CFG_1WS 0x08 //< DS2482 Config 1-Wire Speed |
||
56 | |||
57 | // DS2482 channel selection code defines |
||
58 | #define DS2482_CH_IO0 0xF0 //< DS2482 Select Channel IO0 |
||
59 | #define DS2482_CH_IO1 0xE1 //< DS2482 Select Channel IO1 |
||
60 | #define DS2482_CH_IO2 0xD2 //< DS2482 Select Channel IO2 |
||
61 | #define DS2482_CH_IO3 0xC3 //< DS2482 Select Channel IO3 |
||
62 | #define DS2482_CH_IO4 0xB4 //< DS2482 Select Channel IO4 |
||
63 | #define DS2482_CH_IO5 0xA5 //< DS2482 Select Channel IO5 |
||
64 | #define DS2482_CH_IO6 0x96 //< DS2482 Select Channel IO6 |
||
65 | #define DS2482_CH_IO7 0x87 //< DS2482 Select Channel IO7 |
||
66 | |||
67 | // DS2482 read pointer code defines |
||
68 | #define DS2482_READPTR_SR 0xF0 //< DS2482 Status Register |
||
69 | #define DS2482_READPTR_RDR 0xE1 //< DS2482 Read Data Register |
||
70 | #define DS2482_READPTR_CSR 0xD2 //< DS2482 Channel Selection Register |
||
71 | #define DS2482_READPTR_CR 0xC3 //< DS2482 Configuration Register |
||
72 | |||
73 | // functions |
||
74 | |||
75 | //! Initialize the DS2482 chip |
||
76 | // returns: |
||
77 | // 0 if successful |
||
78 | // non-zero if unsuccessful (chip not present) |
||
79 | u08 ds2482Init(u08 i2cAddr); |
||
80 | u08 ds2482Reset(u08 i2cAddr); |
||
81 | u08 ds2482SendCmd(u08 cmd); |
||
82 | u08 ds2482SendCmdArg(u08 cmd, u08 arg); |
||
83 | u08 ds2482BusyWait(void); |
||
84 | u08 ds2482BusReset(void); |
||
85 | u08 ds2482BusTransferBit(u08 bit); |
||
86 | u08 ds2482BusTriplet(u08 dir); |
||
87 | u08 ds2482BusLevel(void); |
||
88 | void ds2482BusWriteByte(u08 data); |
||
89 | u08 ds2482BusReadByte(void); |
||
90 | |||
91 | #endif |
Powered by WebSVN v2.8.3