Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
IanBenzMaxim
Date:
Fri May 13 07:48:35 2016 -0500
Revision:
74:23be10c32fa3
Parent:
73:2cecc1372acc
Child:
75:8b627804927c
Assimilated indentation and braces.

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
IanBenzMaxim 73:2cecc1372acc 33 #ifndef OneWire_Masters_OneWireMaster
IanBenzMaxim 73:2cecc1372acc 34 #define OneWire_Masters_OneWireMaster
j3 5:ce108eeb878d 35
IanBenzMaxim 73:2cecc1372acc 36 #include <stdint.h>
IanBenzMaxim 73:2cecc1372acc 37 #include <stddef.h>
j3 5:ce108eeb878d 38
IanBenzMaxim 73:2cecc1372acc 39 #include "RomId.h"
IanBenzMaxim 73:2cecc1372acc 40
IanBenzMaxim 73:2cecc1372acc 41 namespace OneWire
IanBenzMaxim 73:2cecc1372acc 42 {
IanBenzMaxim 73:2cecc1372acc 43 namespace Masters
IanBenzMaxim 32:bce180b544ed 44 {
IanBenzMaxim 73:2cecc1372acc 45 /// Base class for all 1-Wire Masters.
IanBenzMaxim 73:2cecc1372acc 46 class OneWireMaster
IanBenzMaxim 74:23be10c32fa3 47 {
IanBenzMaxim 73:2cecc1372acc 48 public:
IanBenzMaxim 73:2cecc1372acc 49 /// Speed of the 1-Wire bus
IanBenzMaxim 73:2cecc1372acc 50 enum OWSpeed
IanBenzMaxim 73:2cecc1372acc 51 {
IanBenzMaxim 73:2cecc1372acc 52 SPEED_STANDARD = 0x00,
IanBenzMaxim 73:2cecc1372acc 53 SPEED_OVERDRIVE = 0x01
IanBenzMaxim 73:2cecc1372acc 54 };
IanBenzMaxim 74:23be10c32fa3 55
IanBenzMaxim 73:2cecc1372acc 56 /// Level of the 1-Wire bus
IanBenzMaxim 73:2cecc1372acc 57 enum OWLevel
IanBenzMaxim 73:2cecc1372acc 58 {
IanBenzMaxim 73:2cecc1372acc 59 LEVEL_NORMAL = 0x00,
IanBenzMaxim 73:2cecc1372acc 60 LEVEL_STRONG = 0x02,
IanBenzMaxim 73:2cecc1372acc 61 LEVEL_PROGRAM = 0x04,
IanBenzMaxim 73:2cecc1372acc 62 };
IanBenzMaxim 74:23be10c32fa3 63
IanBenzMaxim 73:2cecc1372acc 64 /// Search direction for the Triplet
IanBenzMaxim 73:2cecc1372acc 65 enum SearchDirection
IanBenzMaxim 73:2cecc1372acc 66 {
IanBenzMaxim 73:2cecc1372acc 67 DIRECTION_WRITE_ZERO = 0,
IanBenzMaxim 73:2cecc1372acc 68 DIRECTION_WRITE_ONE = 1
IanBenzMaxim 73:2cecc1372acc 69 };
IanBenzMaxim 74:23be10c32fa3 70
IanBenzMaxim 73:2cecc1372acc 71 /// Result of all 1-Wire commands
IanBenzMaxim 73:2cecc1372acc 72 enum CmdResult
IanBenzMaxim 73:2cecc1372acc 73 {
IanBenzMaxim 73:2cecc1372acc 74 Success,
IanBenzMaxim 73:2cecc1372acc 75 CommunicationWriteError,
IanBenzMaxim 73:2cecc1372acc 76 CommunicationReadError,
IanBenzMaxim 73:2cecc1372acc 77 TimeoutError,
IanBenzMaxim 73:2cecc1372acc 78 OperationFailure
IanBenzMaxim 73:2cecc1372acc 79 };
IanBenzMaxim 74:23be10c32fa3 80
IanBenzMaxim 73:2cecc1372acc 81 /// State used by all ROM ID search functions.
IanBenzMaxim 73:2cecc1372acc 82 struct SearchState
IanBenzMaxim 73:2cecc1372acc 83 {
IanBenzMaxim 73:2cecc1372acc 84 RomId romId;
IanBenzMaxim 73:2cecc1372acc 85 uint8_t last_discrepancy;
IanBenzMaxim 73:2cecc1372acc 86 uint8_t last_family_discrepancy;
IanBenzMaxim 73:2cecc1372acc 87 bool last_device_flag;
IanBenzMaxim 74:23be10c32fa3 88
IanBenzMaxim 73:2cecc1372acc 89 /// Reset to the search state to start at the beginning.
IanBenzMaxim 73:2cecc1372acc 90 void reset()
IanBenzMaxim 73:2cecc1372acc 91 {
IanBenzMaxim 73:2cecc1372acc 92 last_discrepancy = 0;
IanBenzMaxim 73:2cecc1372acc 93 last_device_flag = false;
IanBenzMaxim 73:2cecc1372acc 94 last_family_discrepancy = 0;
IanBenzMaxim 73:2cecc1372acc 95 romId.reset();
IanBenzMaxim 73:2cecc1372acc 96 }
IanBenzMaxim 74:23be10c32fa3 97
IanBenzMaxim 73:2cecc1372acc 98 SearchState() { reset(); }
IanBenzMaxim 73:2cecc1372acc 99 };
IanBenzMaxim 74:23be10c32fa3 100
IanBenzMaxim 73:2cecc1372acc 101 /// Perform a CRC16 calculation.
IanBenzMaxim 73:2cecc1372acc 102 /// @param CRC16 Beginning state of the CRC generator.
IanBenzMaxim 73:2cecc1372acc 103 /// @param data Data to pass though the CRC generator.
IanBenzMaxim 73:2cecc1372acc 104 /// @returns The calculated CRC16.
IanBenzMaxim 73:2cecc1372acc 105 static uint16_t calculateCRC16(uint16_t CRC16, uint16_t data);
IanBenzMaxim 74:23be10c32fa3 106
IanBenzMaxim 73:2cecc1372acc 107 /// Perform a CRC16 calculation with variable length data.
IanBenzMaxim 73:2cecc1372acc 108 /// @param[in] data Data array to pass through the CRC generator.
IanBenzMaxim 73:2cecc1372acc 109 /// @param data_offset Offset of the data array to begin processing.
IanBenzMaxim 73:2cecc1372acc 110 /// @param data_len Length of the data array to process.
IanBenzMaxim 73:2cecc1372acc 111 /// @param crc Beginning state of the CRC generator.
IanBenzMaxim 73:2cecc1372acc 112 /// @returns The calculated CRC16.
IanBenzMaxim 73:2cecc1372acc 113 static uint16_t calculateCRC16(const uint8_t * data, size_t data_offset, size_t data_len, uint16_t crc = 0);
IanBenzMaxim 74:23be10c32fa3 114
IanBenzMaxim 73:2cecc1372acc 115 /// Allow freeing through a base class pointer.
IanBenzMaxim 73:2cecc1372acc 116 virtual ~OneWireMaster() { }
IanBenzMaxim 74:23be10c32fa3 117
IanBenzMaxim 73:2cecc1372acc 118 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 119 * @brief OWInitMaster()
IanBenzMaxim 74:23be10c32fa3 120 *
IanBenzMaxim 73:2cecc1372acc 121 * @details Initiializes particular master being instaniated.
IanBenzMaxim 73:2cecc1372acc 122 * Added to interface to provide a common 'init' function between
IanBenzMaxim 73:2cecc1372acc 123 * all masters
IanBenzMaxim 73:2cecc1372acc 124 *
IanBenzMaxim 73:2cecc1372acc 125 * On Entry:
IanBenzMaxim 73:2cecc1372acc 126 *
IanBenzMaxim 73:2cecc1372acc 127 * On Exit:
IanBenzMaxim 73:2cecc1372acc 128 *
IanBenzMaxim 73:2cecc1372acc 129 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 130 virtual CmdResult OWInitMaster(void) = 0;
IanBenzMaxim 74:23be10c32fa3 131
IanBenzMaxim 73:2cecc1372acc 132 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 133 * @brief OWReset()
IanBenzMaxim 74:23be10c32fa3 134 *
IanBenzMaxim 74:23be10c32fa3 135 * @details Reset all of the devices on the 1-Wire Net and return
IanBenzMaxim 73:2cecc1372acc 136 * the result.
IanBenzMaxim 73:2cecc1372acc 137 *
IanBenzMaxim 73:2cecc1372acc 138 * On Entry:
IanBenzMaxim 73:2cecc1372acc 139 *
IanBenzMaxim 73:2cecc1372acc 140 * On Exit:
IanBenzMaxim 73:2cecc1372acc 141 *
IanBenzMaxim 73:2cecc1372acc 142 * @returns OperationFailure if reset was performed but no
IanBenzMaxim 73:2cecc1372acc 143 * presence pulse was detected.
IanBenzMaxim 73:2cecc1372acc 144 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 145 virtual CmdResult OWReset(void) = 0;
IanBenzMaxim 74:23be10c32fa3 146
IanBenzMaxim 73:2cecc1372acc 147 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 148 * @brief OWTouchBit()
IanBenzMaxim 74:23be10c32fa3 149 *
IanBenzMaxim 74:23be10c32fa3 150 * @details Send 1 bit of communication to the 1-Wire Net and return
IanBenzMaxim 74:23be10c32fa3 151 * the result 1 bit read from the 1-Wire Net. The
IanBenzMaxim 74:23be10c32fa3 152 * parameter 'sendbit' least significant bit is used and
IanBenzMaxim 74:23be10c32fa3 153 * the least significant bit of the result is the return
IanBenzMaxim 73:2cecc1372acc 154 * bit.
IanBenzMaxim 73:2cecc1372acc 155 *
IanBenzMaxim 73:2cecc1372acc 156 * On Entry:
IanBenzMaxim 73:2cecc1372acc 157 * @param[in] 'sendbit' - the least significant bit is the bit to send
IanBenzMaxim 73:2cecc1372acc 158 *
IanBenzMaxim 73:2cecc1372acc 159 * On Exit:
IanBenzMaxim 73:2cecc1372acc 160 *
IanBenzMaxim 73:2cecc1372acc 161 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 162 virtual CmdResult OWTouchBitSetLevel(uint8_t & sendrecvbit, OWLevel after_level) = 0;
IanBenzMaxim 74:23be10c32fa3 163
IanBenzMaxim 73:2cecc1372acc 164 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 165 * @brief OWWRiteByte()
IanBenzMaxim 74:23be10c32fa3 166 *
IanBenzMaxim 74:23be10c32fa3 167 * @details Send 8 bits of communication to the 1-Wire Net and
IanBenzMaxim 74:23be10c32fa3 168 * verify that the 8 bits read from the 1-Wire Net is the
IanBenzMaxim 74:23be10c32fa3 169 * same (write operation).The parameter 'sendbyte' least
IanBenzMaxim 73:2cecc1372acc 170 * significant 8 bits are used.
IanBenzMaxim 73:2cecc1372acc 171 *
IanBenzMaxim 73:2cecc1372acc 172 * On Entry:
IanBenzMaxim 73:2cecc1372acc 173 * @param[in] 'sendbyte' - 8 bits to send (least significant byte)
IanBenzMaxim 73:2cecc1372acc 174 *
IanBenzMaxim 73:2cecc1372acc 175 * On Exit:
IanBenzMaxim 73:2cecc1372acc 176 *
IanBenzMaxim 73:2cecc1372acc 177 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 178 virtual CmdResult OWWriteByteSetLevel(uint8_t sendbyte, OWLevel after_level) = 0;
IanBenzMaxim 74:23be10c32fa3 179
IanBenzMaxim 73:2cecc1372acc 180 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 181 * @brief OWReadByte()
IanBenzMaxim 74:23be10c32fa3 182 *
IanBenzMaxim 74:23be10c32fa3 183 * @details Send 8 bits of read communication to the 1-Wire Net
IanBenzMaxim 73:2cecc1372acc 184 * and return the result 8 bits read from the 1-Wire Net.
IanBenzMaxim 73:2cecc1372acc 185 *
IanBenzMaxim 73:2cecc1372acc 186 * On Entry:
IanBenzMaxim 73:2cecc1372acc 187 *
IanBenzMaxim 73:2cecc1372acc 188 * On Exit:
IanBenzMaxim 73:2cecc1372acc 189 *
IanBenzMaxim 73:2cecc1372acc 190 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 191 virtual CmdResult OWReadByteSetLevel(uint8_t & recvbyte, OWLevel after_level) = 0;
IanBenzMaxim 74:23be10c32fa3 192
IanBenzMaxim 73:2cecc1372acc 193 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 194 * @brief OWWriteBlock()
IanBenzMaxim 74:23be10c32fa3 195 *
IanBenzMaxim 74:23be10c32fa3 196 * @details complements OWBlock, writes 'tran_len' bytes from
IanBenzMaxim 73:2cecc1372acc 197 * 'tran_buf' to 1-wire Net.
IanBenzMaxim 73:2cecc1372acc 198 *
IanBenzMaxim 73:2cecc1372acc 199 * On Entry:
IanBenzMaxim 73:2cecc1372acc 200 * @param[in] tran_buf - pointer to data to write
IanBenzMaxim 73:2cecc1372acc 201 * @param[in] tran_len - number of bytes to write
IanBenzMaxim 73:2cecc1372acc 202 *
IanBenzMaxim 73:2cecc1372acc 203 * On Exit:
IanBenzMaxim 73:2cecc1372acc 204 *
IanBenzMaxim 73:2cecc1372acc 205 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 206 virtual CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
IanBenzMaxim 74:23be10c32fa3 207
IanBenzMaxim 73:2cecc1372acc 208 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 209 * @brief OWReadBlock()
IanBenzMaxim 74:23be10c32fa3 210 *
IanBenzMaxim 74:23be10c32fa3 211 * @details complements OWBlock, reads 'recv_len' bytes from
IanBenzMaxim 73:2cecc1372acc 212 * 1-wire Net and puts them in 'recv_buf'.
IanBenzMaxim 73:2cecc1372acc 213 *
IanBenzMaxim 73:2cecc1372acc 214 * On Entry:
IanBenzMaxim 73:2cecc1372acc 215 * @param[in] recv_buf - pointer to receive buffer
IanBenzMaxim 73:2cecc1372acc 216 * @param[in] recv_len - number of bytes to read
IanBenzMaxim 73:2cecc1372acc 217 *
IanBenzMaxim 73:2cecc1372acc 218 * On Exit:
IanBenzMaxim 74:23be10c32fa3 219 *
IanBenzMaxim 73:2cecc1372acc 220 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 221 virtual CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len);
IanBenzMaxim 74:23be10c32fa3 222
IanBenzMaxim 73:2cecc1372acc 223 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 224 * @brief OWSetSpeed()
IanBenzMaxim 74:23be10c32fa3 225 *
IanBenzMaxim 73:2cecc1372acc 226 * @details Set the 1-Wire Net communication speed.
IanBenzMaxim 73:2cecc1372acc 227 *
IanBenzMaxim 73:2cecc1372acc 228 * On Entry:
IanBenzMaxim 73:2cecc1372acc 229 * @param[in] 'new_speed' - new speed defined as
IanBenzMaxim 73:2cecc1372acc 230 * MODE_STANDARD 0x00
IanBenzMaxim 73:2cecc1372acc 231 * MODE_OVERDRIVE 0x01
IanBenzMaxim 73:2cecc1372acc 232 *
IanBenzMaxim 73:2cecc1372acc 233 * On Exit:
IanBenzMaxim 73:2cecc1372acc 234 *
IanBenzMaxim 73:2cecc1372acc 235 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 236 virtual CmdResult OWSetSpeed(OWSpeed new_speed) = 0;
IanBenzMaxim 74:23be10c32fa3 237
IanBenzMaxim 73:2cecc1372acc 238 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 239 * @brief OWSetLevel()
IanBenzMaxim 73:2cecc1372acc 240 *
IanBenzMaxim 74:23be10c32fa3 241 * @details Set the 1-Wire Net line level pull-up to normal. The
IanBenzMaxim 74:23be10c32fa3 242 * ds2484 does only allows enabling strong pull-up on a
IanBenzMaxim 74:23be10c32fa3 243 * bit or byte event. Consequently this function only
IanBenzMaxim 74:23be10c32fa3 244 * allows the MODE_STANDARD argument. To enable strong
IanBenzMaxim 74:23be10c32fa3 245 * pull-up use OWWriteBytePower or OWReadBitPower.
IanBenzMaxim 73:2cecc1372acc 246 *
IanBenzMaxim 73:2cecc1372acc 247 * On Entry:
IanBenzMaxim 73:2cecc1372acc 248 * @param[in] 'new_level' - new level defined as
IanBenzMaxim 73:2cecc1372acc 249 * MODE_STANDARD 0x00
IanBenzMaxim 73:2cecc1372acc 250 *
IanBenzMaxim 73:2cecc1372acc 251 * On Exit:
IanBenzMaxim 73:2cecc1372acc 252 *
IanBenzMaxim 73:2cecc1372acc 253 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 254 virtual CmdResult OWSetLevel(OWLevel new_level) = 0;
IanBenzMaxim 74:23be10c32fa3 255
IanBenzMaxim 73:2cecc1372acc 256 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 257 * @brief OWTriplet()
IanBenzMaxim 74:23be10c32fa3 258 *
IanBenzMaxim 73:2cecc1372acc 259 * @details Perform one bit of a 1-Wire search. This command
IanBenzMaxim 73:2cecc1372acc 260 * does two read bits and one write bit. The write bit is either
IanBenzMaxim 73:2cecc1372acc 261 * the default direction (all device have same bit) or in case
IanBenzMaxim 73:2cecc1372acc 262 * of a discrepancy, the 'search_direction' parameter is used.
IanBenzMaxim 74:23be10c32fa3 263 *
IanBenzMaxim 73:2cecc1372acc 264 * @param[in,out] search_direction
IanBenzMaxim 73:2cecc1372acc 265 * Input with desired direction in case both read bits are zero.
IanBenzMaxim 73:2cecc1372acc 266 * Output with direction taken based on read bits.
IanBenzMaxim 74:23be10c32fa3 267 *
IanBenzMaxim 73:2cecc1372acc 268 * @param[out] sbr Bit result of first read operation.
IanBenzMaxim 73:2cecc1372acc 269 * @param[out] tsb Bit result of second read operation.
IanBenzMaxim 73:2cecc1372acc 270 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 271 virtual CmdResult OWTriplet(SearchDirection & search_direction, uint8_t & sbr, uint8_t & tsb);
IanBenzMaxim 74:23be10c32fa3 272
IanBenzMaxim 73:2cecc1372acc 273 /// OWWriteBit()
IanBenzMaxim 73:2cecc1372acc 274 CmdResult OWWriteBitSetLevel(uint8_t sendbit, OWLevel after_level) { return OWTouchBitSetLevel(sendbit, after_level); }
IanBenzMaxim 74:23be10c32fa3 275
IanBenzMaxim 73:2cecc1372acc 276 /// OWReadBit()
IanBenzMaxim 73:2cecc1372acc 277 CmdResult OWReadBitSetLevel(uint8_t & recvbit, OWLevel after_level) { recvbit = 0x01; return OWTouchBitSetLevel(recvbit, after_level); }
IanBenzMaxim 74:23be10c32fa3 278
IanBenzMaxim 73:2cecc1372acc 279 // Alternate forms of read and write functions
IanBenzMaxim 73:2cecc1372acc 280 CmdResult OWWriteBit(uint8_t sendbit) { return OWWriteBitSetLevel(sendbit, LEVEL_NORMAL); }
IanBenzMaxim 73:2cecc1372acc 281 CmdResult OWReadBit(uint8_t & recvbit) { return OWReadBitSetLevel(recvbit, LEVEL_NORMAL); }
IanBenzMaxim 73:2cecc1372acc 282 CmdResult OWWriteBitPower(uint8_t sendbit) { return OWWriteBitSetLevel(sendbit, LEVEL_STRONG); }
IanBenzMaxim 73:2cecc1372acc 283 CmdResult OWReadBitPower(uint8_t & recvbit) { return OWReadBitSetLevel(recvbit, LEVEL_STRONG); }
IanBenzMaxim 73:2cecc1372acc 284 CmdResult OWWriteByte(uint8_t sendbyte) { return OWWriteByteSetLevel(sendbyte, LEVEL_NORMAL); }
IanBenzMaxim 73:2cecc1372acc 285 CmdResult OWReadByte(uint8_t & recvbyte) { return OWReadByteSetLevel(recvbyte, LEVEL_NORMAL); }
IanBenzMaxim 73:2cecc1372acc 286 CmdResult OWWriteBytePower(uint8_t sendbyte) { return OWWriteByteSetLevel(sendbyte, LEVEL_STRONG); }
IanBenzMaxim 73:2cecc1372acc 287 CmdResult OWReadBytePower(uint8_t & recvbyte) { return OWReadByteSetLevel(recvbyte, LEVEL_STRONG); }
IanBenzMaxim 74:23be10c32fa3 288
IanBenzMaxim 73:2cecc1372acc 289 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 290 * @brief OWFirst()
IanBenzMaxim 74:23be10c32fa3 291 *
IanBenzMaxim 73:2cecc1372acc 292 * @details Find the 'first' devices on the 1-Wire network
IanBenzMaxim 73:2cecc1372acc 293 *
IanBenzMaxim 73:2cecc1372acc 294 * On Entry:
IanBenzMaxim 73:2cecc1372acc 295 *
IanBenzMaxim 73:2cecc1372acc 296 * On Exit:
IanBenzMaxim 73:2cecc1372acc 297 *
IanBenzMaxim 73:2cecc1372acc 298 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 299 CmdResult OWFirst(SearchState & searchState);
IanBenzMaxim 74:23be10c32fa3 300
IanBenzMaxim 73:2cecc1372acc 301 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 302 * @brief OWNext()
IanBenzMaxim 74:23be10c32fa3 303 *
IanBenzMaxim 73:2cecc1372acc 304 * @details Find the 'next' devices on the 1-Wire network
IanBenzMaxim 73:2cecc1372acc 305 *
IanBenzMaxim 73:2cecc1372acc 306 * On Entry:
IanBenzMaxim 73:2cecc1372acc 307 *
IanBenzMaxim 73:2cecc1372acc 308 * On Exit:
IanBenzMaxim 73:2cecc1372acc 309 *
IanBenzMaxim 73:2cecc1372acc 310 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 311 CmdResult OWNext(SearchState & searchState);
IanBenzMaxim 74:23be10c32fa3 312
IanBenzMaxim 73:2cecc1372acc 313 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 314 * @brief OWVerify()
IanBenzMaxim 74:23be10c32fa3 315 *
IanBenzMaxim 74:23be10c32fa3 316 * @details Verify the device with the ROM number in ROM_NO buffer
IanBenzMaxim 73:2cecc1372acc 317 * is present.
IanBenzMaxim 73:2cecc1372acc 318 *
IanBenzMaxim 73:2cecc1372acc 319 * On Entry:
IanBenzMaxim 73:2cecc1372acc 320 *
IanBenzMaxim 73:2cecc1372acc 321 * On Exit:
IanBenzMaxim 73:2cecc1372acc 322 *
IanBenzMaxim 73:2cecc1372acc 323 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 324 CmdResult OWVerify(const RomId & romId);
IanBenzMaxim 74:23be10c32fa3 325
IanBenzMaxim 73:2cecc1372acc 326 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 327 * @brief OWTargetSetup()
IanBenzMaxim 74:23be10c32fa3 328 *
IanBenzMaxim 74:23be10c32fa3 329 * @details Setup the search to find the device type 'family_code'
IanBenzMaxim 73:2cecc1372acc 330 * on the next call to OWNext() if it is present.
IanBenzMaxim 73:2cecc1372acc 331 *
IanBenzMaxim 73:2cecc1372acc 332 * On Entry:
IanBenzMaxim 73:2cecc1372acc 333 * @param[in] family_code - family code of device
IanBenzMaxim 73:2cecc1372acc 334 *
IanBenzMaxim 73:2cecc1372acc 335 * On Exit:
IanBenzMaxim 73:2cecc1372acc 336 *
IanBenzMaxim 73:2cecc1372acc 337 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 338 void OWTargetSetup(SearchState & searchState);
IanBenzMaxim 74:23be10c32fa3 339
IanBenzMaxim 73:2cecc1372acc 340 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 341 * @brief OWFamilySkipSetup()
IanBenzMaxim 74:23be10c32fa3 342 *
IanBenzMaxim 74:23be10c32fa3 343 * @details Setup the search to skip the current device type on the
IanBenzMaxim 73:2cecc1372acc 344 * next call to OWNext().
IanBenzMaxim 73:2cecc1372acc 345 *
IanBenzMaxim 73:2cecc1372acc 346 * On Entry:
IanBenzMaxim 73:2cecc1372acc 347 *
IanBenzMaxim 73:2cecc1372acc 348 * On Exit:
IanBenzMaxim 73:2cecc1372acc 349 *
IanBenzMaxim 73:2cecc1372acc 350 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 351 void OWFamilySkipSetup(SearchState & searchState);
IanBenzMaxim 74:23be10c32fa3 352
IanBenzMaxim 73:2cecc1372acc 353 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 354 * @brief OWReadROM()
IanBenzMaxim 74:23be10c32fa3 355 *
IanBenzMaxim 73:2cecc1372acc 356 * @details Only use this command with a single drop bus, data
IanBenzMaxim 73:2cecc1372acc 357 * collisions will occur if more than 1 device on bus.
IanBenzMaxim 73:2cecc1372acc 358 * Issues READ_ROM command, slave device will respond with ROM ID.
IanBenzMaxim 73:2cecc1372acc 359 *
IanBenzMaxim 73:2cecc1372acc 360 * On Entry:
IanBenzMaxim 73:2cecc1372acc 361 *
IanBenzMaxim 73:2cecc1372acc 362 * On Exit:
IanBenzMaxim 73:2cecc1372acc 363 *
IanBenzMaxim 73:2cecc1372acc 364 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 365 CmdResult OWReadROM(RomId & romId);
IanBenzMaxim 74:23be10c32fa3 366
IanBenzMaxim 73:2cecc1372acc 367 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 368 * @brief OWSkipROM()
IanBenzMaxim 74:23be10c32fa3 369 *
IanBenzMaxim 73:2cecc1372acc 370 * @details Issue SKIP_ROM command on 1-wire bus
IanBenzMaxim 73:2cecc1372acc 371 *
IanBenzMaxim 73:2cecc1372acc 372 * On Entry:
IanBenzMaxim 73:2cecc1372acc 373 *
IanBenzMaxim 73:2cecc1372acc 374 * On Exit:
IanBenzMaxim 73:2cecc1372acc 375 *
IanBenzMaxim 73:2cecc1372acc 376 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 377 CmdResult OWSkipROM(void);
IanBenzMaxim 74:23be10c32fa3 378
IanBenzMaxim 73:2cecc1372acc 379 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 380 * @brief OWMatchROM()
IanBenzMaxim 74:23be10c32fa3 381 *
IanBenzMaxim 73:2cecc1372acc 382 * @details Issues MATCH_ROM command on 1-wire bus and then sends
IanBenzMaxim 73:2cecc1372acc 383 * the rom id in _rom_number
IanBenzMaxim 73:2cecc1372acc 384 *
IanBenzMaxim 73:2cecc1372acc 385 * On Entry:
IanBenzMaxim 73:2cecc1372acc 386 *
IanBenzMaxim 73:2cecc1372acc 387 * On Exit:
IanBenzMaxim 73:2cecc1372acc 388 *
IanBenzMaxim 73:2cecc1372acc 389 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 390 CmdResult OWMatchROM(const RomId & romId);
IanBenzMaxim 74:23be10c32fa3 391
IanBenzMaxim 73:2cecc1372acc 392 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 393 * @brief OWOverdriveSkipROM()
IanBenzMaxim 74:23be10c32fa3 394 *
IanBenzMaxim 74:23be10c32fa3 395 * @details Issues OVERDRIVE_SKIP rom command. DS248X OW speed
IanBenzMaxim 73:2cecc1372acc 396 * is set to SPEED_OVERDRIVE
IanBenzMaxim 73:2cecc1372acc 397 *
IanBenzMaxim 73:2cecc1372acc 398 * On Entry:
IanBenzMaxim 73:2cecc1372acc 399 *
IanBenzMaxim 73:2cecc1372acc 400 * On Exit:
IanBenzMaxim 73:2cecc1372acc 401 *
IanBenzMaxim 73:2cecc1372acc 402 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 403 CmdResult OWOverdriveSkipROM(void);
IanBenzMaxim 74:23be10c32fa3 404
IanBenzMaxim 73:2cecc1372acc 405 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 406 * @brief OWOverdriveMatchROM()
IanBenzMaxim 74:23be10c32fa3 407 *
IanBenzMaxim 74:23be10c32fa3 408 * @details Issues OVERDRIVE_MATCH rom command. DS248X OW speed
IanBenzMaxim 73:2cecc1372acc 409 * is set to SPEED_OVERDRIVE
IanBenzMaxim 73:2cecc1372acc 410 *
IanBenzMaxim 73:2cecc1372acc 411 * On Entry:
IanBenzMaxim 73:2cecc1372acc 412 *
IanBenzMaxim 73:2cecc1372acc 413 * On Exit:
IanBenzMaxim 73:2cecc1372acc 414 *
IanBenzMaxim 73:2cecc1372acc 415 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 416 CmdResult OWOverdriveMatchROM(const RomId & romId);
IanBenzMaxim 74:23be10c32fa3 417
IanBenzMaxim 73:2cecc1372acc 418 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 419 * @brief OWResume()
IanBenzMaxim 74:23be10c32fa3 420 *
IanBenzMaxim 74:23be10c32fa3 421 * @details Issues RESUME command, very usefull. Is like skip
IanBenzMaxim 74:23be10c32fa3 422 * on a multidrop bus, however you must first select the device
IanBenzMaxim 74:23be10c32fa3 423 * you want to interface with using a MATCH, or SEARCH. The
IanBenzMaxim 74:23be10c32fa3 424 * device stays selected until another device is selected,
IanBenzMaxim 73:2cecc1372acc 425 * see slave datasheet for detailed explanation.
IanBenzMaxim 73:2cecc1372acc 426 *
IanBenzMaxim 73:2cecc1372acc 427 * On Entry:
IanBenzMaxim 73:2cecc1372acc 428 *
IanBenzMaxim 73:2cecc1372acc 429 * On Exit:
IanBenzMaxim 73:2cecc1372acc 430 *
IanBenzMaxim 73:2cecc1372acc 431 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 432 CmdResult OWResume(void);
IanBenzMaxim 74:23be10c32fa3 433
IanBenzMaxim 73:2cecc1372acc 434 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 435 * @brief OWSearch()
IanBenzMaxim 74:23be10c32fa3 436 *
IanBenzMaxim 74:23be10c32fa3 437 * @details The 'OWSearch' function does a general search. This
IanBenzMaxim 74:23be10c32fa3 438 * function continues from the previous search state. The
IanBenzMaxim 74:23be10c32fa3 439 * search state can be reset by using the 'OWFirst'
IanBenzMaxim 74:23be10c32fa3 440 * function. This function contains one parameter
IanBenzMaxim 74:23be10c32fa3 441 * 'alarm_only'. When 'alarm_only' is TRUE (1) the find
IanBenzMaxim 74:23be10c32fa3 442 * alarm command 0xEC is sent instead of the normal search
IanBenzMaxim 74:23be10c32fa3 443 * command 0xF0. Using the find alarm command 0xEC will
IanBenzMaxim 74:23be10c32fa3 444 * limit the search to only 1-Wire devices that are in an
IanBenzMaxim 73:2cecc1372acc 445 * 'alarm' state.
IanBenzMaxim 73:2cecc1372acc 446 *
IanBenzMaxim 73:2cecc1372acc 447 * On Entry:
IanBenzMaxim 73:2cecc1372acc 448 *
IanBenzMaxim 73:2cecc1372acc 449 * On Exit:
IanBenzMaxim 73:2cecc1372acc 450 *
IanBenzMaxim 73:2cecc1372acc 451 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 452 CmdResult OWSearch(SearchState & searchState);
IanBenzMaxim 73:2cecc1372acc 453 };
IanBenzMaxim 73:2cecc1372acc 454 }
IanBenzMaxim 73:2cecc1372acc 455 }
j3 15:f6cb0d906fb6 456
IanBenzMaxim 74:23be10c32fa3 457 #endif