Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Slaves/OneWireSlave.h@86:2ce08ca58b9e, 2016-06-15 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Wed Jun 15 15:00:06 2016 -0500
- Revision:
- 86:2ce08ca58b9e
- Parent:
- OneWireSlave.h@82:c11090a32471
- Child:
- 103:6dcbb5166da1
Updated to match new directory structure.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IanBenzMaxim | 75:8b627804927c | 1 | /******************************************************************//** |
IanBenzMaxim | 75:8b627804927c | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
IanBenzMaxim | 75:8b627804927c | 3 | * |
IanBenzMaxim | 75:8b627804927c | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
IanBenzMaxim | 75:8b627804927c | 5 | * copy of this software and associated documentation files (the "Software"), |
IanBenzMaxim | 75:8b627804927c | 6 | * to deal in the Software without restriction, including without limitation |
IanBenzMaxim | 75:8b627804927c | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
IanBenzMaxim | 75:8b627804927c | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
IanBenzMaxim | 75:8b627804927c | 9 | * Software is furnished to do so, subject to the following conditions: |
IanBenzMaxim | 75:8b627804927c | 10 | * |
IanBenzMaxim | 75:8b627804927c | 11 | * The above copyright notice and this permission notice shall be included |
IanBenzMaxim | 75:8b627804927c | 12 | * in all copies or substantial portions of the Software. |
IanBenzMaxim | 75:8b627804927c | 13 | * |
IanBenzMaxim | 75:8b627804927c | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
IanBenzMaxim | 75:8b627804927c | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
IanBenzMaxim | 75:8b627804927c | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
IanBenzMaxim | 75:8b627804927c | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
IanBenzMaxim | 75:8b627804927c | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
IanBenzMaxim | 75:8b627804927c | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
IanBenzMaxim | 75:8b627804927c | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
IanBenzMaxim | 75:8b627804927c | 21 | * |
IanBenzMaxim | 75:8b627804927c | 22 | * Except as contained in this notice, the name of Maxim Integrated |
IanBenzMaxim | 75:8b627804927c | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
IanBenzMaxim | 75:8b627804927c | 24 | * Products, Inc. Branding Policy. |
IanBenzMaxim | 75:8b627804927c | 25 | * |
IanBenzMaxim | 75:8b627804927c | 26 | * The mere transfer of this software does not imply any licenses |
IanBenzMaxim | 75:8b627804927c | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
IanBenzMaxim | 75:8b627804927c | 28 | * trademarks, maskwork rights, or any other form of intellectual |
IanBenzMaxim | 75:8b627804927c | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
IanBenzMaxim | 75:8b627804927c | 30 | * ownership rights. |
IanBenzMaxim | 75:8b627804927c | 31 | **********************************************************************/ |
IanBenzMaxim | 75:8b627804927c | 32 | |
IanBenzMaxim | 74:23be10c32fa3 | 33 | #ifndef OneWire_OneWireSlave |
IanBenzMaxim | 74:23be10c32fa3 | 34 | #define OneWire_OneWireSlave |
IanBenzMaxim | 25:bdb1c5a53b58 | 35 | |
IanBenzMaxim | 76:84e6c4994e29 | 36 | #include <stddef.h> |
IanBenzMaxim | 73:2cecc1372acc | 37 | #include "RomId.h" |
IanBenzMaxim | 77:529edb329ee0 | 38 | #include "RomIterator.h" |
IanBenzMaxim | 25:bdb1c5a53b58 | 39 | |
IanBenzMaxim | 73:2cecc1372acc | 40 | namespace OneWire |
IanBenzMaxim | 25:bdb1c5a53b58 | 41 | { |
IanBenzMaxim | 76:84e6c4994e29 | 42 | class OneWireMaster; |
IanBenzMaxim | 76:84e6c4994e29 | 43 | |
IanBenzMaxim | 74:23be10c32fa3 | 44 | /// Base class for all 1-Wire Slaves. |
IanBenzMaxim | 74:23be10c32fa3 | 45 | class OneWireSlave |
IanBenzMaxim | 73:2cecc1372acc | 46 | { |
IanBenzMaxim | 74:23be10c32fa3 | 47 | public: |
IanBenzMaxim | 74:23be10c32fa3 | 48 | enum CmdResult |
IanBenzMaxim | 74:23be10c32fa3 | 49 | { |
IanBenzMaxim | 74:23be10c32fa3 | 50 | Success, |
IanBenzMaxim | 74:23be10c32fa3 | 51 | CommunicationError, |
IanBenzMaxim | 77:529edb329ee0 | 52 | CrcError, |
IanBenzMaxim | 74:23be10c32fa3 | 53 | TimeoutError, |
IanBenzMaxim | 74:23be10c32fa3 | 54 | OperationFailure |
IanBenzMaxim | 74:23be10c32fa3 | 55 | }; |
IanBenzMaxim | 74:23be10c32fa3 | 56 | |
IanBenzMaxim | 82:c11090a32471 | 57 | /// @{ |
IanBenzMaxim | 74:23be10c32fa3 | 58 | /// 1-Wire ROM ID for this slave device. |
IanBenzMaxim | 82:c11090a32471 | 59 | RomId romId() const { return m_romId; } |
IanBenzMaxim | 82:c11090a32471 | 60 | void setRomId(const RomId & romId) { m_romId = romId; } |
IanBenzMaxim | 82:c11090a32471 | 61 | /// @} |
IanBenzMaxim | 82:c11090a32471 | 62 | |
IanBenzMaxim | 77:529edb329ee0 | 63 | private: |
IanBenzMaxim | 82:c11090a32471 | 64 | RomId m_romId; |
IanBenzMaxim | 82:c11090a32471 | 65 | RandomAccessRomIterator & m_selector; |
IanBenzMaxim | 76:84e6c4994e29 | 66 | |
IanBenzMaxim | 76:84e6c4994e29 | 67 | protected: |
IanBenzMaxim | 77:529edb329ee0 | 68 | /// @param selector Provides 1-Wire ROM selection and bus access. |
IanBenzMaxim | 82:c11090a32471 | 69 | OneWireSlave(RandomAccessRomIterator & selector) : m_selector(selector) { } |
IanBenzMaxim | 76:84e6c4994e29 | 70 | |
IanBenzMaxim | 77:529edb329ee0 | 71 | /// Select this slave device by ROM ID. |
IanBenzMaxim | 82:c11090a32471 | 72 | OneWireMaster::CmdResult selectDevice() const { return m_selector.selectDevice(m_romId); } |
IanBenzMaxim | 77:529edb329ee0 | 73 | |
IanBenzMaxim | 77:529edb329ee0 | 74 | /// The 1-Wire master for this slave device. |
IanBenzMaxim | 82:c11090a32471 | 75 | OneWireMaster & master() const { return m_selector.master(); } |
IanBenzMaxim | 73:2cecc1372acc | 76 | }; |
IanBenzMaxim | 73:2cecc1372acc | 77 | } |
IanBenzMaxim | 25:bdb1c5a53b58 | 78 | |
IanBenzMaxim | 49:36954b62f503 | 79 | #endif |