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.

Committer:
j3
Date:
Mon Mar 21 23:18:45 2016 +0000
Revision:
23:e8e403d61359
Parent:
21:00c94aeb533e
Child:
24:8942d8478d68
Merged OneWireInterface into OneWireMaster for clarity

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 5:ce108eeb878d 1 /******************************************************************//**
j3 5:ce108eeb878d 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 5:ce108eeb878d 3 *
j3 5:ce108eeb878d 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 5:ce108eeb878d 5 * copy of this software and associated documentation files (the "Software"),
j3 5:ce108eeb878d 6 * to deal in the Software without restriction, including without limitation
j3 5:ce108eeb878d 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 5:ce108eeb878d 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 5:ce108eeb878d 9 * Software is furnished to do so, subject to the following conditions:
j3 5:ce108eeb878d 10 *
j3 5:ce108eeb878d 11 * The above copyright notice and this permission notice shall be included
j3 5:ce108eeb878d 12 * in all copies or substantial portions of the Software.
j3 5:ce108eeb878d 13 *
j3 5:ce108eeb878d 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 5:ce108eeb878d 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 5:ce108eeb878d 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 5:ce108eeb878d 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 5:ce108eeb878d 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 5:ce108eeb878d 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 5:ce108eeb878d 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 5:ce108eeb878d 21 *
j3 5:ce108eeb878d 22 * Except as contained in this notice, the name of Maxim Integrated
j3 5:ce108eeb878d 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 5:ce108eeb878d 24 * Products, Inc. Branding Policy.
j3 5:ce108eeb878d 25 *
j3 5:ce108eeb878d 26 * The mere transfer of this software does not imply any licenses
j3 5:ce108eeb878d 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 5:ce108eeb878d 28 * trademarks, maskwork rights, or any other form of intellectual
j3 5:ce108eeb878d 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 5:ce108eeb878d 30 * ownership rights.
j3 5:ce108eeb878d 31 **********************************************************************/
j3 5:ce108eeb878d 32
j3 5:ce108eeb878d 33
j3 15:f6cb0d906fb6 34 #ifndef ONEWIREMASTER_H
j3 15:f6cb0d906fb6 35 #define ONEWIREMASTER_H
j3 5:ce108eeb878d 36
j3 5:ce108eeb878d 37
j3 5:ce108eeb878d 38 #include "mbed.h"
j3 23:e8e403d61359 39 #include "RomId.hpp"
j3 5:ce108eeb878d 40
j3 5:ce108eeb878d 41
j3 23:e8e403d61359 42 class OneWireMaster
j3 15:f6cb0d906fb6 43 {
j3 15:f6cb0d906fb6 44 public:
j3 15:f6cb0d906fb6 45
j3 23:e8e403d61359 46 enum OW_ROM_CMD
j3 23:e8e403d61359 47 {
j3 23:e8e403d61359 48 READ_ROM = 0x33,
j3 23:e8e403d61359 49 MATCH_ROM = 0x55,
j3 23:e8e403d61359 50 SEARCH_ROM = 0xF0,
j3 23:e8e403d61359 51 SKIP_ROM = 0xCC,
j3 23:e8e403d61359 52 RESUME = 0xA5,
j3 23:e8e403d61359 53 OVERDRIVE_SKIP = 0x3C,
j3 23:e8e403d61359 54 OVERDRIVE_MATCH = 0x69
j3 23:e8e403d61359 55 };
j3 23:e8e403d61359 56
j3 23:e8e403d61359 57 enum OW_SPEED
j3 23:e8e403d61359 58 {
j3 23:e8e403d61359 59 SPEED_STANDARD = 0x00,
j3 23:e8e403d61359 60 SPEED_OVERDRIVE = 0x01
j3 23:e8e403d61359 61 };
j3 23:e8e403d61359 62
j3 23:e8e403d61359 63 enum OW_LEVEL
j3 23:e8e403d61359 64 {
j3 23:e8e403d61359 65 LEVEL_NORMAL = 0x00,
j3 23:e8e403d61359 66 LEVEL_STRONG = 0x02
j3 23:e8e403d61359 67 };
j3 23:e8e403d61359 68
j3 23:e8e403d61359 69 enum CmdResult
j3 23:e8e403d61359 70 {
j3 23:e8e403d61359 71 Success,
j3 23:e8e403d61359 72 CommunicationWriteError,
j3 23:e8e403d61359 73 CommunicationReadError,
j3 23:e8e403d61359 74 TimeoutError,
j3 23:e8e403d61359 75 OperationFailure
j3 23:e8e403d61359 76 };
j3 23:e8e403d61359 77
j3 17:b646b1e3970b 78 static uint16_t calculateCRC16(uint16_t CRC16, uint16_t data);
j3 17:b646b1e3970b 79
IanBenzMaxim 21:00c94aeb533e 80 static uint16_t calculateCRC16(const uint8_t * data, size_t data_offset, size_t data_len, uint16_t crc = 0);
j3 17:b646b1e3970b 81
j3 23:e8e403d61359 82
j3 23:e8e403d61359 83 /**********************************************************//**
j3 23:e8e403d61359 84 * @brief OWInitMaster()
j3 23:e8e403d61359 85 *
j3 23:e8e403d61359 86 * @details Initiializes particular master being instaniated.
j3 23:e8e403d61359 87 * Added to interface to provide a common 'init' function between
j3 23:e8e403d61359 88 * all masters
j3 23:e8e403d61359 89 *
j3 23:e8e403d61359 90 * On Entry:
j3 23:e8e403d61359 91 *
j3 23:e8e403d61359 92 * On Exit:
j3 23:e8e403d61359 93 *
j3 23:e8e403d61359 94 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 95 **************************************************************/
j3 23:e8e403d61359 96 virtual CmdResult OWInitMaster(void) = 0;
j3 23:e8e403d61359 97
j3 23:e8e403d61359 98
j3 23:e8e403d61359 99 /**********************************************************//**
j3 23:e8e403d61359 100 * @brief OWReset()
j3 23:e8e403d61359 101 *
j3 23:e8e403d61359 102 * @details Reset all of the devices on the 1-Wire Net and return
j3 23:e8e403d61359 103 * the result.
j3 23:e8e403d61359 104 *
j3 23:e8e403d61359 105 * On Entry:
j3 23:e8e403d61359 106 *
j3 23:e8e403d61359 107 * On Exit:
j3 23:e8e403d61359 108 *
j3 23:e8e403d61359 109 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 110 **************************************************************/
j3 23:e8e403d61359 111 virtual CmdResult OWReset(void) = 0;
j3 23:e8e403d61359 112
j3 23:e8e403d61359 113
j3 23:e8e403d61359 114 /**********************************************************//**
j3 23:e8e403d61359 115 * @brief OWTouchBit()
j3 23:e8e403d61359 116 *
j3 23:e8e403d61359 117 * @details Send 1 bit of communication to the 1-Wire Net and return
j3 23:e8e403d61359 118 * the result 1 bit read from the 1-Wire Net. The
j3 23:e8e403d61359 119 * parameter 'sendbit' least significant bit is used and
j3 23:e8e403d61359 120 * the least significant bit of the result is the return
j3 23:e8e403d61359 121 * bit.
j3 23:e8e403d61359 122 *
j3 23:e8e403d61359 123 * On Entry:
j3 23:e8e403d61359 124 * @param[in] 'sendbit' - the least significant bit is the bit to send
j3 23:e8e403d61359 125 *
j3 23:e8e403d61359 126 * On Exit:
j3 23:e8e403d61359 127 *
j3 23:e8e403d61359 128 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 129 **************************************************************/
j3 23:e8e403d61359 130 virtual CmdResult OWTouchBit(uint8_t & sendrecvbit) = 0;
j3 23:e8e403d61359 131
j3 23:e8e403d61359 132
j3 23:e8e403d61359 133 /**********************************************************//**
j3 23:e8e403d61359 134 * @brief OWWRiteByte()
j3 23:e8e403d61359 135 *
j3 23:e8e403d61359 136 * @details Send 8 bits of communication to the 1-Wire Net and
j3 23:e8e403d61359 137 * verify that the 8 bits read from the 1-Wire Net is the
j3 23:e8e403d61359 138 * same (write operation).The parameter 'sendbyte' least
j3 23:e8e403d61359 139 * significant 8 bits are used.
j3 23:e8e403d61359 140 *
j3 23:e8e403d61359 141 * On Entry:
j3 23:e8e403d61359 142 * @param[in] 'sendbyte' - 8 bits to send (least significant byte)
j3 23:e8e403d61359 143 *
j3 23:e8e403d61359 144 * On Exit:
j3 23:e8e403d61359 145 *
j3 23:e8e403d61359 146 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 147 **************************************************************/
j3 23:e8e403d61359 148 virtual CmdResult OWWriteByte(uint8_t sendbyte) = 0;
j3 23:e8e403d61359 149
j3 23:e8e403d61359 150
j3 23:e8e403d61359 151 /**********************************************************//**
j3 23:e8e403d61359 152 * @brief OWReadByte()
j3 23:e8e403d61359 153 *
j3 23:e8e403d61359 154 * @details Send 8 bits of read communication to the 1-Wire Net
j3 23:e8e403d61359 155 * and return the result 8 bits read from the 1-Wire Net.
j3 23:e8e403d61359 156 *
j3 23:e8e403d61359 157 * On Entry:
j3 23:e8e403d61359 158 *
j3 23:e8e403d61359 159 * On Exit:
j3 23:e8e403d61359 160 *
j3 23:e8e403d61359 161 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 162 **************************************************************/
j3 23:e8e403d61359 163 virtual CmdResult OWReadByte(uint8_t & recvbyte) = 0;
j3 23:e8e403d61359 164
j3 23:e8e403d61359 165
j3 23:e8e403d61359 166 /**********************************************************//**
j3 23:e8e403d61359 167 * @brief OWWriteBlock()
j3 23:e8e403d61359 168 *
j3 23:e8e403d61359 169 * @details complements OWBlock, writes 'tran_len' bytes from
j3 23:e8e403d61359 170 * 'tran_buf' to 1-wire Net.
j3 23:e8e403d61359 171 *
j3 23:e8e403d61359 172 * On Entry:
j3 23:e8e403d61359 173 * @param[in] tran_buf - pointer to data to write
j3 23:e8e403d61359 174 * @param[in] tran_len - number of bytes to write
j3 23:e8e403d61359 175 *
j3 23:e8e403d61359 176 * On Exit:
j3 23:e8e403d61359 177 *
j3 23:e8e403d61359 178 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 179 **************************************************************/
j3 23:e8e403d61359 180 virtual CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len) = 0;
j3 23:e8e403d61359 181
j3 15:f6cb0d906fb6 182
j3 23:e8e403d61359 183 /**********************************************************//**
j3 23:e8e403d61359 184 * @brief OWReadBlock()
j3 23:e8e403d61359 185 *
j3 23:e8e403d61359 186 * @details complements OWBlock, reads 'recv_len' bytes from
j3 23:e8e403d61359 187 * 1-wire Net and puts them in 'recv_buf'.
j3 23:e8e403d61359 188 *
j3 23:e8e403d61359 189 * On Entry:
j3 23:e8e403d61359 190 * @param[in] recv_buf - pointer to receive buffer
j3 23:e8e403d61359 191 * @param[in] recv_len - number of bytes to read
j3 23:e8e403d61359 192 *
j3 23:e8e403d61359 193 * On Exit:
j3 23:e8e403d61359 194 *
j3 23:e8e403d61359 195 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 196 **************************************************************/
j3 23:e8e403d61359 197 virtual CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len) = 0;
j3 23:e8e403d61359 198
j3 23:e8e403d61359 199
j3 23:e8e403d61359 200 /**********************************************************//**
j3 23:e8e403d61359 201 * @brief OWSearch()
j3 23:e8e403d61359 202 *
j3 23:e8e403d61359 203 * @details The 'OWSearch' function does a general search. This
j3 23:e8e403d61359 204 * function continues from the previous search state. The
j3 23:e8e403d61359 205 * search state can be reset by using the 'OWFirst'
j3 23:e8e403d61359 206 * function. This function contains one parameter
j3 23:e8e403d61359 207 * 'alarm_only'. When 'alarm_only' is TRUE (1) the find
j3 23:e8e403d61359 208 * alarm command 0xEC is sent instead of the normal search
j3 23:e8e403d61359 209 * command 0xF0. Using the find alarm command 0xEC will
j3 23:e8e403d61359 210 * limit the search to only 1-Wire devices that are in an
j3 23:e8e403d61359 211 * 'alarm' state.
j3 23:e8e403d61359 212 *
j3 23:e8e403d61359 213 * On Entry:
j3 23:e8e403d61359 214 *
j3 23:e8e403d61359 215 * On Exit:
j3 23:e8e403d61359 216 *
j3 23:e8e403d61359 217 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 218 **************************************************************/
j3 23:e8e403d61359 219 virtual CmdResult OWSearch(RomId & romId) = 0;
j3 23:e8e403d61359 220
j3 23:e8e403d61359 221
j3 23:e8e403d61359 222 /**********************************************************//**
j3 23:e8e403d61359 223 * @brief OWSpeed()
j3 23:e8e403d61359 224 *
j3 23:e8e403d61359 225 * @details Set the 1-Wire Net communication speed.
j3 23:e8e403d61359 226 *
j3 23:e8e403d61359 227 * On Entry:
j3 23:e8e403d61359 228 * @param[in] 'new_speed' - new speed defined as
j3 23:e8e403d61359 229 * MODE_STANDARD 0x00
j3 23:e8e403d61359 230 * MODE_OVERDRIVE 0x01
j3 23:e8e403d61359 231 *
j3 23:e8e403d61359 232 * On Exit:
j3 23:e8e403d61359 233 *
j3 23:e8e403d61359 234 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 235 **************************************************************/
j3 23:e8e403d61359 236 virtual CmdResult OWSpeed(OW_SPEED new_speed) = 0;
j3 15:f6cb0d906fb6 237
j3 23:e8e403d61359 238 /**********************************************************//**
j3 23:e8e403d61359 239 * @brief OWLevel()
j3 23:e8e403d61359 240 *
j3 23:e8e403d61359 241 * @details Set the 1-Wire Net line level pull-up to normal. The
j3 23:e8e403d61359 242 * ds2484 does only allows enabling strong pull-up on a
j3 23:e8e403d61359 243 * bit or byte event. Consequently this function only
j3 23:e8e403d61359 244 * allows the MODE_STANDARD argument. To enable strong
j3 23:e8e403d61359 245 * pull-up use OWWriteBytePower or OWReadBitPower.
j3 23:e8e403d61359 246 *
j3 23:e8e403d61359 247 * On Entry:
j3 23:e8e403d61359 248 * @param[in] 'new_level' - new level defined as
j3 23:e8e403d61359 249 * MODE_STANDARD 0x00
j3 23:e8e403d61359 250 *
j3 23:e8e403d61359 251 * On Exit:
j3 23:e8e403d61359 252 *
j3 23:e8e403d61359 253 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 254 **************************************************************/
j3 23:e8e403d61359 255 virtual CmdResult OWLevel(OW_LEVEL new_level) = 0;
j3 23:e8e403d61359 256
j3 23:e8e403d61359 257
j3 23:e8e403d61359 258 /**********************************************************//**
j3 23:e8e403d61359 259 * @brief OWWriteBytePower()
j3 23:e8e403d61359 260 *
j3 23:e8e403d61359 261 * @details Send 8 bits of communication to the 1-Wire Net and
j3 23:e8e403d61359 262 * verify that the 8 bits read from the 1-Wire Net is the
j3 23:e8e403d61359 263 * same (write operation). The parameter 'sendbyte' least
j3 23:e8e403d61359 264 * significant 8 bits are used. After the 8 bits are sent
j3 23:e8e403d61359 265 * change the level of the 1-Wire net.
j3 23:e8e403d61359 266 *
j3 23:e8e403d61359 267 * On Entry:
j3 23:e8e403d61359 268 * @param[in] 'sendbyte' - 8 bits to send (least significant bit)
j3 23:e8e403d61359 269 *
j3 23:e8e403d61359 270 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 271 **************************************************************/
j3 23:e8e403d61359 272 virtual CmdResult OWWriteBytePower(uint8_t sendbyte) = 0;
j3 23:e8e403d61359 273
j3 23:e8e403d61359 274
j3 23:e8e403d61359 275 /**********************************************************//**
j3 23:e8e403d61359 276 * @brief OWReadBitPower()
j3 23:e8e403d61359 277 *
j3 23:e8e403d61359 278 * @details Send 1 bit of communication to the 1-Wire Net and verify
j3 23:e8e403d61359 279 * that the response matches the 'applyPowerResponse' bit
j3 23:e8e403d61359 280 * and apply power delivery to the 1-Wire net. Note that
j3 23:e8e403d61359 281 * some implementations may apply the power first and then
j3 23:e8e403d61359 282 * turn it off if the response is incorrect.
j3 23:e8e403d61359 283 *
j3 23:e8e403d61359 284 * On Entry:
j3 23:e8e403d61359 285 * @param[in] 'applyPowerResponse' - 1 bit response to check,
j3 23:e8e403d61359 286 * if correct
j3 23:e8e403d61359 287 * then start power delivery
j3 23:e8e403d61359 288 *
j3 23:e8e403d61359 289 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 290 **************************************************************/
j3 23:e8e403d61359 291 virtual CmdResult OWReadBitPower(uint8_t applyPowerResponse) = 0;
j3 23:e8e403d61359 292
j3 23:e8e403d61359 293
j3 23:e8e403d61359 294 virtual CmdResult OWReadBytePower(uint8_t & recvbyte) = 0;
j3 23:e8e403d61359 295 //{ return OperationFailure; }
j3 17:b646b1e3970b 296
j3 23:e8e403d61359 297
j3 23:e8e403d61359 298 //Part of OneWireInterface that should only be implemented once
j3 23:e8e403d61359 299
j3 23:e8e403d61359 300
j3 23:e8e403d61359 301 /**********************************************************//**
j3 23:e8e403d61359 302 * @brief OWWriteBit()
j3 23:e8e403d61359 303 *
j3 23:e8e403d61359 304 * @details Send 1 bit of communication to the 1-Wire Net.
j3 23:e8e403d61359 305 * The parameter 'sendbit' least significant bit is used.
j3 23:e8e403d61359 306 *
j3 23:e8e403d61359 307 * On Entry:
j3 23:e8e403d61359 308 * @param[in] 'sendbit' - 1 bit to send (least significant byte)
j3 23:e8e403d61359 309 *
j3 23:e8e403d61359 310 * On Exit:
j3 23:e8e403d61359 311 *
j3 23:e8e403d61359 312 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 313 **************************************************************/
j3 23:e8e403d61359 314 virtual CmdResult OWWriteBit(uint8_t sendbit);
j3 23:e8e403d61359 315
j3 23:e8e403d61359 316
j3 23:e8e403d61359 317 /**********************************************************//**
j3 23:e8e403d61359 318 * @brief OWReadBit()
j3 23:e8e403d61359 319 *
j3 23:e8e403d61359 320 * @details Reads 1 bit of communication from the 1-Wire Net and
j3 23:e8e403d61359 321 * returns the result
j3 23:e8e403d61359 322 *
j3 23:e8e403d61359 323 * On Entry:
j3 23:e8e403d61359 324 *
j3 23:e8e403d61359 325 * On Exit:
j3 23:e8e403d61359 326 *
j3 23:e8e403d61359 327 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 328 **************************************************************/
j3 23:e8e403d61359 329 virtual CmdResult OWReadBit(uint8_t & recvbit);
j3 23:e8e403d61359 330
j3 23:e8e403d61359 331
j3 23:e8e403d61359 332 /**********************************************************//**
j3 23:e8e403d61359 333 * @brief OWTouchByte()
j3 23:e8e403d61359 334 *
j3 23:e8e403d61359 335 * @details Send 8 bits of communication to the 1-Wire Net and
j3 23:e8e403d61359 336 * return the result 8 bits read from the 1-Wire Net. The
j3 23:e8e403d61359 337 * parameter 'sendbyte' least significant 8 bits are used
j3 23:e8e403d61359 338 * and the least significant 8 bits of the result is the
j3 23:e8e403d61359 339 * return byte.
j3 23:e8e403d61359 340 *
j3 23:e8e403d61359 341 * On Entry:
j3 23:e8e403d61359 342 * @param[in] 'sendbyte' - 8 bits to send (least significant byte)
j3 23:e8e403d61359 343 *
j3 23:e8e403d61359 344 * On Exit:
j3 23:e8e403d61359 345 *
j3 23:e8e403d61359 346 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 347 **************************************************************/
j3 23:e8e403d61359 348 virtual CmdResult OWTouchByte(uint8_t & sendrecvbyte);
j3 23:e8e403d61359 349
j3 23:e8e403d61359 350
j3 23:e8e403d61359 351 /**********************************************************//**
j3 23:e8e403d61359 352 * @brief OWBlock()
j3 23:e8e403d61359 353 *
j3 23:e8e403d61359 354 * @details The 'OWBlock' transfers a block of data to and from the
j3 23:e8e403d61359 355 * 1-Wire Net. The result is returned in the same buffer.
j3 23:e8e403d61359 356 *
j3 23:e8e403d61359 357 * On Entry:
j3 23:e8e403d61359 358 * @param[in] 'tran_buf' - pointer to a block of unsigned
j3 23:e8e403d61359 359 * chars of length 'tran_len' that
j3 23:e8e403d61359 360 * will be sent to the 1-Wire Net
j3 23:e8e403d61359 361 * @param[in] 'tran_len' - length in bytes to transfer
j3 23:e8e403d61359 362 *
j3 23:e8e403d61359 363 * On Exit:
j3 23:e8e403d61359 364 *
j3 23:e8e403d61359 365 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 366 **************************************************************/
j3 23:e8e403d61359 367 virtual CmdResult OWBlock(uint8_t *tran_buf, uint8_t tran_len);
j3 23:e8e403d61359 368
j3 23:e8e403d61359 369
j3 23:e8e403d61359 370 /**********************************************************//**
j3 23:e8e403d61359 371 * @brief OWFirst()
j3 23:e8e403d61359 372 *
j3 23:e8e403d61359 373 * @details Find the 'first' devices on the 1-Wire network
j3 23:e8e403d61359 374 *
j3 23:e8e403d61359 375 * On Entry:
j3 23:e8e403d61359 376 *
j3 23:e8e403d61359 377 * On Exit:
j3 23:e8e403d61359 378 *
j3 23:e8e403d61359 379 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 380 **************************************************************/
j3 23:e8e403d61359 381 virtual CmdResult OWFirst(RomId & romId);
j3 23:e8e403d61359 382
j3 23:e8e403d61359 383
j3 23:e8e403d61359 384 /**********************************************************//**
j3 23:e8e403d61359 385 * @brief OWNext()
j3 23:e8e403d61359 386 *
j3 23:e8e403d61359 387 * @details Find the 'next' devices on the 1-Wire network
j3 23:e8e403d61359 388 *
j3 23:e8e403d61359 389 * On Entry:
j3 23:e8e403d61359 390 *
j3 23:e8e403d61359 391 * On Exit:
j3 23:e8e403d61359 392 *
j3 23:e8e403d61359 393 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 394 **************************************************************/
j3 23:e8e403d61359 395 virtual CmdResult OWNext(RomId & romId);
j3 23:e8e403d61359 396
j3 23:e8e403d61359 397
j3 23:e8e403d61359 398 /**********************************************************//**
j3 23:e8e403d61359 399 * @brief OWVerify()
j3 23:e8e403d61359 400 *
j3 23:e8e403d61359 401 * @details Verify the device with the ROM number in ROM_NO buffer
j3 23:e8e403d61359 402 * is present.
j3 23:e8e403d61359 403 *
j3 23:e8e403d61359 404 * On Entry:
j3 23:e8e403d61359 405 *
j3 23:e8e403d61359 406 * On Exit:
j3 23:e8e403d61359 407 *
j3 23:e8e403d61359 408 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 409 **************************************************************/
j3 23:e8e403d61359 410 virtual CmdResult OWVerify(const RomId & romId);
j3 23:e8e403d61359 411
j3 23:e8e403d61359 412
j3 23:e8e403d61359 413 /**********************************************************//**
j3 23:e8e403d61359 414 * @brief OWTargetSetup()
j3 23:e8e403d61359 415 *
j3 23:e8e403d61359 416 * @details Setup the search to find the device type 'family_code'
j3 23:e8e403d61359 417 * on the next call to OWNext() if it is present.
j3 23:e8e403d61359 418 *
j3 23:e8e403d61359 419 * On Entry:
j3 23:e8e403d61359 420 * @param[in] family_code - family code of device
j3 23:e8e403d61359 421 *
j3 23:e8e403d61359 422 * On Exit:
j3 23:e8e403d61359 423 *
j3 23:e8e403d61359 424 * @return
j3 23:e8e403d61359 425 **************************************************************/
j3 17:b646b1e3970b 426 virtual void OWTargetSetup(RomId & romId);
j3 23:e8e403d61359 427
j3 23:e8e403d61359 428
j3 23:e8e403d61359 429 /**********************************************************//**
j3 23:e8e403d61359 430 * @brief OWFamilySkipSetup()
j3 23:e8e403d61359 431 *
j3 23:e8e403d61359 432 * @details Setup the search to skip the current device type on the
j3 23:e8e403d61359 433 * next call to OWNext().
j3 23:e8e403d61359 434 *
j3 23:e8e403d61359 435 * On Entry:
j3 23:e8e403d61359 436 *
j3 23:e8e403d61359 437 * On Exit:
j3 23:e8e403d61359 438 *
j3 23:e8e403d61359 439 * @return
j3 23:e8e403d61359 440 **************************************************************/
j3 15:f6cb0d906fb6 441 virtual void OWFamilySkipSetup(void);
j3 15:f6cb0d906fb6 442
j3 23:e8e403d61359 443
j3 23:e8e403d61359 444 /**********************************************************//**
j3 23:e8e403d61359 445 * @brief OWReadROM()
j3 23:e8e403d61359 446 *
j3 23:e8e403d61359 447 * @details Only use this command with a single drop bus, data
j3 23:e8e403d61359 448 * collisions will occur if more than 1 device on bus.
j3 23:e8e403d61359 449 * Issues READ_ROM command, slave device will respond with ROM ID.
j3 23:e8e403d61359 450 *
j3 23:e8e403d61359 451 * On Entry:
j3 23:e8e403d61359 452 *
j3 23:e8e403d61359 453 * On Exit:
j3 23:e8e403d61359 454 *
j3 23:e8e403d61359 455 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 456 **************************************************************/
j3 23:e8e403d61359 457 virtual CmdResult OWReadROM(RomId & romId);
j3 23:e8e403d61359 458
j3 15:f6cb0d906fb6 459
j3 23:e8e403d61359 460 /**********************************************************//**
j3 23:e8e403d61359 461 * @brief OWSkipROM()
j3 23:e8e403d61359 462 *
j3 23:e8e403d61359 463 * @details Issue SKIP_ROM command on 1-wire bus
j3 23:e8e403d61359 464 *
j3 23:e8e403d61359 465 * On Entry:
j3 23:e8e403d61359 466 *
j3 23:e8e403d61359 467 * On Exit:
j3 23:e8e403d61359 468 *
j3 23:e8e403d61359 469 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 470 **************************************************************/
j3 23:e8e403d61359 471 virtual CmdResult OWSkipROM(void);
j3 23:e8e403d61359 472
j3 15:f6cb0d906fb6 473
j3 23:e8e403d61359 474 /**********************************************************//**
j3 23:e8e403d61359 475 * @brief OWMatchROM()
j3 23:e8e403d61359 476 *
j3 23:e8e403d61359 477 * @details Issues MATCH_ROM command on 1-wire bus and then sends
j3 23:e8e403d61359 478 * the rom id in _rom_number
j3 23:e8e403d61359 479 *
j3 23:e8e403d61359 480 * On Entry:
j3 23:e8e403d61359 481 *
j3 23:e8e403d61359 482 * On Exit:
j3 23:e8e403d61359 483 *
j3 23:e8e403d61359 484 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 485 **************************************************************/
j3 23:e8e403d61359 486 virtual CmdResult OWMatchROM(const RomId & romId);
j3 23:e8e403d61359 487
j3 15:f6cb0d906fb6 488
j3 23:e8e403d61359 489 /**********************************************************//**
j3 23:e8e403d61359 490 * @brief OWOverdriveSkipROM()
j3 23:e8e403d61359 491 *
j3 23:e8e403d61359 492 * @details Issues OVERDRIVE_SKIP rom command. DS248X OW speed
j3 23:e8e403d61359 493 * is set to SPEED_OVERDRIVE
j3 23:e8e403d61359 494 *
j3 23:e8e403d61359 495 * On Entry:
j3 23:e8e403d61359 496 *
j3 23:e8e403d61359 497 * On Exit:
j3 23:e8e403d61359 498 *
j3 23:e8e403d61359 499 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 500 **************************************************************/
j3 23:e8e403d61359 501 virtual CmdResult OWOverdriveSkipROM(void);
j3 15:f6cb0d906fb6 502
j3 15:f6cb0d906fb6 503
j3 23:e8e403d61359 504 /**********************************************************//**
j3 23:e8e403d61359 505 * @brief OWOverdriveMatchROM()
j3 23:e8e403d61359 506 *
j3 23:e8e403d61359 507 * @details Issues OVERDRIVE_MATCH rom command. DS248X OW speed
j3 23:e8e403d61359 508 * is set to SPEED_OVERDRIVE
j3 23:e8e403d61359 509 *
j3 23:e8e403d61359 510 * On Entry:
j3 23:e8e403d61359 511 *
j3 23:e8e403d61359 512 * On Exit:
j3 23:e8e403d61359 513 *
j3 23:e8e403d61359 514 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 515 **************************************************************/
j3 23:e8e403d61359 516 virtual CmdResult OWOverdriveMatchROM(const RomId & romId);
j3 23:e8e403d61359 517
j3 15:f6cb0d906fb6 518
j3 23:e8e403d61359 519 /**********************************************************//**
j3 23:e8e403d61359 520 * @brief OWResume()
j3 23:e8e403d61359 521 *
j3 23:e8e403d61359 522 * @details Issues RESUME command, very usefull. Is like skip
j3 23:e8e403d61359 523 * on a multidrop bus, however you must first select the device
j3 23:e8e403d61359 524 * you want to interface with using a MATCH, or SEARCH. The
j3 23:e8e403d61359 525 * device stays selected until another device is selected,
j3 23:e8e403d61359 526 * see slave datasheet for detailed explanation.
j3 23:e8e403d61359 527 *
j3 23:e8e403d61359 528 * On Entry:
j3 23:e8e403d61359 529 *
j3 23:e8e403d61359 530 * On Exit:
j3 23:e8e403d61359 531 *
j3 23:e8e403d61359 532 * @return CmdResult - zero on success, non-zero on failure
j3 23:e8e403d61359 533 **************************************************************/
j3 23:e8e403d61359 534 virtual CmdResult OWResume(void);
IanBenzMaxim 21:00c94aeb533e 535
j3 15:f6cb0d906fb6 536 protected:
j3 15:f6cb0d906fb6 537
j3 15:f6cb0d906fb6 538 // Search state
j3 15:f6cb0d906fb6 539 uint8_t _last_discrepancy;
j3 15:f6cb0d906fb6 540 uint8_t _last_family_discrepancy;
IanBenzMaxim 21:00c94aeb533e 541 bool _last_device_flag;
IanBenzMaxim 21:00c94aeb533e 542
IanBenzMaxim 21:00c94aeb533e 543 private:
j3 17:b646b1e3970b 544
j3 17:b646b1e3970b 545 static const uint16_t _oddparity[16];
j3 15:f6cb0d906fb6 546 };
j3 15:f6cb0d906fb6 547
j3 15:f6cb0d906fb6 548
j3 15:f6cb0d906fb6 549
j3 5:ce108eeb878d 550
j3 5:ce108eeb878d 551
j3 5:ce108eeb878d 552 #endif /*ONEWIREMASTERSSHARED_H*/