temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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