Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
OneWire_Masters/OneWireMaster.h@15:f6cb0d906fb6, 2016-03-16 (annotated)
- Committer:
- j3
- Date:
- Wed Mar 16 01:19:45 2016 +0000
- Revision:
- 15:f6cb0d906fb6
- Parent:
- OneWire_Masters/OneWireMastersShared.h@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?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 5:ce108eeb878d | 1 | /******************************************************************//** |
j3 | 15:f6cb0d906fb6 | 2 | * @file OneWireMaster.h |
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 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 | #ifndef ONEWIREMASTER_H |
j3 | 15:f6cb0d906fb6 | 48 | #define ONEWIREMASTER_H |
j3 | 5:ce108eeb878d | 49 | |
j3 | 5:ce108eeb878d | 50 | |
j3 | 5:ce108eeb878d | 51 | #include "mbed.h" |
j3 | 15:f6cb0d906fb6 | 52 | #include "OneWireInterface.h" |
j3 | 5:ce108eeb878d | 53 | |
j3 | 5:ce108eeb878d | 54 | |
j3 | 15:f6cb0d906fb6 | 55 | class OneWireMaster: public OneWireInterface |
j3 | 15:f6cb0d906fb6 | 56 | { |
j3 | 15:f6cb0d906fb6 | 57 | public: |
j3 | 15:f6cb0d906fb6 | 58 | |
j3 | 15:f6cb0d906fb6 | 59 | //Part of OneWireInterface that should only be implemented once |
j3 | 15:f6cb0d906fb6 | 60 | //See OneWireInterface.h for documentation |
j3 | 15:f6cb0d906fb6 | 61 | |
j3 | 15:f6cb0d906fb6 | 62 | virtual void OWWriteBit(uint8_t sendbit); |
j3 | 15:f6cb0d906fb6 | 63 | |
j3 | 15:f6cb0d906fb6 | 64 | virtual uint8_t OWReadBit(); |
j3 | 15:f6cb0d906fb6 | 65 | |
j3 | 15:f6cb0d906fb6 | 66 | virtual uint8_t OWTouchByte(uint8_t sendbyte); |
j3 | 15:f6cb0d906fb6 | 67 | |
j3 | 15:f6cb0d906fb6 | 68 | virtual void OWBlock(uint8_t *tran_buf, uint8_t tran_len); |
j3 | 15:f6cb0d906fb6 | 69 | |
j3 | 15:f6cb0d906fb6 | 70 | virtual void OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len); |
j3 | 15:f6cb0d906fb6 | 71 | |
j3 | 15:f6cb0d906fb6 | 72 | virtual void OWReadBlock(uint8_t *recv_buf, uint8_t recv_len); |
j3 | 15:f6cb0d906fb6 | 73 | |
j3 | 15:f6cb0d906fb6 | 74 | virtual bool OWFirst(void); |
j3 | 15:f6cb0d906fb6 | 75 | |
j3 | 15:f6cb0d906fb6 | 76 | virtual bool OWNext(void); |
j3 | 15:f6cb0d906fb6 | 77 | |
j3 | 15:f6cb0d906fb6 | 78 | virtual bool OWVerify(void); |
j3 | 15:f6cb0d906fb6 | 79 | |
j3 | 15:f6cb0d906fb6 | 80 | virtual void OWTargetSetup(uint8_t family_code); |
j3 | 15:f6cb0d906fb6 | 81 | |
j3 | 15:f6cb0d906fb6 | 82 | virtual void OWFamilySkipSetup(void); |
j3 | 15:f6cb0d906fb6 | 83 | |
j3 | 15:f6cb0d906fb6 | 84 | virtual bool OWReadROM(void); |
j3 | 15:f6cb0d906fb6 | 85 | |
j3 | 15:f6cb0d906fb6 | 86 | virtual bool OWSkipROM(void); |
j3 | 15:f6cb0d906fb6 | 87 | |
j3 | 15:f6cb0d906fb6 | 88 | virtual bool OWMatchROM(void); |
j3 | 15:f6cb0d906fb6 | 89 | |
j3 | 15:f6cb0d906fb6 | 90 | virtual bool OWOverdriveSkipROM(void); |
j3 | 15:f6cb0d906fb6 | 91 | |
j3 | 15:f6cb0d906fb6 | 92 | virtual bool OWOverdriveMatchROM(void); |
j3 | 15:f6cb0d906fb6 | 93 | |
j3 | 15:f6cb0d906fb6 | 94 | virtual bool OWResume(void); |
j3 | 15:f6cb0d906fb6 | 95 | |
j3 | 15:f6cb0d906fb6 | 96 | virtual const uint8_t (&OWgetROMnumber() const)[ROMnumberLen]; |
j3 | 15:f6cb0d906fb6 | 97 | |
j3 | 15:f6cb0d906fb6 | 98 | static uint8_t OWCalc_crc8(uint8_t data, uint8_t crc8); |
j3 | 15:f6cb0d906fb6 | 99 | |
j3 | 15:f6cb0d906fb6 | 100 | protected: |
j3 | 15:f6cb0d906fb6 | 101 | |
j3 | 15:f6cb0d906fb6 | 102 | // Search state |
j3 | 15:f6cb0d906fb6 | 103 | uint8_t _rom_number[ROMnumberLen]; |
j3 | 15:f6cb0d906fb6 | 104 | uint8_t _last_discrepancy; |
j3 | 15:f6cb0d906fb6 | 105 | uint8_t _last_family_discrepancy; |
j3 | 15:f6cb0d906fb6 | 106 | uint8_t _last_device_flag; |
j3 | 15:f6cb0d906fb6 | 107 | uint8_t _crc8; |
j3 | 15:f6cb0d906fb6 | 108 | }; |
j3 | 15:f6cb0d906fb6 | 109 | |
j3 | 15:f6cb0d906fb6 | 110 | |
j3 | 15:f6cb0d906fb6 | 111 | |
j3 | 5:ce108eeb878d | 112 | |
j3 | 5:ce108eeb878d | 113 | |
j3 | 5:ce108eeb878d | 114 | #endif /*ONEWIREMASTERSSHARED_H*/ |