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