1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.
Dependents: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
Superseded by MaximInterface.
Slaves/Bridges/DS28E17/DS28E17.h@107:4697f641eafb, 2016-08-03 (annotated)
- Committer:
- j3
- Date:
- Wed Aug 03 22:23:47 2016 +0000
- Revision:
- 107:4697f641eafb
- Parent:
- 105:e6ba25711c05
- Child:
- 108:01aa7b13a5f9
Updated DS28E17 mbr fxs to follow naming convention
Who changed what in which revision?
User | Revision | Line number | New 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> |
j3 | 104:3f48daed532b | 38 | #include "Slaves/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 | * |
IanBenzMaxim | 76:84e6c4994e29 | 83 | * On Entry: |
j3 | 95:5ebdf5d955f4 | 84 | * @param[in] selector - RandomAccessRomIterator object that |
j3 | 95:5ebdf5d955f4 | 85 | * encapsulates master associated with this device and rom control |
j3 | 95:5ebdf5d955f4 | 86 | * commands |
IanBenzMaxim | 76:84e6c4994e29 | 87 | **************************************************************/ |
IanBenzMaxim | 77:529edb329ee0 | 88 | DS28E17(RandomAccessRomIterator &selector); |
IanBenzMaxim | 74:23be10c32fa3 | 89 | |
IanBenzMaxim | 76:84e6c4994e29 | 90 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 91 | * @brief Write to selected DS28E17's I2C with Stop. |
IanBenzMaxim | 76:84e6c4994e29 | 92 | * Poll until I2C write complete and receive status info. |
IanBenzMaxim | 76:84e6c4994e29 | 93 | * |
IanBenzMaxim | 76:84e6c4994e29 | 94 | * @details Output on I2C: S, Address + Write, Write Data [1-255], P |
IanBenzMaxim | 76:84e6c4994e29 | 95 | * |
IanBenzMaxim | 76:84e6c4994e29 | 96 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 97 | * @param[in] I2C_addr - |
IanBenzMaxim | 76:84e6c4994e29 | 98 | * Writes I2C address. The least significant bit of the I2C |
IanBenzMaxim | 76:84e6c4994e29 | 99 | * address is automatically cleared by the command. |
IanBenzMaxim | 76:84e6c4994e29 | 100 | * |
IanBenzMaxim | 76:84e6c4994e29 | 101 | * @param[in] length |
IanBenzMaxim | 76:84e6c4994e29 | 102 | * The number of data bytes to be written ranging from 01h to FFh. |
IanBenzMaxim | 76:84e6c4994e29 | 103 | * A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 104 | * |
IanBenzMaxim | 76:84e6c4994e29 | 105 | * @param[in] *data |
IanBenzMaxim | 76:84e6c4994e29 | 106 | * User defines write data ranging from 1-255 bytes. |
IanBenzMaxim | 76:84e6c4994e29 | 107 | * |
IanBenzMaxim | 76:84e6c4994e29 | 108 | * On Exit: |
IanBenzMaxim | 76:84e6c4994e29 | 109 | * @param[out] status |
IanBenzMaxim | 76:84e6c4994e29 | 110 | * Detects the condition of the Start (bit3), N/A (bit2), |
IanBenzMaxim | 76:84e6c4994e29 | 111 | * Address(bit1) and CRC16(bit0) bits. |
IanBenzMaxim | 76:84e6c4994e29 | 112 | * b3;0=No Err|1=I2CStart prev-not issued, |
IanBenzMaxim | 76:84e6c4994e29 | 113 | * b2;0=No Err|1=I2C N/A Err, |
IanBenzMaxim | 76:84e6c4994e29 | 114 | * b1;0=No Err|1=Addr Err, |
IanBenzMaxim | 76:84e6c4994e29 | 115 | * b0;0=Valid CRC16|1=Invalid CRC16 |
IanBenzMaxim | 76:84e6c4994e29 | 116 | * |
IanBenzMaxim | 76:84e6c4994e29 | 117 | * @param[out] wr_status |
IanBenzMaxim | 76:84e6c4994e29 | 118 | * Indicates which write byte NACK’d. A value of 00h indicates |
IanBenzMaxim | 76:84e6c4994e29 | 119 | * all bytes were acknowledged by the slave. |
IanBenzMaxim | 76:84e6c4994e29 | 120 | * A non-zero value indicates the byte number that NACK’d. |
IanBenzMaxim | 76:84e6c4994e29 | 121 | * |
j3 | 95:5ebdf5d955f4 | 122 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 123 | **************************************************************/ |
j3 | 107:4697f641eafb | 124 | CmdResult i2cWriteDataWithStop(uint8_t I2C_addr, uint8_t length, |
IanBenzMaxim | 76:84e6c4994e29 | 125 | uint8_t *data, uint8_t &status, |
IanBenzMaxim | 76:84e6c4994e29 | 126 | uint8_t &wr_status); |
IanBenzMaxim | 74:23be10c32fa3 | 127 | |
IanBenzMaxim | 76:84e6c4994e29 | 128 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 129 | * @brief Write to selected DS28E17's I2C No Stop. |
IanBenzMaxim | 76:84e6c4994e29 | 130 | * Poll until I2C write complete and receive status info. |
IanBenzMaxim | 76:84e6c4994e29 | 131 | * |
IanBenzMaxim | 76:84e6c4994e29 | 132 | * @details Output on I2C: S, Address + Write, Write Data [1-255] |
IanBenzMaxim | 76:84e6c4994e29 | 133 | * |
IanBenzMaxim | 76:84e6c4994e29 | 134 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 135 | * @param[in] I2C_addr |
IanBenzMaxim | 76:84e6c4994e29 | 136 | * Writes I2C address. The least significant bit of the I2C address |
IanBenzMaxim | 76:84e6c4994e29 | 137 | * is automatically cleared by the command. |
IanBenzMaxim | 76:84e6c4994e29 | 138 | * |
IanBenzMaxim | 76:84e6c4994e29 | 139 | * @param[in] length |
IanBenzMaxim | 76:84e6c4994e29 | 140 | * The number of data bytes to be written ranging from 01h to FFh. |
IanBenzMaxim | 76:84e6c4994e29 | 141 | * A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 142 | * |
IanBenzMaxim | 76:84e6c4994e29 | 143 | * @param[in] *data |
IanBenzMaxim | 76:84e6c4994e29 | 144 | * User defines write data ranging from 1-255 bytes. |
IanBenzMaxim | 76:84e6c4994e29 | 145 | * |
IanBenzMaxim | 76:84e6c4994e29 | 146 | * On Exit: |
IanBenzMaxim | 76:84e6c4994e29 | 147 | * @param[out] status |
IanBenzMaxim | 76:84e6c4994e29 | 148 | * Detects the condition of the Start (bit3), N/A (bit2), |
IanBenzMaxim | 76:84e6c4994e29 | 149 | * Address(bit1) and CRC16(bit0) bits. |
IanBenzMaxim | 76:84e6c4994e29 | 150 | * b3;0=No Err|1=I2CStart prev-not issued, |
IanBenzMaxim | 76:84e6c4994e29 | 151 | * b2;0=No Err|1=I2C N/A Err, |
IanBenzMaxim | 76:84e6c4994e29 | 152 | * b1;0=No Err|1=Addr Err, |
IanBenzMaxim | 76:84e6c4994e29 | 153 | * b0;0=Valid CRC16|1=Invalid CRC16 |
IanBenzMaxim | 76:84e6c4994e29 | 154 | * |
IanBenzMaxim | 76:84e6c4994e29 | 155 | * @param[out] wr_status |
IanBenzMaxim | 76:84e6c4994e29 | 156 | * Indicates which write byte NACK’d. A value of 00h indicates |
IanBenzMaxim | 76:84e6c4994e29 | 157 | * all bytes were acknowledged by the slave. |
IanBenzMaxim | 76:84e6c4994e29 | 158 | * A non-zero value indicates the byte number that NACK’d. |
IanBenzMaxim | 76:84e6c4994e29 | 159 | * |
j3 | 95:5ebdf5d955f4 | 160 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 161 | **************************************************************/ |
j3 | 107:4697f641eafb | 162 | CmdResult i2cWriteDataNoStop(uint8_t I2C_addr, uint8_t length, |
IanBenzMaxim | 76:84e6c4994e29 | 163 | uint8_t *data, uint8_t &status, |
IanBenzMaxim | 76:84e6c4994e29 | 164 | uint8_t &wr_status); |
IanBenzMaxim | 74:23be10c32fa3 | 165 | |
IanBenzMaxim | 74:23be10c32fa3 | 166 | |
IanBenzMaxim | 76:84e6c4994e29 | 167 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 168 | * @brief Write to selected DS28E17's I2C with Data only. |
IanBenzMaxim | 76:84e6c4994e29 | 169 | * Poll until I2C write complete and receive status info. |
IanBenzMaxim | 76:84e6c4994e29 | 170 | * |
IanBenzMaxim | 76:84e6c4994e29 | 171 | * @details Output on I2C: Write Data [1-255] |
IanBenzMaxim | 76:84e6c4994e29 | 172 | * |
IanBenzMaxim | 76:84e6c4994e29 | 173 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 174 | * @param[in] length |
IanBenzMaxim | 76:84e6c4994e29 | 175 | * The number of data bytes to be written ranging from 01h to FFh. |
IanBenzMaxim | 76:84e6c4994e29 | 176 | * A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 177 | * |
IanBenzMaxim | 76:84e6c4994e29 | 178 | * @param[in] *data |
IanBenzMaxim | 76:84e6c4994e29 | 179 | * User defines write data ranging from 1-255 bytes. |
IanBenzMaxim | 76:84e6c4994e29 | 180 | * |
IanBenzMaxim | 76:84e6c4994e29 | 181 | * On Exit: |
IanBenzMaxim | 76:84e6c4994e29 | 182 | * @param[out] status |
IanBenzMaxim | 76:84e6c4994e29 | 183 | * Detects the condition of the Start (bit3), N/A (bit2), |
IanBenzMaxim | 76:84e6c4994e29 | 184 | * Address(bit1) and CRC16(bit0) bits. |
IanBenzMaxim | 76:84e6c4994e29 | 185 | * b3;0=No Err|1=I2CStart prev-not issued, |
IanBenzMaxim | 76:84e6c4994e29 | 186 | * b2;0=No Err|1=I2C N/A Err, |
IanBenzMaxim | 76:84e6c4994e29 | 187 | * b1;0=No Err|1=Addr Err, |
IanBenzMaxim | 76:84e6c4994e29 | 188 | * b0;0=Valid CRC16|1=Invalid CRC16 |
IanBenzMaxim | 76:84e6c4994e29 | 189 | * |
IanBenzMaxim | 76:84e6c4994e29 | 190 | * @param[out] wr_status |
IanBenzMaxim | 76:84e6c4994e29 | 191 | * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave. |
IanBenzMaxim | 76:84e6c4994e29 | 192 | * A non-zero value indicates the byte number that NACK’d. |
IanBenzMaxim | 76:84e6c4994e29 | 193 | * |
j3 | 95:5ebdf5d955f4 | 194 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 195 | **************************************************************/ |
j3 | 107:4697f641eafb | 196 | CmdResult i2cWriteDataOnly(uint8_t length, uint8_t *data, |
IanBenzMaxim | 76:84e6c4994e29 | 197 | uint8_t &status, uint8_t &wr_status); |
IanBenzMaxim | 74:23be10c32fa3 | 198 | |
IanBenzMaxim | 74:23be10c32fa3 | 199 | |
IanBenzMaxim | 76:84e6c4994e29 | 200 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 201 | * @brief Write to selected DS28E17's I2C with Stop. |
IanBenzMaxim | 76:84e6c4994e29 | 202 | * Poll until I2C write complete and receive status info. |
IanBenzMaxim | 76:84e6c4994e29 | 203 | * |
IanBenzMaxim | 76:84e6c4994e29 | 204 | * @details Output on I2C: Write Data [1-255], P |
IanBenzMaxim | 76:84e6c4994e29 | 205 | * |
IanBenzMaxim | 76:84e6c4994e29 | 206 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 207 | * @param[in] length |
IanBenzMaxim | 76:84e6c4994e29 | 208 | * The number of data bytes to be written ranging from 01h to FFh. |
IanBenzMaxim | 76:84e6c4994e29 | 209 | * A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 210 | * |
IanBenzMaxim | 76:84e6c4994e29 | 211 | * @param[in] *data |
IanBenzMaxim | 76:84e6c4994e29 | 212 | * User defines write data ranging from 1-255 bytes. |
IanBenzMaxim | 76:84e6c4994e29 | 213 | * |
IanBenzMaxim | 76:84e6c4994e29 | 214 | * On Exit: |
IanBenzMaxim | 76:84e6c4994e29 | 215 | * @param[out] status |
IanBenzMaxim | 76:84e6c4994e29 | 216 | * Detects the condition of the Start (bit3), N/A (bit2), |
IanBenzMaxim | 76:84e6c4994e29 | 217 | * Address(bit1) and CRC16(bit0) bits. |
IanBenzMaxim | 76:84e6c4994e29 | 218 | * b3;0=No Err|1=I2CStart prev-not issued, |
IanBenzMaxim | 76:84e6c4994e29 | 219 | * b2;0=No Err|1=I2C N/A Err, |
IanBenzMaxim | 76:84e6c4994e29 | 220 | * b1;0=No Err|1=Addr Err, |
IanBenzMaxim | 76:84e6c4994e29 | 221 | * b0;0=Valid CRC16|1=Invalid CRC16 |
IanBenzMaxim | 76:84e6c4994e29 | 222 | * |
IanBenzMaxim | 76:84e6c4994e29 | 223 | * @param[out] wr_status |
IanBenzMaxim | 76:84e6c4994e29 | 224 | * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave. |
IanBenzMaxim | 76:84e6c4994e29 | 225 | * A non-zero value indicates the byte number that NACK’d. |
IanBenzMaxim | 76:84e6c4994e29 | 226 | * |
j3 | 95:5ebdf5d955f4 | 227 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 228 | **************************************************************/ |
j3 | 107:4697f641eafb | 229 | CmdResult i2cWriteDataOnlyWithStop(uint8_t length, uint8_t *data, |
IanBenzMaxim | 76:84e6c4994e29 | 230 | uint8_t &status, uint8_t &wr_status); |
IanBenzMaxim | 74:23be10c32fa3 | 231 | |
IanBenzMaxim | 74:23be10c32fa3 | 232 | |
IanBenzMaxim | 76:84e6c4994e29 | 233 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 234 | * @brief Write to selected DS28E17's I2C with Stop and poll until I2C write complete |
IanBenzMaxim | 76:84e6c4994e29 | 235 | * receive status info, and read data with a stop at the end. |
IanBenzMaxim | 76:84e6c4994e29 | 236 | * |
IanBenzMaxim | 76:84e6c4994e29 | 237 | * @details Output on I2C: |
IanBenzMaxim | 76:84e6c4994e29 | 238 | * S, Slave Address + Write, Write Data [1-255], |
IanBenzMaxim | 76:84e6c4994e29 | 239 | * Sr, Address + Read, Read Data [1-255], P (NACK last read byte) |
IanBenzMaxim | 76:84e6c4994e29 | 240 | * |
IanBenzMaxim | 76:84e6c4994e29 | 241 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 242 | * @param[in] I2C_addr |
IanBenzMaxim | 76:84e6c4994e29 | 243 | * Writes I2C address. The least significant bit of the I2C address |
IanBenzMaxim | 76:84e6c4994e29 | 244 | * is automatically cleared by the command. |
IanBenzMaxim | 76:84e6c4994e29 | 245 | * |
IanBenzMaxim | 76:84e6c4994e29 | 246 | * @param[in] length |
IanBenzMaxim | 76:84e6c4994e29 | 247 | * The number of data bytes to be written ranging from 01h to FFh. |
IanBenzMaxim | 76:84e6c4994e29 | 248 | * A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 249 | * |
IanBenzMaxim | 76:84e6c4994e29 | 250 | * @param[in] *data |
IanBenzMaxim | 76:84e6c4994e29 | 251 | * User defines write data ranging from 1-255 bytes. |
IanBenzMaxim | 76:84e6c4994e29 | 252 | * |
IanBenzMaxim | 76:84e6c4994e29 | 253 | * @param[in] nu_bytes_read |
IanBenzMaxim | 76:84e6c4994e29 | 254 | * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 255 | * |
IanBenzMaxim | 76:84e6c4994e29 | 256 | * On Exit: |
IanBenzMaxim | 76:84e6c4994e29 | 257 | * @param[out] status |
IanBenzMaxim | 76:84e6c4994e29 | 258 | * Detects the condition of the Start (bit3), N/A (bit2), |
IanBenzMaxim | 76:84e6c4994e29 | 259 | * Address(bit1) and CRC16(bit0) bits. |
IanBenzMaxim | 76:84e6c4994e29 | 260 | * b3;0=No Err|1=I2CStart prev-not issued, |
IanBenzMaxim | 76:84e6c4994e29 | 261 | * b2;0=No Err|1=I2C N/A Err, |
IanBenzMaxim | 76:84e6c4994e29 | 262 | * b1;0=No Err|1=Addr Err, |
IanBenzMaxim | 76:84e6c4994e29 | 263 | * b0;0=Valid CRC16|1=Invalid CRC16 |
IanBenzMaxim | 76:84e6c4994e29 | 264 | * |
IanBenzMaxim | 76:84e6c4994e29 | 265 | * @param[out] wr_status |
IanBenzMaxim | 76:84e6c4994e29 | 266 | * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave. |
IanBenzMaxim | 76:84e6c4994e29 | 267 | * A non-zero value indicates the byte number that NACK’d. |
IanBenzMaxim | 76:84e6c4994e29 | 268 | * |
IanBenzMaxim | 76:84e6c4994e29 | 269 | * @param[out] *read_data |
IanBenzMaxim | 76:84e6c4994e29 | 270 | * Array of read data received from I2C. |
IanBenzMaxim | 76:84e6c4994e29 | 271 | * |
j3 | 95:5ebdf5d955f4 | 272 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 273 | **************************************************************/ |
j3 | 107:4697f641eafb | 274 | CmdResult i2cWriteReadDataWithStop(uint8_t I2C_addr, uint8_t length, |
IanBenzMaxim | 76:84e6c4994e29 | 275 | uint8_t *data, uint8_t nu_bytes_read, |
IanBenzMaxim | 76:84e6c4994e29 | 276 | uint8_t &status, uint8_t &wr_status, |
IanBenzMaxim | 76:84e6c4994e29 | 277 | uint8_t *read_data); |
IanBenzMaxim | 74:23be10c32fa3 | 278 | |
IanBenzMaxim | 74:23be10c32fa3 | 279 | |
IanBenzMaxim | 76:84e6c4994e29 | 280 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 281 | * @brief Selected DS28E17's and send I2C address and poll until |
IanBenzMaxim | 76:84e6c4994e29 | 282 | * I2C read address complete, receive status info, and read data |
IanBenzMaxim | 76:84e6c4994e29 | 283 | * with a stop at the end. |
IanBenzMaxim | 76:84e6c4994e29 | 284 | * |
IanBenzMaxim | 76:84e6c4994e29 | 285 | * @details Output on I2C: |
IanBenzMaxim | 76:84e6c4994e29 | 286 | * S, Slave Address + Read, Read Data [1-255], P (NACK last read byte) |
IanBenzMaxim | 76:84e6c4994e29 | 287 | * |
IanBenzMaxim | 76:84e6c4994e29 | 288 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 289 | * @param[in] I2C_addr |
IanBenzMaxim | 76:84e6c4994e29 | 290 | * Writes I2C address. The least significant bit of the I2C address |
IanBenzMaxim | 76:84e6c4994e29 | 291 | * is automatically cleared by the command. |
IanBenzMaxim | 76:84e6c4994e29 | 292 | * |
IanBenzMaxim | 76:84e6c4994e29 | 293 | * On Exit: |
IanBenzMaxim | 76:84e6c4994e29 | 294 | * @param[out] nu_bytes_read |
IanBenzMaxim | 76:84e6c4994e29 | 295 | * Number of I2C bytes to read. A value of zero will assert the Error Detected pin (ED). |
IanBenzMaxim | 76:84e6c4994e29 | 296 | * |
IanBenzMaxim | 76:84e6c4994e29 | 297 | * @param[out] status |
IanBenzMaxim | 76:84e6c4994e29 | 298 | * Detects the condition of the Start (bit3), N/A (bit2), |
IanBenzMaxim | 76:84e6c4994e29 | 299 | * Address(bit1) and CRC16(bit0) bits. |
IanBenzMaxim | 76:84e6c4994e29 | 300 | * b3;0=No Err|1=I2CStart prev-not issued, |
IanBenzMaxim | 76:84e6c4994e29 | 301 | * b2;0=No Err|1=I2C N/A Err, |
IanBenzMaxim | 76:84e6c4994e29 | 302 | * b1;0=No Err|1=Addr Err, |
IanBenzMaxim | 76:84e6c4994e29 | 303 | * b0;0=Valid CRC16|1=Invalid CRC16 |
IanBenzMaxim | 76:84e6c4994e29 | 304 | * |
IanBenzMaxim | 76:84e6c4994e29 | 305 | * @param[out] *read_data |
IanBenzMaxim | 76:84e6c4994e29 | 306 | * Array of read data received from I2C. |
IanBenzMaxim | 76:84e6c4994e29 | 307 | * |
j3 | 95:5ebdf5d955f4 | 308 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 309 | **************************************************************/ |
j3 | 107:4697f641eafb | 310 | CmdResult i2cReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read, |
IanBenzMaxim | 76:84e6c4994e29 | 311 | uint8_t &status, uint8_t *read_data); |
IanBenzMaxim | 74:23be10c32fa3 | 312 | |
IanBenzMaxim | 74:23be10c32fa3 | 313 | |
IanBenzMaxim | 76:84e6c4994e29 | 314 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 315 | * @brief Write to Configuration Register of DS28E17. |
IanBenzMaxim | 76:84e6c4994e29 | 316 | * |
IanBenzMaxim | 76:84e6c4994e29 | 317 | * @details |
IanBenzMaxim | 76:84e6c4994e29 | 318 | * |
IanBenzMaxim | 76:84e6c4994e29 | 319 | * On Entry: |
IanBenzMaxim | 76:84e6c4994e29 | 320 | * @param[in] data |
IanBenzMaxim | 76:84e6c4994e29 | 321 | * sent to configuration register |
IanBenzMaxim | 76:84e6c4994e29 | 322 | * |
j3 | 95:5ebdf5d955f4 | 323 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 324 | **************************************************************/ |
j3 | 107:4697f641eafb | 325 | CmdResult writeConfigReg(uint8_t data); |
IanBenzMaxim | 74:23be10c32fa3 | 326 | |
IanBenzMaxim | 74:23be10c32fa3 | 327 | |
IanBenzMaxim | 76:84e6c4994e29 | 328 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 329 | * @brief Read the Configuration Register of DS28E17. |
IanBenzMaxim | 76:84e6c4994e29 | 330 | * |
IanBenzMaxim | 76:84e6c4994e29 | 331 | * @details |
IanBenzMaxim | 76:84e6c4994e29 | 332 | * |
IanBenzMaxim | 76:84e6c4994e29 | 333 | * On Exit: |
j3 | 95:5ebdf5d955f4 | 334 | * @param[out] config - contents of configuration register |
IanBenzMaxim | 76:84e6c4994e29 | 335 | * |
j3 | 95:5ebdf5d955f4 | 336 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 337 | **************************************************************/ |
j3 | 107:4697f641eafb | 338 | CmdResult readConfigReg(uint8_t & config); |
IanBenzMaxim | 74:23be10c32fa3 | 339 | |
IanBenzMaxim | 74:23be10c32fa3 | 340 | |
IanBenzMaxim | 76:84e6c4994e29 | 341 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 342 | * @brief The Enable Sleep Mode command puts the device into a low current mode. |
IanBenzMaxim | 76:84e6c4994e29 | 343 | * All 1-Wire communication is ignored until woken up. Immediately after |
IanBenzMaxim | 76:84e6c4994e29 | 344 | * the command, the device monitors the WAKEUP input pin and |
IanBenzMaxim | 76:84e6c4994e29 | 345 | * exits sleep mode on a rising edge. |
IanBenzMaxim | 76:84e6c4994e29 | 346 | * |
j3 | 95:5ebdf5d955f4 | 347 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 348 | **************************************************************/ |
j3 | 107:4697f641eafb | 349 | CmdResult enableSleepMode(); |
IanBenzMaxim | 74:23be10c32fa3 | 350 | |
IanBenzMaxim | 74:23be10c32fa3 | 351 | |
IanBenzMaxim | 76:84e6c4994e29 | 352 | /**********************************************************//** |
IanBenzMaxim | 76:84e6c4994e29 | 353 | * @brief Read the Device Revision of DS28E17. The revision value |
IanBenzMaxim | 76:84e6c4994e29 | 354 | * should never be zero. The upper nibble is the major revision |
IanBenzMaxim | 76:84e6c4994e29 | 355 | * and the lower nibble is the minor revision. |
IanBenzMaxim | 76:84e6c4994e29 | 356 | * |
j3 | 95:5ebdf5d955f4 | 357 | * On Exit: |
j3 | 95:5ebdf5d955f4 | 358 | * @param[out] rev - device revision |
IanBenzMaxim | 76:84e6c4994e29 | 359 | * |
j3 | 95:5ebdf5d955f4 | 360 | * @return CmdResult - result of operation |
IanBenzMaxim | 76:84e6c4994e29 | 361 | **************************************************************/ |
j3 | 107:4697f641eafb | 362 | CmdResult readDeviceRevision(uint8_t & rev); |
IanBenzMaxim | 74:23be10c32fa3 | 363 | |
IanBenzMaxim | 76:84e6c4994e29 | 364 | private: |
IanBenzMaxim | 78:0cbbac7f2016 | 365 | static const size_t pollLimit = 10000; |
IanBenzMaxim | 74:23be10c32fa3 | 366 | |
j3 | 107:4697f641eafb | 367 | CmdResult sendPacket(const uint8_t * data, uint8_t data_length, |
IanBenzMaxim | 76:84e6c4994e29 | 368 | uint8_t & status, uint8_t & wr_status); |
IanBenzMaxim | 74:23be10c32fa3 | 369 | |
IanBenzMaxim | 76:84e6c4994e29 | 370 | //overloaded function for I2C read only command |
j3 | 107:4697f641eafb | 371 | CmdResult sendPacket(const uint8_t * data, uint8_t data_length, |
IanBenzMaxim | 76:84e6c4994e29 | 372 | uint8_t & status); |
IanBenzMaxim | 76:84e6c4994e29 | 373 | }; |
IanBenzMaxim | 73:2cecc1372acc | 374 | } |
j3 | 4:ca27db159b10 | 375 | |
IanBenzMaxim | 74:23be10c32fa3 | 376 | #endif |
j3 | 17:b646b1e3970b | 377 |