久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2941|回復: 1
打印 上一主題 下一主題
收起左側

USB鼠標源碼 Labview USB-RAW-Bulk上位機發送數據STM32下位機接受

[復制鏈接]
跳轉到指定樓層
樓主
為了獲得一點黑幣,好下載,也是不擇手段了!

IDE-Version:
*********************************************
μVision V4

下載方式
*********************************************
·SWD  JTAG

程序功能
*********************************************
·STM32 USB鼠標實驗

硬件連接                     
*********************************************
·將USB插到開發板上

實驗現象
*********************************************
·可以使用KEY來控制電腦的鼠標的方向



單片機源程序如下:
  1. /*********************************************************************************************************
  2. *
  3. * File                : main.c
  4. * Hardware Environment:
  5. * Build Environment   : RealView MDK-ARM  Version: 4.32
  6. * Version             : V1.0
  7. * By                  : mao
  8. *
  9. *
  10. *********************************************************************************************************/

  11. /* Includes ------------------------------------------------------------------*/
  12. #include "stm32f10x.h"
  13. #include "usb_lib.h"
  14. #include "hw_config.h"
  15. #include "usb_pwr.h"
  16. #include "usart1.h"
  17. #include "Data.h"

  18. #ifdef __GNUC__
  19.   /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
  20.      set to 'Yes') calls __io_putchar() */
  21.   #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
  22. #else
  23.   #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
  24. #endif /* __GNUC__ */

  25. /* Private function prototypes -----------------------------------------------*/

  26. u8         MsgCmd;

  27. void  Delay (uint32_t nCount);

  28. void USB_SendString(u8 *str)           //
  29. {
  30.      u8 ii=0;   
  31.      while(*str)
  32.      {
  33.          Transi_Buffer[ii++]=*(str++);
  34.          if (ii ==22) break;
  35.      }
  36.      UserToPMABufferCopy(Transi_Buffer, ENDP2_TXADDR, 22);
  37.      _SetEPTxStatus(ENDP2, EP_TX_VALID);
  38. }

  39. /*******************************************************************************
  40. * Function Name  : main
  41. * Description    : Main program
  42. * Input          : None
  43. * Output         : None
  44. * Return         : None
  45. * Attention                 : None
  46. *******************************************************************************/
  47. int main(void)
  48. {
  49.   
  50.   Set_System();
  51.   
  52.   USB_Interrupts_Config();
  53.   
  54.   Set_USBClock();
  55.   
  56.   USB_Init();

  57.     /* USART1 config 115200 8-N-1 */
  58.   USART1_Config();
  59.   NVIC_USART1_Configuration();
  60.   MsgCmd=0;
  61.   
  62.   while (1)
  63.   {
  64.         if(MsgCmd)                                          //當上位機發送數據以后,對MsgCmd置1         
  65.         {  
  66.             Delay(50000);                          //沒有這個延時,會少部分數據?為什么?
  67. //                while(EP_RX_NAK!=GetEPRxStatus(ENDP1));
  68.                 printf("\r\n進入主函數");
  69.                 GET_CMD();
  70.         }        

  71.   }
  72. }


  73. /*******************************************************************************
  74. * Function Name  : Delay
  75. * Description    : Delay Time
  76. * Input          : - nCount: Delay Time
  77. * Output         : None
  78. * Return         : None
  79. * Attention                 : None
  80. *******************************************************************************/
  81. void  Delay (uint32_t nCount)
  82. {
  83.   for(; nCount != 0; nCount--)
  84.   {
  85.   }
  86. }

  87. /*******************************************************************************
  88. * Function Name  : GPIO_Configuration
  89. * Description    : Configure GPIO Pin
  90. * Input          : None
  91. * Output         : None
  92. * Return         : None
  93. * Attention                 : None
  94. *******************************************************************************/
  95. //void GPIO_Configuration(void)
  96. //{
  97. //  GPIO_InitTypeDef GPIO_InitStructure;
  98. //  
  99. //  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE);                                                  
  100. ///**
  101. // *  LED1 -> PB15 , LED2 -> PB14 , LED3 -> PB13 , LED4 -> PB12
  102. // */                                         
  103. //  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
  104. //  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  105. //  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  106. //  GPIO_Init(GPIOB, &GPIO_InitStructure);
  107. //}
  108. //
  109. #ifdef  USE_FULL_ASSERT

  110. /**
  111.   * @brief  Reports the name of the source file and the source line number
  112.   *   where the assert_param error has occurred.
  113.   * @param  file: pointer to the source file name
  114.   * @param  line: assert_param error line source number
  115.   * @retval None
  116.   */
  117. void assert_failed(uint8_t* file, uint32_t line)
  118. {
  119.   /* User can add his own implementation to report the file name and line number,
  120.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  121.   /* Infinite loop */
  122.   while (1)
  123.   {
  124.   }
  125. }
  126. #endif

  127. /*********************************************************************************************************
  128.       END FILE
  129. *********************************************************************************************************/

復制代碼

所有資料51hei提供下載:
usb下位機1(上位機發,下位機收).rar (407.71 KB, 下載次數: 36)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:341045 發表于 2018-6-9 09:01 | 只看該作者
很好的參考資料, 收藏了
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 精品国产乱码久久久久久图片 | 视频一区二区三区中文字幕 | 久久99精品久久久久蜜桃tv | 亚洲成人a v | 国产免费自拍 | 国产精品久久久久久久久久免费看 | 久久亚洲一区二区三区四区 | 国产一区免费视频 | 中文字幕在线观看视频一区 | 国产一区精品在线 | 三级国产三级在线 | 精品福利一区 | 懂色中文一区二区三区在线视频 | 日韩精品免费 | 久久久亚洲综合 | 在线视频一区二区 | 久久久女| 1级毛片| 夜夜草视频 | 毛片免费看的 | 久久性 | 精品国产一区二区在线 | 亚洲成人一区 | 欧美一级久久精品 | 日韩一区二区三区在线播放 | 午夜精品久久 | 日本免费黄色 | 久久久精品久久久 | 成人av电影免费在线观看 | 岛国av免费在线观看 | 91精品久久久久久久久久小网站 | 中文字幕在线三区 | 亚洲一二三区在线观看 | 91看片免费版 | 免费观看a级毛片在线播放 黄网站免费入口 | 午夜成人免费视频 | 欧美一区二区三区在线观看视频 | 国产色婷婷久久99精品91 | 久久国产精品视频 | 一区二区av | 欧美精品国产精品 |