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