Mistake on this page?
Report an issue in GitHub or email us
Transaction.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2015 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 #include "platform/FunctionPointer.h"
22 
23 namespace mbed {
24 /** \addtogroup platform */
25 /** @{*/
26 /**
27  * \defgroup platform_Transaction Transaction class
28  * @{
29  */
30 
31 /** Transaction structure
32  */
33 typedef 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  */
47 template<typename Class>
48 class Transaction {
49 public:
50  Transaction(Class *tpointer, const transaction_t &transaction) : _obj(tpointer), _data(transaction)
51  {
52  }
53 
54  Transaction() : _obj(), _data()
55  {
56  }
57 
58  ~Transaction()
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 
80 private:
81  Class *_obj;
82  transaction_t _data;
83 };
84 /**@}*/
85 
86 /**@}*/
87 }
88 
89 #endif
Transaction class defines a transaction.
Definition: Transaction.h:48
void * tx_buffer
Tx buffer.
Definition: Transaction.h:34
transaction_t * get_transaction()
Get the transaction.
Definition: Transaction.h:75
uint8_t width
Buffer&#39;s word width (8, 16, 32, 64)
Definition: Transaction.h:40
event_callback_t callback
User&#39;s callback.
Definition: Transaction.h:39
size_t tx_length
Length of Tx buffer.
Definition: Transaction.h:35
void * rx_buffer
Rx buffer.
Definition: Transaction.h:36
Transaction structure.
Definition: Transaction.h:33
uint32_t event
Event for a transaction.
Definition: Transaction.h:38
Class * get_object()
Get object&#39;s instance for the transaction.
Definition: Transaction.h:66
size_t rx_length
Length of Rx buffer.
Definition: Transaction.h:37
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.