Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
j3
Date:
Sun Jul 03 20:35:38 2016 +0000
Revision:
101:e7f76cb49584
Parent:
95:5ebdf5d955f4
Child:
104:3f48daed532b
Added DS18B20 support to OW Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 4:ca27db159b10 1 /******************************************************************//**
j3 4:ca27db159b10 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 4:ca27db159b10 3 *
j3 4:ca27db159b10 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 4:ca27db159b10 5 * copy of this software and associated documentation files (the "Software"),
j3 4:ca27db159b10 6 * to deal in the Software without restriction, including without limitation
j3 4:ca27db159b10 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 4:ca27db159b10 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 4:ca27db159b10 9 * Software is furnished to do so, subject to the following conditions:
j3 4:ca27db159b10 10 *
j3 4:ca27db159b10 11 * The above copyright notice and this permission notice shall be included
j3 4:ca27db159b10 12 * in all copies or substantial portions of the Software.
j3 4:ca27db159b10 13 *
j3 4:ca27db159b10 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 4:ca27db159b10 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 4:ca27db159b10 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 4:ca27db159b10 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 4:ca27db159b10 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 4:ca27db159b10 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 4:ca27db159b10 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 4:ca27db159b10 21 *
j3 4:ca27db159b10 22 * Except as contained in this notice, the name of Maxim Integrated
j3 4:ca27db159b10 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 4:ca27db159b10 24 * Products, Inc. Branding Policy.
j3 4:ca27db159b10 25 *
j3 4:ca27db159b10 26 * The mere transfer of this software does not imply any licenses
j3 4:ca27db159b10 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 4:ca27db159b10 28 * trademarks, maskwork rights, or any other form of intellectual
j3 4:ca27db159b10 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 4:ca27db159b10 30 * ownership rights.
j3 4:ca27db159b10 31 **********************************************************************/
j3 4:ca27db159b10 32
IanBenzMaxim 73:2cecc1372acc 33 #ifndef OneWire_Bridge_DS28E17
IanBenzMaxim 73:2cecc1372acc 34 #define OneWire_Bridge_DS28E17
j3 4:ca27db159b10 35
IanBenzMaxim 73:2cecc1372acc 36 #include <stdint.h>
IanBenzMaxim 73:2cecc1372acc 37 #include <stddef.h>
IanBenzMaxim 73:2cecc1372acc 38 #include "OneWireSlave.h"
j3 4:ca27db159b10 39
IanBenzMaxim 73:2cecc1372acc 40 namespace OneWire
j3 4:ca27db159b10 41 {
IanBenzMaxim 76:84e6c4994e29 42 class OneWireMaster;
j3 93:e496a45ce796 43
j3 93:e496a45ce796 44 /**
j3 93:e496a45ce796 45 * @brief DS28E17 1-Wire®-to-I2C Master Bridge
j3 93:e496a45ce796 46 *
j3 93:e496a45ce796 47 * @details The DS28E17 is a 1-Wire slave to I2C master bridge
j3 93:e496a45ce796 48 * device that interfaces directly to I2C slaves at standard
j3 93:e496a45ce796 49 * (100kHz max) or fast (400kHz max). Data transfers serially by
j3 93:e496a45ce796 50 * means of the 1-Wire® protocol, which requires only a single data
j3 93:e496a45ce796 51 * lead and a ground return. Every DS28E17 is guaranteed to have a
j3 93:e496a45ce796 52 * unique 64-bit ROM registration number that serves as a node
j3 93:e496a45ce796 53 * address in the 1-Wire network. Multiple DS28E17 devices can
j3 93:e496a45ce796 54 * coexist with other devices in the 1-Wire network and be accessed
j3 93:e496a45ce796 55 * individually without affecting other devices. The DS28E17 allows
j3 93:e496a45ce796 56 * using complex I2C devices such as display controllers, ADCs, DACs,
j3 93:e496a45ce796 57 * I2C sensors, etc. in a 1-Wire environment. Each self-timed DS28E17
j3 93:e496a45ce796 58 * provides 1-Wire access for a single I2C interface.
j3 93:e496a45ce796 59 *
j3 93:e496a45ce796 60 */
IanBenzMaxim 76:84e6c4994e29 61 class DS28E17 : public OneWireSlave
IanBenzMaxim 73:2cecc1372acc 62 {
IanBenzMaxim 76:84e6c4994e29 63 public:
j3 101:e7f76cb49584 64
j3 101:e7f76cb49584 65 static const uint8_t DS28E17_FAMILY_CODE = 0x19;
j3 93:e496a45ce796 66
j3 93:e496a45ce796 67 ///Result of all operations
IanBenzMaxim 76:84e6c4994e29 68 enum CmdResult
IanBenzMaxim 73:2cecc1372acc 69 {
IanBenzMaxim 76:84e6c4994e29 70 Success,
IanBenzMaxim 76:84e6c4994e29 71 CommsReadBitError,
IanBenzMaxim 76:84e6c4994e29 72 CommsWriteBitError,
IanBenzMaxim 76:84e6c4994e29 73 CommsReadByteError,
IanBenzMaxim 76:84e6c4994e29 74 CommsWriteByteError,
IanBenzMaxim 76:84e6c4994e29 75 CommsReadBlockError,
IanBenzMaxim 76:84e6c4994e29 76 CommsWriteBlockError,
IanBenzMaxim 76:84e6c4994e29 77 TimeoutError,
IanBenzMaxim 76:84e6c4994e29 78 OperationFailure
IanBenzMaxim 76:84e6c4994e29 79 };
IanBenzMaxim 74:23be10c32fa3 80
IanBenzMaxim 76:84e6c4994e29 81 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 82 * @brief DS28E17 constructor
IanBenzMaxim 76:84e6c4994e29 83 *
IanBenzMaxim 76:84e6c4994e29 84 *
IanBenzMaxim 76:84e6c4994e29 85 * On Entry:
j3 95:5ebdf5d955f4 86 * @param[in] selector - RandomAccessRomIterator object that
j3 95:5ebdf5d955f4 87 * encapsulates master associated with this device and rom control
j3 95:5ebdf5d955f4 88 * commands
IanBenzMaxim 76:84e6c4994e29 89 **************************************************************/
IanBenzMaxim 77:529edb329ee0 90 DS28E17(RandomAccessRomIterator &selector);
IanBenzMaxim 74:23be10c32fa3 91
IanBenzMaxim 76:84e6c4994e29 92 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 93 * @brief Write to selected DS28E17's I2C with Stop.
IanBenzMaxim 76:84e6c4994e29 94 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 95 *
IanBenzMaxim 76:84e6c4994e29 96 * @details Output on I2C: S, Address + Write, Write Data [1-255], P
IanBenzMaxim 76:84e6c4994e29 97 *
IanBenzMaxim 76:84e6c4994e29 98 * On Entry:
IanBenzMaxim 76:84e6c4994e29 99 * @param[in] I2C_addr -
IanBenzMaxim 76:84e6c4994e29 100 * Writes I2C address. The least significant bit of the I2C
IanBenzMaxim 76:84e6c4994e29 101 * address is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 102 *
IanBenzMaxim 76:84e6c4994e29 103 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 104 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 105 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 106 *
IanBenzMaxim 76:84e6c4994e29 107 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 108 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 109 *
IanBenzMaxim 76:84e6c4994e29 110 * On Exit:
IanBenzMaxim 76:84e6c4994e29 111 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 112 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 113 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 114 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 115 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 116 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 117 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 118 *
IanBenzMaxim 76:84e6c4994e29 119 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 120 * Indicates which write byte NACK’d. A value of 00h indicates
IanBenzMaxim 76:84e6c4994e29 121 * all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 122 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 123 *
j3 95:5ebdf5d955f4 124 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 125 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 126 CmdResult I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length,
IanBenzMaxim 76:84e6c4994e29 127 uint8_t *data, uint8_t &status,
IanBenzMaxim 76:84e6c4994e29 128 uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 129
IanBenzMaxim 76:84e6c4994e29 130 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 131 * @brief Write to selected DS28E17's I2C No Stop.
IanBenzMaxim 76:84e6c4994e29 132 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 133 *
IanBenzMaxim 76:84e6c4994e29 134 * @details Output on I2C: S, Address + Write, Write Data [1-255]
IanBenzMaxim 76:84e6c4994e29 135 *
IanBenzMaxim 76:84e6c4994e29 136 * On Entry:
IanBenzMaxim 76:84e6c4994e29 137 * @param[in] I2C_addr
IanBenzMaxim 76:84e6c4994e29 138 * Writes I2C address. The least significant bit of the I2C address
IanBenzMaxim 76:84e6c4994e29 139 * is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 140 *
IanBenzMaxim 76:84e6c4994e29 141 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 142 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 143 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 144 *
IanBenzMaxim 76:84e6c4994e29 145 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 146 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 147 *
IanBenzMaxim 76:84e6c4994e29 148 * On Exit:
IanBenzMaxim 76:84e6c4994e29 149 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 150 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 151 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 152 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 153 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 154 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 155 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 156 *
IanBenzMaxim 76:84e6c4994e29 157 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 158 * Indicates which write byte NACK’d. A value of 00h indicates
IanBenzMaxim 76:84e6c4994e29 159 * all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 160 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 161 *
j3 95:5ebdf5d955f4 162 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 163 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 164 CmdResult I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length,
IanBenzMaxim 76:84e6c4994e29 165 uint8_t *data, uint8_t &status,
IanBenzMaxim 76:84e6c4994e29 166 uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 167
IanBenzMaxim 74:23be10c32fa3 168
IanBenzMaxim 76:84e6c4994e29 169 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 170 * @brief Write to selected DS28E17's I2C with Data only.
IanBenzMaxim 76:84e6c4994e29 171 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 172 *
IanBenzMaxim 76:84e6c4994e29 173 * @details Output on I2C: Write Data [1-255]
IanBenzMaxim 76:84e6c4994e29 174 *
IanBenzMaxim 76:84e6c4994e29 175 * On Entry:
IanBenzMaxim 76:84e6c4994e29 176 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 177 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 178 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 179 *
IanBenzMaxim 76:84e6c4994e29 180 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 181 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 182 *
IanBenzMaxim 76:84e6c4994e29 183 * On Exit:
IanBenzMaxim 76:84e6c4994e29 184 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 185 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 186 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 187 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 188 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 189 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 190 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 191 *
IanBenzMaxim 76:84e6c4994e29 192 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 193 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 194 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 195 *
j3 95:5ebdf5d955f4 196 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 197 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 198 CmdResult I2C_WriteDataOnly(uint8_t length, uint8_t *data,
IanBenzMaxim 76:84e6c4994e29 199 uint8_t &status, uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 200
IanBenzMaxim 74:23be10c32fa3 201
IanBenzMaxim 76:84e6c4994e29 202 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 203 * @brief Write to selected DS28E17's I2C with Stop.
IanBenzMaxim 76:84e6c4994e29 204 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 205 *
IanBenzMaxim 76:84e6c4994e29 206 * @details Output on I2C: Write Data [1-255], P
IanBenzMaxim 76:84e6c4994e29 207 *
IanBenzMaxim 76:84e6c4994e29 208 * On Entry:
IanBenzMaxim 76:84e6c4994e29 209 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 210 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 211 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 212 *
IanBenzMaxim 76:84e6c4994e29 213 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 214 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 215 *
IanBenzMaxim 76:84e6c4994e29 216 * On Exit:
IanBenzMaxim 76:84e6c4994e29 217 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 218 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 219 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 220 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 221 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 222 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 223 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 224 *
IanBenzMaxim 76:84e6c4994e29 225 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 226 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 227 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 228 *
j3 95:5ebdf5d955f4 229 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 230 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 231 CmdResult I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data,
IanBenzMaxim 76:84e6c4994e29 232 uint8_t &status, uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 233
IanBenzMaxim 74:23be10c32fa3 234
IanBenzMaxim 76:84e6c4994e29 235 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 236 * @brief Write to selected DS28E17's I2C with Stop and poll until I2C write complete
IanBenzMaxim 76:84e6c4994e29 237 * receive status info, and read data with a stop at the end.
IanBenzMaxim 76:84e6c4994e29 238 *
IanBenzMaxim 76:84e6c4994e29 239 * @details Output on I2C:
IanBenzMaxim 76:84e6c4994e29 240 * S, Slave Address + Write, Write Data [1-255],
IanBenzMaxim 76:84e6c4994e29 241 * Sr, Address + Read, Read Data [1-255], P (NACK last read byte)
IanBenzMaxim 76:84e6c4994e29 242 *
IanBenzMaxim 76:84e6c4994e29 243 * On Entry:
IanBenzMaxim 76:84e6c4994e29 244 * @param[in] I2C_addr
IanBenzMaxim 76:84e6c4994e29 245 * Writes I2C address. The least significant bit of the I2C address
IanBenzMaxim 76:84e6c4994e29 246 * is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 247 *
IanBenzMaxim 76:84e6c4994e29 248 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 249 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 250 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 251 *
IanBenzMaxim 76:84e6c4994e29 252 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 253 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 254 *
IanBenzMaxim 76:84e6c4994e29 255 * @param[in] nu_bytes_read
IanBenzMaxim 76:84e6c4994e29 256 * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 257 *
IanBenzMaxim 76:84e6c4994e29 258 * On Exit:
IanBenzMaxim 76:84e6c4994e29 259 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 260 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 261 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 262 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 263 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 264 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 265 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 266 *
IanBenzMaxim 76:84e6c4994e29 267 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 268 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 269 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 270 *
IanBenzMaxim 76:84e6c4994e29 271 * @param[out] *read_data
IanBenzMaxim 76:84e6c4994e29 272 * Array of read data received from I2C.
IanBenzMaxim 76:84e6c4994e29 273 *
j3 95:5ebdf5d955f4 274 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 275 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 276 CmdResult I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length,
IanBenzMaxim 76:84e6c4994e29 277 uint8_t *data, uint8_t nu_bytes_read,
IanBenzMaxim 76:84e6c4994e29 278 uint8_t &status, uint8_t &wr_status,
IanBenzMaxim 76:84e6c4994e29 279 uint8_t *read_data);
IanBenzMaxim 74:23be10c32fa3 280
IanBenzMaxim 74:23be10c32fa3 281
IanBenzMaxim 76:84e6c4994e29 282 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 283 * @brief Selected DS28E17's and send I2C address and poll until
IanBenzMaxim 76:84e6c4994e29 284 * I2C read address complete, receive status info, and read data
IanBenzMaxim 76:84e6c4994e29 285 * with a stop at the end.
IanBenzMaxim 76:84e6c4994e29 286 *
IanBenzMaxim 76:84e6c4994e29 287 * @details Output on I2C:
IanBenzMaxim 76:84e6c4994e29 288 * S, Slave Address + Read, Read Data [1-255], P (NACK last read byte)
IanBenzMaxim 76:84e6c4994e29 289 *
IanBenzMaxim 76:84e6c4994e29 290 * On Entry:
IanBenzMaxim 76:84e6c4994e29 291 * @param[in] I2C_addr
IanBenzMaxim 76:84e6c4994e29 292 * Writes I2C address. The least significant bit of the I2C address
IanBenzMaxim 76:84e6c4994e29 293 * is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 294 *
IanBenzMaxim 76:84e6c4994e29 295 * On Exit:
IanBenzMaxim 76:84e6c4994e29 296 * @param[out] nu_bytes_read
IanBenzMaxim 76:84e6c4994e29 297 * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 298 *
IanBenzMaxim 76:84e6c4994e29 299 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 300 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 301 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 302 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 303 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 304 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 305 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 306 *
IanBenzMaxim 76:84e6c4994e29 307 * @param[out] *read_data
IanBenzMaxim 76:84e6c4994e29 308 * Array of read data received from I2C.
IanBenzMaxim 76:84e6c4994e29 309 *
j3 95:5ebdf5d955f4 310 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 311 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 312 CmdResult I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read,
IanBenzMaxim 76:84e6c4994e29 313 uint8_t &status, uint8_t *read_data);
IanBenzMaxim 74:23be10c32fa3 314
IanBenzMaxim 74:23be10c32fa3 315
IanBenzMaxim 76:84e6c4994e29 316 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 317 * @brief Write to Configuration Register of DS28E17.
IanBenzMaxim 76:84e6c4994e29 318 *
IanBenzMaxim 76:84e6c4994e29 319 * @details
IanBenzMaxim 76:84e6c4994e29 320 *
IanBenzMaxim 76:84e6c4994e29 321 * On Entry:
IanBenzMaxim 76:84e6c4994e29 322 * @param[in] data
IanBenzMaxim 76:84e6c4994e29 323 * sent to configuration register
IanBenzMaxim 76:84e6c4994e29 324 *
j3 95:5ebdf5d955f4 325 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 326 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 327 CmdResult WriteConfigReg(uint8_t data);
IanBenzMaxim 74:23be10c32fa3 328
IanBenzMaxim 74:23be10c32fa3 329
IanBenzMaxim 76:84e6c4994e29 330 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 331 * @brief Read the Configuration Register of DS28E17.
IanBenzMaxim 76:84e6c4994e29 332 *
IanBenzMaxim 76:84e6c4994e29 333 * @details
IanBenzMaxim 76:84e6c4994e29 334 *
IanBenzMaxim 76:84e6c4994e29 335 * On Exit:
j3 95:5ebdf5d955f4 336 * @param[out] config - contents of configuration register
IanBenzMaxim 76:84e6c4994e29 337 *
j3 95:5ebdf5d955f4 338 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 339 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 340 CmdResult ReadConfigReg(uint8_t & config);
IanBenzMaxim 74:23be10c32fa3 341
IanBenzMaxim 74:23be10c32fa3 342
IanBenzMaxim 76:84e6c4994e29 343 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 344 * @brief The Enable Sleep Mode command puts the device into a low current mode.
IanBenzMaxim 76:84e6c4994e29 345 * All 1-Wire communication is ignored until woken up. Immediately after
IanBenzMaxim 76:84e6c4994e29 346 * the command, the device monitors the WAKEUP input pin and
IanBenzMaxim 76:84e6c4994e29 347 * exits sleep mode on a rising edge.
IanBenzMaxim 76:84e6c4994e29 348 *
j3 95:5ebdf5d955f4 349 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 350 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 351 CmdResult EnableSleepMode();
IanBenzMaxim 74:23be10c32fa3 352
IanBenzMaxim 74:23be10c32fa3 353
IanBenzMaxim 76:84e6c4994e29 354 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 355 * @brief Read the Device Revision of DS28E17. The revision value
IanBenzMaxim 76:84e6c4994e29 356 * should never be zero. The upper nibble is the major revision
IanBenzMaxim 76:84e6c4994e29 357 * and the lower nibble is the minor revision.
IanBenzMaxim 76:84e6c4994e29 358 *
j3 95:5ebdf5d955f4 359 * On Exit:
j3 95:5ebdf5d955f4 360 * @param[out] rev - device revision
IanBenzMaxim 76:84e6c4994e29 361 *
j3 95:5ebdf5d955f4 362 * @return CmdResult - result of operation
IanBenzMaxim 76:84e6c4994e29 363 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 364 CmdResult ReadDeviceRevision(uint8_t & rev);
IanBenzMaxim 74:23be10c32fa3 365
IanBenzMaxim 76:84e6c4994e29 366 private:
IanBenzMaxim 78:0cbbac7f2016 367 static const size_t pollLimit = 10000;
IanBenzMaxim 74:23be10c32fa3 368
IanBenzMaxim 76:84e6c4994e29 369 CmdResult send_packet(const uint8_t * data, uint8_t data_length,
IanBenzMaxim 76:84e6c4994e29 370 uint8_t & status, uint8_t & wr_status);
IanBenzMaxim 74:23be10c32fa3 371
IanBenzMaxim 76:84e6c4994e29 372 //overloaded function for I2C read only command
IanBenzMaxim 76:84e6c4994e29 373 CmdResult send_packet(const uint8_t * data, uint8_t data_length,
IanBenzMaxim 76:84e6c4994e29 374 uint8_t & status);
IanBenzMaxim 76:84e6c4994e29 375 };
IanBenzMaxim 73:2cecc1372acc 376 }
j3 4:ca27db159b10 377
IanBenzMaxim 74:23be10c32fa3 378 #endif
j3 17:b646b1e3970b 379