#include "custom_hid_test.h" #include "cmsis_os.h" #include "usb_device.h" #include "usbd_customhid.h" extern USBD_HandleTypeDef hUsbDeviceFS; uint8_t tx_buffer[64]; //Variable to store the output data uint8_t report_buffer[64]; //Variable to receive the report buffer uint8_t flag = 0; //Variable to store the button flag uint8_t rx_flag = 0; //Variable to store the reception flag osThreadId_t usb_task_handle; const osThreadAttr_t usb_task_attributes = { .name = "usb_test", .priority = (osPriority_t) osPriorityNormal, .stack_size = 128 * 2 }; void usb_test_task(void *argument); // void usb_test_init(void) { for (int i = 0; i < 64; i++) { tx_buffer[i] = i; } usb_task_handle = osThreadNew(usb_test_task, NULL, &usb_task_attributes); } // void usb_test_rx_data_copy(uint8_t *data) { memcpy(report_buffer, data, 64); } // void usb_test_set_rx_flag(void) { rx_flag = 1; } // void usb_test_task(void *argument) { for (;;) { if (rx_flag) { // Пришли данные. Нужно обработать! rx_flag = 0; } USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, tx_buffer, 64); osDelay(100); } }