Modified for BG96
Fork of mbed-dev by
platform/Transaction.h@187:0387e8f68319, 2018-09-06 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Sep 06 13:40:20 2018 +0100
- Revision:
- 187:0387e8f68319
- Parent:
- 178:79309dc6340a
mbed-dev library. Release version 163
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 */ |
AnnaBridge | 178:79309dc6340a | 24 | /** @{*/ |
AnnaBridge | 178:79309dc6340a | 25 | /** |
AnnaBridge | 178:79309dc6340a | 26 | * \defgroup platform_Transaction Transaction class |
AnnaBridge | 178:79309dc6340a | 27 | * @{ |
AnnaBridge | 178:79309dc6340a | 28 | */ |
<> | 149:156823d33999 | 29 | |
<> | 149:156823d33999 | 30 | /** Transaction structure |
<> | 149:156823d33999 | 31 | */ |
<> | 149:156823d33999 | 32 | typedef struct { |
<> | 149:156823d33999 | 33 | void *tx_buffer; /**< Tx buffer */ |
<> | 149:156823d33999 | 34 | size_t tx_length; /**< Length of Tx buffer*/ |
<> | 149:156823d33999 | 35 | void *rx_buffer; /**< Rx buffer */ |
<> | 149:156823d33999 | 36 | size_t rx_length; /**< Length of Rx buffer */ |
<> | 149:156823d33999 | 37 | uint32_t event; /**< Event for a transaction */ |
<> | 149:156823d33999 | 38 | event_callback_t callback; /**< User's callback */ |
<> | 149:156823d33999 | 39 | uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ |
<> | 149:156823d33999 | 40 | } transaction_t; |
<> | 149:156823d33999 | 41 | |
<> | 149:156823d33999 | 42 | /** Transaction class defines a transaction. |
<> | 149:156823d33999 | 43 | * |
AnnaBridge | 167:e84263d55307 | 44 | * @note Synchronization level: Not protected |
<> | 149:156823d33999 | 45 | */ |
<> | 149:156823d33999 | 46 | template<typename Class> |
<> | 149:156823d33999 | 47 | class Transaction { |
<> | 149:156823d33999 | 48 | public: |
AnnaBridge | 187:0387e8f68319 | 49 | Transaction(Class *tpointer, const transaction_t &transaction) : _obj(tpointer), _data(transaction) |
AnnaBridge | 187:0387e8f68319 | 50 | { |
<> | 149:156823d33999 | 51 | } |
<> | 149:156823d33999 | 52 | |
AnnaBridge | 187:0387e8f68319 | 53 | Transaction() : _obj(), _data() |
AnnaBridge | 187:0387e8f68319 | 54 | { |
<> | 149:156823d33999 | 55 | } |
<> | 149:156823d33999 | 56 | |
AnnaBridge | 187:0387e8f68319 | 57 | ~Transaction() |
AnnaBridge | 187:0387e8f68319 | 58 | { |
<> | 149:156823d33999 | 59 | } |
<> | 149:156823d33999 | 60 | |
<> | 149:156823d33999 | 61 | /** Get object's instance for the transaction |
<> | 149:156823d33999 | 62 | * |
<> | 149:156823d33999 | 63 | * @return The object which was stored |
<> | 149:156823d33999 | 64 | */ |
AnnaBridge | 187:0387e8f68319 | 65 | Class *get_object() |
AnnaBridge | 187:0387e8f68319 | 66 | { |
<> | 149:156823d33999 | 67 | return _obj; |
<> | 149:156823d33999 | 68 | } |
<> | 149:156823d33999 | 69 | |
<> | 149:156823d33999 | 70 | /** Get the transaction |
<> | 149:156823d33999 | 71 | * |
<> | 149:156823d33999 | 72 | * @return The transaction which was stored |
<> | 149:156823d33999 | 73 | */ |
AnnaBridge | 187:0387e8f68319 | 74 | transaction_t *get_transaction() |
AnnaBridge | 187:0387e8f68319 | 75 | { |
<> | 149:156823d33999 | 76 | return &_data; |
<> | 149:156823d33999 | 77 | } |
<> | 149:156823d33999 | 78 | |
<> | 149:156823d33999 | 79 | private: |
AnnaBridge | 187:0387e8f68319 | 80 | Class *_obj; |
<> | 149:156823d33999 | 81 | transaction_t _data; |
<> | 149:156823d33999 | 82 | }; |
AnnaBridge | 178:79309dc6340a | 83 | /**@}*/ |
<> | 149:156823d33999 | 84 | |
AnnaBridge | 178:79309dc6340a | 85 | /**@}*/ |
<> | 149:156823d33999 | 86 | } |
<> | 149:156823d33999 | 87 | |
<> | 149:156823d33999 | 88 | #endif |