mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
mbed library release version 165

Who changed what in which revision?

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