Extended MaximInterface

Dependents:   mbed_DS28EC20_GPIO

Committer:
IanBenzMaxim
Date:
Wed Jan 23 13:11:04 2019 -0600
Revision:
6:a8c83a2e6fa4
Parent:
0:f77ad7f72d04
Child:
7:471901a04573
Updated to version 1.6 and removed platform files that are incompatible with mbed.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 0:f77ad7f72d04 1 /*******************************************************************************
IanBenzMaxim 0:f77ad7f72d04 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
IanBenzMaxim 0:f77ad7f72d04 3 *
IanBenzMaxim 0:f77ad7f72d04 4 * Permission is hereby granted, free of charge, to any person obtaining a
IanBenzMaxim 0:f77ad7f72d04 5 * copy of this software and associated documentation files (the "Software"),
IanBenzMaxim 0:f77ad7f72d04 6 * to deal in the Software without restriction, including without limitation
IanBenzMaxim 0:f77ad7f72d04 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
IanBenzMaxim 0:f77ad7f72d04 8 * and/or sell copies of the Software, and to permit persons to whom the
IanBenzMaxim 0:f77ad7f72d04 9 * Software is furnished to do so, subject to the following conditions:
IanBenzMaxim 0:f77ad7f72d04 10 *
IanBenzMaxim 0:f77ad7f72d04 11 * The above copyright notice and this permission notice shall be included
IanBenzMaxim 0:f77ad7f72d04 12 * in all copies or substantial portions of the Software.
IanBenzMaxim 0:f77ad7f72d04 13 *
IanBenzMaxim 0:f77ad7f72d04 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
IanBenzMaxim 0:f77ad7f72d04 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
IanBenzMaxim 0:f77ad7f72d04 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IanBenzMaxim 0:f77ad7f72d04 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
IanBenzMaxim 0:f77ad7f72d04 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
IanBenzMaxim 0:f77ad7f72d04 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
IanBenzMaxim 0:f77ad7f72d04 20 * OTHER DEALINGS IN THE SOFTWARE.
IanBenzMaxim 0:f77ad7f72d04 21 *
IanBenzMaxim 0:f77ad7f72d04 22 * Except as contained in this notice, the name of Maxim Integrated
IanBenzMaxim 0:f77ad7f72d04 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
IanBenzMaxim 0:f77ad7f72d04 24 * Products, Inc. Branding Policy.
IanBenzMaxim 0:f77ad7f72d04 25 *
IanBenzMaxim 0:f77ad7f72d04 26 * The mere transfer of this software does not imply any licenses
IanBenzMaxim 0:f77ad7f72d04 27 * of trade secrets, proprietary technology, copyrights, patents,
IanBenzMaxim 0:f77ad7f72d04 28 * trademarks, maskwork rights, or any other form of intellectual
IanBenzMaxim 0:f77ad7f72d04 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
IanBenzMaxim 0:f77ad7f72d04 30 * ownership rights.
IanBenzMaxim 0:f77ad7f72d04 31 *******************************************************************************/
IanBenzMaxim 0:f77ad7f72d04 32
IanBenzMaxim 0:f77ad7f72d04 33 #ifndef MaximInterface_SelectRom
IanBenzMaxim 0:f77ad7f72d04 34 #define MaximInterface_SelectRom
IanBenzMaxim 0:f77ad7f72d04 35
IanBenzMaxim 0:f77ad7f72d04 36 #include <MaximInterface/Utilities/Export.h>
IanBenzMaxim 0:f77ad7f72d04 37 #include <MaximInterface/Utilities/Function.hpp>
IanBenzMaxim 0:f77ad7f72d04 38 #include <MaximInterface/Utilities/RomId.hpp>
IanBenzMaxim 0:f77ad7f72d04 39 #include <MaximInterface/Utilities/system_error.hpp>
IanBenzMaxim 0:f77ad7f72d04 40 #include "RomCommands.hpp"
IanBenzMaxim 0:f77ad7f72d04 41
IanBenzMaxim 0:f77ad7f72d04 42 namespace MaximInterface {
IanBenzMaxim 0:f77ad7f72d04 43
IanBenzMaxim 0:f77ad7f72d04 44 class OneWireMaster;
IanBenzMaxim 0:f77ad7f72d04 45
IanBenzMaxim 6:a8c83a2e6fa4 46 /// Selects a 1-Wire device on the bus for communication.
IanBenzMaxim 0:f77ad7f72d04 47 typedef Function<error_code(OneWireMaster &)> SelectRom;
IanBenzMaxim 0:f77ad7f72d04 48
IanBenzMaxim 0:f77ad7f72d04 49 /// Selector for a multidrop 1-Wire bus.
IanBenzMaxim 0:f77ad7f72d04 50 class SelectMatchRom {
IanBenzMaxim 0:f77ad7f72d04 51 public:
IanBenzMaxim 0:f77ad7f72d04 52 typedef SelectRom::argument_type argument_type;
IanBenzMaxim 0:f77ad7f72d04 53 typedef SelectRom::result_type result_type;
IanBenzMaxim 0:f77ad7f72d04 54
IanBenzMaxim 6:a8c83a2e6fa4 55 explicit SelectMatchRom(RomId::const_span romId) { setRomId(romId); }
IanBenzMaxim 0:f77ad7f72d04 56
IanBenzMaxim 6:a8c83a2e6fa4 57 RomId::const_span romId() const { return romId_; }
IanBenzMaxim 6:a8c83a2e6fa4 58
IanBenzMaxim 6:a8c83a2e6fa4 59 void setRomId(RomId::const_span romId) { copy(romId, make_span(romId_)); }
IanBenzMaxim 0:f77ad7f72d04 60
IanBenzMaxim 0:f77ad7f72d04 61 MaximInterface_EXPORT error_code operator()(OneWireMaster & master) const;
IanBenzMaxim 0:f77ad7f72d04 62
IanBenzMaxim 0:f77ad7f72d04 63 private:
IanBenzMaxim 6:a8c83a2e6fa4 64 RomId::array romId_;
IanBenzMaxim 0:f77ad7f72d04 65 };
IanBenzMaxim 0:f77ad7f72d04 66
IanBenzMaxim 6:a8c83a2e6fa4 67 /// Selector for a multidrop 1-Wire bus where slaves support the Resume ROM
IanBenzMaxim 6:a8c83a2e6fa4 68 /// command.
IanBenzMaxim 0:f77ad7f72d04 69 class SelectMatchRomWithResume {
IanBenzMaxim 0:f77ad7f72d04 70 public:
IanBenzMaxim 0:f77ad7f72d04 71 typedef SelectRom::argument_type argument_type;
IanBenzMaxim 0:f77ad7f72d04 72 typedef SelectRom::result_type result_type;
IanBenzMaxim 0:f77ad7f72d04 73
IanBenzMaxim 0:f77ad7f72d04 74 struct SharedData {
IanBenzMaxim 6:a8c83a2e6fa4 75 SharedData() : lastRomId() {}
IanBenzMaxim 6:a8c83a2e6fa4 76 RomId::array lastRomId;
IanBenzMaxim 0:f77ad7f72d04 77 };
IanBenzMaxim 0:f77ad7f72d04 78
IanBenzMaxim 6:a8c83a2e6fa4 79 SelectMatchRomWithResume(SharedData & data, RomId::const_span romId)
IanBenzMaxim 6:a8c83a2e6fa4 80 : data(&data) {
IanBenzMaxim 6:a8c83a2e6fa4 81 setRomId(romId);
IanBenzMaxim 6:a8c83a2e6fa4 82 }
IanBenzMaxim 0:f77ad7f72d04 83
IanBenzMaxim 6:a8c83a2e6fa4 84 void setSharedData(SharedData & data) { this->data = &data; }
IanBenzMaxim 6:a8c83a2e6fa4 85
IanBenzMaxim 6:a8c83a2e6fa4 86 RomId::const_span romId() const { return romId_; }
IanBenzMaxim 6:a8c83a2e6fa4 87
IanBenzMaxim 6:a8c83a2e6fa4 88 void setRomId(RomId::const_span romId) { copy(romId, make_span(romId_)); }
IanBenzMaxim 0:f77ad7f72d04 89
IanBenzMaxim 0:f77ad7f72d04 90 MaximInterface_EXPORT error_code operator()(OneWireMaster & master) const;
IanBenzMaxim 0:f77ad7f72d04 91
IanBenzMaxim 0:f77ad7f72d04 92 private:
IanBenzMaxim 0:f77ad7f72d04 93 SharedData * data;
IanBenzMaxim 6:a8c83a2e6fa4 94 RomId::array romId_;
IanBenzMaxim 0:f77ad7f72d04 95 };
IanBenzMaxim 0:f77ad7f72d04 96
IanBenzMaxim 0:f77ad7f72d04 97 } // namespace MaximInterface
IanBenzMaxim 0:f77ad7f72d04 98
IanBenzMaxim 0:f77ad7f72d04 99 #endif