-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathDigiCDC.h
More file actions
63 lines (44 loc) · 1.29 KB
/
DigiCDC.h
File metadata and controls
63 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
CDC Arduino Library by Ihsan Kehribar (kehribar.me)
and Digistump LLC (digistump.com)
- all changes made under the same license as V-USB
*/
#ifndef __DigiCDC_h__
#define __DigiCDC_h__
#include "usbdrv.h"
#include "Stream.h"
#include "ringBuffer.h"
#define HW_CDC_TX_BUF_SIZE 32
#define HW_CDC_RX_BUF_SIZE 32
#define HW_CDC_BULK_OUT_SIZE 8
#define HW_CDC_BULK_IN_SIZE 8
/* library functions and variables start */
static uint8_t tmp[HW_CDC_BULK_IN_SIZE];
static uint8_t index = 0;
static RingBuffer_t rxBuf;
static uint8_t rxBuf_Data[HW_CDC_RX_BUF_SIZE];
static RingBuffer_t txBuf;
static uint8_t txBuf_Data[HW_CDC_TX_BUF_SIZE];
class DigiCDCDevice : public Stream {
public:
DigiCDCDevice();
void begin(), begin(unsigned long x);
void end();
void refresh();
void task();
void delay(long milli);
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual bool getDTR(void);
virtual bool getRTS(void);
virtual void flush(void);
virtual size_t write(uint8_t);
using Print::write;
operator bool();
private:
void usbBegin();
void usbPollWrapper();
};
extern DigiCDCDevice SerialUSB;
#endif // __DigiCDC_h__