STM32F2的USB中断及数据发送问题

[复制链接]
11093|2
 楼主| ticomi 发表于 2013-6-19 10:37 | 显示全部楼层 |阅读模式
STM32F2的USB库文件很多,分析起来很麻烦,我现在虽然已经让计算机识别到了USB设备,但是还无法配置和接收及发送数据。下面是USB的中断函数代码,我想知道怎么才能知道这些函数的功能,及怎么调用发送和接收函数?

谢谢!
  1. uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev)
  2. {
  3.   USB_OTG_GINTSTS_TypeDef  gintr_status;
  4.   uint32_t retval = 0;
  5.   
  6.   if (USB_OTG_IsDeviceMode(pdev)) /* ensure that we are in device mode */
  7.   {
  8.     gintr_status.d32 = USB_OTG_ReadCoreItr(pdev);
  9.     if (!gintr_status.d32) /* avoid spurious interrupt */
  10.     {
  11.       return 0;
  12.     }
  13.    
  14.     if (gintr_status.b.outepintr)
  15.     {
  16.       retval |= DCD_HandleOutEP_ISR(pdev);
  17.     }   
  18.    
  19.     if (gintr_status.b.inepint)
  20.     {
  21.       retval |= DCD_HandleInEP_ISR(pdev);
  22.     }
  23.    
  24.     if (gintr_status.b.modemismatch)
  25.     {
  26.       USB_OTG_GINTSTS_TypeDef  gintsts;
  27.       
  28.       /* Clear interrupt */
  29.       gintsts.d32 = 0;
  30.       gintsts.b.modemismatch = 1;
  31.       USB_OTG_WRITE_REG32(&pdev->regs.GREGS->GINTSTS, gintsts.d32);
  32.     }
  33.    
  34.     if (gintr_status.b.wkupintr)
  35.     {
  36.       retval |= DCD_HandleResume_ISR(pdev);
  37.     }
  38.    
  39.     if (gintr_status.b.usbsuspend)
  40.     {
  41.       retval |= DCD_HandleUSBSuspend_ISR(pdev);
  42.     }
  43.     if (gintr_status.b.sofintr)
  44.     {
  45.       retval |= DCD_HandleSof_ISR(pdev);
  46.       
  47.     }
  48.    
  49.     if (gintr_status.b.rxstsqlvl)
  50.     {
  51.       retval |= DCD_HandleRxStatusQueueLevel_ISR(pdev);
  52.       
  53.     }
  54.    
  55.     if (gintr_status.b.usbreset)
  56.     {
  57.       retval |= DCD_HandleUsbReset_ISR(pdev);
  58.       
  59.     }
  60.     if (gintr_status.b.enumdone)
  61.     {
  62.       retval |= DCD_HandleEnumDone_ISR(pdev);
  63.     }
  64.    
  65.     if (gintr_status.b.incomplisoin)
  66.     {
  67.       retval |= DCD_IsoINIncomplete_ISR(pdev);
  68.     }

  69.     if (gintr_status.b.incomplisoout)
  70.     {
  71.       retval |= DCD_IsoOUTIncomplete_ISR(pdev);
  72.     }   
  73. #ifdef VBUS_SENSING_ENABLED
  74.     if (gintr_status.b.sessreqintr)
  75.     {
  76.       retval |= DCD_SessionRequest_ISR(pdev);
  77.     }

  78.     if (gintr_status.b.otgintr)
  79.     {
  80.       retval |= DCD_OTG_ISR(pdev);
  81.     }   
  82. #endif   
  83.   }
  84.   return retval;
  85. }
这个函数哪部分是告知有数据到达且调用接收函数的?
IJK 发表于 2013-6-19 12:13 | 显示全部楼层
简单来说,DCD_HandleOutEP_ISR相当于 调用接收函数。
但实际上,USB通信一般不是按这个思路来做的,LZ最好先学习一下USB基础知识。
 楼主| ticomi 发表于 2013-6-19 12:47 | 显示全部楼层
IJK 发表于 2013-6-19 12:13
简单来说,DCD_HandleOutEP_ISR相当于 调用接收函数。
但实际上,USB通信一般不是按这个思路来做的,LZ最好 ...

谢谢指点,USB太复杂了,我现在只能使用库文件来做,又担心不完全理解的话一旦出现问题无法解决也不能保证USB的稳定性。

现在对着代码和资料在逐步的分析源码和USB基础性的知识,有一些理解了。

谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

50

主题

852

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部