2016-10-06 13:21:30 +02:00
|
|
|
/*
|
|
|
|
HardwareSerial.h - Hardware serial library for Wiring
|
|
|
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
Modified 28 September 2010 by Mark Sproul
|
|
|
|
Modified 14 August 2012 by Alarus
|
|
|
|
Modified 3 December 2013 by Matthijs Kooijman
|
|
|
|
Modified 18 December 2014 by Ivan Grokhotkov (esp8266 platform support)
|
|
|
|
Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266)
|
|
|
|
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HardwareSerial_h
|
|
|
|
#define HardwareSerial_h
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include "Stream.h"
|
|
|
|
#include "esp32-hal.h"
|
|
|
|
|
|
|
|
class HardwareSerial: public Stream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HardwareSerial(int uart_nr);
|
|
|
|
|
2017-10-13 10:46:56 +02:00
|
|
|
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false);
|
2016-10-06 13:21:30 +02:00
|
|
|
void end();
|
|
|
|
int available(void);
|
2018-04-06 18:07:46 +02:00
|
|
|
int availableForWrite(void);
|
2016-10-06 13:21:30 +02:00
|
|
|
int peek(void);
|
|
|
|
int read(void);
|
|
|
|
void flush(void);
|
|
|
|
size_t write(uint8_t);
|
|
|
|
size_t write(const uint8_t *buffer, size_t size);
|
|
|
|
|
2016-11-16 16:30:13 +01:00
|
|
|
inline size_t write(const char * s)
|
|
|
|
{
|
|
|
|
return write((uint8_t*) s, strlen(s));
|
|
|
|
}
|
2016-10-06 13:21:30 +02:00
|
|
|
inline size_t write(unsigned long n)
|
|
|
|
{
|
|
|
|
return write((uint8_t) n);
|
|
|
|
}
|
|
|
|
inline size_t write(long n)
|
|
|
|
{
|
|
|
|
return write((uint8_t) n);
|
|
|
|
}
|
|
|
|
inline size_t write(unsigned int n)
|
|
|
|
{
|
|
|
|
return write((uint8_t) n);
|
|
|
|
}
|
|
|
|
inline size_t write(int n)
|
|
|
|
{
|
|
|
|
return write((uint8_t) n);
|
|
|
|
}
|
2017-09-21 11:00:12 +02:00
|
|
|
uint32_t baudRate();
|
2016-10-06 13:21:30 +02:00
|
|
|
operator bool() const;
|
|
|
|
|
|
|
|
void setDebugOutput(bool);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int _uart_nr;
|
|
|
|
uart_t* _uart;
|
|
|
|
};
|
|
|
|
|
2018-04-06 18:02:59 +02:00
|
|
|
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
2016-10-06 13:21:30 +02:00
|
|
|
extern HardwareSerial Serial;
|
2018-04-06 18:02:59 +02:00
|
|
|
#endif
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
#endif
|