美文网首页
8. USB HID Device

8. USB HID Device

作者: T_K_233 | 来源:发表于2020-12-25 22:31 被阅读0次

    https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf

    image.png image.png image.png

    勾选 “Generate peripheral initialization ...” 一项,以便能够更改库函数

    image.png

    打开 usbd_hid.cusb_device.c 文件

    image.png

    main.c

    /* USER CODE BEGIN Includes */
    #include "usbd_hid.h"
    /* USER CODE END Includes */
    
    // ...
    
      /* USER CODE BEGIN 2 */
    
      extern USBD_HandleTypeDef hUsbDeviceFS;
      uint8_t HID_buffer[8] = {0};
      /* USER CODE END 2 */
    
      // ...
    
        /* USER CODE BEGIN 3 */
    
        HID_buffer[0] = 0b00000010; // shift
        HID_buffer[2] = 7;          // D
    
        USBD_HID_SendReport(&hUsbDeviceFS, HID_buffer, 8);
        HAL_Delay(20);
    
        HID_buffer[0] = 0; // shift
        HID_buffer[2] = 0;          // D
    
        USBD_HID_SendReport(&hUsbDeviceFS, HID_buffer, 8);
    
        HAL_Delay(2000);
    
      }
      /* USER CODE END 3 */
    

    相关文章

      网友评论

          本文标题:8. USB HID Device

          本文链接:https://www.haomeiwen.com/subject/vuqlrktx.html