完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我是新的USB世界。我最近开始使用MPLAB和声和32位PIC。到现在为止,我试过(使用SUSTCCESS)使用USAT和定时器模块,但现在我尝试在HupPoPH配置器之后制作一个USB HID设备连接。我做了所有的步骤,并将我的固件与例子进行比较,但是我可以。我认为这是一个枚举问题,因为我发现带有枚举状态的图形和PIC检测到电源,并使Deice附接功能,之后(从图形)主机发送重置进入默认状态但不发生,它只接收RESE。这是我正在做的关于“Upj:App.c—UBSyDeice,HythyEdvyRead App.UbBeDeice HiDeVethHANDLE(UBS.DeVice,HythyAdvultiHID,UbjDeVice,HythyEngEvin事件,VUL*EVEDATA,UntPrTrt用户数据)的消息。*与实例示例相同的方式*UBSyDeice、ApviSubBeDeice EvEnthDrand(UbjDeVice事件)、VUT*PATATE、UTIPSTrt上下文){Unt8}t ActudioEngiguy;UTI1616T FrAMNENUM;UBSySturk附件速度;ASE UBSDEVICE.EngEnviPoByType检测到:sEndEngScript(“UbjDeVice,EnvithPosivEngult\rn”);AbthDeVelue.UbDeV句柄;StUBE;send_string("USB_DEVICE_EEVENT_EVENT_EVEVENT_SUSPENDED。n")send_ED:send_string("send_send_string("send_USB_DEV_DEV_DEVICE_EEEEEEEEEVENT_EEEEEEEEEEVENT_EVENT_EEEEVENT_SUTETE_SUSPENENENENDEDEDE_USB_UUUSB_DEV_EEVENT_EVENT_SUENENENEN_SUSPENENENDEDE_SUSPDE_SUSPDE。\\\DEVICE_EVENT_RESET.n");break;case USB_DEVICE_EVENT_DEC已确定的:send_string("USB_DEVICE_EEEVENT_EEVENT_DEDEDEDEDEFIFIGURED.\\\\n"");appData.deviceConConConConfigured=appData.appData.deviceConfigured=false=false;appData.appData.conficonficonficonfi的配的配置=appData=appData.appData.confi配置值=((appData.appData.conficonficonfi配置值==((((((((((((((((((((((((((((((((((((((((((((((((((())USB USB USB USB USB(USB_DEV_DEVICE_EVENT_DADATA_CONFIGURED*)pData)-pData)-gt;配置值;配置值;USB_DEVICE_HID_EventHandHandlerSet;USB_DEVICE_HID_事件处理程序(appData.hid实例appData.hidInsInstanapp,APP_USB设备HIHIDEHIDEDEDEDEDEDEDEHandHandHandHandHandHandHandHandHandHandHandHandHandHand处理程序(uintptptr_t)&appData;activeConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConConconfi=((USB_DEV_DEV_DEV_DEV_DEV_ED:send_string("USB_DEVICE_EEEVENT_EEEEEEEEEEVENT_RESRESUM。\\\\\\\\\\n");break case;断例USB USB USB_DEV UUUSB_DEV_DEV_EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEUUUUUUUUUUUEEEEEEEEEEEEEEEEEEEEEEEdata.u***DevHandle,pData,32;break;大小写USB_DEVICE_EVEN发送_字符串("USB_DEVICE_EVENT_CONVE_CONCON_CONCON_CONTR_trans_trans_TRANSFER_TATATATATATA接收到。\n"");USB_DEV_DEV_DEV_CONTRTR_TRA_TRATRANSFER_DATA接收到:send_字符串("USB_USB_DEV_DEV_EVE_EVE_CONTR_CONTR_CONTR_CONTR_TRA_TRA_TRA_TRA_TRA_TRA_TRA_DATA_SENT_SENT_DATA SENT_SENT_SENT:中断;案例USB_DEV_DEV_DEV_中断;情况USB_DEVICE_EVEICE_EVENT_EVENT_EVEVE_EEEEEEEEEEEEEEDEDPOINT_ENDPOINT_ENDPOI_ENDPOI_RE_RE_RE_RE_RE_RE_RE_RE_RE_COMPLET:break;断断;案例USB_USB_DEV_DEV_DEVICE_DEVICE_EEEEEEEEEEEEEEEYNC_SYNCH_FRAM_FRAM_SYNC_FRAM:USB_SYNC_SYNC_SYNC_SYNC_FRAM_SYNC_FR_SYYu***DevHandle, &frameNumber,2);break;case USB_DEVICE_EVENT_ERROR:default:break;}//return USB_DEVICE_EVENT_ERROR;}void APP_Tasks(void){.(appData.state){/*应用程序的初始状态。*/case APP_STATE_INIT: {send_string(“APP_STATE_INITrn”);appData.u***DevHandle=USB_DEVICE_Open(USB_DEVICE_INDEX_0,DRV_IO_INTENT_READWRITE);if(appData.u***DevHandle!USB_DEVICE_HANDLE_INVALID){USB_DEVICE_HANDLE_INVALID){USB_DEVICE_EventHand处理程序集(appData.u***DevHandle,appDataData.u***DevHandHandle,APP_USB设备设备EveEveDeviceEveEveEveEveEveEveEveEveEventHandHandHand处理程序,0);appData.state=APP_STATE_STATE_WATE_WAIT_WAIT_._FOR_FOR_CONFIFIFIGURATI;send_string("设备层处理程序创建\\\\\\\\APP_STATE_WAIT_._CONFIGUR.:{if(appData.deviceConfigured){/*Device准备好运行主任务*/appData.hidDataRecei.=false;appData.hidDataTransmitted=true;appData.state=APP_STATE_MAIN_TASK;/*放置新的读取请求。*/USB_DEVICE_HID_ReportReceive(USB_DEVICE_HID_INDEX_0, &appData.rxTransferHandle, appData.receiveDataBuffer, 64); }break;}case APP_STATE_MAIN_TASK: {send_string(“APP_STATE_MAIN_TASKrn”);if(!appData.deviceConfigured){/*Device未配置*/appData.state=APP_STATE_WAIT_._CONFIGUR.;}.if(appData.hidDataRecei.){send_string("Recei.datarn");if(appData.hidDataTransmitted){send_string("Data..datarn");appData..DataBuffer[0]=0x81;appData.hidDataTransmitted=false;/*准备USB模块将数据分组发送到主机*/USB_DEVICE_HID_ReportSend(USB_DEVICE_HID_INDEX_0,&appData.txTransferHandle,appData..DataBuffer,64);appData.hidDataRecei.=false;send_string(“Data sendrn”);/*放置一个新的rEAD请求。*/USB_DEVICE_HID_ReportReceive(USB_DEVICE_HID_INDEX_0,&appData.rxTransferHandle,appData.receiveDataBuffer,64);}break;}break default:break;}}抱歉对于长篇文章,其他函数与示例相同。我正在使用PIC32 MX27 0F256D,使用一个8MHz的晶体,带有PLL的USB时钟。已经检查了USB连接,并在VBUS上安装了一个10uF电容。从USB到PIC:红线VUSB到PIN 42 VBUSWhite线D-到PIN 9 D-Green线D+到PIN 8 D+GND到GND。非常感谢。
以上来自于百度翻译 以下为原文 Hi, I'm new in the USB World. I recently started to work with MPLAB HARMony and 32 bits PIC's. Until now, I tried (sussccefully) use the USART and Timers modules, but now I'm trying to make an USB HID Device Connection following the Harmpony configurator. I made all the steps, and compare my firmware with the examples but I can't make it, I think that is an enumeration problem because I found the graphic with the enumeration states and the PIC detect the power, and make the DeviceAttach function, after that (from the graphic) the host send a RESET to enter to the Default state but that not happen, it just receive the reset order from the host and after that the PC show a message saying "Undefined device connected". This is what I'm doing concerning to the USB: app.c - USB_DEVICE_HID_EVENT_RESPONSE APP_USBDeviceHIDEventHandler (USB_DEVICE_HID_INDEX iHID, USB_DEVICE_HID_EVENT event, void * eventData, uintptr_t userData) *Declared same way as the examples* USB_DEVICE_EVENT_RESPONSE APP_USBDeviceEventHandler (USB_DEVICE_EVENT event, void * pData, uintptr_t context) { uint8_t activeConfiguration; uint16_t frameNumber; USB_SPEED attachSpeed; USB_SETUP_PACKET * setupEventData; // Handling of each event switch(event) { case USB_DEVICE_EVENT_POWER_DETECTED: send_string("USB_DEVICE_EVENT_POWER_DETECTEDrn"); USB_DEVICE_Attach (appData.u***DevHandle); break; case USB_DEVICE_EVENT_POWER_REMOVED: send_string("USB_DEVICE_EVENT_POWER_REMOVEDrn"); USB_DEVICE_Detach(appData.u***DevHandle); break; case USB_DEVICE_EVENT_SUSPENDED: send_string("USB_DEVICE_EVENT_SUSPENDED.n"); break; case USB_DEVICE_EVENT_SOF: send_string("USB_DEVICE_EVENT_SOF.n"); frameNumber = ((USB_DEVICE_EVENT_DATA_SOF *)pData)->frameNumber; break; case USB_DEVICE_EVENT_RESET : send_string("USB_DEVICE_EVENT_RESET.n"); break; case USB_DEVICE_EVENT_DECONFIGURED : send_string("USB_DEVICE_EVENT_DECONFIGURED.n"); appData.deviceConfigured = false; appData.state = APP_STATE_WAIT_FOR_CONFIGURATION; break; case USB_DEVICE_EVENT_CONFIGURED : send_string("USB_DEVICE_EVENT_CONFIGURED.n"); appData.deviceConfigured = true; appData.configurationValue = ((USB_DEVICE_EVENT_DATA_CONFIGURED*)pData)->configurationValue; USB_DEVICE_HID_EventHandlerSet(appData.hidInstance, APP_USBDeviceHIDEventHandler, (uintptr_t)&appData); activeConfiguration = ((USB_DEVICE_EVENT_DATA_CONFIGURED *)pData)->configurationValue; break; case USB_DEVICE_EVENT_RESUMED: send_string("USB_DEVICE_EVENT_RESUMED.n"); break; case USB_DEVICE_EVENT_CONTROL_TRANSFER_SETUP_REQUEST: send_string("USB_DEVICE_EVENT_CONTROL_TRANSFER_SETUP_REQUEST.n"); setupEventData = (USB_SETUP_PACKET *)pData; USB_DEVICE_ControlReceive(appData.u***DevHandle, pData, 32); break; case USB_DEVICE_EVENT_CONTROL_TRANSFER_DATA_RECEIVED: send_string("USB_DEVICE_EVENT_CONTROL_TRANSFER_DATA_RECEIVED.n"); USB_DEVICE_ControlStatus(appData.u***DevHandle, USB_DEVICE_CONTROL_STATUS_OK); break; case USB_DEVICE_EVENT_CONTROL_TRANSFER_DATA_SENT: break; case USB_DEVICE_EVENT_CONTROL_TRANSFER_ABORTED: break; case USB_DEVICE_EVENT_ENDPOINT_READ_COMPLETE: break; case USB_DEVICE_EVENT_ENDPOINT_WRITE_COMPLETE: break; case USB_DEVICE_EVENT_SET_DESCRIPTOR: send_string("USB_DEVICE_EVENT_SET_DESCRIPTOR");break; case USB_DEVICE_EVENT_SYNCH_FRAME: USB_DEVICE_ControlSend(appData.u***DevHandle, &frameNumber, 2); break; case USB_DEVICE_EVENT_ERROR : default: break; } //return USB_DEVICE_EVENT_ERROR; } void APP_Tasks ( void ) { switch ( appData.state ) { /* Application's initial state. */ case APP_STATE_INIT: { send_string("APP_STATE_INITrn"); appData.u***DevHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0, DRV_IO_INTENT_READWRITE ); if (appData.u***DevHandle!= USB_DEVICE_HANDLE_INVALID) {USB_DEVICE_EventHandlerSet(appData.u***DevHandle, APP_USBDeviceEventHandler, 0); appData.state = APP_STATE_WAIT_FOR_CONFIGURATION; send_string("Device Layer Handler createdrn"); } else {send_string("Device Layer Handler creation failedrn");} break; } case APP_STATE_WAIT_FOR_CONFIGURATION: { if(appData.deviceConfigured) { /* Device is ready to run the main task */ appData.hidDataReceived = false; appData.hidDataTransmitted = true; appData.state = APP_STATE_MAIN_TASK; /* Place a new read request. */ USB_DEVICE_HID_ReportReceive (USB_DEVICE_HID_INDEX_0, &appData.rxTransferHandle, appData.receiveDataBuffer, 64); } break; } case APP_STATE_MAIN_TASK: { send_string("APP_STATE_MAIN_TASKrn"); if(!appData.deviceConfigured) { /* Device is not configured */ appData.state = APP_STATE_WAIT_FOR_CONFIGURATION; } else if( appData.hidDataReceived ) { send_string("Received datarn"); if(appData.hidDataTransmitted) { send_string("Data already transmited datarn"); appData.transmitDataBuffer[0] = 0x81; appData.hidDataTransmitted = false; /* Prepare the USB module to send the data packet to the host */ USB_DEVICE_HID_ReportSend (USB_DEVICE_HID_INDEX_0, &appData.txTransferHandle, appData.transmitDataBuffer, 64 ); appData.hidDataReceived = false; send_string("Data sentrn"); /* Place a new read request. */ USB_DEVICE_HID_ReportReceive (USB_DEVICE_HID_INDEX_0, &appData.rxTransferHandle, appData.receiveDataBuffer, 64 ); } } break;} default: break; }}} Sorry for the long post, the other functions are the same from the examples. I'm working with the PIC32MX270F256D, using a 8MHz crystal, with the PLL for the USB clock. Already check the USB Connections and put a 10uF capacitor on VBUS. From the USB to the PIC: Red wire VUSB to PIN 42 VBUS White Wire D- to PIN 9 D- Green Wire D+ to PIN 8 D+ GND to GND. Thank you a lot. Attached Image(s) |
|
相关推荐
4个回答
|
|
你好,既然你使用的是Harmony,那么在位于这里http://www..hip.com/for./f291.aspx的和谐论坛上提问可能会让你得到更好的服务。
以上来自于百度翻译 以下为原文 Hi there, Since you're using Harmony, you'll probably be better served by asking in the Harmony forum which is located here http://www.microchip.com/forums/f291.aspx |
|
|
|
嘿,谢谢你的帮助。我在想,当我使用HID设备时,我不需要驱动程序,因为它是一个通用驱动程序,对吧?是的,我尝试了一些例子,但他们根本没有编译。问候来自巴西,
以上来自于百度翻译 以下为原文 Hey, thanks for the help but. I was thinking that as Im using a HID device, I won't need the drivers because is a generic driver, right? And Yes, I tried with some examples but they don't compile at all. Greetings form Brazil, |
|
|
|
好吧,我把这些UART消息详细地看一下微处理器内部正在发生的事情。在枚举过程的任何阶段,我都会发出一个消息,当我把微处理器连接到CPU时,我得到了:谢谢你的帮助。
以上来自于百度翻译 以下为原文 Well, I put those UART message to take a detailed sight about what's happening inside the Microprocessor. I Put a message in any stage of the enumeration process and when I connect the micro to the CPU I get this: Thanks for the help. Attached Image(s) |
|
|
|
好吧,我准备和另一个帖子里的其他人谈谈,我必须把端点号固定到两个。它起作用了。谢谢大家的帮助,问候,
以上来自于百度翻译 以下为原文 Well, I allready talk with someone else in another post, I jkust had to fix the endpoints numbers to two. And it works. Thank you all for the help. Greetings, |
|
|
|
只有小组成员才能发言,加入小组>>
5231 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3200 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
770浏览 1评论
658浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
587浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
668浏览 0评论
570浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 23:04 , Processed in 1.287170 second(s), Total 81, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号