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