Home Alert System

Dependencies:   PWM_Tone_Library DHT

Committer:
ethaderu
Date:
Tue Mar 05 02:34:44 2019 +0000
Revision:
3:78f223d34f36
Publish 1

Who changed what in which revision?

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