Merge pull request #195 from romerod/master

Add possibility to set a custom FTDI PID
This commit is contained in:
Kristian Sloth Lauszus 2015-12-29 23:46:49 +01:00
commit f90ba2c16d
2 changed files with 14 additions and 4 deletions

View file

@ -20,12 +20,13 @@ const uint8_t FTDI::epDataInIndex = 1;
const uint8_t FTDI::epDataOutIndex = 2;
const uint8_t FTDI::epInterruptInIndex = 3;
FTDI::FTDI(USB *p, FTDIAsyncOper *pasync) :
FTDI::FTDI(USB *p, FTDIAsyncOper *pasync, uint16_t idProduct) :
pAsync(pasync),
pUsb(p),
bAddress(0),
bNumEP(1),
wFTDIType(0) {
wFTDIType(0),
wIdProduct(idProduct) {
for(uint8_t i = 0; i < FTDI_MAX_ENDPOINTS; i++) {
epInfo[i].epAddr = 0;
epInfo[i].maxPktSize = (i) ? 0 : 8;
@ -82,8 +83,16 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
if(rcode)
goto FailGetDevDescr;
if(udd->idVendor != FTDI_VID || udd->idProduct != FTDI_PID)
if(udd->idVendor != FTDI_VID || udd->idProduct != wIdProduct)
{
USBTRACE("FTDI Init: Product not supported\r\n");
USBTRACE2("Expected VID:", FTDI_VID);
USBTRACE2("Found VID:", udd->idVendor);
USBTRACE2("Expected PID:", wIdProduct);
USBTRACE2("Found PID:", udd->idProduct);
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
}
// Save type of FTDI chip
wFTDIType = udd->bcdDevice;

View file

@ -107,13 +107,14 @@ class FTDI : public USBDeviceConfig, public UsbConfigXtracter {
uint32_t qNextPollTime; // next poll time
bool bPollEnable; // poll enable flag
uint16_t wFTDIType; // Type of FTDI chip
uint16_t wIdProduct; // expected PID
EpInfo epInfo[FTDI_MAX_ENDPOINTS];
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
public:
FTDI(USB *pusb, FTDIAsyncOper *pasync);
FTDI(USB *pusb, FTDIAsyncOper *pasync, uint16_t idProduct = FTDI_PID);
uint8_t SetBaudRate(uint32_t baud);
uint8_t SetModemControl(uint16_t control);