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