2014-10-29 06:36:47 -07:00
/******************************************************************************
* The MIT License
*
* Copyright ( c ) 2010 Perry Hung .
*
* Permission is hereby granted , free of charge , to any person
* obtaining a copy of this software and associated documentation
* files ( the " Software " ) , to deal in the Software without
* restriction , including without limitation the rights to use , copy ,
* modify , merge , publish , distribute , sublicense , and / or sell copies
* of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND ,
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
* ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @ brief Wirish USB virtual serial port ( SerialUSB ) .
*/
# ifndef _WIRISH_USB_SERIAL_H_
# define _WIRISH_USB_SERIAL_H_
2014-12-03 13:08:49 -08:00
# include "Print.h"
# include "boards.h"
2014-12-28 10:23:44 -08:00
# include "Stream.h"
2014-10-29 06:36:47 -07:00
/**
* @ brief Virtual serial terminal .
*/
2014-12-03 13:08:49 -08:00
class USBSerial : public Stream {
2014-10-29 06:36:47 -07:00
public :
USBSerial ( void ) ;
void begin ( void ) ;
2014-11-21 11:46:57 -08:00
// Roger Clark. Added dummy function so that existing Arduino sketches which specify baud rate will compile.
void begin ( unsigned long ) ;
void begin ( unsigned long , uint8_t ) ;
2014-10-29 06:36:47 -07:00
void end ( void ) ;
2014-12-20 23:08:16 -08:00
operator bool ( ) { return true ; } // Roger Clark. This is needed because in cardinfo.ino it does if (!Serial) . It seems to be a work around for the Leonardo that we needed to implement just to be compliant with the API
2014-12-03 13:08:49 -08:00
virtual int available ( void ) ; // Changed to virtual
2014-10-29 06:36:47 -07:00
uint32 read ( void * buf , uint32 len ) ;
2014-12-03 13:08:49 -08:00
// uint8 read(void);
2014-10-29 06:36:47 -07:00
2014-12-03 13:08:49 -08:00
// 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 ) ;
2014-11-21 11:46:57 -08:00
size_t write ( uint8 ) ;
size_t write ( const char * str ) ;
size_t write ( const void * , uint32 ) ;
2014-10-29 06:36:47 -07:00
uint8 getRTS ( ) ;
uint8 getDTR ( ) ;
uint8 isConnected ( ) ;
uint8 pending ( ) ;
} ;
2015-05-13 03:33:30 -07:00
# ifdef SERIAL_USB
2014-12-04 14:29:11 -08:00
extern USBSerial Serial ;
2014-10-29 06:36:47 -07:00
# endif
# endif