PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266
Embed:
(wiki syntax)
Show/hide line numbers
Transaction.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_TRANSACTION_H 00017 #define MBED_TRANSACTION_H 00018 00019 #include "platform/platform.h" 00020 #include "platform/FunctionPointer.h" 00021 00022 namespace mbed { 00023 /** \addtogroup platform */ 00024 /** @{*/ 00025 00026 /** Transaction structure 00027 */ 00028 typedef struct { 00029 void *tx_buffer; /**< Tx buffer */ 00030 size_t tx_length; /**< Length of Tx buffer*/ 00031 void *rx_buffer; /**< Rx buffer */ 00032 size_t rx_length; /**< Length of Rx buffer */ 00033 uint32_t event; /**< Event for a transaction */ 00034 event_callback_t callback; /**< User's callback */ 00035 uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ 00036 } transaction_t; 00037 00038 /** Transaction class defines a transaction. 00039 * 00040 * @Note Synchronization level: Not protected 00041 */ 00042 template<typename Class> 00043 class Transaction { 00044 public: 00045 Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { 00046 } 00047 00048 Transaction() : _obj(), _data() { 00049 } 00050 00051 ~Transaction() { 00052 } 00053 00054 /** Get object's instance for the transaction 00055 * 00056 * @return The object which was stored 00057 */ 00058 Class* get_object() { 00059 return _obj; 00060 } 00061 00062 /** Get the transaction 00063 * 00064 * @return The transaction which was stored 00065 */ 00066 transaction_t* get_transaction() { 00067 return &_data; 00068 } 00069 00070 private: 00071 Class* _obj; 00072 transaction_t _data; 00073 }; 00074 00075 } 00076 00077 #endif 00078 00079 /** @}*/
Generated on Tue Jul 12 2022 14:11:11 by 1.7.2