Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxajk committed Mar 4, 2016
1 parent e73a684 commit b85e21c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
11 changes: 5 additions & 6 deletions cdcacm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 5 additions & 6 deletions cdcacm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
21 changes: 14 additions & 7 deletions cdcftdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions cdcftdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


};

Expand Down
40 changes: 20 additions & 20 deletions examples/board_qc/board_qc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b85e21c

Please sign in to comment.