Partially complete work to bring SerialUSB to Arduino 1.0 API. Still need to write code for SerialUSB.flash and SerialUSB.peek
This commit is contained in:
parent
79668ed667
commit
e0179c57fa
|
@ -152,7 +152,7 @@ int HardwareSerial::available(void) {
|
||||||
|
|
||||||
int HardwareSerial::peek(void)
|
int HardwareSerial::peek(void)
|
||||||
{
|
{
|
||||||
return usart_getc(this->usart_device);
|
return usart_peek(this->usart_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
int HardwareSerial::availableForWrite(void)
|
int HardwareSerial::availableForWrite(void)
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
|
|
||||||
/* Set up/tear down */
|
/* Set up/tear down */
|
||||||
void begin(uint32 baud);
|
void begin(uint32 baud);
|
||||||
void end();
|
void end();
|
||||||
virtual int available(void);
|
virtual int available(void);
|
||||||
virtual int peek(void);
|
virtual int peek(void);
|
||||||
virtual int read(void);
|
virtual int read(void);
|
||||||
|
|
|
@ -127,10 +127,22 @@ size_t n = 0;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 USBSerial::available(void) {
|
int USBSerial::available(void) {
|
||||||
return usb_cdcacm_data_available();
|
return usb_cdcacm_data_available();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int USBSerial::peek(void)
|
||||||
|
{
|
||||||
|
#warning "TO DO!"
|
||||||
|
uint8 b;
|
||||||
|
return usb_cdcacm_peek(&b,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void USBSerial::flush(void)
|
||||||
|
{
|
||||||
|
#warning "TO DO!"
|
||||||
|
}
|
||||||
|
|
||||||
uint32 USBSerial::read(void *buf, uint32 len) {
|
uint32 USBSerial::read(void *buf, uint32 len) {
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -145,7 +157,7 @@ uint32 USBSerial::read(void *buf, uint32 len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Blocks forever until 1 byte is received */
|
/* Blocks forever until 1 byte is received */
|
||||||
uint8 USBSerial::read(void) {
|
int USBSerial::read(void) {
|
||||||
uint8 b;
|
uint8 b;
|
||||||
this->read(&b, 1);
|
this->read(&b, 1);
|
||||||
return b;
|
return b;
|
||||||
|
|
|
@ -31,13 +31,14 @@
|
||||||
#ifndef _WIRISH_USB_SERIAL_H_
|
#ifndef _WIRISH_USB_SERIAL_H_
|
||||||
#define _WIRISH_USB_SERIAL_H_
|
#define _WIRISH_USB_SERIAL_H_
|
||||||
|
|
||||||
#include <Print.h>
|
#include "Print.h"
|
||||||
#include <boards.h>
|
#include "boards.h"
|
||||||
|
#include "stream.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Virtual serial terminal.
|
* @brief Virtual serial terminal.
|
||||||
*/
|
*/
|
||||||
class USBSerial : public Print {
|
class USBSerial : public Stream {
|
||||||
public:
|
public:
|
||||||
USBSerial(void);
|
USBSerial(void);
|
||||||
|
|
||||||
|
@ -46,14 +47,20 @@ public:
|
||||||
// Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile.
|
// Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile.
|
||||||
void begin(unsigned long);
|
void begin(unsigned long);
|
||||||
void begin(unsigned long, uint8_t);
|
void begin(unsigned long, uint8_t);
|
||||||
|
|
||||||
void end(void);
|
void end(void);
|
||||||
|
|
||||||
uint32 available(void);
|
virtual int available(void);// Changed to virtual
|
||||||
|
|
||||||
uint32 read(void *buf, uint32 len);
|
uint32 read(void *buf, uint32 len);
|
||||||
uint8 read(void);
|
// uint8 read(void);
|
||||||
|
|
||||||
|
// Roger Clark. added functions to support Arduino 1.0 API
|
||||||
|
virtual int peek(void);
|
||||||
|
virtual int read(void);
|
||||||
|
int availableForWrite(void);
|
||||||
|
virtual void flush(void);
|
||||||
|
|
||||||
|
|
||||||
size_t write(uint8);
|
size_t write(uint8);
|
||||||
size_t write(const char *str);
|
size_t write(const char *str);
|
||||||
size_t write(const void*, uint32);
|
size_t write(const void*, uint32);
|
||||||
|
|
Loading…
Reference in New Issue