The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
98:8ab26030e058
12

Who changed what in which revision?

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