PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266
Embed:
(wiki syntax)
Show/hide line numbers
RawSerial.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 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_RAW_SERIAL_H 00017 #define MBED_RAW_SERIAL_H 00018 00019 #include "platform/platform.h" 00020 00021 #if DEVICE_SERIAL 00022 00023 #include "drivers/SerialBase.h" 00024 #include "hal/serial_api.h" 00025 00026 namespace mbed { 00027 /** \addtogroup drivers */ 00028 /** @{*/ 00029 00030 /** A serial port (UART) for communication with other serial devices 00031 * This is a variation of the Serial class that doesn't use streams, 00032 * thus making it safe to use in interrupt handlers with the RTOS. 00033 * 00034 * Can be used for Full Duplex communication, or Simplex by specifying 00035 * one pin as NC (Not Connected) 00036 * 00037 * @Note Synchronization level: Not protected 00038 * 00039 * Example: 00040 * @code 00041 * // Send a char to the PC 00042 * 00043 * #include "mbed.h" 00044 * 00045 * RawSerial pc(USBTX, USBRX); 00046 * 00047 * int main() { 00048 * pc.putc('A'); 00049 * } 00050 * @endcode 00051 */ 00052 class RawSerial: public SerialBase { 00053 00054 public: 00055 /** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud. 00056 * 00057 * @param tx Transmit pin 00058 * @param rx Receive pin 00059 * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) 00060 * 00061 * @note 00062 * Either tx or rx may be specified as NC if unused 00063 */ 00064 RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); 00065 00066 /** Write a char to the serial port 00067 * 00068 * @param c The char to write 00069 * 00070 * @returns The written char or -1 if an error occured 00071 */ 00072 int putc(int c); 00073 00074 /** Read a char from the serial port 00075 * 00076 * @returns The char read from the serial port 00077 */ 00078 int getc(); 00079 00080 /** Write a string to the serial port 00081 * 00082 * @param str The string to write 00083 * 00084 * @returns 0 if the write succeeds, EOF for error 00085 */ 00086 int puts(const char *str); 00087 00088 int printf(const char *format, ...); 00089 00090 protected: 00091 00092 /** Acquire exclusive access to this serial port 00093 */ 00094 virtual void lock(void); 00095 00096 /** Release exclusive access to this serial port 00097 */ 00098 virtual void unlock(void); 00099 }; 00100 00101 } // namespace mbed 00102 00103 #endif 00104 00105 #endif 00106 00107 /** @}*/
Generated on Tue Jul 12 2022 14:11:10 by 1.7.2