19 const uint8_t FTDI::epDataInIndex = 1;
20 const uint8_t FTDI::epDataOutIndex = 2;
21 const uint8_t FTDI::epInterruptInIndex = 3;
41 uint8_t
FTDI::Init(uint8_t parent, uint8_t port,
bool lowspeed) {
44 uint8_t buf[constBufSize];
105 rcode = pUsb->
setAddr(0, 0, bAddress);
132 goto FailSetDevTblEntry;
136 for (uint8_t i = 0; i < num_of_conf; i++) {
143 goto FailGetConfDescr;
145 rcode = pUsb->
getConfDescr(bAddress, 0, i, &confDescrParser);
148 goto FailGetConfDescr;
165 rcode = pUsb->
setConf(bAddress, 0, bConfNum);
168 goto FailSetConfDescr;
170 rcode = pAsync->
OnInit(
this);
181 #ifdef DEBUG_USB_HOST
187 #ifdef DEBUG_USB_HOST
193 #ifdef DEBUG_USB_HOST
199 #ifdef DEBUG_USB_HOST
205 #ifdef DEBUG_USB_HOST
210 #ifdef DEBUG_USB_HOST
218 ErrorMessage<uint8_t > (PSTR(
"Conf.Val"), conf);
219 ErrorMessage<uint8_t > (PSTR(
"Iface Num"), iface);
220 ErrorMessage<uint8_t > (PSTR(
"Alt.Set"), alt);
227 index = epInterruptInIndex;
230 index = ((pep->
bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
241 PrintEndpointDescriptor(pep);
270 uint16_t baud_value, baud_index = 0;
273 divisor3 = 48000000 / 2 / baud;
276 if ((divisor3 & 0x7) == 7)
279 baud_value = divisor3 >> 3;
282 if (divisor3 == 1) baud_value |= 0xc000;
284 if (divisor3 >= 4) baud_value |= 0x4000;
286 if (divisor3 != 0) baud_value |= 0x8000;
287 if (baud_value == 1) baud_value = 0;
289 static const unsigned char divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3};
290 static const unsigned char divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1};
292 baud_value = divisor3 >> 3;
293 baud_value |= divfrac [divisor3 & 0x7] << 14;
294 baud_index = divindex[divisor3 & 0x7];
297 if (baud_value == 1) baud_value = 0;
299 if (baud_value == 0x4001) baud_value = 1;
303 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);
307 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_MODEM_CTRL, signal & 0xff, signal >> 8, 0, 0, 0, NULL, NULL);
311 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_FLOW_CTRL, xon, xoff, protocol << 8, 0, 0, NULL, NULL);
315 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_DATA, databm & 0xff, databm >> 8, 0, 0, 0, NULL, NULL);
319 return pUsb->
inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
323 return pUsb->
outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr);
327 Notify(PSTR(
"Endpoint descriptor:"), 0x80);
328 Notify(PSTR(
"\r\nLength:\t\t"), 0x80);
329 PrintHex<uint8_t > (ep_ptr->
bLength, 0x80);
330 Notify(PSTR(
"\r\nType:\t\t"), 0x80);
332 Notify(PSTR(
"\r\nAddress:\t"), 0x80);
334 Notify(PSTR(
"\r\nAttributes:\t"), 0x80);
336 Notify(PSTR(
"\r\nMaxPktSize:\t"), 0x80);
338 Notify(PSTR(
"\r\nPoll Intrv:\t"), 0x80);
339 PrintHex<uint8_t > (ep_ptr->
bInterval, 0x80);
340 Notify(PSTR(
"\r\n"), 0x80);