完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好,最近用STM32英贝特开发板调试USB,例程JoyStickMouse用端点EP1来发送数据(EP1_IN),我想添加一个端点来接收数据,情况如下:
1) 添加EP_OUT端点,用bus hound调试,能正确进行读、写; 2) 添加EP2_OUT端点,则bus hound只能接收数据无法发数据; 3) 如果改为EP1_OUT、EP2_IN,则bus hound只能发数据无法接收数据。 似乎,在中断模式下,只能用EP1进行收发数据,请各位指教! 涉及的相关代码如下: /************************************************************** //描述符修改 **************************************************************/ /************** Descriptor of Joystick Mouse interface ****************/ /* 09 */ 0x09, /*bLength: Interface Descriptor size*/ USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType: Interface descriptor type*/ 0x00, /*bInterfaceNumber: Number of Interface*/ 0x00, /*bAlternateSetting: Alternate setting*/ 0x02, /*bNumEndpoints: Number of endpoints except EP0*/ 0x00, /*bInterfaceClass: HID*/ 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ 0, /*iInterface: Index of string descriptor*/ /******************** Descriptor of EP1_OUT ********************/ /* 18 */ 0x07, /*bLength: Endpoint Descriptor size*/ USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/ 0x01, /*bEndpointAddress: Endpoint Address (OUT)*/ // bit 3...0 : the endpoint number // bit 6...4 : reserved // bit 7 : 0(OUT), 1(IN) 0x03, /*bmAttributes: Interrupt endpoint*/ // bit 1...0 : Transfer type // 00(CONTROL), 01(ISOCHRONOUS), 10(BULK), 11(INTERRUPT) // bit 3...2 : Synchronization type // 00(No Synch), 01(Asynchronous), 10(Adaptive), 11(Synchronous) // bit 5...4 : Endpoint Usage type // 00(data), 01(Feedback), 10(Implicit feedback data endpoint), 11(Reserved) // bit 7...6 : Reserved, must be zero 0x40, /*wMaxPacketSize: 64 Byte max */ 0x00, 0x0a, /*bInterval: Polling Interval (10 ms)*/ /* 25 */ /******************** Descriptor of EP2_IN ********************/ 0x07, /*bLength: Endpoint Descriptor size*/ USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/ 0x82, /*bEndpointAddress: Endpoint Address (IN)*/ 0x03, /*bmAttributes: Interrupt endpoint*/ 0x04, /*wMaxPacketSize: 4 Byte max */ 0x00, 0x0a, /*bInterval: Polling Interval (10 ms)*/ /* 32 */ /************************************************************** //复位函数 **************************************************************/ //******************************************************* // TODO: Add your code here! //******************************************************* /* Initialize Endpoint 1 */ // Set the endpoint type SetEPType(ENDP1, EP_INTERRUPT); // Set the endpoint data buffer address SetEPRxAddr(ENDP1, ENDP1_RXADDR); // Set the number of recevie data SetEPRxCount(ENDP1, ENDP1_PACKETSIZE); // Initialize the RX/TX status SetEPRxStatus(ENDP1, EP_RX_VALID); SetEPTxStatus(ENDP1, EP_TX_DIS); /* Initialize Endpoint 2 */ // Set the endpoint type SetEPType(ENDP2, EP_INTERRUPT); // Set the endpoint data buffer address SetEPTxAddr(ENDP2, ENDP2_TXADDR); // Set the number of transmit data SetEPTxCount(ENDP2, 4); // Initialize the RX/TX status SetEPRxStatus(ENDP2, EP_RX_DIS); SetEPTxStatus(ENDP2, EP_TX_NAK); /************************************************************** //正确接收数据回调函数 **************************************************************/ void CTR_OUT1(void) { unsigned char pRev[64]; unsigned short wCount; wCount = GetEPRxCount(ENDP1); //获取收到的长度 PMAToUserBufferCopy(pRev, GetEPRxAddr(ENDP1), wCount); //复制数据 SetEPRxValid(ENDP1); //设置端点有效,以接收下一次数据 } /************************************************************** //发送数据 **************************************************************/ /*copy mouse position info in ENDP1 Tx Packet Memory Area*/ UserToPMABufferCopy(Mouse_Buffer, GetEPTxAddr(ENDP2), 4); /* Set the number of transmit data */ SetEPTxCount(ENDP2, 4); /* enable endpoint for transmission */ SetEPTxValid(ENDP2); /************************************************************** //正确发送数据回调函数 **************************************************************/ void CTR_IN2(void) { SetEPRxStatus(ENDP2, EP_RX_DIS); SetEPTxStatus(ENDP2, EP_TX_NAK); } |
|
相关推荐
1个回答
|
|
|
1. 首先,请确保您的USB设备描述符(Device Descriptor)和配置描述符(Configuration Descriptor)正确配置了所需的端点。根据您的需求,您需要添加一个新的OUT端点(EP2_OUT)。 2. 在您的USB设备驱动程序中,您需要为新的EP2_OUT端点添加相应的处理函数。这通常包括初始化端点、处理数据传输等。 3. 在中断服务例程(ISR)中,确保正确处理与EP2_OUT端点相关的中断。这可能包括处理数据接收、空包传输等。 4. 检查您的USB堆栈是否支持多端点传输。有些USB堆栈可能对多端点传输有限制,这可能导致您遇到的问题。 5. 如果可能,请尝试使用其他USB调试工具,如WireShark或USBPcap,以确保问题不是由Bus Hound引起的。 6. 检查您的硬件连接,确保STM32开发板与计算机之间的连接正确无误。 7. 如果问题仍然存在,请考虑在STM32开发板的固件中添加一些调试信息,以便更好地了解问题所在。 |
|
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
4182 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
3252 浏览 1 评论
2782 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
2214 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
15087 浏览 2 评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
3141浏览 4评论
stm32f4下spi+dma读取数据不对是什么原因导致的?
1928浏览 3评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
2096浏览 3评论
2008浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
2202浏览 3评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 22:36 , Processed in 0.612282 second(s), Total 75, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2560