From b85e21cf98ea63a1da409fc4d8389bab71cc1c5d Mon Sep 17 00:00:00 2001 From: "Andrew J. Kroll" Date: Fri, 4 Mar 2016 16:00:55 -0500 Subject: [PATCH] fixes --- cdcacm.cpp | 11 +++++----- cdcacm.h | 11 +++++----- cdcftdi.cpp | 21 ++++++++++++------ cdcftdi.h | 4 ++++ examples/board_qc/board_qc.ino | 40 +++++++++++++++++----------------- 5 files changed, 48 insertions(+), 39 deletions(-) diff --git a/cdcacm.cpp b/cdcacm.cpp index 2cd2c9a82..cf180b483 100644 --- a/cdcacm.cpp +++ b/cdcacm.cpp @@ -269,12 +269,11 @@ uint8_t ACM::Release() { } uint8_t ACM::Poll() { - uint8_t rcode = 0; - - if(!bPollEnable) - return 0; - - return rcode; + //uint8_t rcode = 0; + //if(!bPollEnable) + // return 0; + //return rcode; + return 0; } uint8_t ACM::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) { diff --git a/cdcacm.h b/cdcacm.h index 8372f56b5..dd248100a 100644 --- a/cdcacm.h +++ b/cdcacm.h @@ -162,10 +162,6 @@ typedef struct { class ACM : public USBDeviceConfig, public UsbConfigXtracter { protected: - static const uint8_t epDataInIndex; // DataIn endpoint index - static const uint8_t epDataOutIndex; // DataOUT endpoint index - static const uint8_t epInterruptInIndex; // InterruptIN endpoint index - USB *pUsb; CDCAsyncOper *pAsync; uint8_t bAddress; @@ -178,11 +174,14 @@ class ACM : public USBDeviceConfig, public UsbConfigXtracter { volatile bool ready; //device ready indicator tty_features _enhanced_status; // current status - EpInfo epInfo[ACM_MAX_ENDPOINTS]; - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); public: + static const uint8_t epDataInIndex; // DataIn endpoint index + static const uint8_t epDataOutIndex; // DataOUT endpoint index + static const uint8_t epInterruptInIndex; // InterruptIN endpoint index + EpInfo epInfo[ACM_MAX_ENDPOINTS]; + ACM(USB *pusb, CDCAsyncOper *pasync); uint8_t SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); diff --git a/cdcftdi.cpp b/cdcftdi.cpp index 80d21d16e..bc53127b5 100644 --- a/cdcftdi.cpp +++ b/cdcftdi.cpp @@ -51,15 +51,17 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) { USBTRACE("FTDI Init\r\n"); - if(bAddress) + if(bAddress) { + USBTRACE("FTDI CLASS IN USE??\r\n"); return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - + } // Get pointer to pseudo device with address 0 assigned p = addrPool.GetUsbDevicePtr(0); - if(!p) + if(!p) { + USBTRACE("FTDI NO ADDRESS??\r\n"); return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - + } if(!p->epinfo) { USBTRACE("epinfo\r\n"); return USB_ERROR_EPINFO_IS_NULL; @@ -79,11 +81,16 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) { // Restore p->epinfo p->epinfo = oldep_ptr; - if(rcode) + if(rcode) { + goto FailGetDevDescr; - if(udd->idVendor != FTDI_VID || udd->idProduct != FTDI_PID) + } + if(udd->idVendor != FTDI_VID && udd->idProduct != FTDI_PID) { + USBTRACE("FTDI NO SUPPORT??\r\n"); + Serial.println(udd->idVendor, HEX); + Serial.println(udd->idProduct, HEX); return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - +} // Save type of FTDI chip wFTDIType = udd->bcdDevice; diff --git a/cdcftdi.h b/cdcftdi.h index 5a133241a..a9b0e950e 100644 --- a/cdcftdi.h +++ b/cdcftdi.h @@ -137,6 +137,10 @@ class FTDI : public USBDeviceConfig, public UsbConfigXtracter { virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { return (vid == FTDI_VID && pid == FTDI_PID); } + virtual bool isReady() { + return bPollEnable; + }; + }; diff --git a/examples/board_qc/board_qc.ino b/examples/board_qc/board_qc.ino index ddd1c5a60..34fc6592d 100644 --- a/examples/board_qc/board_qc.ino +++ b/examples/board_qc/board_qc.ino @@ -80,26 +80,26 @@ void setup() { /* GPIO test */ /* in order to simplify board layout, GPIN pins on text fixture are connected to GPOUT */ /* in reverse order, i.e, GPIN0 is connected to GPOUT7, GPIN1 to GPOUT6, etc. */ - { - uint8_t tmpbyte; - E_Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"), 0x80); - for(uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) { - Usb.gpioWr(sample_gpio); - tmpbyte = Usb.gpioRd(); - /* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */ - tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; - if(sample_gpio != tmpbyte) { - E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80); - print_hex(sample_gpio, 8); - E_Notify(PSTR(" Value read: "), 0x80); - print_hex(tmpbyte, 8); - E_Notify(PSTR(" "), 0x80); - press_any_key(); - break; - }//if( sample_gpio != tmpbyte... - }//for( uint8_t sample_gpio... - E_Notify(PSTR("\r\nGPIO test passed."), 0x80); - }//GPIO test + //{ + // uint8_t tmpbyte; + // E_Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"), 0x80); + // for(uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) { + // Usb.gpioWr(sample_gpio); + // tmpbyte = Usb.gpioRd(); + // /* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */ + // tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; + // if(sample_gpio != tmpbyte) { + // E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80); + // print_hex(sample_gpio, 8); + // E_Notify(PSTR(" Value read: "), 0x80); + // print_hex(tmpbyte, 8); + // E_Notify(PSTR(" "), 0x80); + // press_any_key(); + // break; + // }//if( sample_gpio != tmpbyte... + // }//for( uint8_t sample_gpio... + // E_Notify(PSTR("\r\nGPIO test passed."), 0x80); + //}//GPIO test /* PLL test. Stops/starts MAX3421E oscillator several times */ { E_Notify(PSTR("\r\nPLL test. 100 chip resets will be performed"), 0x80);