JM9 XRCU Board 0.1.3a
Libraries API Reference
Loading...
Searching...
No Matches
USBSerial.h
1/*
2 Copyright (c) 2015 Arduino LLC. All right reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 See the GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#ifndef _USBSERIAL_H_
20#define _USBSERIAL_H_
21
22#if defined (USBCON) && defined(USBD_USE_CDC)
23#include "Stream.h"
24#include "usbd_core.h"
25
26//================================================================================
27// Serial over CDC
28class USBSerial : public Stream {
29 public:
30 void begin(void);
31 void begin(uint32_t);
32 void begin(uint32_t, uint8_t);
33 void end(void);
34
35 virtual int available(void);
36 virtual int availableForWrite(void);
37 virtual int peek(void);
38 virtual int read(void);
39 virtual size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
40 virtual size_t readBytesUntil(char terminator, char *buffer, size_t length); // as readBytes with terminator character
41 virtual void flush(void);
42 virtual size_t write(uint8_t);
43 virtual size_t write(const uint8_t *buffer, size_t size);
44 using Print::write; // pull in write(str) from Print
45 operator bool(void);
46
47 // These return the settings specified by the USB host for the
48 // serial port. These aren't really used, but are offered here
49 // in case a sketch wants to act on these settings.
50 uint32_t baud();
51 uint8_t stopbits();
52 uint8_t paritytype();
53 uint8_t numbits();
54
55 void dtr(bool enable);
56 bool dtr();
57 bool rts();
58 enum {
59 ONE_STOP_BIT = 0,
60 ONE_AND_HALF_STOP_BIT = 1,
61 TWO_STOP_BITS = 2,
62 };
63 enum {
64 NO_PARITY = 0,
65 ODD_PARITY = 1,
66 EVEN_PARITY = 2,
67 MARK_PARITY = 3,
68 SPACE_PARITY = 4,
69 };
70};
71
72extern USBSerial SerialUSB;
73#endif /* USBCON */
74#endif /* _USBSERIAL_H_ */
Definition Stream.h:49