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);
206 ErrorMessage<uint8_t > (PSTR(
"Conf.Val"), conf);
207 ErrorMessage<uint8_t > (PSTR(
"Iface Num"), iface);
208 ErrorMessage<uint8_t > (PSTR(
"Alt.Set"), alt);
215 index = epInterruptInIndex;
218 index = ((pep->
bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
229 PrintEndpointDescriptor(pep);
258 uint16_t baud_value, baud_index = 0;
261 divisor3 = 48000000 / 2 / baud;
264 if ((divisor3 & 0x7) == 7)
267 baud_value = divisor3 >> 3;
270 if (divisor3 == 1) baud_value |= 0xc000;
272 if (divisor3 >= 4) baud_value |= 0x4000;
274 if (divisor3 != 0) baud_value |= 0x8000;
275 if (baud_value == 1) baud_value = 0;
277 static const unsigned char divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3};
278 static const unsigned char divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1};
280 baud_value = divisor3 >> 3;
281 baud_value |= divfrac [divisor3 & 0x7] << 14;
282 baud_index = divindex[divisor3 & 0x7];
285 if (baud_value == 1) baud_value = 0;
287 if (baud_value == 0x4001) baud_value = 1;
291 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);
295 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_MODEM_CTRL, signal & 0xff, signal >> 8, 0, 0, 0, NULL, NULL);
299 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_FLOW_CTRL, xon, xoff, protocol << 8, 0, 0, NULL, NULL);
303 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_DATA, databm & 0xff, databm >> 8, 0, 0, 0, NULL, NULL);
307 return pUsb->
inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
311 return pUsb->
outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr);
315 Notify(PSTR(
"Endpoint descriptor:"), 0x80);
316 Notify(PSTR(
"\r\nLength:\t\t"), 0x80);
317 PrintHex<uint8_t > (ep_ptr->
bLength, 0x80);
318 Notify(PSTR(
"\r\nType:\t\t"), 0x80);
320 Notify(PSTR(
"\r\nAddress:\t"), 0x80);
322 Notify(PSTR(
"\r\nAttributes:\t"), 0x80);
324 Notify(PSTR(
"\r\nMaxPktSize:\t"), 0x80);
326 Notify(PSTR(
"\r\nPoll Intrv:\t"), 0x80);
327 PrintHex<uint8_t > (ep_ptr->
bInterval, 0x80);
328 Notify(PSTR(
"\r\n"), 0x80);