標(biāo)題: STM32鼠標(biāo)按鍵程序 [打印本頁]

作者: fourz    時(shí)間: 2020-1-9 12:58
標(biāo)題: STM32鼠標(biāo)按鍵程序
鼠標(biāo)按鍵的實(shí)現(xiàn),沒main函數(shù)
  1. #include <stm32f10x_lib.h>
  2. #include "sys.h"
  3. #include "delay.h"          
  4. #include "usb_lib.h"
  5. #include "hw_config.h"
  6. #include "usb_pwr.h"  

  7. extern u8 EP1BUSY;
  8. extern u8 USB_INIT;

  9. u8 key[2]={0x4f,0x50};
  10.                   
  11. int main(void)
  12. {
  13.         u32 i=0;
  14.         u8 j=0;

  15.         Stm32_Clock_Init(9);//系統(tǒng)時(shí)鐘設(shè)置
  16.         delay_init(72);                //延時(shí)初始化
  17.         //USB配置
  18.         USB_Interrupts_Config();   
  19.         Set_USBClock();  
  20.         USB_Init();      
  21.         while(1)
  22.         {
  23.                 if(USB_INIT)
  24.                 {
  25.                         if(bDeviceState==CONFIGURED)
  26.                         {
  27.                                 if (EP1BUSY==0)
  28.                                 {
  29.                                         i++;
  30.                                         if(i%2)
  31.                                         {
  32.                                                 Joystick_Send(0x01, 0, key[j]);
  33.                                                 j++;
  34.                                                 if(j==2)
  35.                                                         j=0;
  36.                                         }
  37.                                         else
  38.                                                 Joystick_Send(0x01, 0, 0);
  39.                                 }
  40.                         }
  41.                 }
  42.         }
  43. }
復(fù)制代碼


STM32_USB_鼠標(biāo)鍵盤.zip

158.76 KB, 下載次數(shù): 29, 下載積分: 黑幣 -5






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1