我写的代码也顺便帮我看看哪有问题吧!多谢- #include // part specific constants and macros
- #include "PSoCAPI.h" // PSoC API definitions for all User Modules
- extern BYTE UsbResetFlag;
- void main(void)
- {
- BYTE str[8];//used to save data from pc
- BYTE EpState;//used to save the endpoint state
- WORD Size;//used to save the size of the data from pc
-
- M8C_EnableGInt;
- USBFS_Start(0,USB_5V_OPERATION);//start usb with 5
- while(1)
- {
- if(UsbResetFlag)
- {
- while(!USBFS_bGetConfiguration());// Wait for the USB device to enumerate
-
- USBFS_EnableOutEP(1);
-
- EpState=USBFS_bGetEPState(1);//Gets the Endpoint state for the specified endpoint
-
- while(!USBFS_bGetEPAckState(1));//Determines whether or not an ACK transaction occurred
- //on this endpoint by reading the ACK bit
- //in the control register of the endpoint
- Size=USBFS_wGetEPCount(1);//This functions returns the value of the endpoint count register
-
- USBFS_bReadOutEP(1,str,8);//Moves the specified number of bytes from endpoint RAM to data RAM
-
- LCD_Start();//display the state and the data
- LCD_Position(0,1);
- LCD_PrHexByte(EpState);
- LCD_Position(0,6);
- LCD_PrHexByte(Size);
- LCD_Position(1,1);
- LCD_PrString(str);
- UsbResetFlag = 0;
- }
- }
|