mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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