Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Links/LoggingI2CMaster.hpp@10:de4b8812877d, 2020-01-06 (annotated)
- Committer:
- reARMnimator
- Date:
- Mon Jan 06 15:54:55 2020 +0000
- Revision:
- 10:de4b8812877d
- Parent:
- 6:a8c83a2e6fa4
Fixed inappropriate include path.
Who changed what in which revision?
User | Revision | Line number | New 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_LoggingI2CMaster |
IanBenzMaxim | 0:f77ad7f72d04 | 34 | #define MaximInterface_LoggingI2CMaster |
IanBenzMaxim | 0:f77ad7f72d04 | 35 | |
IanBenzMaxim | 0:f77ad7f72d04 | 36 | #include <string> |
IanBenzMaxim | 0:f77ad7f72d04 | 37 | #include <MaximInterface/Links/I2CMasterDecorator.hpp> |
IanBenzMaxim | 0:f77ad7f72d04 | 38 | #include <MaximInterface/Utilities/Export.h> |
IanBenzMaxim | 0:f77ad7f72d04 | 39 | #include <MaximInterface/Utilities/WriteMessage.hpp> |
IanBenzMaxim | 0:f77ad7f72d04 | 40 | |
IanBenzMaxim | 0:f77ad7f72d04 | 41 | namespace MaximInterface { |
IanBenzMaxim | 0:f77ad7f72d04 | 42 | |
IanBenzMaxim | 0:f77ad7f72d04 | 43 | class LoggingI2CMaster : public I2CMasterDecorator { |
IanBenzMaxim | 0:f77ad7f72d04 | 44 | public: |
IanBenzMaxim | 0:f77ad7f72d04 | 45 | explicit LoggingI2CMaster( |
IanBenzMaxim | 0:f77ad7f72d04 | 46 | I2CMaster & i2c, const WriteMessage & writeMessage = WriteMessage()) |
IanBenzMaxim | 0:f77ad7f72d04 | 47 | : I2CMasterDecorator(i2c), writeMessage(writeMessage), messageBuilder() {} |
IanBenzMaxim | 0:f77ad7f72d04 | 48 | |
IanBenzMaxim | 0:f77ad7f72d04 | 49 | void setWriteMessage(const WriteMessage & writeMessage) { |
IanBenzMaxim | 0:f77ad7f72d04 | 50 | this->writeMessage = writeMessage; |
IanBenzMaxim | 0:f77ad7f72d04 | 51 | } |
IanBenzMaxim | 0:f77ad7f72d04 | 52 | |
IanBenzMaxim | 0:f77ad7f72d04 | 53 | MaximInterface_EXPORT virtual error_code start(uint_least8_t address); |
IanBenzMaxim | 6:a8c83a2e6fa4 | 54 | |
IanBenzMaxim | 0:f77ad7f72d04 | 55 | MaximInterface_EXPORT virtual error_code stop(); |
IanBenzMaxim | 6:a8c83a2e6fa4 | 56 | |
IanBenzMaxim | 0:f77ad7f72d04 | 57 | MaximInterface_EXPORT virtual error_code writeByte(uint_least8_t data); |
IanBenzMaxim | 6:a8c83a2e6fa4 | 58 | |
IanBenzMaxim | 0:f77ad7f72d04 | 59 | MaximInterface_EXPORT virtual error_code |
IanBenzMaxim | 6:a8c83a2e6fa4 | 60 | writeBlock(span<const uint_least8_t> data); |
IanBenzMaxim | 6:a8c83a2e6fa4 | 61 | |
IanBenzMaxim | 0:f77ad7f72d04 | 62 | MaximInterface_EXPORT virtual error_code readByte(AckStatus status, |
IanBenzMaxim | 0:f77ad7f72d04 | 63 | uint_least8_t & data); |
IanBenzMaxim | 0:f77ad7f72d04 | 64 | MaximInterface_EXPORT virtual error_code |
IanBenzMaxim | 6:a8c83a2e6fa4 | 65 | readBlock(AckStatus status, span<uint_least8_t> data); |
IanBenzMaxim | 3:f818ea5172ed | 66 | |
IanBenzMaxim | 3:f818ea5172ed | 67 | protected: |
IanBenzMaxim | 3:f818ea5172ed | 68 | MaximInterface_EXPORT virtual error_code |
IanBenzMaxim | 6:a8c83a2e6fa4 | 69 | writePacketImpl(uint_least8_t address, span<const uint_least8_t> data, |
IanBenzMaxim | 6:a8c83a2e6fa4 | 70 | bool sendStop); |
IanBenzMaxim | 6:a8c83a2e6fa4 | 71 | |
IanBenzMaxim | 6:a8c83a2e6fa4 | 72 | MaximInterface_EXPORT virtual error_code |
IanBenzMaxim | 6:a8c83a2e6fa4 | 73 | readPacketImpl(uint_least8_t address, span<uint_least8_t> data, |
IanBenzMaxim | 6:a8c83a2e6fa4 | 74 | bool sendStop); |
IanBenzMaxim | 0:f77ad7f72d04 | 75 | |
IanBenzMaxim | 0:f77ad7f72d04 | 76 | private: |
IanBenzMaxim | 0:f77ad7f72d04 | 77 | void tryWriteMessage(); |
IanBenzMaxim | 0:f77ad7f72d04 | 78 | |
IanBenzMaxim | 0:f77ad7f72d04 | 79 | WriteMessage writeMessage; |
IanBenzMaxim | 0:f77ad7f72d04 | 80 | std::string messageBuilder; |
IanBenzMaxim | 0:f77ad7f72d04 | 81 | }; |
IanBenzMaxim | 0:f77ad7f72d04 | 82 | |
IanBenzMaxim | 0:f77ad7f72d04 | 83 | } // namespace MaximInterface |
IanBenzMaxim | 0:f77ad7f72d04 | 84 | |
IanBenzMaxim | 6:a8c83a2e6fa4 | 85 | #endif |