19 const uint8_t FTDI::epDataInIndex = 1;
20 const uint8_t FTDI::epDataOutIndex = 2;
21 const uint8_t FTDI::epInterruptInIndex = 3;
43 uint8_t
FTDI::Init(uint8_t parent, uint8_t port,
bool lowspeed)
47 uint8_t buf[constBufSize];
109 rcode = pUsb->
setAddr( 0, 0, bAddress );
137 goto FailSetDevTblEntry;
141 for (uint8_t i=0; i<num_of_conf; i++)
147 rcode = pUsb->
getConfDescr(bAddress, 0, i, &confDescrParser);
164 rcode = pUsb->
setConf(bAddress, 0, bConfNum);
167 goto FailSetConfDescr;
169 rcode = pAsync->
OnInit(
this);
208 Serial.println(rcode, HEX);
216 ErrorMessage<uint8_t>(PSTR(
"Conf.Val"), conf);
217 ErrorMessage<uint8_t>(PSTR(
"Iface Num"),iface);
218 ErrorMessage<uint8_t>(PSTR(
"Alt.Set"), alt);
225 index = epInterruptInIndex;
228 index = ((pep->
bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
239 PrintEndpointDescriptor(pep);
271 uint16_t baud_value, baud_index = 0;
274 divisor3 = 48000000 / 2 / baud;
278 if ((divisor3 & 0x7) == 7)
281 baud_value = divisor3 >> 3;
284 if (divisor3 == 1) baud_value |= 0xc000;
else
285 if (divisor3 >= 4) baud_value |= 0x4000;
else
286 if (divisor3 != 0) baud_value |= 0x8000;
287 if (baud_value == 1) baud_value = 0;
291 static const unsigned char divfrac [8] = { 0, 3, 2, 0, 1, 1, 2, 3 };
292 static const unsigned char divindex[8] = { 0, 0, 0, 1, 0, 1, 1, 1 };
294 baud_value = divisor3 >> 3;
295 baud_value |= divfrac [divisor3 & 0x7] << 14;
296 baud_index = divindex[divisor3 & 0x7];
299 if (baud_value == 1) baud_value = 0;
else
300 if (baud_value == 0x4001) baud_value = 1;
304 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_BAUD_RATE, baud_value & 0xff, baud_value >> 8, baud_index, 0, 0, NULL, NULL );
309 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_MODEM_CTRL, signal & 0xff, signal >> 8, 0, 0, 0, NULL, NULL);
314 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_FLOW_CTRL, xon, xoff, protocol << 8, 0, 0, NULL, NULL);
319 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_DATA, databm & 0xff, databm >> 8, 0, 0, 0, NULL, NULL);
324 return pUsb->
inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
329 return pUsb->
outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr);
334 Notify(PSTR(
"Endpoint descriptor:"));
335 Notify(PSTR(
"\r\nLength:\t\t"));
336 PrintHex<uint8_t>(ep_ptr->
bLength);
337 Notify(PSTR(
"\r\nType:\t\t"));
339 Notify(PSTR(
"\r\nAddress:\t"));
341 Notify(PSTR(
"\r\nAttributes:\t"));
343 Notify(PSTR(
"\r\nMaxPktSize:\t"));
345 Notify(PSTR(
"\r\nPoll Intrv:\t"));