Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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