mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge #110
This commit is contained in:
commit
5d7ce9d022
2 changed files with 63 additions and 2 deletions
|
@ -30,6 +30,9 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
UsbDevice *p = NULL;
|
||||
EpInfo *oldep_ptr = NULL;
|
||||
uint8_t num_of_conf; // number of configurations
|
||||
#ifdef PL2303_COMPAT
|
||||
enum pl2303_type pltype = unknown;
|
||||
#endif
|
||||
|
||||
AddressPool &addrPool = pUsb->GetAddressPool();
|
||||
|
||||
|
@ -69,6 +72,18 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if(udd->idVendor != PL_VID && CHECK_PID(udd->idProduct))
|
||||
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||
|
||||
/* determine chip variant */
|
||||
#ifdef PL2303_COMPAT
|
||||
if(udd->bDeviceClass == 0x02 )
|
||||
pltype = type_0;
|
||||
else if(udd->bMaxPacketSize0 == 0x40 )
|
||||
pltype = rev_HX;
|
||||
else if(udd->bDeviceClass == 0x00)
|
||||
pltype = type_1;
|
||||
else if(udd->bDeviceClass == 0xff)
|
||||
pltype = type_1;
|
||||
#endif
|
||||
|
||||
// Save type of PL chip
|
||||
wPLType = udd->bcdDevice;
|
||||
|
||||
|
@ -145,6 +160,28 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
if(rcode)
|
||||
goto FailSetConfDescr;
|
||||
|
||||
#ifdef PL2303_COMPAT
|
||||
/* Shamanic dance - sending Prolific init data as-is */
|
||||
vendorRead( 0x84, 0x84, 0, buf );
|
||||
vendorWrite( 0x04, 0x04, 0 );
|
||||
vendorRead( 0x84, 0x84, 0, buf );
|
||||
vendorRead( 0x83, 0x83, 0, buf );
|
||||
vendorRead( 0x84, 0x84, 0, buf );
|
||||
vendorWrite( 0x04, 0x04, 1 );
|
||||
vendorRead( 0x84, 0x84, 0, buf);
|
||||
vendorRead( 0x83, 0x83, 0, buf);
|
||||
vendorWrite( 0, 0, 1 );
|
||||
vendorWrite( 1, 0, 0 );
|
||||
if( pltype == rev_HX ) {
|
||||
vendorWrite( 2, 0, 0x44 );
|
||||
vendorWrite( 0x06, 0x06, 0 ); // From W7 init
|
||||
}
|
||||
else {
|
||||
vendorWrite( 2, 0, 0x24 );
|
||||
}
|
||||
/* Shamanic dance end */
|
||||
#endif
|
||||
/* Calling post-init callback */
|
||||
rcode = pAsync->OnInit(this);
|
||||
|
||||
if(rcode)
|
||||
|
|
|
@ -19,6 +19,8 @@ e-mail : support@circuitsathome.com
|
|||
|
||||
#include "cdcacm.h"
|
||||
|
||||
//#define PL2303_COMPAT // Uncomment it if you have compatibility problems
|
||||
|
||||
#define PL_VID 0x067B
|
||||
#define CHECK_PID(pid) ( pid != 0x2303 && pid != 0x0609 )
|
||||
|
||||
|
@ -109,8 +111,9 @@ enum tXO_State {
|
|||
|
||||
enum pl2303_type {
|
||||
unknown,
|
||||
type_1, /* don't know the difference between type 0 and */
|
||||
rev_X, /* type 1, until someone from prolific tells us... */
|
||||
type_0, /* don't know the difference between type 0 and */
|
||||
type_1, /* type 1, until someone from prolific tells us... */
|
||||
rev_X,
|
||||
rev_HX, /* HX version of the pl2303 chip */
|
||||
rev_H
|
||||
};
|
||||
|
@ -130,6 +133,27 @@ public:
|
|||
|
||||
//// UsbConfigXtracter implementation
|
||||
//virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
|
||||
|
||||
#ifdef PL2303_COMPAT
|
||||
private:
|
||||
/* Prolific proprietary requests */
|
||||
uint8_t vendorRead( uint8_t val_lo, uint8_t val_hi, uint16_t index, uint8_t* buf );
|
||||
uint8_t vendorWrite( uint8_t val_lo, uint8_t val_hi, uint8_t index );
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef PL2303_COMPAT
|
||||
/* vendor read request */
|
||||
inline uint8_t PL2303::vendorRead( uint8_t val_lo, uint8_t val_hi, uint16_t index, uint8_t* buf )
|
||||
{
|
||||
return( pUsb->ctrlReq(bAddress, 0, VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, val_lo, val_hi, index, 1, 1, buf, NULL ));
|
||||
}
|
||||
|
||||
/* vendor write request */
|
||||
inline uint8_t PL2303::vendorWrite( uint8_t val_lo, uint8_t val_hi, uint8_t index )
|
||||
{
|
||||
return( pUsb->ctrlReq(bAddress, 0, VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, val_lo, val_hi, index, 0, 0, NULL, NULL ));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CDCPROLIFIC_H__
|
||||
|
|
Loading…
Reference in a new issue