Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
j3
Date:
Tue Feb 09 03:30:22 2016 +0000
Revision:
5:ce108eeb878d
added additional rom command functions to interface and moved initialization of members to init list vs constructor body.  Made other modifications suggested by Ian

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 5:ce108eeb878d 1 /******************************************************************//**
j3 5:ce108eeb878d 2 * @file OneWireMastersShared.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 5:ce108eeb878d 12 * @brief Source file for functions shared between masters, that should
j3 5:ce108eeb878d 13 * be implemented by each master, only one implementation
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 5:ce108eeb878d 47 #include "OneWireMastersShared.h"
j3 5:ce108eeb878d 48
j3 5:ce108eeb878d 49
j3 5:ce108eeb878d 50 //*********************************************************************
j3 5:ce108eeb878d 51 uint8_t OWCalc_crc8(uint8_t data, uint8_t crc8)
j3 5:ce108eeb878d 52 {
j3 5:ce108eeb878d 53 unsigned char i;
j3 5:ce108eeb878d 54
j3 5:ce108eeb878d 55 // See Application Note 27
j3 5:ce108eeb878d 56 crc8 = crc8 ^ data;
j3 5:ce108eeb878d 57 for (i = 0; i < 8; ++i)
j3 5:ce108eeb878d 58 {
j3 5:ce108eeb878d 59 if (crc8 & 1)
j3 5:ce108eeb878d 60 {
j3 5:ce108eeb878d 61 crc8 = (crc8 >> 1) ^ 0x8c;
j3 5:ce108eeb878d 62 }
j3 5:ce108eeb878d 63 else
j3 5:ce108eeb878d 64 {
j3 5:ce108eeb878d 65 crc8 = (crc8 >> 1);
j3 5:ce108eeb878d 66 }
j3 5:ce108eeb878d 67 }
j3 5:ce108eeb878d 68
j3 5:ce108eeb878d 69 return crc8;
j3 5:ce108eeb878d 70 }
j3 5:ce108eeb878d 71