Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 /** 00026 * \defgroup platform_Transaction Transaction class 00027 * @{ 00028 */ 00029 00030 /** Transaction structure 00031 */ 00032 typedef struct { 00033 void *tx_buffer; /**< Tx buffer */ 00034 size_t tx_length; /**< Length of Tx buffer*/ 00035 void *rx_buffer; /**< Rx buffer */ 00036 size_t rx_length; /**< Length of Rx buffer */ 00037 uint32_t event; /**< Event for a transaction */ 00038 event_callback_t callback; /**< User's callback */ 00039 uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ 00040 } transaction_t; 00041 00042 /** Transaction class defines a transaction. 00043 * 00044 * @note Synchronization level: Not protected 00045 */ 00046 template<typename Class> 00047 class Transaction { 00048 public: 00049 Transaction(Class *tpointer, const transaction_t &transaction) : _obj(tpointer), _data(transaction) 00050 { 00051 } 00052 00053 Transaction() : _obj(), _data() 00054 { 00055 } 00056 00057 ~Transaction() 00058 { 00059 } 00060 00061 /** Get object's instance for the transaction 00062 * 00063 * @return The object which was stored 00064 */ 00065 Class *get_object() 00066 { 00067 return _obj; 00068 } 00069 00070 /** Get the transaction 00071 * 00072 * @return The transaction which was stored 00073 */ 00074 transaction_t *get_transaction() 00075 { 00076 return &_data; 00077 } 00078 00079 private: 00080 Class *_obj; 00081 transaction_t _data; 00082 }; 00083 /**@}*/ 00084 00085 /**@}*/ 00086 } 00087 00088 #endif
Generated on Tue Aug 9 2022 00:37:23 by
