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