This fork captures the mbed lib v125 for ease of integration into older projects.
Fork of mbed-dev by
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.h" 00020 #include "FunctionPointer.h" 00021 00022 namespace mbed { 00023 00024 /** Transaction structure 00025 */ 00026 typedef struct { 00027 void *tx_buffer; /**< Tx buffer */ 00028 size_t tx_length; /**< Length of Tx buffer*/ 00029 void *rx_buffer; /**< Rx buffer */ 00030 size_t rx_length; /**< Length of Rx buffer */ 00031 uint32_t event; /**< Event for a transaction */ 00032 event_callback_t callback; /**< User's callback */ 00033 uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ 00034 } transaction_t; 00035 00036 /** Transaction class defines a transaction. 00037 * 00038 * @Note Synchronization level: Not protected 00039 */ 00040 template<typename Class> 00041 class Transaction { 00042 public: 00043 Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { 00044 } 00045 00046 Transaction() : _obj(), _data() { 00047 } 00048 00049 ~Transaction() { 00050 } 00051 00052 /** Get object's instance for the transaction 00053 * 00054 * @return The object which was stored 00055 */ 00056 Class* get_object() { 00057 return _obj; 00058 } 00059 00060 /** Get the transaction 00061 * 00062 * @return The transaction which was stored 00063 */ 00064 transaction_t* get_transaction() { 00065 return &_data; 00066 } 00067 00068 private: 00069 Class* _obj; 00070 transaction_t _data; 00071 }; 00072 00073 } 00074 00075 #endif
Generated on Tue Jul 12 2022 19:06:16 by 1.7.2