test
Fork of mbed-dev by
platform/Transaction.h@178:d650f5d4c87a, 2017-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Nov 08 13:50:44 2017 +0000
- Revision:
- 178:d650f5d4c87a
- Parent:
- 168:e84263d55307
This updates the lib to the mbed lib v 155
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /* mbed Microcontroller Library |
<> | 149:156823d33999 | 2 | * Copyright (c) 2015 ARM Limited |
<> | 149:156823d33999 | 3 | * |
<> | 149:156823d33999 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 149:156823d33999 | 5 | * you may not use this file except in compliance with the License. |
<> | 149:156823d33999 | 6 | * You may obtain a copy of the License at |
<> | 149:156823d33999 | 7 | * |
<> | 149:156823d33999 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 149:156823d33999 | 9 | * |
<> | 149:156823d33999 | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 149:156823d33999 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 149:156823d33999 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 149:156823d33999 | 13 | * See the License for the specific language governing permissions and |
<> | 149:156823d33999 | 14 | * limitations under the License. |
<> | 149:156823d33999 | 15 | */ |
<> | 149:156823d33999 | 16 | #ifndef MBED_TRANSACTION_H |
<> | 149:156823d33999 | 17 | #define MBED_TRANSACTION_H |
<> | 149:156823d33999 | 18 | |
<> | 149:156823d33999 | 19 | #include "platform/platform.h" |
<> | 149:156823d33999 | 20 | #include "platform/FunctionPointer.h" |
<> | 149:156823d33999 | 21 | |
<> | 149:156823d33999 | 22 | namespace mbed { |
<> | 149:156823d33999 | 23 | /** \addtogroup platform */ |
<> | 149:156823d33999 | 24 | |
<> | 149:156823d33999 | 25 | /** Transaction structure |
AnnaBridge | 168:e84263d55307 | 26 | * @ingroup platform |
<> | 149:156823d33999 | 27 | */ |
<> | 149:156823d33999 | 28 | typedef struct { |
<> | 149:156823d33999 | 29 | void *tx_buffer; /**< Tx buffer */ |
<> | 149:156823d33999 | 30 | size_t tx_length; /**< Length of Tx buffer*/ |
<> | 149:156823d33999 | 31 | void *rx_buffer; /**< Rx buffer */ |
<> | 149:156823d33999 | 32 | size_t rx_length; /**< Length of Rx buffer */ |
<> | 149:156823d33999 | 33 | uint32_t event; /**< Event for a transaction */ |
<> | 149:156823d33999 | 34 | event_callback_t callback; /**< User's callback */ |
<> | 149:156823d33999 | 35 | uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ |
<> | 149:156823d33999 | 36 | } transaction_t; |
<> | 149:156823d33999 | 37 | |
<> | 149:156823d33999 | 38 | /** Transaction class defines a transaction. |
<> | 149:156823d33999 | 39 | * |
AnnaBridge | 168:e84263d55307 | 40 | * @note Synchronization level: Not protected |
AnnaBridge | 168:e84263d55307 | 41 | * @ingroup platform |
<> | 149:156823d33999 | 42 | */ |
<> | 149:156823d33999 | 43 | template<typename Class> |
<> | 149:156823d33999 | 44 | class Transaction { |
<> | 149:156823d33999 | 45 | public: |
<> | 149:156823d33999 | 46 | Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { |
<> | 149:156823d33999 | 47 | } |
<> | 149:156823d33999 | 48 | |
<> | 149:156823d33999 | 49 | Transaction() : _obj(), _data() { |
<> | 149:156823d33999 | 50 | } |
<> | 149:156823d33999 | 51 | |
<> | 149:156823d33999 | 52 | ~Transaction() { |
<> | 149:156823d33999 | 53 | } |
<> | 149:156823d33999 | 54 | |
<> | 149:156823d33999 | 55 | /** Get object's instance for the transaction |
<> | 149:156823d33999 | 56 | * |
<> | 149:156823d33999 | 57 | * @return The object which was stored |
<> | 149:156823d33999 | 58 | */ |
<> | 149:156823d33999 | 59 | Class* get_object() { |
<> | 149:156823d33999 | 60 | return _obj; |
<> | 149:156823d33999 | 61 | } |
<> | 149:156823d33999 | 62 | |
<> | 149:156823d33999 | 63 | /** Get the transaction |
<> | 149:156823d33999 | 64 | * |
<> | 149:156823d33999 | 65 | * @return The transaction which was stored |
<> | 149:156823d33999 | 66 | */ |
<> | 149:156823d33999 | 67 | transaction_t* get_transaction() { |
<> | 149:156823d33999 | 68 | return &_data; |
<> | 149:156823d33999 | 69 | } |
<> | 149:156823d33999 | 70 | |
<> | 149:156823d33999 | 71 | private: |
<> | 149:156823d33999 | 72 | Class* _obj; |
<> | 149:156823d33999 | 73 | transaction_t _data; |
<> | 149:156823d33999 | 74 | }; |
<> | 149:156823d33999 | 75 | |
<> | 149:156823d33999 | 76 | } |
<> | 149:156823d33999 | 77 | |
<> | 149:156823d33999 | 78 | #endif |