mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-07 06:01:35 +03:00
Fix build errors
This commit is contained in:
@ -28,67 +28,46 @@
|
||||
|
||||
#include "Stream.h"
|
||||
|
||||
// Define constants and variables for buffering incoming serial data. We're
|
||||
// using a ring buffer (I think), in which head is the index of the location
|
||||
// to which to write the next incoming character and tail is the index of the
|
||||
// location from which to read.
|
||||
// NOTE: a "power of 2" buffer size is reccomended to dramatically
|
||||
// optimize all the modulo operations for ring buffers.
|
||||
#if !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE))
|
||||
#if (RAMEND < 1000)
|
||||
#define SERIAL_TX_BUFFER_SIZE 16
|
||||
#define SERIAL_RX_BUFFER_SIZE 16
|
||||
#else
|
||||
#define SERIAL_TX_BUFFER_SIZE 64
|
||||
#define SERIAL_RX_BUFFER_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
#if (SERIAL_TX_BUFFER_SIZE>256)
|
||||
typedef uint16_t tx_buffer_index_t;
|
||||
#else
|
||||
typedef uint8_t tx_buffer_index_t;
|
||||
#endif
|
||||
#if (SERIAL_RX_BUFFER_SIZE>256)
|
||||
typedef uint16_t rx_buffer_index_t;
|
||||
#else
|
||||
typedef uint8_t rx_buffer_index_t;
|
||||
#endif
|
||||
|
||||
// Define config for Serial.begin(baud, config);
|
||||
#define SERIAL_5N1 0x00
|
||||
#define SERIAL_6N1 0x02
|
||||
#define SERIAL_7N1 0x04
|
||||
#define SERIAL_8N1 0x06
|
||||
#define SERIAL_5N2 0x08
|
||||
#define SERIAL_6N2 0x0A
|
||||
#define SERIAL_7N2 0x0C
|
||||
#define SERIAL_8N2 0x0E
|
||||
#define SERIAL_5E1 0x20
|
||||
#define SERIAL_6E1 0x22
|
||||
#define SERIAL_7E1 0x24
|
||||
#define SERIAL_8E1 0x26
|
||||
#define SERIAL_5E2 0x28
|
||||
#define SERIAL_6E2 0x2A
|
||||
#define SERIAL_7E2 0x2C
|
||||
#define SERIAL_8E2 0x2E
|
||||
#define SERIAL_5O1 0x30
|
||||
#define SERIAL_6O1 0x32
|
||||
#define SERIAL_7O1 0x34
|
||||
#define SERIAL_8O1 0x36
|
||||
#define SERIAL_5O2 0x38
|
||||
#define SERIAL_6O2 0x3A
|
||||
#define SERIAL_7O2 0x3C
|
||||
#define SERIAL_8O2 0x3E
|
||||
typedef uint32_t tx_buffer_index_t;
|
||||
typedef uint32_t rx_buffer_index_t;
|
||||
|
||||
// // Define config for Serial.begin(baud, config);
|
||||
// #define SERIAL_5N1 0x00
|
||||
// #define SERIAL_6N1 0x02
|
||||
// #define SERIAL_7N1 0x04
|
||||
// #define SERIAL_8N1 0x06
|
||||
// #define SERIAL_5N2 0x08
|
||||
// #define SERIAL_6N2 0x0A
|
||||
// #define SERIAL_7N2 0x0C
|
||||
// #define SERIAL_8N2 0x0E
|
||||
// #define SERIAL_5E1 0x20
|
||||
// #define SERIAL_6E1 0x22
|
||||
// #define SERIAL_7E1 0x24
|
||||
// #define SERIAL_8E1 0x26
|
||||
// #define SERIAL_5E2 0x28
|
||||
// #define SERIAL_6E2 0x2A
|
||||
// #define SERIAL_7E2 0x2C
|
||||
// #define SERIAL_8E2 0x2E
|
||||
// #define SERIAL_5O1 0x30
|
||||
// #define SERIAL_6O1 0x32
|
||||
// #define SERIAL_7O1 0x34
|
||||
// #define SERIAL_8O1 0x36
|
||||
// #define SERIAL_5O2 0x38
|
||||
// #define SERIAL_6O2 0x3A
|
||||
// #define SERIAL_7O2 0x3C
|
||||
// #define SERIAL_8O2 0x3E
|
||||
|
||||
struct uart_;
|
||||
typedef uart_ uart_t;
|
||||
class HardwareSerial : public Stream
|
||||
{
|
||||
protected:
|
||||
volatile uint8_t * const _ubrrh;
|
||||
volatile uint8_t * const _ubrrl;
|
||||
volatile uint8_t * const _ucsra;
|
||||
volatile uint8_t * const _ucsrb;
|
||||
volatile uint8_t * const _ucsrc;
|
||||
volatile uint8_t * const _udr;
|
||||
uart_t* _uart;
|
||||
// Has any byte been written to the UART since begin()
|
||||
bool _written;
|
||||
|
||||
@ -97,18 +76,13 @@ class HardwareSerial : public Stream
|
||||
volatile tx_buffer_index_t _tx_buffer_head;
|
||||
volatile tx_buffer_index_t _tx_buffer_tail;
|
||||
|
||||
// Don't put any members after these buffers, since only the first
|
||||
// 32 bytes of this struct can be accessed quickly using the ldd
|
||||
// instruction.
|
||||
unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE];
|
||||
unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE];
|
||||
|
||||
public:
|
||||
inline HardwareSerial(
|
||||
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
||||
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
||||
volatile uint8_t *ucsrc, volatile uint8_t *udr);
|
||||
void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
|
||||
HardwareSerial() : _uart(0) { }
|
||||
|
||||
void begin(unsigned long baud) { begin(baud, 0); }
|
||||
void begin(unsigned long, uint8_t);
|
||||
void end();
|
||||
virtual int available(void);
|
||||
@ -125,27 +99,10 @@ class HardwareSerial : public Stream
|
||||
operator bool() { return true; }
|
||||
|
||||
// Interrupt handlers - Not intended to be called externally
|
||||
inline void _rx_complete_irq(void);
|
||||
void _rx_complete_irq(char c);
|
||||
void _tx_udr_empty_irq(void);
|
||||
};
|
||||
|
||||
#if defined(UBRRH) || defined(UBRR0H)
|
||||
extern HardwareSerial Serial;
|
||||
#define HAVE_HWSERIAL0
|
||||
#endif
|
||||
#if defined(UBRR1H)
|
||||
extern HardwareSerial Serial1;
|
||||
#define HAVE_HWSERIAL1
|
||||
#endif
|
||||
#if defined(UBRR2H)
|
||||
extern HardwareSerial Serial2;
|
||||
#define HAVE_HWSERIAL2
|
||||
#endif
|
||||
#if defined(UBRR3H)
|
||||
extern HardwareSerial Serial3;
|
||||
#define HAVE_HWSERIAL3
|
||||
#endif
|
||||
|
||||
extern void serialEventRun(void) __attribute__((weak));
|
||||
extern HardwareSerial Serial;
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user