Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
j3
Date:
Fri Jun 24 21:06:46 2016 +0000
Revision:
93:e496a45ce796
Parent:
86:2ce08ca58b9e
Child:
95:5ebdf5d955f4
added autodoc markups for DS2413 and DS28E17 classes

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 93:e496a45ce796 64
j3 93:e496a45ce796 65 ///Result of all operations
IanBenzMaxim 76:84e6c4994e29 66 enum CmdResult
IanBenzMaxim 73:2cecc1372acc 67 {
IanBenzMaxim 76:84e6c4994e29 68 Success,
IanBenzMaxim 76:84e6c4994e29 69 CommsReadBitError,
IanBenzMaxim 76:84e6c4994e29 70 CommsWriteBitError,
IanBenzMaxim 76:84e6c4994e29 71 CommsReadByteError,
IanBenzMaxim 76:84e6c4994e29 72 CommsWriteByteError,
IanBenzMaxim 76:84e6c4994e29 73 CommsReadBlockError,
IanBenzMaxim 76:84e6c4994e29 74 CommsWriteBlockError,
IanBenzMaxim 76:84e6c4994e29 75 TimeoutError,
IanBenzMaxim 76:84e6c4994e29 76 OperationFailure
IanBenzMaxim 76:84e6c4994e29 77 };
IanBenzMaxim 74:23be10c32fa3 78
IanBenzMaxim 76:84e6c4994e29 79 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 80 * @brief DS28E17 constructor
IanBenzMaxim 76:84e6c4994e29 81 *
IanBenzMaxim 76:84e6c4994e29 82 * @details
IanBenzMaxim 76:84e6c4994e29 83 *
IanBenzMaxim 76:84e6c4994e29 84 * On Entry:
IanBenzMaxim 76:84e6c4994e29 85 * @param[in] p_owm - pointer to a 1-wire master of the following
IanBenzMaxim 76:84e6c4994e29 86 * types; Ds248x, Ds2480b, OwGpio which
IanBenzMaxim 76:84e6c4994e29 87 * inherit the base class 'OneWireInterface'
IanBenzMaxim 76:84e6c4994e29 88 *
IanBenzMaxim 76:84e6c4994e29 89 * On Exit:
IanBenzMaxim 76:84e6c4994e29 90 * @return
IanBenzMaxim 76:84e6c4994e29 91 **************************************************************/
IanBenzMaxim 77:529edb329ee0 92 DS28E17(RandomAccessRomIterator &selector);
IanBenzMaxim 74:23be10c32fa3 93
IanBenzMaxim 76:84e6c4994e29 94 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 95 * @brief Write to selected DS28E17's I2C with Stop.
IanBenzMaxim 76:84e6c4994e29 96 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 97 *
IanBenzMaxim 76:84e6c4994e29 98 * @details Output on I2C: S, Address + Write, Write Data [1-255], P
IanBenzMaxim 76:84e6c4994e29 99 *
IanBenzMaxim 76:84e6c4994e29 100 * On Entry:
IanBenzMaxim 76:84e6c4994e29 101 * @param[in] I2C_addr -
IanBenzMaxim 76:84e6c4994e29 102 * Writes I2C address. The least significant bit of the I2C
IanBenzMaxim 76:84e6c4994e29 103 * address is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 104 *
IanBenzMaxim 76:84e6c4994e29 105 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 106 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 107 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 108 *
IanBenzMaxim 76:84e6c4994e29 109 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 110 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 111 *
IanBenzMaxim 76:84e6c4994e29 112 * On Exit:
IanBenzMaxim 76:84e6c4994e29 113 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 114 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 115 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 116 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 117 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 118 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 119 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 120 *
IanBenzMaxim 76:84e6c4994e29 121 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 122 * Indicates which write byte NACK’d. A value of 00h indicates
IanBenzMaxim 76:84e6c4994e29 123 * all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 124 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 125 *
IanBenzMaxim 76:84e6c4994e29 126 * @return
IanBenzMaxim 76:84e6c4994e29 127 * true if device selected and written @n
IanBenzMaxim 76:84e6c4994e29 128 * false if failed device select
IanBenzMaxim 76:84e6c4994e29 129 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 130 CmdResult I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length,
IanBenzMaxim 76:84e6c4994e29 131 uint8_t *data, uint8_t &status,
IanBenzMaxim 76:84e6c4994e29 132 uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 133
IanBenzMaxim 76:84e6c4994e29 134 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 135 * @brief Write to selected DS28E17's I2C No Stop.
IanBenzMaxim 76:84e6c4994e29 136 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 137 *
IanBenzMaxim 76:84e6c4994e29 138 * @details Output on I2C: S, Address + Write, Write Data [1-255]
IanBenzMaxim 76:84e6c4994e29 139 *
IanBenzMaxim 76:84e6c4994e29 140 * On Entry:
IanBenzMaxim 76:84e6c4994e29 141 * @param[in] I2C_addr
IanBenzMaxim 76:84e6c4994e29 142 * Writes I2C address. The least significant bit of the I2C address
IanBenzMaxim 76:84e6c4994e29 143 * is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 144 *
IanBenzMaxim 76:84e6c4994e29 145 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 146 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 147 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 148 *
IanBenzMaxim 76:84e6c4994e29 149 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 150 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 151 *
IanBenzMaxim 76:84e6c4994e29 152 * On Exit:
IanBenzMaxim 76:84e6c4994e29 153 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 154 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 155 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 156 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 157 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 158 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 159 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 160 *
IanBenzMaxim 76:84e6c4994e29 161 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 162 * Indicates which write byte NACK’d. A value of 00h indicates
IanBenzMaxim 76:84e6c4994e29 163 * all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 164 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 165 *
IanBenzMaxim 76:84e6c4994e29 166 * @return
IanBenzMaxim 76:84e6c4994e29 167 * true if device selected and written @n
IanBenzMaxim 76:84e6c4994e29 168 * false if failed device select
IanBenzMaxim 76:84e6c4994e29 169 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 170 CmdResult I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length,
IanBenzMaxim 76:84e6c4994e29 171 uint8_t *data, uint8_t &status,
IanBenzMaxim 76:84e6c4994e29 172 uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 173
IanBenzMaxim 74:23be10c32fa3 174
IanBenzMaxim 76:84e6c4994e29 175 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 176 * @brief Write to selected DS28E17's I2C with Data only.
IanBenzMaxim 76:84e6c4994e29 177 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 178 *
IanBenzMaxim 76:84e6c4994e29 179 * @details Output on I2C: Write Data [1-255]
IanBenzMaxim 76:84e6c4994e29 180 *
IanBenzMaxim 76:84e6c4994e29 181 * On Entry:
IanBenzMaxim 76:84e6c4994e29 182 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 183 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 184 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 185 *
IanBenzMaxim 76:84e6c4994e29 186 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 187 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 188 *
IanBenzMaxim 76:84e6c4994e29 189 * On Exit:
IanBenzMaxim 76:84e6c4994e29 190 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 191 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 192 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 193 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 194 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 195 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 196 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 197 *
IanBenzMaxim 76:84e6c4994e29 198 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 199 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 200 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 201 *
IanBenzMaxim 76:84e6c4994e29 202 * @return
IanBenzMaxim 76:84e6c4994e29 203 * true if device selected and written @n
IanBenzMaxim 76:84e6c4994e29 204 * false if failed device select
IanBenzMaxim 76:84e6c4994e29 205 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 206 CmdResult I2C_WriteDataOnly(uint8_t length, uint8_t *data,
IanBenzMaxim 76:84e6c4994e29 207 uint8_t &status, uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 208
IanBenzMaxim 74:23be10c32fa3 209
IanBenzMaxim 76:84e6c4994e29 210 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 211 * @brief Write to selected DS28E17's I2C with Stop.
IanBenzMaxim 76:84e6c4994e29 212 * Poll until I2C write complete and receive status info.
IanBenzMaxim 76:84e6c4994e29 213 *
IanBenzMaxim 76:84e6c4994e29 214 * @details Output on I2C: Write Data [1-255], P
IanBenzMaxim 76:84e6c4994e29 215 *
IanBenzMaxim 76:84e6c4994e29 216 * On Entry:
IanBenzMaxim 76:84e6c4994e29 217 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 218 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 219 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 220 *
IanBenzMaxim 76:84e6c4994e29 221 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 222 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 223 *
IanBenzMaxim 76:84e6c4994e29 224 * On Exit:
IanBenzMaxim 76:84e6c4994e29 225 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 226 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 227 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 228 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 229 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 230 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 231 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 232 *
IanBenzMaxim 76:84e6c4994e29 233 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 234 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 235 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 236 *
IanBenzMaxim 76:84e6c4994e29 237 * @return
IanBenzMaxim 76:84e6c4994e29 238 * true if device selected and written @n
IanBenzMaxim 76:84e6c4994e29 239 * false if failed device select
IanBenzMaxim 76:84e6c4994e29 240 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 241 CmdResult I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data,
IanBenzMaxim 76:84e6c4994e29 242 uint8_t &status, uint8_t &wr_status);
IanBenzMaxim 74:23be10c32fa3 243
IanBenzMaxim 74:23be10c32fa3 244
IanBenzMaxim 76:84e6c4994e29 245 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 246 * @brief Write to selected DS28E17's I2C with Stop and poll until I2C write complete
IanBenzMaxim 76:84e6c4994e29 247 * receive status info, and read data with a stop at the end.
IanBenzMaxim 76:84e6c4994e29 248 *
IanBenzMaxim 76:84e6c4994e29 249 * @details Output on I2C:
IanBenzMaxim 76:84e6c4994e29 250 * S, Slave Address + Write, Write Data [1-255],
IanBenzMaxim 76:84e6c4994e29 251 * Sr, Address + Read, Read Data [1-255], P (NACK last read byte)
IanBenzMaxim 76:84e6c4994e29 252 *
IanBenzMaxim 76:84e6c4994e29 253 * On Entry:
IanBenzMaxim 76:84e6c4994e29 254 * @param[in] I2C_addr
IanBenzMaxim 76:84e6c4994e29 255 * Writes I2C address. The least significant bit of the I2C address
IanBenzMaxim 76:84e6c4994e29 256 * is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 257 *
IanBenzMaxim 76:84e6c4994e29 258 * @param[in] length
IanBenzMaxim 76:84e6c4994e29 259 * The number of data bytes to be written ranging from 01h to FFh.
IanBenzMaxim 76:84e6c4994e29 260 * A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 261 *
IanBenzMaxim 76:84e6c4994e29 262 * @param[in] *data
IanBenzMaxim 76:84e6c4994e29 263 * User defines write data ranging from 1-255 bytes.
IanBenzMaxim 76:84e6c4994e29 264 *
IanBenzMaxim 76:84e6c4994e29 265 * @param[in] nu_bytes_read
IanBenzMaxim 76:84e6c4994e29 266 * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 267 *
IanBenzMaxim 76:84e6c4994e29 268 * On Exit:
IanBenzMaxim 76:84e6c4994e29 269 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 270 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 271 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 272 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 273 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 274 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 275 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 276 *
IanBenzMaxim 76:84e6c4994e29 277 * @param[out] wr_status
IanBenzMaxim 76:84e6c4994e29 278 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
IanBenzMaxim 76:84e6c4994e29 279 * A non-zero value indicates the byte number that NACK’d.
IanBenzMaxim 76:84e6c4994e29 280 *
IanBenzMaxim 76:84e6c4994e29 281 * @param[out] *read_data
IanBenzMaxim 76:84e6c4994e29 282 * Array of read data received from I2C.
IanBenzMaxim 76:84e6c4994e29 283 *
IanBenzMaxim 76:84e6c4994e29 284 * @return
IanBenzMaxim 76:84e6c4994e29 285 * true if device selected, written and read @n
IanBenzMaxim 76:84e6c4994e29 286 * false if failed device select or timeout occurred or CRC16 error
IanBenzMaxim 76:84e6c4994e29 287 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 288 CmdResult I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length,
IanBenzMaxim 76:84e6c4994e29 289 uint8_t *data, uint8_t nu_bytes_read,
IanBenzMaxim 76:84e6c4994e29 290 uint8_t &status, uint8_t &wr_status,
IanBenzMaxim 76:84e6c4994e29 291 uint8_t *read_data);
IanBenzMaxim 74:23be10c32fa3 292
IanBenzMaxim 74:23be10c32fa3 293
IanBenzMaxim 76:84e6c4994e29 294 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 295 * @brief Selected DS28E17's and send I2C address and poll until
IanBenzMaxim 76:84e6c4994e29 296 * I2C read address complete, receive status info, and read data
IanBenzMaxim 76:84e6c4994e29 297 * with a stop at the end.
IanBenzMaxim 76:84e6c4994e29 298 *
IanBenzMaxim 76:84e6c4994e29 299 * @details Output on I2C:
IanBenzMaxim 76:84e6c4994e29 300 * S, Slave Address + Read, Read Data [1-255], P (NACK last read byte)
IanBenzMaxim 76:84e6c4994e29 301 *
IanBenzMaxim 76:84e6c4994e29 302 * On Entry:
IanBenzMaxim 76:84e6c4994e29 303 * @param[in] I2C_addr
IanBenzMaxim 76:84e6c4994e29 304 * Writes I2C address. The least significant bit of the I2C address
IanBenzMaxim 76:84e6c4994e29 305 * is automatically cleared by the command.
IanBenzMaxim 76:84e6c4994e29 306 *
IanBenzMaxim 76:84e6c4994e29 307 * On Exit:
IanBenzMaxim 76:84e6c4994e29 308 * @param[out] nu_bytes_read
IanBenzMaxim 76:84e6c4994e29 309 * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
IanBenzMaxim 76:84e6c4994e29 310 *
IanBenzMaxim 76:84e6c4994e29 311 * @param[out] status
IanBenzMaxim 76:84e6c4994e29 312 * Detects the condition of the Start (bit3), N/A (bit2),
IanBenzMaxim 76:84e6c4994e29 313 * Address(bit1) and CRC16(bit0) bits.
IanBenzMaxim 76:84e6c4994e29 314 * b3;0=No Err|1=I2CStart prev-not issued,
IanBenzMaxim 76:84e6c4994e29 315 * b2;0=No Err|1=I2C N/A Err,
IanBenzMaxim 76:84e6c4994e29 316 * b1;0=No Err|1=Addr Err,
IanBenzMaxim 76:84e6c4994e29 317 * b0;0=Valid CRC16|1=Invalid CRC16
IanBenzMaxim 76:84e6c4994e29 318 *
IanBenzMaxim 76:84e6c4994e29 319 * @param[out] *read_data
IanBenzMaxim 76:84e6c4994e29 320 * Array of read data received from I2C.
IanBenzMaxim 76:84e6c4994e29 321 *
IanBenzMaxim 76:84e6c4994e29 322 * @return
IanBenzMaxim 76:84e6c4994e29 323 * true if device selected, written and read @n
IanBenzMaxim 76:84e6c4994e29 324 * false if failed device select or timeout occurred or CRC16 error
IanBenzMaxim 76:84e6c4994e29 325 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 326 CmdResult I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read,
IanBenzMaxim 76:84e6c4994e29 327 uint8_t &status, uint8_t *read_data);
IanBenzMaxim 74:23be10c32fa3 328
IanBenzMaxim 74:23be10c32fa3 329
IanBenzMaxim 76:84e6c4994e29 330 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 331 * @brief Write to Configuration Register of DS28E17.
IanBenzMaxim 76:84e6c4994e29 332 *
IanBenzMaxim 76:84e6c4994e29 333 * @details
IanBenzMaxim 76:84e6c4994e29 334 *
IanBenzMaxim 76:84e6c4994e29 335 * On Entry:
IanBenzMaxim 76:84e6c4994e29 336 * @param[in] data
IanBenzMaxim 76:84e6c4994e29 337 * sent to configuration register
IanBenzMaxim 76:84e6c4994e29 338 *
IanBenzMaxim 76:84e6c4994e29 339 * On Exit:
IanBenzMaxim 76:84e6c4994e29 340 *
IanBenzMaxim 76:84e6c4994e29 341 * @return
IanBenzMaxim 76:84e6c4994e29 342 * true if device selected and written @n
IanBenzMaxim 76:84e6c4994e29 343 * false if failed device select
IanBenzMaxim 76:84e6c4994e29 344 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 345 CmdResult WriteConfigReg(uint8_t data);
IanBenzMaxim 74:23be10c32fa3 346
IanBenzMaxim 74:23be10c32fa3 347
IanBenzMaxim 76:84e6c4994e29 348 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 349 * @brief Read the Configuration Register of DS28E17.
IanBenzMaxim 76:84e6c4994e29 350 *
IanBenzMaxim 76:84e6c4994e29 351 * @details
IanBenzMaxim 76:84e6c4994e29 352 *
IanBenzMaxim 76:84e6c4994e29 353 * On Entry:
IanBenzMaxim 76:84e6c4994e29 354 *
IanBenzMaxim 76:84e6c4994e29 355 * On Exit:
IanBenzMaxim 76:84e6c4994e29 356 *
IanBenzMaxim 76:84e6c4994e29 357 * @return
IanBenzMaxim 76:84e6c4994e29 358 * true if device selected and read correctly @n
IanBenzMaxim 76:84e6c4994e29 359 * false if failed device select
IanBenzMaxim 76:84e6c4994e29 360 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 361 CmdResult ReadConfigReg(uint8_t & config);
IanBenzMaxim 74:23be10c32fa3 362
IanBenzMaxim 74:23be10c32fa3 363
IanBenzMaxim 76:84e6c4994e29 364 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 365 * @brief The Enable Sleep Mode command puts the device into a low current mode.
IanBenzMaxim 76:84e6c4994e29 366 * All 1-Wire communication is ignored until woken up. Immediately after
IanBenzMaxim 76:84e6c4994e29 367 * the command, the device monitors the WAKEUP input pin and
IanBenzMaxim 76:84e6c4994e29 368 * exits sleep mode on a rising edge.
IanBenzMaxim 76:84e6c4994e29 369 *
IanBenzMaxim 76:84e6c4994e29 370 * @details
IanBenzMaxim 76:84e6c4994e29 371 *
IanBenzMaxim 76:84e6c4994e29 372 * On Entry:
IanBenzMaxim 76:84e6c4994e29 373 *
IanBenzMaxim 76:84e6c4994e29 374 * On Exit:
IanBenzMaxim 76:84e6c4994e29 375 *
IanBenzMaxim 76:84e6c4994e29 376 * @return
IanBenzMaxim 76:84e6c4994e29 377 * true if device selected and written @n
IanBenzMaxim 76:84e6c4994e29 378 * false if failed device select*
IanBenzMaxim 76:84e6c4994e29 379 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 380 CmdResult EnableSleepMode();
IanBenzMaxim 74:23be10c32fa3 381
IanBenzMaxim 74:23be10c32fa3 382
IanBenzMaxim 76:84e6c4994e29 383 /**********************************************************//**
IanBenzMaxim 76:84e6c4994e29 384 * @brief Read the Device Revision of DS28E17. The revision value
IanBenzMaxim 76:84e6c4994e29 385 * should never be zero. The upper nibble is the major revision
IanBenzMaxim 76:84e6c4994e29 386 * and the lower nibble is the minor revision.
IanBenzMaxim 76:84e6c4994e29 387 *
IanBenzMaxim 76:84e6c4994e29 388 * @details
IanBenzMaxim 76:84e6c4994e29 389 *
IanBenzMaxim 76:84e6c4994e29 390 * On Entry:
IanBenzMaxim 76:84e6c4994e29 391 *
IanBenzMaxim 76:84e6c4994e29 392 * On Exit:
IanBenzMaxim 76:84e6c4994e29 393 *
IanBenzMaxim 76:84e6c4994e29 394 * @return
IanBenzMaxim 76:84e6c4994e29 395 * revision value if device selected and read correctly @n
IanBenzMaxim 76:84e6c4994e29 396 * false if failed device select (i.e. 00h)
IanBenzMaxim 76:84e6c4994e29 397 **************************************************************/
IanBenzMaxim 76:84e6c4994e29 398 CmdResult ReadDeviceRevision(uint8_t & rev);
IanBenzMaxim 74:23be10c32fa3 399
IanBenzMaxim 76:84e6c4994e29 400 private:
IanBenzMaxim 78:0cbbac7f2016 401 static const size_t pollLimit = 10000;
IanBenzMaxim 74:23be10c32fa3 402
IanBenzMaxim 76:84e6c4994e29 403 CmdResult send_packet(const uint8_t * data, uint8_t data_length,
IanBenzMaxim 76:84e6c4994e29 404 uint8_t & status, uint8_t & wr_status);
IanBenzMaxim 74:23be10c32fa3 405
IanBenzMaxim 76:84e6c4994e29 406 //overloaded function for I2C read only command
IanBenzMaxim 76:84e6c4994e29 407 CmdResult send_packet(const uint8_t * data, uint8_t data_length,
IanBenzMaxim 76:84e6c4994e29 408 uint8_t & status);
IanBenzMaxim 76:84e6c4994e29 409 };
IanBenzMaxim 73:2cecc1372acc 410 }
j3 4:ca27db159b10 411
IanBenzMaxim 74:23be10c32fa3 412 #endif
j3 17:b646b1e3970b 413