Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
j3
Date:
Wed Mar 16 01:19:45 2016 +0000
Revision:
15:f6cb0d906fb6
Parent:
OneWire_Masters/OneWireMastersShared.cpp@5:ce108eeb878d
Child:
17:b646b1e3970b
Removed duplicated code between masters by providing 'OneWireMaster' class that implements common parts of OneWireInterface.  OneWireMaster is now the class inherited by individual master implementations.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 5:ce108eeb878d 1 /******************************************************************//**
j3 15:f6cb0d906fb6 2 * @file OneWireMaster.cpp
j3 5:ce108eeb878d 3 *
j3 5:ce108eeb878d 4 * @author Justin Jordan
j3 5:ce108eeb878d 5 *
j3 5:ce108eeb878d 6 * @version 0.0.0
j3 5:ce108eeb878d 7 *
j3 5:ce108eeb878d 8 * Started: 08FEB16
j3 5:ce108eeb878d 9 *
j3 5:ce108eeb878d 10 * Updated:
j3 5:ce108eeb878d 11 *
j3 15:f6cb0d906fb6 12 * @brief Header file for functions shared between masters, that should
j3 15:f6cb0d906fb6 13 * be implemented only once.
j3 5:ce108eeb878d 14 ***********************************************************************
j3 5:ce108eeb878d 15 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 5:ce108eeb878d 16 *
j3 5:ce108eeb878d 17 * Permission is hereby granted, free of charge, to any person obtaining a
j3 5:ce108eeb878d 18 * copy of this software and associated documentation files (the "Software"),
j3 5:ce108eeb878d 19 * to deal in the Software without restriction, including without limitation
j3 5:ce108eeb878d 20 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 5:ce108eeb878d 21 * and/or sell copies of the Software, and to permit persons to whom the
j3 5:ce108eeb878d 22 * Software is furnished to do so, subject to the following conditions:
j3 5:ce108eeb878d 23 *
j3 5:ce108eeb878d 24 * The above copyright notice and this permission notice shall be included
j3 5:ce108eeb878d 25 * in all copies or substantial portions of the Software.
j3 5:ce108eeb878d 26 *
j3 5:ce108eeb878d 27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 5:ce108eeb878d 28 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 5:ce108eeb878d 29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 5:ce108eeb878d 30 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 5:ce108eeb878d 31 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 5:ce108eeb878d 32 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 5:ce108eeb878d 33 * OTHER DEALINGS IN THE SOFTWARE.
j3 5:ce108eeb878d 34 *
j3 5:ce108eeb878d 35 * Except as contained in this notice, the name of Maxim Integrated
j3 5:ce108eeb878d 36 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 5:ce108eeb878d 37 * Products, Inc. Branding Policy.
j3 5:ce108eeb878d 38 *
j3 5:ce108eeb878d 39 * The mere transfer of this software does not imply any licenses
j3 5:ce108eeb878d 40 * of trade secrets, proprietary technology, copyrights, patents,
j3 5:ce108eeb878d 41 * trademarks, maskwork rights, or any other form of intellectual
j3 5:ce108eeb878d 42 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 5:ce108eeb878d 43 * ownership rights.
j3 5:ce108eeb878d 44 **********************************************************************/
j3 5:ce108eeb878d 45
j3 5:ce108eeb878d 46
j3 15:f6cb0d906fb6 47 #include "OneWireMaster.h"
j3 15:f6cb0d906fb6 48
j3 15:f6cb0d906fb6 49
j3 15:f6cb0d906fb6 50 //*********************************************************************
j3 15:f6cb0d906fb6 51 void OneWireMaster::OWWriteBit(uint8_t sendbit)
j3 15:f6cb0d906fb6 52 {
j3 15:f6cb0d906fb6 53 OWTouchBit(sendbit);
j3 15:f6cb0d906fb6 54 }
j3 15:f6cb0d906fb6 55
j3 15:f6cb0d906fb6 56
j3 15:f6cb0d906fb6 57 //*********************************************************************
j3 15:f6cb0d906fb6 58 uint8_t OneWireMaster::OWReadBit()
j3 15:f6cb0d906fb6 59 {
j3 15:f6cb0d906fb6 60 return(OWTouchBit(0x01));
j3 15:f6cb0d906fb6 61 }
j3 15:f6cb0d906fb6 62
j3 15:f6cb0d906fb6 63
j3 15:f6cb0d906fb6 64 //*********************************************************************
j3 15:f6cb0d906fb6 65 uint8_t OneWireMaster::OWTouchByte(uint8_t sendbyte)
j3 15:f6cb0d906fb6 66 {
j3 15:f6cb0d906fb6 67 uint8_t rtn_val;
j3 15:f6cb0d906fb6 68
j3 15:f6cb0d906fb6 69 if (sendbyte == 0xFF)
j3 15:f6cb0d906fb6 70 {
j3 15:f6cb0d906fb6 71 rtn_val = OWReadByte();
j3 15:f6cb0d906fb6 72 }
j3 15:f6cb0d906fb6 73 else
j3 15:f6cb0d906fb6 74 {
j3 15:f6cb0d906fb6 75 OWWriteByte(sendbyte);
j3 15:f6cb0d906fb6 76 rtn_val = sendbyte;
j3 15:f6cb0d906fb6 77 }
j3 15:f6cb0d906fb6 78
j3 15:f6cb0d906fb6 79 return(rtn_val);
j3 15:f6cb0d906fb6 80 }
j3 15:f6cb0d906fb6 81
j3 15:f6cb0d906fb6 82
j3 15:f6cb0d906fb6 83 //*********************************************************************
j3 15:f6cb0d906fb6 84 void OneWireMaster::OWBlock(uint8_t *tran_buf, uint8_t tran_len)
j3 15:f6cb0d906fb6 85 {
j3 15:f6cb0d906fb6 86 uint8_t i;
j3 15:f6cb0d906fb6 87
j3 15:f6cb0d906fb6 88 for (i = 0; i < tran_len; i++)
j3 15:f6cb0d906fb6 89 {
j3 15:f6cb0d906fb6 90 tran_buf[i] = OWTouchByte(tran_buf[i]);
j3 15:f6cb0d906fb6 91 }
j3 15:f6cb0d906fb6 92 }
j3 15:f6cb0d906fb6 93
j3 15:f6cb0d906fb6 94
j3 15:f6cb0d906fb6 95 //*********************************************************************
j3 15:f6cb0d906fb6 96 void OneWireMaster::OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len)
j3 15:f6cb0d906fb6 97 {
j3 15:f6cb0d906fb6 98 uint8_t idx;
j3 15:f6cb0d906fb6 99
j3 15:f6cb0d906fb6 100 for(idx = 0; idx < tran_len; idx++)
j3 15:f6cb0d906fb6 101 {
j3 15:f6cb0d906fb6 102 OWWriteByte(tran_buf[idx]);
j3 15:f6cb0d906fb6 103 }
j3 15:f6cb0d906fb6 104 }
j3 15:f6cb0d906fb6 105
j3 15:f6cb0d906fb6 106
j3 15:f6cb0d906fb6 107 //*********************************************************************
j3 15:f6cb0d906fb6 108 void OneWireMaster::OWReadBlock(uint8_t *recv_buf, uint8_t recv_len)
j3 15:f6cb0d906fb6 109 {
j3 15:f6cb0d906fb6 110 uint8_t idx;
j3 15:f6cb0d906fb6 111
j3 15:f6cb0d906fb6 112 for(idx = 0; idx < recv_len; idx++)
j3 15:f6cb0d906fb6 113 {
j3 15:f6cb0d906fb6 114 recv_buf[idx] = OWReadByte();
j3 15:f6cb0d906fb6 115 }
j3 15:f6cb0d906fb6 116 }
j3 15:f6cb0d906fb6 117
j3 15:f6cb0d906fb6 118
j3 15:f6cb0d906fb6 119 //*********************************************************************
j3 15:f6cb0d906fb6 120 bool OneWireMaster::OWFirst(void)
j3 15:f6cb0d906fb6 121 {
j3 15:f6cb0d906fb6 122 // reset the search state
j3 15:f6cb0d906fb6 123 _last_discrepancy = 0;
j3 15:f6cb0d906fb6 124 _last_device_flag = false;
j3 15:f6cb0d906fb6 125 _last_family_discrepancy = 0;
j3 15:f6cb0d906fb6 126
j3 15:f6cb0d906fb6 127 return OWSearch();
j3 15:f6cb0d906fb6 128 }
j3 15:f6cb0d906fb6 129
j3 15:f6cb0d906fb6 130
j3 15:f6cb0d906fb6 131 //*********************************************************************
j3 15:f6cb0d906fb6 132 bool OneWireMaster::OWNext(void)
j3 15:f6cb0d906fb6 133 {
j3 15:f6cb0d906fb6 134 // leave the search state alone
j3 15:f6cb0d906fb6 135 return OWSearch();
j3 15:f6cb0d906fb6 136 }
j3 15:f6cb0d906fb6 137
j3 15:f6cb0d906fb6 138
j3 15:f6cb0d906fb6 139 //*********************************************************************
j3 15:f6cb0d906fb6 140 bool OneWireMaster::OWVerify(void)
j3 15:f6cb0d906fb6 141 {
j3 15:f6cb0d906fb6 142 bool rtn_val = false;
j3 15:f6cb0d906fb6 143
j3 15:f6cb0d906fb6 144 uint8_t rom_backup[8];
j3 15:f6cb0d906fb6 145 uint8_t i,rslt,ld_backup,ldf_backup,lfd_backup;
j3 15:f6cb0d906fb6 146
j3 15:f6cb0d906fb6 147 // keep a backup copy of the current state
j3 15:f6cb0d906fb6 148 for (i = 0; i < 8; i++)
j3 15:f6cb0d906fb6 149 {
j3 15:f6cb0d906fb6 150 rom_backup[i] = _rom_number[i];
j3 15:f6cb0d906fb6 151 }
j3 15:f6cb0d906fb6 152
j3 15:f6cb0d906fb6 153 ld_backup = _last_discrepancy;
j3 15:f6cb0d906fb6 154 ldf_backup = _last_device_flag;
j3 15:f6cb0d906fb6 155 lfd_backup = _last_family_discrepancy;
j3 15:f6cb0d906fb6 156
j3 15:f6cb0d906fb6 157 // set search to find the same device
j3 15:f6cb0d906fb6 158 _last_discrepancy = 64;
j3 15:f6cb0d906fb6 159 _last_device_flag = false;
j3 15:f6cb0d906fb6 160
j3 15:f6cb0d906fb6 161 if (OWSearch())
j3 15:f6cb0d906fb6 162 {
j3 15:f6cb0d906fb6 163 // check if same device found
j3 15:f6cb0d906fb6 164 rslt = true;
j3 15:f6cb0d906fb6 165 for (i = 0; i < 8; i++)
j3 15:f6cb0d906fb6 166 {
j3 15:f6cb0d906fb6 167 if (rom_backup[i] != _rom_number[i])
j3 15:f6cb0d906fb6 168 {
j3 15:f6cb0d906fb6 169 rslt = false;
j3 15:f6cb0d906fb6 170 break;
j3 15:f6cb0d906fb6 171 }
j3 15:f6cb0d906fb6 172 }
j3 15:f6cb0d906fb6 173 }
j3 15:f6cb0d906fb6 174 else
j3 15:f6cb0d906fb6 175 {
j3 15:f6cb0d906fb6 176 rslt = false;
j3 15:f6cb0d906fb6 177 }
j3 15:f6cb0d906fb6 178
j3 15:f6cb0d906fb6 179 // restore the search state
j3 15:f6cb0d906fb6 180 for (i = 0; i < 8; i++)
j3 15:f6cb0d906fb6 181 {
j3 15:f6cb0d906fb6 182 _rom_number[i] = rom_backup[i];
j3 15:f6cb0d906fb6 183 }
j3 15:f6cb0d906fb6 184
j3 15:f6cb0d906fb6 185 _last_discrepancy = ld_backup;
j3 15:f6cb0d906fb6 186 _last_device_flag = ldf_backup;
j3 15:f6cb0d906fb6 187 _last_family_discrepancy = lfd_backup;
j3 15:f6cb0d906fb6 188
j3 15:f6cb0d906fb6 189 // return the result of the verify
j3 15:f6cb0d906fb6 190 rtn_val = rslt;
j3 15:f6cb0d906fb6 191
j3 15:f6cb0d906fb6 192 return(rtn_val);
j3 15:f6cb0d906fb6 193 }
j3 15:f6cb0d906fb6 194
j3 15:f6cb0d906fb6 195
j3 15:f6cb0d906fb6 196 //*********************************************************************
j3 15:f6cb0d906fb6 197 void OneWireMaster::OWTargetSetup(uint8_t family_code)
j3 15:f6cb0d906fb6 198 {
j3 15:f6cb0d906fb6 199 uint8_t i;
j3 15:f6cb0d906fb6 200
j3 15:f6cb0d906fb6 201 // set the search state to find SearchFamily type devices
j3 15:f6cb0d906fb6 202 _rom_number[0] = family_code;
j3 15:f6cb0d906fb6 203 for (i = 1; i < 8; i++)
j3 15:f6cb0d906fb6 204 {
j3 15:f6cb0d906fb6 205 _rom_number[i] = 0;
j3 15:f6cb0d906fb6 206 }
j3 15:f6cb0d906fb6 207
j3 15:f6cb0d906fb6 208 _last_discrepancy = 64;
j3 15:f6cb0d906fb6 209 _last_family_discrepancy = 0;
j3 15:f6cb0d906fb6 210 _last_device_flag = false;
j3 15:f6cb0d906fb6 211 }
j3 5:ce108eeb878d 212
j3 5:ce108eeb878d 213
j3 5:ce108eeb878d 214 //*********************************************************************
j3 15:f6cb0d906fb6 215 void OneWireMaster::OWFamilySkipSetup(void)
j3 15:f6cb0d906fb6 216 {
j3 15:f6cb0d906fb6 217 // set the Last discrepancy to last family discrepancy
j3 15:f6cb0d906fb6 218 _last_discrepancy = _last_family_discrepancy;
j3 15:f6cb0d906fb6 219
j3 15:f6cb0d906fb6 220 // clear the last family discrpepancy
j3 15:f6cb0d906fb6 221 _last_family_discrepancy = 0;
j3 15:f6cb0d906fb6 222
j3 15:f6cb0d906fb6 223 // check for end of list
j3 15:f6cb0d906fb6 224 if (_last_discrepancy == 0)
j3 15:f6cb0d906fb6 225 {
j3 15:f6cb0d906fb6 226 _last_device_flag = true;
j3 15:f6cb0d906fb6 227 }
j3 15:f6cb0d906fb6 228 }
j3 15:f6cb0d906fb6 229
j3 15:f6cb0d906fb6 230
j3 15:f6cb0d906fb6 231 //*********************************************************************
j3 15:f6cb0d906fb6 232 bool OneWireMaster::OWReadROM(void)
j3 15:f6cb0d906fb6 233 {
j3 15:f6cb0d906fb6 234 bool rtn_val = false;
j3 15:f6cb0d906fb6 235
j3 15:f6cb0d906fb6 236 if(!OWReset())
j3 15:f6cb0d906fb6 237 {
j3 15:f6cb0d906fb6 238 rtn_val = false;
j3 15:f6cb0d906fb6 239 }
j3 15:f6cb0d906fb6 240 else
j3 15:f6cb0d906fb6 241 {
j3 15:f6cb0d906fb6 242 if(!OWWriteByte(READ_ROM))
j3 15:f6cb0d906fb6 243 {
j3 15:f6cb0d906fb6 244 rtn_val = false;
j3 15:f6cb0d906fb6 245 }
j3 15:f6cb0d906fb6 246 else
j3 15:f6cb0d906fb6 247 {
j3 15:f6cb0d906fb6 248 OWReadBlock(_rom_number, ROMnumberLen);
j3 15:f6cb0d906fb6 249 rtn_val = true;
j3 15:f6cb0d906fb6 250 }
j3 15:f6cb0d906fb6 251 }
j3 15:f6cb0d906fb6 252
j3 15:f6cb0d906fb6 253 return rtn_val;
j3 15:f6cb0d906fb6 254 }
j3 15:f6cb0d906fb6 255
j3 15:f6cb0d906fb6 256
j3 15:f6cb0d906fb6 257 //*********************************************************************
j3 15:f6cb0d906fb6 258 bool OneWireMaster::OWSkipROM(void)
j3 15:f6cb0d906fb6 259 {
j3 15:f6cb0d906fb6 260 bool rtn_val = false;
j3 15:f6cb0d906fb6 261
j3 15:f6cb0d906fb6 262 if(!OWReset())
j3 15:f6cb0d906fb6 263 {
j3 15:f6cb0d906fb6 264 rtn_val = false;
j3 15:f6cb0d906fb6 265 }
j3 15:f6cb0d906fb6 266 else
j3 15:f6cb0d906fb6 267 {
j3 15:f6cb0d906fb6 268 if(!OWWriteByte(SKIP_ROM))
j3 15:f6cb0d906fb6 269 {
j3 15:f6cb0d906fb6 270 rtn_val = false;
j3 15:f6cb0d906fb6 271 }
j3 15:f6cb0d906fb6 272 else
j3 15:f6cb0d906fb6 273 {
j3 15:f6cb0d906fb6 274 rtn_val = true;
j3 15:f6cb0d906fb6 275 }
j3 15:f6cb0d906fb6 276 }
j3 15:f6cb0d906fb6 277
j3 15:f6cb0d906fb6 278 return rtn_val;
j3 15:f6cb0d906fb6 279 }
j3 15:f6cb0d906fb6 280
j3 15:f6cb0d906fb6 281
j3 15:f6cb0d906fb6 282 //*********************************************************************
j3 15:f6cb0d906fb6 283 bool OneWireMaster::OWMatchROM(void)
j3 15:f6cb0d906fb6 284 {
j3 15:f6cb0d906fb6 285 bool rtn_val = false;
j3 15:f6cb0d906fb6 286 uint8_t idx;
j3 15:f6cb0d906fb6 287
j3 15:f6cb0d906fb6 288 if(!OWReset())
j3 15:f6cb0d906fb6 289 {
j3 15:f6cb0d906fb6 290 rtn_val = false;
j3 15:f6cb0d906fb6 291 }
j3 15:f6cb0d906fb6 292 else
j3 15:f6cb0d906fb6 293 {
j3 15:f6cb0d906fb6 294 if(!OWWriteByte(MATCH_ROM))
j3 15:f6cb0d906fb6 295 {
j3 15:f6cb0d906fb6 296 rtn_val = false;
j3 15:f6cb0d906fb6 297 }
j3 15:f6cb0d906fb6 298 else
j3 15:f6cb0d906fb6 299 {
j3 15:f6cb0d906fb6 300 for(idx = 0; idx < ROMnumberLen; idx++)
j3 15:f6cb0d906fb6 301 {
j3 15:f6cb0d906fb6 302 OWWriteByte(_rom_number[idx]);
j3 15:f6cb0d906fb6 303 }
j3 15:f6cb0d906fb6 304 rtn_val = true;
j3 15:f6cb0d906fb6 305 }
j3 15:f6cb0d906fb6 306 }
j3 15:f6cb0d906fb6 307
j3 15:f6cb0d906fb6 308 return rtn_val;
j3 15:f6cb0d906fb6 309 }
j3 15:f6cb0d906fb6 310
j3 15:f6cb0d906fb6 311
j3 15:f6cb0d906fb6 312 //*********************************************************************
j3 15:f6cb0d906fb6 313 bool OneWireMaster::OWOverdriveSkipROM(void)
j3 15:f6cb0d906fb6 314 {
j3 15:f6cb0d906fb6 315 bool rtn_val = false;
j3 15:f6cb0d906fb6 316
j3 15:f6cb0d906fb6 317 if(!OWReset())
j3 15:f6cb0d906fb6 318 {
j3 15:f6cb0d906fb6 319 rtn_val = false;
j3 15:f6cb0d906fb6 320 }
j3 15:f6cb0d906fb6 321 else
j3 15:f6cb0d906fb6 322 {
j3 15:f6cb0d906fb6 323 if(!OWWriteByte(OVERDRIVE_SKIP))
j3 15:f6cb0d906fb6 324 {
j3 15:f6cb0d906fb6 325 rtn_val = false;
j3 15:f6cb0d906fb6 326 }
j3 15:f6cb0d906fb6 327 else
j3 15:f6cb0d906fb6 328 {
j3 15:f6cb0d906fb6 329 //change speed for subsequent comands
j3 15:f6cb0d906fb6 330 OWSpeed(SPEED_OVERDRIVE);
j3 15:f6cb0d906fb6 331 rtn_val = true;
j3 15:f6cb0d906fb6 332 }
j3 15:f6cb0d906fb6 333 }
j3 15:f6cb0d906fb6 334
j3 15:f6cb0d906fb6 335 return rtn_val;
j3 15:f6cb0d906fb6 336 }
j3 15:f6cb0d906fb6 337
j3 15:f6cb0d906fb6 338
j3 15:f6cb0d906fb6 339 //*********************************************************************
j3 15:f6cb0d906fb6 340 bool OneWireMaster::OWOverdriveMatchROM(void)
j3 15:f6cb0d906fb6 341 {
j3 15:f6cb0d906fb6 342 bool rtn_val = false;
j3 15:f6cb0d906fb6 343 uint8_t idx;
j3 15:f6cb0d906fb6 344
j3 15:f6cb0d906fb6 345 if(!OWReset())
j3 15:f6cb0d906fb6 346 {
j3 15:f6cb0d906fb6 347 rtn_val = false;
j3 15:f6cb0d906fb6 348 }
j3 15:f6cb0d906fb6 349 else
j3 15:f6cb0d906fb6 350 {
j3 15:f6cb0d906fb6 351 if(!OWWriteByte(OVERDRIVE_MATCH))
j3 15:f6cb0d906fb6 352 {
j3 15:f6cb0d906fb6 353 rtn_val = false;
j3 15:f6cb0d906fb6 354 }
j3 15:f6cb0d906fb6 355 else
j3 15:f6cb0d906fb6 356 {
j3 15:f6cb0d906fb6 357 //change speed before sending ROM number
j3 15:f6cb0d906fb6 358 OWSpeed(SPEED_OVERDRIVE);
j3 15:f6cb0d906fb6 359
j3 15:f6cb0d906fb6 360 for(idx = 0; idx < ROMnumberLen; idx++)
j3 15:f6cb0d906fb6 361 {
j3 15:f6cb0d906fb6 362 OWWriteByte(_rom_number[idx]);
j3 15:f6cb0d906fb6 363 }
j3 15:f6cb0d906fb6 364 rtn_val = true;
j3 15:f6cb0d906fb6 365 }
j3 15:f6cb0d906fb6 366 }
j3 15:f6cb0d906fb6 367
j3 15:f6cb0d906fb6 368 return rtn_val;
j3 15:f6cb0d906fb6 369 }
j3 15:f6cb0d906fb6 370
j3 15:f6cb0d906fb6 371
j3 15:f6cb0d906fb6 372 //*********************************************************************
j3 15:f6cb0d906fb6 373 bool OneWireMaster::OWResume(void)
j3 15:f6cb0d906fb6 374 {
j3 15:f6cb0d906fb6 375 bool rtn_val = false;
j3 15:f6cb0d906fb6 376
j3 15:f6cb0d906fb6 377 if(!OWReset())
j3 15:f6cb0d906fb6 378 {
j3 15:f6cb0d906fb6 379 rtn_val = false;
j3 15:f6cb0d906fb6 380 }
j3 15:f6cb0d906fb6 381 else
j3 15:f6cb0d906fb6 382 {
j3 15:f6cb0d906fb6 383 if(!OWWriteByte(RESUME))
j3 15:f6cb0d906fb6 384 {
j3 15:f6cb0d906fb6 385 rtn_val = false;
j3 15:f6cb0d906fb6 386 }
j3 15:f6cb0d906fb6 387 else
j3 15:f6cb0d906fb6 388 {
j3 15:f6cb0d906fb6 389 rtn_val = true;
j3 15:f6cb0d906fb6 390 }
j3 15:f6cb0d906fb6 391 }
j3 15:f6cb0d906fb6 392
j3 15:f6cb0d906fb6 393 return rtn_val;
j3 15:f6cb0d906fb6 394 }
j3 15:f6cb0d906fb6 395
j3 15:f6cb0d906fb6 396
j3 15:f6cb0d906fb6 397 //*********************************************************************
j3 15:f6cb0d906fb6 398 const uint8_t (&OneWireMaster::OWgetROMnumber() const)[ROMnumberLen]
j3 15:f6cb0d906fb6 399 {
j3 15:f6cb0d906fb6 400 return _rom_number;
j3 15:f6cb0d906fb6 401 }
j3 15:f6cb0d906fb6 402
j3 15:f6cb0d906fb6 403
j3 15:f6cb0d906fb6 404 //*********************************************************************
j3 15:f6cb0d906fb6 405 uint8_t OneWireMaster::OWCalc_crc8(uint8_t data, uint8_t crc8)
j3 5:ce108eeb878d 406 {
j3 5:ce108eeb878d 407 unsigned char i;
j3 5:ce108eeb878d 408
j3 5:ce108eeb878d 409 // See Application Note 27
j3 5:ce108eeb878d 410 crc8 = crc8 ^ data;
j3 5:ce108eeb878d 411 for (i = 0; i < 8; ++i)
j3 5:ce108eeb878d 412 {
j3 5:ce108eeb878d 413 if (crc8 & 1)
j3 5:ce108eeb878d 414 {
j3 5:ce108eeb878d 415 crc8 = (crc8 >> 1) ^ 0x8c;
j3 5:ce108eeb878d 416 }
j3 5:ce108eeb878d 417 else
j3 5:ce108eeb878d 418 {
j3 5:ce108eeb878d 419 crc8 = (crc8 >> 1);
j3 5:ce108eeb878d 420 }
j3 5:ce108eeb878d 421 }
j3 5:ce108eeb878d 422
j3 5:ce108eeb878d 423 return crc8;
j3 5:ce108eeb878d 424 }
j3 5:ce108eeb878d 425