Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
IanBenzMaxim
Date:
Thu May 12 14:38:16 2016 -0500
Revision:
73:2cecc1372acc
Parent:
OneWire_Masters/OneWireMaster.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?

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