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