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];
88 USBTRACE(
"FTDI Init: Product not supported\r\n");
110 rcode = pUsb->
setAddr(0, 0, bAddress);
137 goto FailSetDevTblEntry;
141 for(uint8_t i = 0; i < num_of_conf; i++) {
148 goto FailGetConfDescr;
150 rcode = pUsb->
getConfDescr(bAddress, 0, i, &confDescrParser);
153 goto FailGetConfDescr;
170 rcode = pUsb->
setConf(bAddress, 0, bConfNum);
173 goto FailSetConfDescr;
175 rcode = pAsync->
OnInit(
this);
186 #ifdef DEBUG_USB_HOST 192 #ifdef DEBUG_USB_HOST 198 #ifdef DEBUG_USB_HOST 204 #ifdef DEBUG_USB_HOST 210 #ifdef DEBUG_USB_HOST 221 ErrorMessage<uint8_t > (
PSTR(
"Conf.Val"), conf);
222 ErrorMessage<uint8_t > (
PSTR(
"Iface Num"), iface);
223 ErrorMessage<uint8_t > (
PSTR(
"Alt.Set"), alt);
230 index = epInterruptInIndex;
233 index = ((pep->
bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
245 PrintEndpointDescriptor(pep);
274 uint16_t baud_value, baud_index = 0;
277 divisor3 = 48000000 / 2 / baud;
280 if((divisor3 & 0x7) == 7)
283 baud_value = divisor3 >> 3;
286 if(divisor3 == 1) baud_value |= 0xc000;
288 if(divisor3 >= 4) baud_value |= 0x4000;
290 if(divisor3 != 0) baud_value |= 0x8000;
291 if(baud_value == 1) baud_value = 0;
293 static const unsigned char divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3};
294 static const unsigned char divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1};
296 baud_value = divisor3 >> 3;
297 baud_value |= divfrac [divisor3 & 0x7] << 14;
298 baud_index = divindex[divisor3 & 0x7];
301 if(baud_value == 1) baud_value = 0;
303 if(baud_value == 0x4001) baud_value = 1;
307 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);
311 return pUsb->
ctrlReq(bAddress, 0,
bmREQ_FTDI_OUT,
FTDI_SIO_MODEM_CTRL, signal & 0xff, signal >> 8, 0, 0, 0, NULL, NULL);
315 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);
323 return pUsb->
inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr);
327 return pUsb->
outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr);
333 D_PrintHex<uint8_t > (ep_ptr->
bLength, 0x80);
343 D_PrintHex<uint8_t > (ep_ptr->
bInterval, 0x80);
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
#define USB_ERROR_EPINFO_IS_NULL
uint8_t SetBaudRate(uint32_t baud)
uint8_t SetModemControl(uint16_t control)
#define FTDI_SIO_SET_BAUD_RATE
#define FTDI_SIO_SET_DATA
uint8_t SetFlowControl(uint8_t protocol, uint8_t xon=0x11, uint8_t xoff=0x13)
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
#define NotifyFailGetDevDescr(...)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
uint8_t RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr)
virtual void FreeAddress(uint8_t addr)=0
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p)
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define NotifyFailGetConfDescr(...)
#define USB_NAK_MAX_POWER
FTDI(USB *pusb, FTDIAsyncOper *pasync, uint16_t idProduct=FTDI_PID)
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define FTDI_SIO_SET_FLOW_CTRL
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
virtual uint8_t OnInit(FTDI *pftdi)
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr)
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
virtual uint8_t OnRelease(FTDI *pftdi)
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
uint8_t bNumConfigurations
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
#define FTDI_SIO_MODEM_CTRL
AddressPool & GetAddressPool()
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
#define NotifyFailSetConfDescr(...)
uint8_t SetData(uint16_t databm)
#define FTDI_MAX_ENDPOINTS
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
#define NotifyFailSetDevTblEntry(...)