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