Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
IanBenzMaxim
Date:
Mon Mar 21 14:12:28 2016 -0500
Revision:
21:00c94aeb533e
Parent:
17:b646b1e3970b
Child:
22:686273e55cdc
Added class for DS2465. Added a ReadBytePower operation to OneWireMaster since this is required by the authenticators including the DS28E15. Tweaked member data of OneWireMaster. Added path to header file includes to reduce compiler setup required.

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
j3 4:ca27db159b10 33
j3 4:ca27db159b10 34 #ifndef DS28E17_H
j3 4:ca27db159b10 35 #define DS28E17_H
j3 4:ca27db159b10 36
j3 4:ca27db159b10 37
j3 4:ca27db159b10 38 #include "mbed.h"
IanBenzMaxim 21:00c94aeb533e 39 #include "OneWire_Masters/OneWireMasters.h"
j3 4:ca27db159b10 40
j3 4:ca27db159b10 41
j3 4:ca27db159b10 42 class Ds28e17
j3 4:ca27db159b10 43 {
j3 4:ca27db159b10 44 public:
j3 4:ca27db159b10 45
j3 7:78a8857b3810 46 enum DS28E17_CMDS
j3 7:78a8857b3810 47 {
j3 7:78a8857b3810 48 CMD_I2C_WRITE_W_STOP = 0x4B,
j3 7:78a8857b3810 49 CMD_I2C_WRITE_NO_STOP = 0x5A,
j3 7:78a8857b3810 50 CMD_I2C_WRITE_ONLY = 0x69,
j3 7:78a8857b3810 51 CMD_I2C_WRITE_ONLY_W_STOP = 0x78,
j3 7:78a8857b3810 52 CMD_I2C_READ_W_STOP = 0x87,
j3 7:78a8857b3810 53 CMD_I2C_WRITE_READ_W_STOP = 0x2D,
j3 7:78a8857b3810 54 CMD_WRITE_CONFIG_REG = 0xD2,
j3 7:78a8857b3810 55 CMD_READ_CONFIG_REG = 0xE1,
j3 7:78a8857b3810 56 CMD_DISABLE_OW_MODE = 0x96,
j3 7:78a8857b3810 57 CMD_ENABLE_SLEEP_MODE = 0x1E,
j3 7:78a8857b3810 58 CMD_READ_DEVICE_REV = 0xC3
j3 7:78a8857b3810 59 };
j3 7:78a8857b3810 60
j3 17:b646b1e3970b 61 enum CmdResult
j3 17:b646b1e3970b 62 {
j3 17:b646b1e3970b 63 Success,
j3 17:b646b1e3970b 64 CommsReadBitError,
j3 17:b646b1e3970b 65 CommsWriteBitError,
j3 17:b646b1e3970b 66 CommsReadByteError,
j3 17:b646b1e3970b 67 CommsWriteByteError,
j3 17:b646b1e3970b 68 CommsReadBlockError,
j3 17:b646b1e3970b 69 CommsWriteBlockError,
j3 17:b646b1e3970b 70 TimeoutError,
j3 17:b646b1e3970b 71 OperationFailure
j3 17:b646b1e3970b 72 };
j3 17:b646b1e3970b 73
j3 7:78a8857b3810 74 static const size_t POLL_LIMIT = 10000;
j3 7:78a8857b3810 75
j3 4:ca27db159b10 76 /**********************************************************//**
j3 4:ca27db159b10 77 * @brief Ds28e17 constructor
j3 4:ca27db159b10 78 *
j3 4:ca27db159b10 79 * @details
j3 4:ca27db159b10 80 *
j3 4:ca27db159b10 81 * On Entry:
j3 4:ca27db159b10 82 * @param[in] p_owm - pointer to a 1-wire master of the following
j3 4:ca27db159b10 83 * types; Ds248x, Ds2480b, OwGpio which
j3 4:ca27db159b10 84 * inherit the base class 'OneWireInterface'
j3 4:ca27db159b10 85 *
j3 4:ca27db159b10 86 * On Exit:
j3 4:ca27db159b10 87 * @return
j3 4:ca27db159b10 88 **************************************************************/
j3 7:78a8857b3810 89 Ds28e17(OneWireInterface &owm);
j3 4:ca27db159b10 90
j3 17:b646b1e3970b 91 /**********************************************************//**
j3 17:b646b1e3970b 92 * @brief
j3 17:b646b1e3970b 93 *
j3 17:b646b1e3970b 94 * @details
j3 17:b646b1e3970b 95 *
j3 17:b646b1e3970b 96 * On Entry:
j3 17:b646b1e3970b 97 * @param[in] romId - reference to RomId type
j3 17:b646b1e3970b 98 *
j3 17:b646b1e3970b 99 * On Exit:
j3 17:b646b1e3970b 100 *
j3 17:b646b1e3970b 101 * @return
j3 17:b646b1e3970b 102 **************************************************************/
j3 17:b646b1e3970b 103 void set_rom_id(const RomId & romId);
j3 17:b646b1e3970b 104
j3 17:b646b1e3970b 105 /**********************************************************//**
j3 17:b646b1e3970b 106 * @brief
j3 17:b646b1e3970b 107 *
j3 17:b646b1e3970b 108 * @details
j3 17:b646b1e3970b 109 *
j3 17:b646b1e3970b 110 * On Entry:
j3 17:b646b1e3970b 111 *
j3 17:b646b1e3970b 112 * On Exit:
j3 17:b646b1e3970b 113 *
j3 17:b646b1e3970b 114 * @return current RomId held by this object
j3 17:b646b1e3970b 115 **************************************************************/
j3 17:b646b1e3970b 116 RomId get_rom_id(void);
j3 4:ca27db159b10 117
j3 4:ca27db159b10 118 /**********************************************************//**
j3 4:ca27db159b10 119 * @brief Write to selected DS28E17's I2C with Stop.
j3 4:ca27db159b10 120 * Poll until I2C write complete and receive status info.
j3 4:ca27db159b10 121 *
j3 4:ca27db159b10 122 * @details Output on I2C: S, Address + Write, Write Data [1-255], P
j3 4:ca27db159b10 123 *
j3 4:ca27db159b10 124 * On Entry:
j3 4:ca27db159b10 125 * @param[in] I2C_addr -
j3 4:ca27db159b10 126 * Writes I2C address. The least significant bit of the I2C
j3 4:ca27db159b10 127 * address is automatically cleared by the command.
j3 4:ca27db159b10 128 *
j3 4:ca27db159b10 129 * @param[in] length
j3 4:ca27db159b10 130 * The number of data bytes to be written ranging from 01h to FFh.
j3 4:ca27db159b10 131 * A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 132 *
j3 4:ca27db159b10 133 * @param[in] *data
j3 4:ca27db159b10 134 * User defines write data ranging from 1-255 bytes.
j3 4:ca27db159b10 135 *
j3 4:ca27db159b10 136 * On Exit:
j3 4:ca27db159b10 137 * @param[out] status
j3 4:ca27db159b10 138 * Detects the condition of the Start (bit3), N/A (bit2),
j3 4:ca27db159b10 139 * Address(bit1) and CRC16(bit0) bits.
j3 4:ca27db159b10 140 * b3;0=No Err|1=I2CStart prev-not issued,
j3 4:ca27db159b10 141 * b2;0=No Err|1=I2C N/A Err,
j3 4:ca27db159b10 142 * b1;0=No Err|1=Addr Err,
j3 4:ca27db159b10 143 * b0;0=Valid CRC16|1=Invalid CRC16
j3 4:ca27db159b10 144 *
j3 4:ca27db159b10 145 * @param[out] wr_status
j3 4:ca27db159b10 146 * Indicates which write byte NACK’d. A value of 00h indicates
j3 4:ca27db159b10 147 * all bytes were acknowledged by the slave.
j3 4:ca27db159b10 148 * A non-zero value indicates the byte number that NACK’d.
j3 4:ca27db159b10 149 *
j3 4:ca27db159b10 150 * @return
j3 4:ca27db159b10 151 * true if device selected and written @n
j3 4:ca27db159b10 152 * false if failed device select
j3 4:ca27db159b10 153 **************************************************************/
j3 17:b646b1e3970b 154 CmdResult I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length,
j3 7:78a8857b3810 155 uint8_t *data, uint8_t &status,
j3 7:78a8857b3810 156 uint8_t &wr_status);
j3 4:ca27db159b10 157
j3 4:ca27db159b10 158 /**********************************************************//**
j3 4:ca27db159b10 159 * @brief Write to selected DS28E17's I2C No Stop.
j3 4:ca27db159b10 160 * Poll until I2C write complete and receive status info.
j3 4:ca27db159b10 161 *
j3 4:ca27db159b10 162 * @details Output on I2C: S, Address + Write, Write Data [1-255]
j3 4:ca27db159b10 163 *
j3 4:ca27db159b10 164 * On Entry:
j3 4:ca27db159b10 165 * @param[in] I2C_addr
j3 4:ca27db159b10 166 * Writes I2C address. The least significant bit of the I2C address
j3 4:ca27db159b10 167 * is automatically cleared by the command.
j3 4:ca27db159b10 168 *
j3 4:ca27db159b10 169 * @param[in] length
j3 4:ca27db159b10 170 * The number of data bytes to be written ranging from 01h to FFh.
j3 4:ca27db159b10 171 * A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 172 *
j3 4:ca27db159b10 173 * @param[in] *data
j3 4:ca27db159b10 174 * User defines write data ranging from 1-255 bytes.
j3 4:ca27db159b10 175 *
j3 4:ca27db159b10 176 * On Exit:
j3 4:ca27db159b10 177 * @param[out] status
j3 4:ca27db159b10 178 * Detects the condition of the Start (bit3), N/A (bit2),
j3 4:ca27db159b10 179 * Address(bit1) and CRC16(bit0) bits.
j3 4:ca27db159b10 180 * b3;0=No Err|1=I2CStart prev-not issued,
j3 4:ca27db159b10 181 * b2;0=No Err|1=I2C N/A Err,
j3 4:ca27db159b10 182 * b1;0=No Err|1=Addr Err,
j3 4:ca27db159b10 183 * b0;0=Valid CRC16|1=Invalid CRC16
j3 4:ca27db159b10 184 *
j3 4:ca27db159b10 185 * @param[out] wr_status
j3 4:ca27db159b10 186 * Indicates which write byte NACK’d. A value of 00h indicates
j3 4:ca27db159b10 187 * all bytes were acknowledged by the slave.
j3 4:ca27db159b10 188 * A non-zero value indicates the byte number that NACK’d.
j3 4:ca27db159b10 189 *
j3 4:ca27db159b10 190 * @return
j3 4:ca27db159b10 191 * true if device selected and written @n
j3 4:ca27db159b10 192 * false if failed device select
j3 4:ca27db159b10 193 **************************************************************/
j3 17:b646b1e3970b 194 CmdResult I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length,
j3 7:78a8857b3810 195 uint8_t *data, uint8_t &status,
j3 7:78a8857b3810 196 uint8_t &wr_status);
j3 4:ca27db159b10 197
j3 4:ca27db159b10 198
j3 4:ca27db159b10 199 /**********************************************************//**
j3 4:ca27db159b10 200 * @brief Write to selected DS28E17's I2C with Data only.
j3 4:ca27db159b10 201 * Poll until I2C write complete and receive status info.
j3 4:ca27db159b10 202 *
j3 4:ca27db159b10 203 * @details Output on I2C: Write Data [1-255]
j3 4:ca27db159b10 204 *
j3 4:ca27db159b10 205 * On Entry:
j3 4:ca27db159b10 206 * @param[in] length
j3 4:ca27db159b10 207 * The number of data bytes to be written ranging from 01h to FFh.
j3 4:ca27db159b10 208 * A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 209 *
j3 4:ca27db159b10 210 * @param[in] *data
j3 4:ca27db159b10 211 * User defines write data ranging from 1-255 bytes.
j3 4:ca27db159b10 212 *
j3 4:ca27db159b10 213 * On Exit:
j3 4:ca27db159b10 214 * @param[out] status
j3 4:ca27db159b10 215 * Detects the condition of the Start (bit3), N/A (bit2),
j3 4:ca27db159b10 216 * Address(bit1) and CRC16(bit0) bits.
j3 4:ca27db159b10 217 * b3;0=No Err|1=I2CStart prev-not issued,
j3 4:ca27db159b10 218 * b2;0=No Err|1=I2C N/A Err,
j3 4:ca27db159b10 219 * b1;0=No Err|1=Addr Err,
j3 4:ca27db159b10 220 * b0;0=Valid CRC16|1=Invalid CRC16
j3 4:ca27db159b10 221 *
j3 4:ca27db159b10 222 * @param[out] wr_status
j3 4:ca27db159b10 223 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
j3 4:ca27db159b10 224 * A non-zero value indicates the byte number that NACK’d.
j3 4:ca27db159b10 225 *
j3 4:ca27db159b10 226 * @return
j3 4:ca27db159b10 227 * true if device selected and written @n
j3 4:ca27db159b10 228 * false if failed device select
j3 4:ca27db159b10 229 **************************************************************/
j3 17:b646b1e3970b 230 CmdResult I2C_WriteDataOnly(uint8_t length, uint8_t *data,
j3 7:78a8857b3810 231 uint8_t &status, uint8_t &wr_status);
j3 4:ca27db159b10 232
j3 4:ca27db159b10 233
j3 4:ca27db159b10 234 /**********************************************************//**
j3 4:ca27db159b10 235 * @brief Write to selected DS28E17's I2C with Stop.
j3 4:ca27db159b10 236 * Poll until I2C write complete and receive status info.
j3 4:ca27db159b10 237 *
j3 4:ca27db159b10 238 * @details Output on I2C: Write Data [1-255], P
j3 4:ca27db159b10 239 *
j3 4:ca27db159b10 240 * On Entry:
j3 4:ca27db159b10 241 * @param[in] length
j3 4:ca27db159b10 242 * The number of data bytes to be written ranging from 01h to FFh.
j3 4:ca27db159b10 243 * A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 244 *
j3 4:ca27db159b10 245 * @param[in] *data
j3 4:ca27db159b10 246 * User defines write data ranging from 1-255 bytes.
j3 4:ca27db159b10 247 *
j3 4:ca27db159b10 248 * On Exit:
j3 4:ca27db159b10 249 * @param[out] status
j3 4:ca27db159b10 250 * Detects the condition of the Start (bit3), N/A (bit2),
j3 4:ca27db159b10 251 * Address(bit1) and CRC16(bit0) bits.
j3 4:ca27db159b10 252 * b3;0=No Err|1=I2CStart prev-not issued,
j3 4:ca27db159b10 253 * b2;0=No Err|1=I2C N/A Err,
j3 4:ca27db159b10 254 * b1;0=No Err|1=Addr Err,
j3 4:ca27db159b10 255 * b0;0=Valid CRC16|1=Invalid CRC16
j3 4:ca27db159b10 256 *
j3 4:ca27db159b10 257 * @param[out] wr_status
j3 4:ca27db159b10 258 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
j3 4:ca27db159b10 259 * A non-zero value indicates the byte number that NACK’d.
j3 4:ca27db159b10 260 *
j3 4:ca27db159b10 261 * @return
j3 4:ca27db159b10 262 * true if device selected and written @n
j3 4:ca27db159b10 263 * false if failed device select
j3 4:ca27db159b10 264 **************************************************************/
j3 17:b646b1e3970b 265 CmdResult I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data,
j3 7:78a8857b3810 266 uint8_t &status, uint8_t &wr_status);
j3 4:ca27db159b10 267
j3 4:ca27db159b10 268
j3 4:ca27db159b10 269 /**********************************************************//**
j3 4:ca27db159b10 270 * @brief Write to selected DS28E17's I2C with Stop and poll until I2C write complete
j3 4:ca27db159b10 271 * receive status info, and read data with a stop at the end.
j3 4:ca27db159b10 272 *
j3 4:ca27db159b10 273 * @details Output on I2C:
j3 4:ca27db159b10 274 * S, Slave Address + Write, Write Data [1-255],
j3 4:ca27db159b10 275 * Sr, Address + Read, Read Data [1-255], P (NACK last read byte)
j3 4:ca27db159b10 276 *
j3 4:ca27db159b10 277 * On Entry:
j3 4:ca27db159b10 278 * @param[in] I2C_addr
j3 4:ca27db159b10 279 * Writes I2C address. The least significant bit of the I2C address
j3 4:ca27db159b10 280 * is automatically cleared by the command.
j3 4:ca27db159b10 281 *
j3 4:ca27db159b10 282 * @param[in] length
j3 4:ca27db159b10 283 * The number of data bytes to be written ranging from 01h to FFh.
j3 4:ca27db159b10 284 * A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 285 *
j3 4:ca27db159b10 286 * @param[in] *data
j3 4:ca27db159b10 287 * User defines write data ranging from 1-255 bytes.
j3 4:ca27db159b10 288 *
j3 8:7c7a0ea0c568 289 * @param[in] nu_bytes_read
j3 4:ca27db159b10 290 * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 291 *
j3 8:7c7a0ea0c568 292 * On Exit:
j3 4:ca27db159b10 293 * @param[out] status
j3 4:ca27db159b10 294 * Detects the condition of the Start (bit3), N/A (bit2),
j3 4:ca27db159b10 295 * Address(bit1) and CRC16(bit0) bits.
j3 4:ca27db159b10 296 * b3;0=No Err|1=I2CStart prev-not issued,
j3 4:ca27db159b10 297 * b2;0=No Err|1=I2C N/A Err,
j3 4:ca27db159b10 298 * b1;0=No Err|1=Addr Err,
j3 4:ca27db159b10 299 * b0;0=Valid CRC16|1=Invalid CRC16
j3 4:ca27db159b10 300 *
j3 4:ca27db159b10 301 * @param[out] wr_status
j3 4:ca27db159b10 302 * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave.
j3 4:ca27db159b10 303 * A non-zero value indicates the byte number that NACK’d.
j3 4:ca27db159b10 304 *
j3 4:ca27db159b10 305 * @param[out] *read_data
j3 4:ca27db159b10 306 * Array of read data received from I2C.
j3 4:ca27db159b10 307 *
j3 4:ca27db159b10 308 * @return
j3 4:ca27db159b10 309 * true if device selected, written and read @n
j3 4:ca27db159b10 310 * false if failed device select or timeout occurred or CRC16 error
j3 4:ca27db159b10 311 **************************************************************/
j3 17:b646b1e3970b 312 CmdResult I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length,
j3 4:ca27db159b10 313 uint8_t *data, uint8_t nu_bytes_read,
j3 7:78a8857b3810 314 uint8_t &status, uint8_t &wr_status,
j3 4:ca27db159b10 315 uint8_t *read_data);
j3 4:ca27db159b10 316
j3 4:ca27db159b10 317
j3 4:ca27db159b10 318 /**********************************************************//**
j3 4:ca27db159b10 319 * @brief Selected DS28E17's and send I2C address and poll until
j3 4:ca27db159b10 320 * I2C read address complete, receive status info, and read data
j3 4:ca27db159b10 321 * with a stop at the end.
j3 4:ca27db159b10 322 *
j3 4:ca27db159b10 323 * @details Output on I2C:
j3 4:ca27db159b10 324 * S, Slave Address + Read, Read Data [1-255], P (NACK last read byte)
j3 4:ca27db159b10 325 *
j3 4:ca27db159b10 326 * On Entry:
j3 4:ca27db159b10 327 * @param[in] I2C_addr
j3 4:ca27db159b10 328 * Writes I2C address. The least significant bit of the I2C address
j3 4:ca27db159b10 329 * is automatically cleared by the command.
j3 4:ca27db159b10 330 *
j3 4:ca27db159b10 331 * On Exit:
j3 4:ca27db159b10 332 * @param[out] nu_bytes_read
j3 4:ca27db159b10 333 * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED).
j3 4:ca27db159b10 334 *
j3 4:ca27db159b10 335 * @param[out] status
j3 4:ca27db159b10 336 * Detects the condition of the Start (bit3), N/A (bit2),
j3 4:ca27db159b10 337 * Address(bit1) and CRC16(bit0) bits.
j3 4:ca27db159b10 338 * b3;0=No Err|1=I2CStart prev-not issued,
j3 4:ca27db159b10 339 * b2;0=No Err|1=I2C N/A Err,
j3 4:ca27db159b10 340 * b1;0=No Err|1=Addr Err,
j3 4:ca27db159b10 341 * b0;0=Valid CRC16|1=Invalid CRC16
j3 4:ca27db159b10 342 *
j3 4:ca27db159b10 343 * @param[out] *read_data
j3 4:ca27db159b10 344 * Array of read data received from I2C.
j3 4:ca27db159b10 345 *
j3 4:ca27db159b10 346 * @return
j3 4:ca27db159b10 347 * true if device selected, written and read @n
j3 4:ca27db159b10 348 * false if failed device select or timeout occurred or CRC16 error
j3 4:ca27db159b10 349 **************************************************************/
j3 17:b646b1e3970b 350 CmdResult I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read,
j3 7:78a8857b3810 351 uint8_t &status, uint8_t *read_data);
j3 4:ca27db159b10 352
j3 4:ca27db159b10 353
j3 4:ca27db159b10 354 /**********************************************************//**
j3 4:ca27db159b10 355 * @brief Write to Configuration Register of DS28E17.
j3 4:ca27db159b10 356 *
j3 4:ca27db159b10 357 * @details
j3 4:ca27db159b10 358 *
j3 4:ca27db159b10 359 * On Entry:
j3 4:ca27db159b10 360 * @param[in] data
j3 4:ca27db159b10 361 * sent to configuration register
j3 4:ca27db159b10 362 *
j3 4:ca27db159b10 363 * On Exit:
j3 4:ca27db159b10 364 *
j3 4:ca27db159b10 365 * @return
j3 4:ca27db159b10 366 * true if device selected and written @n
j3 4:ca27db159b10 367 * false if failed device select
j3 4:ca27db159b10 368 **************************************************************/
j3 17:b646b1e3970b 369 CmdResult WriteConfigReg(uint8_t data);
j3 4:ca27db159b10 370
j3 4:ca27db159b10 371
j3 4:ca27db159b10 372 /**********************************************************//**
j3 4:ca27db159b10 373 * @brief Read the Configuration Register of DS28E17.
j3 4:ca27db159b10 374 *
j3 4:ca27db159b10 375 * @details
j3 4:ca27db159b10 376 *
j3 4:ca27db159b10 377 * On Entry:
j3 4:ca27db159b10 378 *
j3 4:ca27db159b10 379 * On Exit:
j3 4:ca27db159b10 380 *
j3 4:ca27db159b10 381 * @return
j3 7:78a8857b3810 382 * true if device selected and read correctly @n
j3 4:ca27db159b10 383 * false if failed device select
j3 4:ca27db159b10 384 **************************************************************/
j3 17:b646b1e3970b 385 CmdResult ReadConfigReg(uint8_t & config);
j3 4:ca27db159b10 386
j3 4:ca27db159b10 387
j3 4:ca27db159b10 388 /**********************************************************//**
j3 4:ca27db159b10 389 * @brief Disable 1-Wire Mode DS28E17 and activates the input detection pin.
j3 4:ca27db159b10 390 * Immediately after the command, all 1-Wire signaling will be ignored
j3 4:ca27db159b10 391 * until the 1W_DET pin is high for more than 3ms.
j3 4:ca27db159b10 392 *
j3 4:ca27db159b10 393 * @details
j3 4:ca27db159b10 394 *
j3 4:ca27db159b10 395 * On Entry:
j3 4:ca27db159b10 396 *
j3 4:ca27db159b10 397 * On Exit:
j3 4:ca27db159b10 398 *
j3 4:ca27db159b10 399 * @return
j3 4:ca27db159b10 400 * true if device selected and written @n
j3 4:ca27db159b10 401 * false if failed device select
j3 4:ca27db159b10 402 **************************************************************/
j3 17:b646b1e3970b 403 CmdResult DisableOWMode();
j3 4:ca27db159b10 404
j3 4:ca27db159b10 405
j3 4:ca27db159b10 406 /**********************************************************//**
j3 4:ca27db159b10 407 * @brief The Enable Sleep Mode command puts the device into a low current mode.
j3 4:ca27db159b10 408 * All 1-Wire communication is ignored until woken up. Immediately after
j3 4:ca27db159b10 409 * the command, the device monitors the WAKEUP input pin and
j3 4:ca27db159b10 410 * exits sleep mode on a rising edge.
j3 4:ca27db159b10 411 *
j3 4:ca27db159b10 412 * @details
j3 4:ca27db159b10 413 *
j3 4:ca27db159b10 414 * On Entry:
j3 4:ca27db159b10 415 *
j3 4:ca27db159b10 416 * On Exit:
j3 4:ca27db159b10 417 *
j3 4:ca27db159b10 418 * @return
j3 4:ca27db159b10 419 * true if device selected and written @n
j3 4:ca27db159b10 420 * false if failed device select*
j3 4:ca27db159b10 421 **************************************************************/
j3 17:b646b1e3970b 422 CmdResult EnableSleepMode();
j3 4:ca27db159b10 423
j3 4:ca27db159b10 424
j3 4:ca27db159b10 425 /**********************************************************//**
j3 4:ca27db159b10 426 * @brief Read the Device Revision of DS28E17. The revision value
j3 4:ca27db159b10 427 * should never be zero. The upper nibble is the major revision
j3 4:ca27db159b10 428 * and the lower nibble is the minor revision.
j3 4:ca27db159b10 429 *
j3 4:ca27db159b10 430 * @details
j3 4:ca27db159b10 431 *
j3 4:ca27db159b10 432 * On Entry:
j3 4:ca27db159b10 433 *
j3 4:ca27db159b10 434 * On Exit:
j3 4:ca27db159b10 435 *
j3 4:ca27db159b10 436 * @return
j3 4:ca27db159b10 437 * revision value if device selected and read correctly @n
j3 4:ca27db159b10 438 * false if failed device select (i.e. 00h)
j3 4:ca27db159b10 439 **************************************************************/
j3 17:b646b1e3970b 440 CmdResult ReadDeviceRevision(uint8_t & rev);
j3 4:ca27db159b10 441
j3 4:ca27db159b10 442 private:
j3 4:ca27db159b10 443
j3 17:b646b1e3970b 444 CmdResult send_packet(const uint8_t * data, uint8_t data_length,
j3 17:b646b1e3970b 445 uint8_t & status, uint8_t & wr_status);
j3 17:b646b1e3970b 446
j3 17:b646b1e3970b 447 //overloaded function for I2C read only command
j3 17:b646b1e3970b 448 CmdResult send_packet(const uint8_t * data, uint8_t data_length,
j3 17:b646b1e3970b 449 uint8_t & status);
j3 17:b646b1e3970b 450
j3 17:b646b1e3970b 451 OneWireInterface &_owm;
j3 17:b646b1e3970b 452 RomId _romId;
j3 7:78a8857b3810 453
j3 4:ca27db159b10 454 uint16_t _crc16;
j3 4:ca27db159b10 455 uint8_t _i2c_speed;
j3 4:ca27db159b10 456
j3 7:78a8857b3810 457 static const uint16_t _oddparity[16];
j3 4:ca27db159b10 458
j3 4:ca27db159b10 459 uint16_t docrc16(uint16_t data);
j3 4:ca27db159b10 460 };
j3 4:ca27db159b10 461
j3 17:b646b1e3970b 462 #endif /*DS28E17_H*/
j3 17:b646b1e3970b 463