The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
platform/Transaction.h@169:a7c7b631e539, 2018-06-22 (annotated)
- Committer:
- Anna Bridge
- Date:
- Fri Jun 22 15:38:59 2018 +0100
- Revision:
- 169:a7c7b631e539
- Parent:
- 158:1c57384330a6
- Child:
- 170:e95d10626187
mbed library. Release version 162
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 156:ff21514d8981 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 156:ff21514d8981 | 2 | * Copyright (c) 2015 ARM Limited |
AnnaBridge | 156:ff21514d8981 | 3 | * |
AnnaBridge | 156:ff21514d8981 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
AnnaBridge | 156:ff21514d8981 | 5 | * you may not use this file except in compliance with the License. |
AnnaBridge | 156:ff21514d8981 | 6 | * You may obtain a copy of the License at |
AnnaBridge | 156:ff21514d8981 | 7 | * |
AnnaBridge | 156:ff21514d8981 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 156:ff21514d8981 | 9 | * |
AnnaBridge | 156:ff21514d8981 | 10 | * Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 156:ff21514d8981 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 156:ff21514d8981 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 156:ff21514d8981 | 13 | * See the License for the specific language governing permissions and |
AnnaBridge | 156:ff21514d8981 | 14 | * limitations under the License. |
AnnaBridge | 156:ff21514d8981 | 15 | */ |
AnnaBridge | 156:ff21514d8981 | 16 | #ifndef MBED_TRANSACTION_H |
AnnaBridge | 156:ff21514d8981 | 17 | #define MBED_TRANSACTION_H |
AnnaBridge | 156:ff21514d8981 | 18 | |
AnnaBridge | 156:ff21514d8981 | 19 | #include "platform/platform.h" |
AnnaBridge | 156:ff21514d8981 | 20 | #include "platform/FunctionPointer.h" |
AnnaBridge | 156:ff21514d8981 | 21 | |
AnnaBridge | 156:ff21514d8981 | 22 | namespace mbed { |
AnnaBridge | 156:ff21514d8981 | 23 | /** \addtogroup platform */ |
AnnaBridge | 158:1c57384330a6 | 24 | /** @{*/ |
AnnaBridge | 158:1c57384330a6 | 25 | /** |
AnnaBridge | 158:1c57384330a6 | 26 | * \defgroup platform_Transaction Transaction class |
AnnaBridge | 158:1c57384330a6 | 27 | * @{ |
AnnaBridge | 158:1c57384330a6 | 28 | */ |
AnnaBridge | 156:ff21514d8981 | 29 | |
AnnaBridge | 156:ff21514d8981 | 30 | /** Transaction structure |
AnnaBridge | 156:ff21514d8981 | 31 | */ |
AnnaBridge | 156:ff21514d8981 | 32 | typedef struct { |
AnnaBridge | 156:ff21514d8981 | 33 | void *tx_buffer; /**< Tx buffer */ |
AnnaBridge | 156:ff21514d8981 | 34 | size_t tx_length; /**< Length of Tx buffer*/ |
AnnaBridge | 156:ff21514d8981 | 35 | void *rx_buffer; /**< Rx buffer */ |
AnnaBridge | 156:ff21514d8981 | 36 | size_t rx_length; /**< Length of Rx buffer */ |
AnnaBridge | 156:ff21514d8981 | 37 | uint32_t event; /**< Event for a transaction */ |
AnnaBridge | 156:ff21514d8981 | 38 | event_callback_t callback; /**< User's callback */ |
AnnaBridge | 156:ff21514d8981 | 39 | uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ |
AnnaBridge | 156:ff21514d8981 | 40 | } transaction_t; |
AnnaBridge | 156:ff21514d8981 | 41 | |
AnnaBridge | 156:ff21514d8981 | 42 | /** Transaction class defines a transaction. |
AnnaBridge | 156:ff21514d8981 | 43 | * |
AnnaBridge | 156:ff21514d8981 | 44 | * @note Synchronization level: Not protected |
AnnaBridge | 156:ff21514d8981 | 45 | */ |
AnnaBridge | 156:ff21514d8981 | 46 | template<typename Class> |
AnnaBridge | 156:ff21514d8981 | 47 | class Transaction { |
AnnaBridge | 156:ff21514d8981 | 48 | public: |
AnnaBridge | 156:ff21514d8981 | 49 | Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { |
AnnaBridge | 156:ff21514d8981 | 50 | } |
AnnaBridge | 156:ff21514d8981 | 51 | |
AnnaBridge | 156:ff21514d8981 | 52 | Transaction() : _obj(), _data() { |
AnnaBridge | 156:ff21514d8981 | 53 | } |
AnnaBridge | 156:ff21514d8981 | 54 | |
AnnaBridge | 156:ff21514d8981 | 55 | ~Transaction() { |
AnnaBridge | 156:ff21514d8981 | 56 | } |
AnnaBridge | 156:ff21514d8981 | 57 | |
AnnaBridge | 156:ff21514d8981 | 58 | /** Get object's instance for the transaction |
AnnaBridge | 156:ff21514d8981 | 59 | * |
AnnaBridge | 156:ff21514d8981 | 60 | * @return The object which was stored |
AnnaBridge | 156:ff21514d8981 | 61 | */ |
AnnaBridge | 156:ff21514d8981 | 62 | Class* get_object() { |
AnnaBridge | 156:ff21514d8981 | 63 | return _obj; |
AnnaBridge | 156:ff21514d8981 | 64 | } |
AnnaBridge | 156:ff21514d8981 | 65 | |
AnnaBridge | 156:ff21514d8981 | 66 | /** Get the transaction |
AnnaBridge | 156:ff21514d8981 | 67 | * |
AnnaBridge | 156:ff21514d8981 | 68 | * @return The transaction which was stored |
AnnaBridge | 156:ff21514d8981 | 69 | */ |
AnnaBridge | 156:ff21514d8981 | 70 | transaction_t* get_transaction() { |
AnnaBridge | 156:ff21514d8981 | 71 | return &_data; |
AnnaBridge | 156:ff21514d8981 | 72 | } |
AnnaBridge | 156:ff21514d8981 | 73 | |
AnnaBridge | 156:ff21514d8981 | 74 | private: |
AnnaBridge | 156:ff21514d8981 | 75 | Class* _obj; |
AnnaBridge | 156:ff21514d8981 | 76 | transaction_t _data; |
AnnaBridge | 156:ff21514d8981 | 77 | }; |
AnnaBridge | 158:1c57384330a6 | 78 | /**@}*/ |
AnnaBridge | 156:ff21514d8981 | 79 | |
AnnaBridge | 158:1c57384330a6 | 80 | /**@}*/ |
AnnaBridge | 156:ff21514d8981 | 81 | } |
AnnaBridge | 156:ff21514d8981 | 82 | |
AnnaBridge | 156:ff21514d8981 | 83 | #endif |