mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-11 17:13:56 -03:00
Update to take advantage of the new Stream class in Arduino 0019.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@387 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
2913b74b3a
commit
009ef940c6
@ -150,7 +150,7 @@ void FastSerial::end()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t
|
int
|
||||||
FastSerial::available(void)
|
FastSerial::available(void)
|
||||||
{
|
{
|
||||||
return((RX_BUFFER_SIZE + _rxBuffer.head - _rxBuffer.tail) % RX_BUFFER_SIZE);
|
return((RX_BUFFER_SIZE + _rxBuffer.head - _rxBuffer.tail) % RX_BUFFER_SIZE);
|
||||||
|
@ -45,11 +45,14 @@
|
|||||||
#define FastSerial_h
|
#define FastSerial_h
|
||||||
|
|
||||||
// disable the stock Arduino serial driver
|
// disable the stock Arduino serial driver
|
||||||
|
#ifdef HardwareSerial_h
|
||||||
|
# error Must include FastSerial.h before the Arduino serial driver is defined.
|
||||||
|
#endif
|
||||||
#define HardwareSerial_h
|
#define HardwareSerial_h
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <Print.h>
|
#include <Stream.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -82,7 +85,7 @@ extern class FastSerial Serial2;
|
|||||||
extern class FastSerial Serial3;
|
extern class FastSerial Serial3;
|
||||||
|
|
||||||
|
|
||||||
class FastSerial : public Print {
|
class FastSerial : public Stream {
|
||||||
public:
|
public:
|
||||||
FastSerial(const uint8_t portNumber,
|
FastSerial(const uint8_t portNumber,
|
||||||
volatile uint8_t *ubrrh,
|
volatile uint8_t *ubrrh,
|
||||||
@ -97,12 +100,12 @@ public:
|
|||||||
// Serial API
|
// Serial API
|
||||||
void begin(long baud);
|
void begin(long baud);
|
||||||
void end(void);
|
void end(void);
|
||||||
uint8_t available(void);
|
int available(void);
|
||||||
int read(void);
|
int read(void);
|
||||||
void flush(void);
|
void flush(void);
|
||||||
void write(uint8_t c);
|
void write(uint8_t c);
|
||||||
void write(const uint8_t *buffer, int count);
|
void write(const uint8_t *buffer, int count);
|
||||||
using Print::write;
|
using Stream::write;
|
||||||
|
|
||||||
// stdio extensions
|
// stdio extensions
|
||||||
int printf(const char *fmt, ...);
|
int printf(const char *fmt, ...);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
// Create a FastSerial driver that looks just like the stock Arduino
|
// Create a FastSerial driver that looks just like the stock Arduino
|
||||||
// driver.
|
// driver.
|
||||||
//
|
//
|
||||||
FastSerial Serial;
|
FastSerialPort0(Serial);
|
||||||
|
|
||||||
//
|
//
|
||||||
// To create a driver for a different serial port, on a board that
|
// To create a driver for a different serial port, on a board that
|
||||||
|
Loading…
Reference in New Issue
Block a user