test

Committer:
elijahsj
Date:
Mon Nov 09 00:02:47 2020 -0500
Revision:
1:8a094db1347f
test

Who changed what in which revision?

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