CDY version that shares functionality with Counter

Dependencies:   SDFileSystem_HelloWorld mbed FATFileSystem

Committer:
Charles David Young
Date:
Mon Nov 05 09:52:17 2018 -0700
Revision:
3:c547dba5d39b
Parent:
0:aa13e1c335cd
debug

Who changed what in which revision?

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