19 const uint8_t FTDI::epDataInIndex = 1;
20 const uint8_t FTDI::epDataOutIndex = 2;
21 const uint8_t FTDI::epInterruptInIndex = 3;
29 wIdProduct(idProduct) {
41 uint8_t
FTDI::Init(uint8_t parent, uint8_t port,
bool lowspeed) {
44 uint8_t buf[constBufSize];
90 USBTRACE(
"FTDI Init: Product not supported\r\n");
112 if(epInfo[0].maxPktSize == 0) epInfo[0].
maxPktSize = 64;
115 rcode = pUsb->
setAddr(0, 0, bAddress);
142 goto FailSetDevTblEntry;
146 for(uint8_t i = 0; i < num_of_conf; i++) {
155 rcode = pUsb->
getConfDescr(bAddress, 0, i, &confDescrParser);
158 goto FailGetConfDescr;
175 rcode = pUsb->
setConf(bAddress, 0, bConfNum);
178 goto FailSetConfDescr;
186 rcode = pAsync->
OnInit(
this);
197 #ifdef DEBUG_USB_HOST
203 #ifdef DEBUG_USB_HOST
209 #ifdef DEBUG_USB_HOST
215 #ifdef DEBUG_USB_HOST
221 #ifdef DEBUG_USB_HOST
227 #ifdef DEBUG_USB_HOST
238 ErrorMessage<uint8_t > (
PSTR(
"Conf.Val"), conf);
239 ErrorMessage<uint8_t > (
PSTR(
"Iface Num"), iface);
240 ErrorMessage<uint8_t > (
PSTR(
"Alt.Set"), alt);
247 index = epInterruptInIndex;
249 index = ((pep->
bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
264 PrintEndpointDescriptor(pep);
294 uint16_t baud_value, baud_index = 0;
296 divisor3 = 48000000 / 2 / baud;
299 if((divisor3 & 0x7) == 7)
302 baud_value = divisor3 >> 3;
305 if(divisor3 == 1) baud_value |= 0xc000;
307 if(divisor3 >= 4) baud_value |= 0x4000;
309 if(divisor3 != 0) baud_value |= 0x8000;
310 if(baud_value == 1) baud_value = 0;
312 static const uint8_t divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3};
313 static const uint8_t divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1};
315 baud_value = divisor3 >> 3;
316 baud_value |= divfrac [divisor3 & 0x7] << 14;
317 baud_index = divindex[divisor3 & 0x7];
320 if(baud_value == 1) baud_value = 0;
322 if(baud_value == 0x4001) baud_value = 1;
326 uint8_t rv = pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_BAUD_RATE, baud_value & 0xff, baud_value >> 8, baud_index, 0, 0, NULL, NULL);
327 if(rv && rv !=
hrNAK) {
336 uint8_t rv = pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_LATENCY_TIMER, l, 0, 0, 0, 0, NULL, NULL);
337 if(rv && rv !=
hrNAK) {
346 uint8_t rv = pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_GET_LATENCY_TIMER, 0, 0, 0, 0, 1, (uint8_t *)l, NULL);
347 if(rv && rv !=
hrNAK) {
354 uint8_t rv = pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_MODEM_CTRL, signal & 0xff, signal >> 8, 0, 0, 0, NULL, NULL);
355 if(rv && rv !=
hrNAK) {
362 uint8_t rv = pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_FLOW_CTRL, xon, xoff, protocol << 8, 0, 0, NULL, NULL);
363 if(rv && rv !=
hrNAK) {
370 uint8_t rv = pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_SET_DATA, databm & 0xff, databm >> 8, 0, 0, 0, NULL, NULL);
371 if(rv && rv !=
hrNAK) {
378 uint8_t rv = pUsb->
inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
379 if(rv && rv !=
hrNAK) {
386 uint8_t rv = pUsb->
outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr);
387 if(rv && rv !=
hrNAK) {
396 D_PrintHex<uint8_t > (ep_ptr->
bLength, 0x80);
406 D_PrintHex<uint8_t > (ep_ptr->
bInterval, 0x80);