peltier with 2 fans

Dependencies:   mbed TextLCD

Committer:
redplam
Date:
Mon Apr 14 02:15:32 2014 +0000
Revision:
4:5213bee8158e
myproject;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
redplam 4:5213bee8158e 1 /*
redplam 4:5213bee8158e 2 * OneWireCRC. This is a port to mbed of Jim Studt's Adruino One Wire
redplam 4:5213bee8158e 3 * library. Please see additional copyrights below this one, including
redplam 4:5213bee8158e 4 * references to other copyrights.
redplam 4:5213bee8158e 5 *
redplam 4:5213bee8158e 6 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
redplam 4:5213bee8158e 7 *
redplam 4:5213bee8158e 8 * This file is part of OneWireCRC.
redplam 4:5213bee8158e 9 *
redplam 4:5213bee8158e 10 * OneWireCRC is free software: you can redistribute it and/or modify
redplam 4:5213bee8158e 11 * it under the terms of the GNU General Public License as published by
redplam 4:5213bee8158e 12 * the Free Software Foundation, either version 3 of the License, or
redplam 4:5213bee8158e 13 * (at your option) any later version.
redplam 4:5213bee8158e 14 *
redplam 4:5213bee8158e 15 * OneWireCRC is distributed in the hope that it will be useful,
redplam 4:5213bee8158e 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
redplam 4:5213bee8158e 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
redplam 4:5213bee8158e 18 * GNU General Public License for more details.
redplam 4:5213bee8158e 19 *
redplam 4:5213bee8158e 20 * You should have received a copy of the GNU General Public License
redplam 4:5213bee8158e 21 * along with OneWireCRC. If not, see <http://www.gnu.org/licenses/>.
redplam 4:5213bee8158e 22 */
redplam 4:5213bee8158e 23 /*
redplam 4:5213bee8158e 24 Copyright (c) 2007, Jim Studt
redplam 4:5213bee8158e 25
redplam 4:5213bee8158e 26 Updated to work with arduino-0008 and to include skip() as of
redplam 4:5213bee8158e 27 2007/07/06. --RJL20
redplam 4:5213bee8158e 28
redplam 4:5213bee8158e 29 Modified to calculate the 8-bit CRC directly, avoiding the need for
redplam 4:5213bee8158e 30 the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010
redplam 4:5213bee8158e 31 -- Tom Pollard, Jan 23, 2008
redplam 4:5213bee8158e 32
redplam 4:5213bee8158e 33 Permission is hereby granted, free of charge, to any person obtaining
redplam 4:5213bee8158e 34 a copy of this software and associated documentation files (the
redplam 4:5213bee8158e 35 "Software"), to deal in the Software without restriction, including
redplam 4:5213bee8158e 36 without limitation the rights to use, copy, modify, merge, publish,
redplam 4:5213bee8158e 37 distribute, sublicense, and/or sell copies of the Software, and to
redplam 4:5213bee8158e 38 permit persons to whom the Software is furnished to do so, subject to
redplam 4:5213bee8158e 39 the following conditions:
redplam 4:5213bee8158e 40
redplam 4:5213bee8158e 41 The above copyright notice and this permission notice shall be
redplam 4:5213bee8158e 42 included in all copies or substantial portions of the Software.
redplam 4:5213bee8158e 43
redplam 4:5213bee8158e 44 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
redplam 4:5213bee8158e 45 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
redplam 4:5213bee8158e 46 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
redplam 4:5213bee8158e 47 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
redplam 4:5213bee8158e 48 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
redplam 4:5213bee8158e 49 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
redplam 4:5213bee8158e 50 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
redplam 4:5213bee8158e 51
redplam 4:5213bee8158e 52 Much of the code was inspired by Derek Yerger's code, though I don't
redplam 4:5213bee8158e 53 think much of that remains. In any event that was..
redplam 4:5213bee8158e 54 (copyleft) 2006 by Derek Yerger - Free to distribute freely.
redplam 4:5213bee8158e 55
redplam 4:5213bee8158e 56 The CRC code was excerpted and inspired by the Dallas Semiconductor
redplam 4:5213bee8158e 57 sample code bearing this copyright.
redplam 4:5213bee8158e 58 */
redplam 4:5213bee8158e 59 //---------------------------------------------------------------------------
redplam 4:5213bee8158e 60 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
redplam 4:5213bee8158e 61 //
redplam 4:5213bee8158e 62 // Permission is hereby granted, free of charge, to any person obtaining a
redplam 4:5213bee8158e 63 // copy of this software and associated documentation files (the "Software"),
redplam 4:5213bee8158e 64 // to deal in the Software without restriction, including without limitation
redplam 4:5213bee8158e 65 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
redplam 4:5213bee8158e 66 // and/or sell copies of the Software, and to permit persons to whom the
redplam 4:5213bee8158e 67 // Software is furnished to do so, subject to the following conditions:
redplam 4:5213bee8158e 68 //
redplam 4:5213bee8158e 69 // The above copyright notice and this permission notice shall be included
redplam 4:5213bee8158e 70 // in all copies or substantial portions of the Software.
redplam 4:5213bee8158e 71 //
redplam 4:5213bee8158e 72 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
redplam 4:5213bee8158e 73 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
redplam 4:5213bee8158e 74 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
redplam 4:5213bee8158e 75 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
redplam 4:5213bee8158e 76 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
redplam 4:5213bee8158e 77 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
redplam 4:5213bee8158e 78 // OTHER DEALINGS IN THE SOFTWARE.
redplam 4:5213bee8158e 79 //
redplam 4:5213bee8158e 80 // Except as contained in this notice, the name of Dallas Semiconductor
redplam 4:5213bee8158e 81 // shall not be used except as stated in the Dallas Semiconductor
redplam 4:5213bee8158e 82 // Branding Policy.
redplam 4:5213bee8158e 83 //--------------------------------------------------------------------------
redplam 4:5213bee8158e 84
redplam 4:5213bee8158e 85 #ifndef SNATCH59_ONEWIRECRC_H
redplam 4:5213bee8158e 86 #define SNATCH59_ONEWIRECRC_H
redplam 4:5213bee8158e 87
redplam 4:5213bee8158e 88 #include <mbed.h>
redplam 4:5213bee8158e 89
redplam 4:5213bee8158e 90 // Select the table-lookup method of computing the 8-bit CRC by setting this to 1
redplam 4:5213bee8158e 91 #ifndef ONEWIRE_CRC8_TABLE
redplam 4:5213bee8158e 92 #define ONEWIRE_CRC8_TABLE 1
redplam 4:5213bee8158e 93 #endif
redplam 4:5213bee8158e 94
redplam 4:5213bee8158e 95 typedef unsigned char BYTE; // used to be uint8_t : something a byte wide, whatever ....
redplam 4:5213bee8158e 96
redplam 4:5213bee8158e 97 enum eSpeed {OVERDRIVE, STANDARD};
redplam 4:5213bee8158e 98
redplam 4:5213bee8158e 99 class OneWireCRC
redplam 4:5213bee8158e 100 {
redplam 4:5213bee8158e 101 public:
redplam 4:5213bee8158e 102 OneWireCRC(PinName oneWire, eSpeed);
redplam 4:5213bee8158e 103
redplam 4:5213bee8158e 104 // reset, read, write functions
redplam 4:5213bee8158e 105 int reset();
redplam 4:5213bee8158e 106 void writeByte(int data);
redplam 4:5213bee8158e 107 int readByte();
redplam 4:5213bee8158e 108 int touchByte(int data);
redplam 4:5213bee8158e 109 void block(BYTE* data, int data_len);
redplam 4:5213bee8158e 110 int overdriveSkip(BYTE* data, int data_len);
redplam 4:5213bee8158e 111
redplam 4:5213bee8158e 112 // address functions
redplam 4:5213bee8158e 113 void matchROM(BYTE rom[8]);
redplam 4:5213bee8158e 114 void skipROM();
redplam 4:5213bee8158e 115
redplam 4:5213bee8158e 116 // address search functions
redplam 4:5213bee8158e 117 void resetSearch();
redplam 4:5213bee8158e 118 BYTE search(BYTE* newAddr);
redplam 4:5213bee8158e 119
redplam 4:5213bee8158e 120 // CRC check functions
redplam 4:5213bee8158e 121 static BYTE crc8(BYTE* addr, BYTE len);
redplam 4:5213bee8158e 122 static unsigned short crc16(unsigned short* data, unsigned short len);
redplam 4:5213bee8158e 123
redplam 4:5213bee8158e 124 private:
redplam 4:5213bee8158e 125 const int* timing;
redplam 4:5213bee8158e 126
redplam 4:5213bee8158e 127 BYTE address[8];
redplam 4:5213bee8158e 128 int searchJunction; // so we can set to it -1 somewhere
redplam 4:5213bee8158e 129 bool searchExhausted;
redplam 4:5213bee8158e 130
redplam 4:5213bee8158e 131 DigitalInOut oneWirePort;
redplam 4:5213bee8158e 132
redplam 4:5213bee8158e 133 // read/write bit functions
redplam 4:5213bee8158e 134 void writeBit(int bit);
redplam 4:5213bee8158e 135 int readBit();
redplam 4:5213bee8158e 136 };
redplam 4:5213bee8158e 137
redplam 4:5213bee8158e 138 #endif