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