新手入门的系列文档【原创】
如果自己的板子没有预留UART口进行调试,可以通过本帖方法配置为虚拟串口复合设备通过API CyU3PDebugPrint 打印调试信息。具体内容如下:
NON-UVC Virtual COM 复合设备,进行调试信息打印。 确认使用的VirtualCOM驱动版本如下:
在3.0下添加如下配置描述符。 更改如下ssconfigurationdescriptor #ifndefCDC_DEBUG 0x1F, 0x00, /* Length of this descriptor and all sub descriptors */ 0x01, /* Number of interfaces */ #else 0x73,0x00, 0x03, /* Number of interfaces */ #endif
在配置描述符最后添加如下信息。 #ifdef CDC_DEBUG , /* Interfaceassociation descriptor */ 0x08, /* Descriptor size*/ CY_FX_INTF_ASSN_DSCR_TYPE, /* Interface association descr type*/ 0x01, /* first interface*/ 0x02, /* InterfaceCount */ 0x02, /* CDC */ 0x02, /* abstract controlmodel */ 0x01, /* AT commands*/ 0x00, /* String descindex for interface */ /* CommunicationInterface descriptor */ 0x09, /* Descriptor size*/ CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 0x01, /* Interface number*/ 0x00, /* Alternatesetting number */ 0x01, /* Number of endpoints*/ 0x02, /* Interface class: Communication Interface */ 0x02, /* Interface subclass */ 0x01, /* Interface protocol code */ 0x00, /* Interfacedescriptor string index */ /* CDCClass-specific Descriptors */ /* Headerfunctional Descriptor */ 0x05, /* Descriptorslength(5) */ 0x24, /* Descriptor type: CS_Interface */ 0x00, /*DescriptorSubType : Header Functional Descriptor */ 0x10,0x01, /* bcdCDC : CDCRelease Number */ /* Abstract ControlManagement Functional Descriptor */ 0x04, /* DescriptorsLength (4) */ 0x24, /* bDescriptorType:CS_INTERFACE */ 0x02, /*bDescriptorSubType: Abstract Control Model Functional Descriptor */ 0x02, /* bmCapabilities:Supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding and the notificationSerial_State */ /* Union FunctionalDescriptor */ 0x05, /* DescriptorsLength (5) */ 0x24, /* bDescriptorType:CS_INTERFACE */ 0x06, /*bDescriptorSubType: Union Functional Descriptor */ 0x01, /* bMasterInterface*/ 0x02, /* bSlaveInterface*/ /* Call ManagementFunctional Descriptor */ 0x05, /* Descriptors Length (5) */ 0x24, /* bDescriptorType: CS_INTERFACE */ 0x01, /* bDescriptorSubType: Call ManagementFunctional Descriptor */ 0x00, /* bmCapabilities: Device sends/receives callmanagement information only over theCommunication Class Interface. */ 0x01, /* Interface Number of Data Class interface */ /* EndpointDescriptor(Interrupt) */ 0x07, /* Descriptor size*/ CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ CY_FX_EP_INTERRUPT_UART, /* Endpoint address and description*/ CY_U3P_USB_EP_INTR, /* Interrupt endpoint type */ 0x40,0x00, /* Max packet size= 64 bytes */ 0x02, /* Servicinginterval for data transfers */ /* Super Speed EndpointCompanion Descriptor */ 0x06, /* Descriptor size*/ CY_U3P_SS_EP_COMPN_DESCR, /* SS Endpoint Companion DescriptorType */ 0x00, /* Max no. ofpackets in a Burst: 1 */ 0x00, /* Attribute: N.A.*/ 0x40, /* Bytes perinterval: 1024 */ 0x00, /* Data InterfaceDescriptor */ 0x09, /* Descriptor size*/ CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 0x02, /* Interface number*/ 0x00, /* Alternatesetting number */ 0x02, /* Number of endpoints*/ 0x0A, /* Interface class:Data interface */ 0x00, /* Interface subclass */ 0x00, /* Interface protocol code */ 0x00, /* Interfacedescriptor string index */ /* EndpointDescriptor(BULK-PRODUCER) */ 0x07, /* Descriptor size*/ CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ CY_FX_EP_PRODUCER_UART, /* Endpointaddress and description */ CY_U3P_USB_EP_BULK, /* BULK endpoint type */ 0x00,0x04, /* Max packet size= 512 bytes */ 0x00, /* Servicing interval for data transfers */ /* Super Speed EndpointCompanion Descriptor */ 0x06, /* Descriptor size*/ CY_U3P_SS_EP_COMPN_DESCR, /* SS Endpoint Companion DescriptorType */ 0x0F, /* Max number ofpackets per burst: 12 */ 0x00, /* Attribute:Streams not defined */ 0x00, /* No meaning forbulk */ 0x00, /* EndpointDescriptor(BULK- CONSUMER) */ 0x07, /* Descriptor size*/ CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ CY_FX_EP_CONSUMER_UART, /* Endpointaddress and description */ CY_U3P_USB_EP_BULK, /* Bulk endpoint type */ 0x00,0x04, /* Max packet size= 512 bytes */ 0x00, /* Servicinginterval for data transfers */ /* Super Speed EndpointCompanion Descriptor */ 0x06, /* Descriptor size*/ CY_U3P_SS_EP_COMPN_DESCR, /* SS Endpoint Companion DescriptorType */ 0x0F, /* Max number ofpackets per burst: 12 */ 0x00, /* Attribute:Streams not defined */ 0x00, /* No meaning forbulk */ 0x00 #endif
|