,,

Fork of Application by Daniel Sygut

Committer:
Zaitsev
Date:
Thu Feb 15 14:29:23 2018 +0000
Revision:
15:2a20c3d2616e
Parent:
10:41552d038a69
j

Who changed what in which revision?

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