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.
Masters/DS248x/DS248x.h@73:2cecc1372acc, 2016-05-12 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Thu May 12 14:38:16 2016 -0500
- Revision:
- 73:2cecc1372acc
- Parent:
- OneWire_Masters/DS248x/ds248x.h@72:6892702709ee
- Child:
- 74:23be10c32fa3
Added namespaces. Renamed files and directories for consistency. Use <stdint.h> instead of <cstdint> since it is not supported by C++98.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 1:91e52f8ab8bf | 1 | /******************************************************************//** |
j3 | 1:91e52f8ab8bf | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 1:91e52f8ab8bf | 3 | * |
j3 | 1:91e52f8ab8bf | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 1:91e52f8ab8bf | 5 | * copy of this software and associated documentation files (the "Software"), |
j3 | 1:91e52f8ab8bf | 6 | * to deal in the Software without restriction, including without limitation |
j3 | 1:91e52f8ab8bf | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 1:91e52f8ab8bf | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 1:91e52f8ab8bf | 9 | * Software is furnished to do so, subject to the following conditions: |
j3 | 1:91e52f8ab8bf | 10 | * |
j3 | 1:91e52f8ab8bf | 11 | * The above copyright notice and this permission notice shall be included |
j3 | 1:91e52f8ab8bf | 12 | * in all copies or substantial portions of the Software. |
j3 | 1:91e52f8ab8bf | 13 | * |
j3 | 1:91e52f8ab8bf | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 1:91e52f8ab8bf | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 1:91e52f8ab8bf | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 1:91e52f8ab8bf | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 1:91e52f8ab8bf | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 1:91e52f8ab8bf | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 1:91e52f8ab8bf | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 1:91e52f8ab8bf | 21 | * |
j3 | 1:91e52f8ab8bf | 22 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 1:91e52f8ab8bf | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 1:91e52f8ab8bf | 24 | * Products, Inc. Branding Policy. |
j3 | 1:91e52f8ab8bf | 25 | * |
j3 | 1:91e52f8ab8bf | 26 | * The mere transfer of this software does not imply any licenses |
j3 | 1:91e52f8ab8bf | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 1:91e52f8ab8bf | 28 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 1:91e52f8ab8bf | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 1:91e52f8ab8bf | 30 | * ownership rights. |
j3 | 1:91e52f8ab8bf | 31 | **********************************************************************/ |
j3 | 1:91e52f8ab8bf | 32 | |
IanBenzMaxim | 73:2cecc1372acc | 33 | #ifndef OneWire_Masters_DS248x |
IanBenzMaxim | 73:2cecc1372acc | 34 | #define OneWire_Masters_DS248x |
j3 | 1:91e52f8ab8bf | 35 | |
IanBenzMaxim | 73:2cecc1372acc | 36 | #include "Masters/OneWireMaster.h" |
IanBenzMaxim | 73:2cecc1372acc | 37 | #include "PinNames.h" |
j3 | 1:91e52f8ab8bf | 38 | |
IanBenzMaxim | 73:2cecc1372acc | 39 | namespace mbed { class I2C; } |
j3 | 1:91e52f8ab8bf | 40 | |
IanBenzMaxim | 73:2cecc1372acc | 41 | namespace OneWire |
j3 | 1:91e52f8ab8bf | 42 | { |
IanBenzMaxim | 73:2cecc1372acc | 43 | namespace Masters |
j3 | 5:ce108eeb878d | 44 | { |
IanBenzMaxim | 73:2cecc1372acc | 45 | class DS248x: public OneWireMaster |
IanBenzMaxim | 73:2cecc1372acc | 46 | { |
IanBenzMaxim | 73:2cecc1372acc | 47 | public: |
IanBenzMaxim | 73:2cecc1372acc | 48 | enum Register |
IanBenzMaxim | 73:2cecc1372acc | 49 | { |
IanBenzMaxim | 73:2cecc1372acc | 50 | ConfigReg = 0xC3, |
IanBenzMaxim | 73:2cecc1372acc | 51 | StatusReg = 0xF0, |
IanBenzMaxim | 73:2cecc1372acc | 52 | ReadDataReg = 0xE1, |
IanBenzMaxim | 73:2cecc1372acc | 53 | PortConfigReg = 0xB4, |
IanBenzMaxim | 73:2cecc1372acc | 54 | ChannelSelectReg = 0xD2 // DS2482-800 only |
IanBenzMaxim | 73:2cecc1372acc | 55 | }; |
IanBenzMaxim | 73:2cecc1372acc | 56 | |
IanBenzMaxim | 73:2cecc1372acc | 57 | // DS2484 only |
IanBenzMaxim | 73:2cecc1372acc | 58 | enum OwAdjustParam |
IanBenzMaxim | 73:2cecc1372acc | 59 | { |
IanBenzMaxim | 73:2cecc1372acc | 60 | tRSTL = 0, |
IanBenzMaxim | 73:2cecc1372acc | 61 | tRSTL_OD, |
IanBenzMaxim | 73:2cecc1372acc | 62 | tMSP, |
IanBenzMaxim | 73:2cecc1372acc | 63 | tMSP_OD, |
IanBenzMaxim | 73:2cecc1372acc | 64 | tW0L, |
IanBenzMaxim | 73:2cecc1372acc | 65 | tW0L_OD, |
IanBenzMaxim | 73:2cecc1372acc | 66 | tREC0, //OD NA |
IanBenzMaxim | 73:2cecc1372acc | 67 | RWPU = 8 //OD NA, see DS2484 datasheet page 13 |
IanBenzMaxim | 73:2cecc1372acc | 68 | }; |
IanBenzMaxim | 73:2cecc1372acc | 69 | |
IanBenzMaxim | 73:2cecc1372acc | 70 | /// Represents a DS2465 configuration. |
IanBenzMaxim | 73:2cecc1372acc | 71 | class Config |
IanBenzMaxim | 73:2cecc1372acc | 72 | { |
IanBenzMaxim | 73:2cecc1372acc | 73 | public: |
IanBenzMaxim | 73:2cecc1372acc | 74 | /// @{ |
IanBenzMaxim | 73:2cecc1372acc | 75 | /// 1-Wire Speed |
IanBenzMaxim | 73:2cecc1372acc | 76 | bool get1WS() const { return m_1WS; } |
IanBenzMaxim | 73:2cecc1372acc | 77 | void set1WS(bool new1WS) { m_1WS = new1WS; } |
IanBenzMaxim | 73:2cecc1372acc | 78 | /// @} |
j3 | 5:ce108eeb878d | 79 | |
IanBenzMaxim | 73:2cecc1372acc | 80 | /// @{ |
IanBenzMaxim | 73:2cecc1372acc | 81 | /// Strong Pullup |
IanBenzMaxim | 73:2cecc1372acc | 82 | bool getSPU() const { return m_SPU; } |
IanBenzMaxim | 73:2cecc1372acc | 83 | void setSPU(bool newSPU) { m_SPU = newSPU; } |
IanBenzMaxim | 73:2cecc1372acc | 84 | /// @} |
IanBenzMaxim | 69:f915c4c59a69 | 85 | |
IanBenzMaxim | 73:2cecc1372acc | 86 | /// @{ |
IanBenzMaxim | 73:2cecc1372acc | 87 | /// 1-Wire Power Down |
IanBenzMaxim | 73:2cecc1372acc | 88 | bool getPDN() const { return m_PDN; } |
IanBenzMaxim | 73:2cecc1372acc | 89 | void setPDN(bool newPDN) { m_PDN = newPDN; } |
IanBenzMaxim | 73:2cecc1372acc | 90 | /// @} |
IanBenzMaxim | 69:f915c4c59a69 | 91 | |
IanBenzMaxim | 73:2cecc1372acc | 92 | /// @{ |
IanBenzMaxim | 73:2cecc1372acc | 93 | /// Active Pullup |
IanBenzMaxim | 73:2cecc1372acc | 94 | bool getAPU() const { return m_APU; } |
IanBenzMaxim | 73:2cecc1372acc | 95 | void setAPU(bool newAPU) { m_APU = newAPU; } |
IanBenzMaxim | 73:2cecc1372acc | 96 | /// @} |
IanBenzMaxim | 69:f915c4c59a69 | 97 | |
IanBenzMaxim | 73:2cecc1372acc | 98 | /// Byte representation that is read from the DS2465. |
IanBenzMaxim | 73:2cecc1372acc | 99 | uint8_t readByte() const; |
IanBenzMaxim | 73:2cecc1372acc | 100 | /// Byte respresentation that is written to the DS2465. |
IanBenzMaxim | 73:2cecc1372acc | 101 | uint8_t writeByte() const; |
IanBenzMaxim | 69:f915c4c59a69 | 102 | |
IanBenzMaxim | 73:2cecc1372acc | 103 | /// Reset to the power-on default config. |
IanBenzMaxim | 73:2cecc1372acc | 104 | void reset(); |
IanBenzMaxim | 73:2cecc1372acc | 105 | Config() { reset(); } |
IanBenzMaxim | 69:f915c4c59a69 | 106 | |
IanBenzMaxim | 73:2cecc1372acc | 107 | private: |
IanBenzMaxim | 73:2cecc1372acc | 108 | bool m_1WS, m_SPU, m_PDN, m_APU; |
IanBenzMaxim | 73:2cecc1372acc | 109 | }; |
IanBenzMaxim | 73:2cecc1372acc | 110 | |
IanBenzMaxim | 73:2cecc1372acc | 111 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 112 | * @brief DS248x constructor |
IanBenzMaxim | 73:2cecc1372acc | 113 | * |
IanBenzMaxim | 73:2cecc1372acc | 114 | * @details allows user to use existing I2C object |
IanBenzMaxim | 73:2cecc1372acc | 115 | * |
IanBenzMaxim | 73:2cecc1372acc | 116 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 117 | * @param[in] p_i2c_bus - pointer to existing I2C object |
IanBenzMaxim | 73:2cecc1372acc | 118 | * |
IanBenzMaxim | 73:2cecc1372acc | 119 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 120 | * @return |
IanBenzMaxim | 73:2cecc1372acc | 121 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 122 | DS248x(mbed::I2C & i2c_bus, uint8_t adrs); |
IanBenzMaxim | 73:2cecc1372acc | 123 | |
IanBenzMaxim | 73:2cecc1372acc | 124 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 125 | * @brief DS248x constructor |
IanBenzMaxim | 73:2cecc1372acc | 126 | * |
IanBenzMaxim | 73:2cecc1372acc | 127 | * @details Object instantiates a new I2C object with no |
IanBenzMaxim | 73:2cecc1372acc | 128 | * public access |
IanBenzMaxim | 73:2cecc1372acc | 129 | * |
IanBenzMaxim | 73:2cecc1372acc | 130 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 131 | * @param[in] sda - sda pin of I2C bus |
IanBenzMaxim | 73:2cecc1372acc | 132 | * @param[in] scl - scl pin of I2C bus |
IanBenzMaxim | 73:2cecc1372acc | 133 | * |
IanBenzMaxim | 73:2cecc1372acc | 134 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 135 | * @return |
IanBenzMaxim | 73:2cecc1372acc | 136 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 137 | DS248x(PinName sda, PinName scl, uint8_t adrs); |
IanBenzMaxim | 73:2cecc1372acc | 138 | |
IanBenzMaxim | 73:2cecc1372acc | 139 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 140 | * @brief DS248x destructor |
IanBenzMaxim | 73:2cecc1372acc | 141 | * |
IanBenzMaxim | 73:2cecc1372acc | 142 | * @details deletes I2C object if owner |
IanBenzMaxim | 73:2cecc1372acc | 143 | * |
IanBenzMaxim | 73:2cecc1372acc | 144 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 145 | * |
IanBenzMaxim | 73:2cecc1372acc | 146 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 147 | * @return |
IanBenzMaxim | 73:2cecc1372acc | 148 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 149 | virtual ~DS248x(); |
IanBenzMaxim | 73:2cecc1372acc | 150 | |
IanBenzMaxim | 73:2cecc1372acc | 151 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 152 | * @brief reset() |
IanBenzMaxim | 73:2cecc1372acc | 153 | * |
IanBenzMaxim | 73:2cecc1372acc | 154 | * @details Perform a device reset on the DS248x |
IanBenzMaxim | 73:2cecc1372acc | 155 | * |
IanBenzMaxim | 73:2cecc1372acc | 156 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 157 | * |
IanBenzMaxim | 73:2cecc1372acc | 158 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 159 | * @return TRUE if device was reset |
IanBenzMaxim | 73:2cecc1372acc | 160 | * FALSE device not detected or failure to perform reset |
IanBenzMaxim | 73:2cecc1372acc | 161 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 162 | OneWireMaster::CmdResult reset(void); |
IanBenzMaxim | 73:2cecc1372acc | 163 | |
IanBenzMaxim | 73:2cecc1372acc | 164 | /// Write a new configuration to the DS2465. |
IanBenzMaxim | 73:2cecc1372acc | 165 | /// @param[in] config New configuration to write. |
IanBenzMaxim | 73:2cecc1372acc | 166 | /// @param verify Verify that the configuration was written successfully. |
IanBenzMaxim | 73:2cecc1372acc | 167 | OneWireMaster::CmdResult writeConfig(const Config & config, bool verify); |
IanBenzMaxim | 69:f915c4c59a69 | 168 | |
IanBenzMaxim | 73:2cecc1372acc | 169 | /// Read the current DS2465 configuration. |
IanBenzMaxim | 73:2cecc1372acc | 170 | /// @returns The cached current configuration. |
IanBenzMaxim | 73:2cecc1372acc | 171 | Config currentConfig() const { return m_curConfig; } |
IanBenzMaxim | 73:2cecc1372acc | 172 | |
IanBenzMaxim | 73:2cecc1372acc | 173 | |
IanBenzMaxim | 73:2cecc1372acc | 174 | OneWireMaster::CmdResult readRegister(Register reg, uint8_t & buf, bool skipSetPointer = false) const; |
IanBenzMaxim | 73:2cecc1372acc | 175 | |
IanBenzMaxim | 73:2cecc1372acc | 176 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 177 | * @brief channel_select() |
IanBenzMaxim | 73:2cecc1372acc | 178 | * |
IanBenzMaxim | 73:2cecc1372acc | 179 | * @details Select the 1-Wire channel on a DS2482-800. |
IanBenzMaxim | 73:2cecc1372acc | 180 | * Min channel = 1 |
IanBenzMaxim | 73:2cecc1372acc | 181 | * |
IanBenzMaxim | 73:2cecc1372acc | 182 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 183 | * @param[in] channel - desired channel of the DS2482 |
IanBenzMaxim | 73:2cecc1372acc | 184 | * |
IanBenzMaxim | 73:2cecc1372acc | 185 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 186 | * @return TRUE if channel selected |
IanBenzMaxim | 73:2cecc1372acc | 187 | * FALSE device not detected or failure to perform select |
IanBenzMaxim | 73:2cecc1372acc | 188 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 189 | OneWireMaster::CmdResult selectChannel(uint8_t channel); |
IanBenzMaxim | 73:2cecc1372acc | 190 | |
IanBenzMaxim | 73:2cecc1372acc | 191 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 192 | * @brief adjust_timing() |
IanBenzMaxim | 73:2cecc1372acc | 193 | * |
IanBenzMaxim | 73:2cecc1372acc | 194 | * @details adjustable timming available in DS2484 only |
IanBenzMaxim | 73:2cecc1372acc | 195 | * |
IanBenzMaxim | 73:2cecc1372acc | 196 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 197 | * @param[in] param - 1 of 8 adjustable parameters |
IanBenzMaxim | 73:2cecc1372acc | 198 | * @param[in] val - new value for parameter, see datasheet |
IanBenzMaxim | 73:2cecc1372acc | 199 | * for codes |
IanBenzMaxim | 73:2cecc1372acc | 200 | * |
IanBenzMaxim | 73:2cecc1372acc | 201 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 202 | * @return TRUE: parameter successfully adjusted |
IanBenzMaxim | 73:2cecc1372acc | 203 | * FALSE: failed to adjust parameter |
IanBenzMaxim | 73:2cecc1372acc | 204 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 205 | OneWireMaster::CmdResult adjustOwPort(OwAdjustParam param, uint8_t val); |
IanBenzMaxim | 73:2cecc1372acc | 206 | |
IanBenzMaxim | 73:2cecc1372acc | 207 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 208 | * @brief search_triplet() |
IanBenzMaxim | 73:2cecc1372acc | 209 | * |
IanBenzMaxim | 73:2cecc1372acc | 210 | * @details Use the DS248x help command '1-Wire triplet' to perform |
IanBenzMaxim | 73:2cecc1372acc | 211 | * one bit of a 1-Wire search. This command does two read |
IanBenzMaxim | 73:2cecc1372acc | 212 | * bits and one write bit. The write bit is either the |
IanBenzMaxim | 73:2cecc1372acc | 213 | * default direction (all device have same bit) or in case |
IanBenzMaxim | 73:2cecc1372acc | 214 | * of a discrepancy, the 'search_direction' parameter is |
IanBenzMaxim | 73:2cecc1372acc | 215 | * used. |
IanBenzMaxim | 73:2cecc1372acc | 216 | * |
IanBenzMaxim | 73:2cecc1372acc | 217 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 218 | * @param[in] search_direction |
IanBenzMaxim | 73:2cecc1372acc | 219 | * |
IanBenzMaxim | 73:2cecc1372acc | 220 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 221 | * @return The DS248x status byte result from the triplet command |
IanBenzMaxim | 73:2cecc1372acc | 222 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 223 | virtual OneWireMaster::CmdResult OWTriplet(SearchDirection & search_direction, uint8_t & sbr, uint8_t & tsb); |
IanBenzMaxim | 73:2cecc1372acc | 224 | |
IanBenzMaxim | 73:2cecc1372acc | 225 | //Part of OneWireMaster that should be implemented for each master |
IanBenzMaxim | 73:2cecc1372acc | 226 | //See OneWireMaster.h for documentation |
IanBenzMaxim | 73:2cecc1372acc | 227 | |
IanBenzMaxim | 73:2cecc1372acc | 228 | /**********************************************************//** |
IanBenzMaxim | 73:2cecc1372acc | 229 | * @brief |
IanBenzMaxim | 73:2cecc1372acc | 230 | * |
IanBenzMaxim | 73:2cecc1372acc | 231 | * @details Detect routine that performs a device reset |
IanBenzMaxim | 73:2cecc1372acc | 232 | * followed by writing the configuration byte to default |
IanBenzMaxim | 73:2cecc1372acc | 233 | * values: |
IanBenzMaxim | 73:2cecc1372acc | 234 | * 1-Wire speed (c1WS) = standard (0) |
IanBenzMaxim | 73:2cecc1372acc | 235 | * Strong pull-up (cSPU) = off (0) |
IanBenzMaxim | 73:2cecc1372acc | 236 | * Presence pulse masking (cPPM) = off (0) |
IanBenzMaxim | 73:2cecc1372acc | 237 | * Active pull-up (cAPU) = on (CONFIG_APU = 0x01) |
IanBenzMaxim | 73:2cecc1372acc | 238 | * |
IanBenzMaxim | 73:2cecc1372acc | 239 | * On Entry: |
IanBenzMaxim | 73:2cecc1372acc | 240 | * |
IanBenzMaxim | 73:2cecc1372acc | 241 | * On Exit: |
IanBenzMaxim | 73:2cecc1372acc | 242 | * @return TRUE if device was detected and written |
IanBenzMaxim | 73:2cecc1372acc | 243 | * FALSE device not detected or failure to write |
IanBenzMaxim | 73:2cecc1372acc | 244 | * configuration byte |
IanBenzMaxim | 73:2cecc1372acc | 245 | **************************************************************/ |
IanBenzMaxim | 73:2cecc1372acc | 246 | virtual OneWireMaster::CmdResult OWInitMaster(void); |
IanBenzMaxim | 73:2cecc1372acc | 247 | |
IanBenzMaxim | 73:2cecc1372acc | 248 | virtual OneWireMaster::CmdResult OWReset(void); |
IanBenzMaxim | 73:2cecc1372acc | 249 | |
IanBenzMaxim | 73:2cecc1372acc | 250 | virtual OneWireMaster::CmdResult OWTouchBitSetLevel(uint8_t & sendrecvbit, OWLevel after_level); |
IanBenzMaxim | 73:2cecc1372acc | 251 | |
IanBenzMaxim | 73:2cecc1372acc | 252 | virtual OneWireMaster::CmdResult OWReadByteSetLevel(uint8_t & recvbyte, OWLevel after_level); |
IanBenzMaxim | 73:2cecc1372acc | 253 | |
IanBenzMaxim | 73:2cecc1372acc | 254 | virtual OneWireMaster::CmdResult OWWriteByteSetLevel(uint8_t sendbyte, OWLevel after_level); |
j3 | 3:644fc630f958 | 255 | |
IanBenzMaxim | 73:2cecc1372acc | 256 | virtual OneWireMaster::CmdResult OWSetSpeed(OWSpeed new_speed); |
IanBenzMaxim | 69:f915c4c59a69 | 257 | |
IanBenzMaxim | 73:2cecc1372acc | 258 | virtual OneWireMaster::CmdResult OWSetLevel(OWLevel new_level); |
IanBenzMaxim | 73:2cecc1372acc | 259 | |
IanBenzMaxim | 73:2cecc1372acc | 260 | private: |
IanBenzMaxim | 73:2cecc1372acc | 261 | enum DS248X_CMDS |
IanBenzMaxim | 73:2cecc1372acc | 262 | { |
IanBenzMaxim | 73:2cecc1372acc | 263 | CMD_DRST = 0xF0, |
IanBenzMaxim | 73:2cecc1372acc | 264 | CMD_WCFG = 0xD2, |
IanBenzMaxim | 73:2cecc1372acc | 265 | CMD_A1WP = 0xC3, // DS2484 only |
IanBenzMaxim | 73:2cecc1372acc | 266 | CMD_CHSL = 0xC3, // DS2482-800 only |
IanBenzMaxim | 73:2cecc1372acc | 267 | CMD_SRP = 0xE1, |
IanBenzMaxim | 73:2cecc1372acc | 268 | CMD_1WRS = 0xB4, |
IanBenzMaxim | 73:2cecc1372acc | 269 | CMD_1WWB = 0xA5, |
IanBenzMaxim | 73:2cecc1372acc | 270 | CMD_1WRB = 0x96, |
IanBenzMaxim | 73:2cecc1372acc | 271 | CMD_1WSB = 0x87, |
IanBenzMaxim | 73:2cecc1372acc | 272 | CMD_1WT = 0x78 |
IanBenzMaxim | 73:2cecc1372acc | 273 | }; |
IanBenzMaxim | 73:2cecc1372acc | 274 | |
IanBenzMaxim | 73:2cecc1372acc | 275 | mbed::I2C *_p_i2c_bus; |
IanBenzMaxim | 73:2cecc1372acc | 276 | uint8_t _adrs; |
IanBenzMaxim | 73:2cecc1372acc | 277 | bool _i2c_owner; |
IanBenzMaxim | 73:2cecc1372acc | 278 | |
IanBenzMaxim | 73:2cecc1372acc | 279 | Config m_curConfig; |
IanBenzMaxim | 69:f915c4c59a69 | 280 | |
IanBenzMaxim | 73:2cecc1372acc | 281 | /// Polls the DS2465 status waiting for the 1-Wire Busy bit (1WB) to be cleared. |
IanBenzMaxim | 73:2cecc1372acc | 282 | /// @param[out] pStatus Optionally retrive the status byte when 1WB cleared. |
IanBenzMaxim | 73:2cecc1372acc | 283 | /// @returns Success or TimeoutError if poll limit reached. |
IanBenzMaxim | 73:2cecc1372acc | 284 | OneWireMaster::CmdResult pollBusy(uint8_t * pStatus = NULL); |
IanBenzMaxim | 73:2cecc1372acc | 285 | |
IanBenzMaxim | 73:2cecc1372acc | 286 | /// Ensure that the desired 1-Wire level is set in the configuration. |
IanBenzMaxim | 73:2cecc1372acc | 287 | /// @param level Desired 1-Wire level. |
IanBenzMaxim | 73:2cecc1372acc | 288 | OneWireMaster::CmdResult configureLevel(OWLevel level); |
IanBenzMaxim | 69:f915c4c59a69 | 289 | |
IanBenzMaxim | 73:2cecc1372acc | 290 | /// @note Allow marking const since not public. |
IanBenzMaxim | 73:2cecc1372acc | 291 | OneWireMaster::CmdResult sendCommand(DS248X_CMDS cmd) const; |
IanBenzMaxim | 73:2cecc1372acc | 292 | |
IanBenzMaxim | 73:2cecc1372acc | 293 | /// @note Allow marking const since not public. |
IanBenzMaxim | 73:2cecc1372acc | 294 | OneWireMaster::CmdResult sendCommand(DS248X_CMDS cmd, uint8_t param) const; |
IanBenzMaxim | 73:2cecc1372acc | 295 | }; |
IanBenzMaxim | 73:2cecc1372acc | 296 | } |
IanBenzMaxim | 73:2cecc1372acc | 297 | } |
j3 | 1:91e52f8ab8bf | 298 | |
IanBenzMaxim | 69:f915c4c59a69 | 299 | #endif /*DS248X_H*/ |