USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cdcprolific.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
8 the GPL2 ("Copyleft").
9 
10 Contact information
11 -------------------
12 
13 Circuits At Home, LTD
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
16  */
17 #if !defined(__CDCPROLIFIC_H__)
18 #define __CDCPROLIFIC_H__
19 
20 #include "cdcacm.h"
21 
22 #define PL_VID 0x067B
23 #define PL_PID ( 0x2303 || 0x0609 )
24 
25 //#define PL_PID 0x0609
26 
27 #define PROLIFIC_REV_H 0x0202
28 #define PROLIFIC_REV_X 0x0300
29 #define PROLIFIC_REV_HX_CHIP_D 0x0400
30 #define PROLIFIC_REV_1 0x0001
31 
32 #define kXOnChar '\x11'
33 #define kXOffChar '\x13'
34 
35 #define SPECIAL_SHIFT (5)
36 #define SPECIAL_MASK ((1<<SPECIAL_SHIFT) - 1)
37 #define STATE_ALL ( PD_RS232_S_MASK | PD_S_MASK )
38 #define FLOW_RX_AUTO ( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO )
39 #define FLOW_TX_AUTO ( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD )
40 #define CAN_BE_AUTO ( FLOW_RX_AUTO | FLOW_TX_AUTO )
41 #define CAN_NOTIFY ( PD_RS232_N_MASK )
42 #define EXTERNAL_MASK ( PD_S_MASK | (PD_RS232_S_MASK & ~PD_RS232_S_LOOP) )
43 #define INTERNAL_DELAY ( PD_RS232_S_LOOP )
44 #define DEFAULT_AUTO ( PD_RS232_A_DTR | PD_RS232_A_RFR | PD_RS232_A_CTS | PD_RS232_A_DSR )
45 #define DEFAULT_NOTIFY 0x00
46 #define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO )
47 
48 #define CONTINUE_SEND 1
49 #define PAUSE_SEND 2
50 
51 #define kRxAutoFlow ((UInt32)( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO ))
52 #define kTxAutoFlow ((UInt32)( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD ))
53 #define kControl_StateMask ((UInt32)( PD_RS232_S_CTS | PD_RS232_S_DSR | PD_RS232_S_CAR | PD_RS232_S_RI ))
54 #define kRxQueueState ((UInt32)( PD_S_RXQ_EMPTY | PD_S_RXQ_LOW_WATER | PD_S_RXQ_HIGH_WATER | PD_S_RXQ_FULL ))
55 #define kTxQueueState ((UInt32)( PD_S_TXQ_EMPTY | PD_S_TXQ_LOW_WATER | PD_S_TXQ_HIGH_WATER | PD_S_TXQ_FULL ))
56 
57 #define kCONTROL_DTR 0x01
58 #define kCONTROL_RTS 0x02
59 
60 enum tXO_State {
61  kXOnSent = -2,
62  kXOffSent = -1,
63  kXO_Idle = 0,
66 };
67 
68 #define kStateTransientMask 0x74
69 #define kBreakError 0x04
70 #define kFrameError 0x10
71 #define kParityError 0x20
72 #define kOverrunError 0x40
73 
74 #define kCTS 0x80
75 #define kDSR 0x02
76 #define kRI 0x08
77 #define kDCD 0x01
78 #define kHandshakeInMask ((UInt32)( PD_RS232_S_CTS | PD_RS232_S_DSR | PD_RS232_S_CAR | PD_RS232_S_RI ))
79 
80 #define VENDOR_WRITE_REQUEST_TYPE 0x40
81 #define VENDOR_WRITE_REQUEST 0x01
82 
83 #define VENDOR_READ_REQUEST_TYPE 0xc0
84 #define VENDOR_READ_REQUEST 0x01
85 
86 // Device Configuration Registers (DCR0, DCR1, DCR2)
87 #define SET_DCR0 0x00
88 #define GET_DCR0 0x80
89 #define DCR0_INIT 0x01
90 #define DCR0_INIT_H 0x41
91 #define DCR0_INIT_X 0x61
92 
93 #define SET_DCR1 0x01
94 #define GET_DCR1 0x81
95 #define DCR1_INIT_H 0x80
96 #define DCR1_INIT_X 0x00
97 
98 #define SET_DCR2 0x02
99 #define GET_DCR2 0x82
100 #define DCR2_INIT_H 0x24
101 #define DCR2_INIT_X 0x44
102 
103 // On-chip Data Buffers:
104 #define RESET_DOWNSTREAM_DATA_PIPE 0x08
105 #define RESET_UPSTREAM_DATA_PIPE 0x09
106 
109  type_1, /* don't know the difference between type 0 and */
110  rev_X, /* type 1, until someone from prolific tells us... */
111  rev_HX, /* HX version of the pl2303 chip */
113 };
114 
115 
116 #define PL_MAX_ENDPOINTS 4
117 
118 class PL2303 : public ACM {
119  uint16_t wPLType; // Type of chip
120 
121 public:
122  PL2303(USB *pusb, CDCAsyncOper *pasync);
123 
124  // USBDeviceConfig implementation
125  virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
126  //virtual uint8_t Release();
127  //virtual uint8_t Poll();
128  //virtual uint8_t GetAddress() { return bAddress; };
129 
131  //virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
132 };
133 
134 #endif // __CDCPROLIFIC_H__
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: cdcprolific.cpp:24
PL2303(USB *pusb, CDCAsyncOper *pasync)
Definition: cdcprolific.cpp:19
tXO_State
Definition: cdcprolific.h:60
pl2303_type
Definition: cdcprolific.h:107
Definition: UsbCore.h:176
Definition: cdcacm.h:138