COSA
An Object-Oriented Platform for Arduino Programming
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
CDC.hh
Go to the documentation of this file.
1
21
#ifndef COSA_CDC_HH
22
#define COSA_CDC_HH
23
24
#include "
Cosa/Types.h
"
25
#include "
Cosa/Power.hh
"
26
#include "
Cosa/IOStream.hh
"
27
28
#if defined(USBCON)
29
30
class
CDC :
public
IOStream::Device
{
31
public
:
33
static
const
uint8_t BUFFER_MAX = 64;
34
39
enum
{
40
DATA5 = 0,
41
DATA6 = _BV(
UCSZ00
),
42
DATA7 = _BV(
UCSZ01
),
43
DATA8 = _BV(
UCSZ01
) | _BV(
UCSZ00
),
44
DATA9 = _BV(
UCSZ02
) | _BV(
UCSZ01
) | _BV(
UCSZ00
),
45
NO_PARITY = 0,
46
EVEN_PARITY = _BV(
UPM01
),
47
ODD_PARITY = _BV(
UPM01
) | _BV(
UPM00
),
48
STOP1 = 0,
49
STOP2 = _BV(
USBS0
)
50
} __attribute__((packed));
51
56
CDC(
IOStream::Device
*
ibuf
) :
57
IOStream
::Device(),
58
m_ibuf(ibuf)
59
{}
60
66
virtual
int
available
()
67
{
68
return
(m_ibuf->available());
69
}
70
72
using
IOStream::Device::write
;
73
81
virtual
int
write
(
const
void
* buf,
size_t
size);
82
90
virtual
int
peekchar
()
91
{
92
return
(m_ibuf->peekchar());
93
}
94
101
virtual
int
peekchar
(
char
c)
102
{
103
return
(m_ibuf->peekchar(c));
104
}
105
113
virtual
int
getchar
()
114
{
115
return
(m_ibuf->getchar());
116
}
117
123
virtual
int
flush
();
124
129
virtual
void
empty
();
130
138
bool
begin(uint32_t baudrate = 9600, uint8_t format = DATA8 + STOP2 + NO_PARITY);
139
144
bool
end()
145
{
146
Power::usb_disable();
147
return
(
true
);
148
}
149
150
protected
:
152
IOStream::Device
* m_ibuf;
153
157
void
accept();
158
160
friend
void
USB_GEN_vect
(
void
);
161
};
162
166
extern
CDC cdc;
167
#endif
168
#endif
Types.h
IOStream
Definition:
IOStream.hh:30
IOStream::Device::write
virtual int write(const void *buf, size_t size)
Definition:
IOStream_Device.cpp:65
UPM00
#define UPM00
Definition:
Leonardo.hh:292
IOStream::Device::empty
virtual void empty()
Definition:
IOStream_Device.cpp:175
IOStream.hh
USBS0
#define USBS0
Definition:
Leonardo.hh:294
Power.hh
UCSZ00
#define UCSZ00
Definition:
Leonardo.hh:289
UCSZ01
#define UCSZ01
Definition:
Leonardo.hh:290
UCSZ02
#define UCSZ02
Definition:
Leonardo.hh:291
UPM01
#define UPM01
Definition:
Leonardo.hh:293
USB_GEN_vect
void USB_GEN_vect(void)
IOStream::Device::flush
virtual int flush()
Definition:
IOStream_Device.cpp:169
IOStream::Device::available
virtual int available()
Definition:
IOStream_Device.cpp:24
IOStream::Device
Definition:
IOStream.hh:63
IOStream::Device::getchar
virtual int getchar()
Definition:
IOStream_Device.cpp:112
IOStream::Device::peekchar
virtual int peekchar()
Definition:
IOStream_Device.cpp:99
ibuf
static IOBuffer< UART::RX_BUFFER_MAX > ibuf
Definition:
UART.cpp:37
cores
cosa
Cosa
CDC.hh
Generated on Thu Aug 31 2017 17:02:02 for COSA by
1.8.11