This commit is contained in:
Andrew J. Kroll 2016-03-04 16:00:55 -05:00
parent e73a684b46
commit b85e21cf98
5 changed files with 48 additions and 39 deletions

View file

@ -269,12 +269,11 @@ uint8_t ACM::Release() {
} }
uint8_t ACM::Poll() { uint8_t ACM::Poll() {
uint8_t rcode = 0; //uint8_t rcode = 0;
//if(!bPollEnable)
if(!bPollEnable) // return 0;
return 0; //return rcode;
return 0;
return rcode;
} }
uint8_t ACM::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) { uint8_t ACM::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) {

View file

@ -162,10 +162,6 @@ typedef struct {
class ACM : public USBDeviceConfig, public UsbConfigXtracter { class ACM : public USBDeviceConfig, public UsbConfigXtracter {
protected: 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; USB *pUsb;
CDCAsyncOper *pAsync; CDCAsyncOper *pAsync;
uint8_t bAddress; uint8_t bAddress;
@ -178,11 +174,14 @@ protected:
volatile bool ready; //device ready indicator volatile bool ready; //device ready indicator
tty_features _enhanced_status; // current status tty_features _enhanced_status; // current status
EpInfo epInfo[ACM_MAX_ENDPOINTS];
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
public: 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); ACM(USB *pusb, CDCAsyncOper *pasync);
uint8_t SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); uint8_t SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr);

View file

@ -51,15 +51,17 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
USBTRACE("FTDI Init\r\n"); USBTRACE("FTDI Init\r\n");
if(bAddress) if(bAddress) {
USBTRACE("FTDI CLASS IN USE??\r\n");
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
}
// Get pointer to pseudo device with address 0 assigned // Get pointer to pseudo device with address 0 assigned
p = addrPool.GetUsbDevicePtr(0); p = addrPool.GetUsbDevicePtr(0);
if(!p) if(!p) {
USBTRACE("FTDI NO ADDRESS??\r\n");
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
}
if(!p->epinfo) { if(!p->epinfo) {
USBTRACE("epinfo\r\n"); USBTRACE("epinfo\r\n");
return USB_ERROR_EPINFO_IS_NULL; 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 // Restore p->epinfo
p->epinfo = oldep_ptr; p->epinfo = oldep_ptr;
if(rcode) if(rcode) {
goto FailGetDevDescr; 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; return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
}
// Save type of FTDI chip // Save type of FTDI chip
wFTDIType = udd->bcdDevice; wFTDIType = udd->bcdDevice;

View file

@ -137,6 +137,10 @@ public:
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
return (vid == FTDI_VID && pid == FTDI_PID); return (vid == FTDI_VID && pid == FTDI_PID);
} }
virtual bool isReady() {
return bPollEnable;
};
}; };

View file

@ -80,26 +80,26 @@ void setup() {
/* GPIO test */ /* GPIO test */
/* in order to simplify board layout, GPIN pins on text fixture are connected to GPOUT */ /* 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. */ /* in reverse order, i.e, GPIN0 is connected to GPOUT7, GPIN1 to GPOUT6, etc. */
{ //{
uint8_t tmpbyte; // uint8_t tmpbyte;
E_Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"), 0x80); // 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++) { // for(uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) {
Usb.gpioWr(sample_gpio); // Usb.gpioWr(sample_gpio);
tmpbyte = Usb.gpioRd(); // tmpbyte = Usb.gpioRd();
/* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */ // /* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */
tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; // tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
if(sample_gpio != tmpbyte) { // if(sample_gpio != tmpbyte) {
E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80); // E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80);
print_hex(sample_gpio, 8); // print_hex(sample_gpio, 8);
E_Notify(PSTR(" Value read: "), 0x80); // E_Notify(PSTR(" Value read: "), 0x80);
print_hex(tmpbyte, 8); // print_hex(tmpbyte, 8);
E_Notify(PSTR(" "), 0x80); // E_Notify(PSTR(" "), 0x80);
press_any_key(); // press_any_key();
break; // break;
}//if( sample_gpio != tmpbyte... // }//if( sample_gpio != tmpbyte...
}//for( uint8_t sample_gpio... // }//for( uint8_t sample_gpio...
E_Notify(PSTR("\r\nGPIO test passed."), 0x80); // E_Notify(PSTR("\r\nGPIO test passed."), 0x80);
}//GPIO test //}//GPIO test
/* PLL test. Stops/starts MAX3421E oscillator several times */ /* PLL test. Stops/starts MAX3421E oscillator several times */
{ {
E_Notify(PSTR("\r\nPLL test. 100 chip resets will be performed"), 0x80); E_Notify(PSTR("\r\nPLL test. 100 chip resets will be performed"), 0x80);