forked
Embed:
(wiki syntax)
Show/hide line numbers
Transaction.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_TRANSACTION_H 00017 #define MBED_TRANSACTION_H 00018 00019 #include "platform/platform.h" 00020 #include "platform/FunctionPointer.h" 00021 00022 namespace mbed { 00023 /** \addtogroup platform */ 00024 00025 /** Transaction structure 00026 * @ingroup platform 00027 */ 00028 typedef struct { 00029 void *tx_buffer; /**< Tx buffer */ 00030 size_t tx_length; /**< Length of Tx buffer*/ 00031 void *rx_buffer; /**< Rx buffer */ 00032 size_t rx_length; /**< Length of Rx buffer */ 00033 uint32_t event; /**< Event for a transaction */ 00034 event_callback_t callback; /**< User's callback */ 00035 uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ 00036 } transaction_t; 00037 00038 /** Transaction class defines a transaction. 00039 * 00040 * @note Synchronization level: Not protected 00041 * @ingroup platform 00042 */ 00043 template<typename Class> 00044 class Transaction { 00045 public: 00046 Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { 00047 } 00048 00049 Transaction() : _obj(), _data() { 00050 } 00051 00052 ~Transaction() { 00053 } 00054 00055 /** Get object's instance for the transaction 00056 * 00057 * @return The object which was stored 00058 */ 00059 Class* get_object() { 00060 return _obj; 00061 } 00062 00063 /** Get the transaction 00064 * 00065 * @return The transaction which was stored 00066 */ 00067 transaction_t* get_transaction() { 00068 return &_data; 00069 } 00070 00071 private: 00072 Class* _obj; 00073 transaction_t _data; 00074 }; 00075 00076 } 00077 00078 #endif
Generated on Tue Jul 12 2022 16:02:33 by 1.7.2