 /********************************************************************************
  * @file           : usbd_custom_hid_if.c
  * @version        : v1.0 zhanli.
  * @brief          : 自定义HID的USB设备的接口文件, 配置报告描述符
 *******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "usbd_custom_hid_if.h"

/* External variables --------------------------------------------------------*/



/* 这个地方配置USB HID 设备的报告描述符 */
__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{
  0x05,0x8c, /* USAGE_PAGE (ST Page) */
  0x09,0x01, /* USAGE (Demo Kit) */
  0xa1,0x01, /* COLLECTION (Application) */

  // The Input report
  0x09,0x03, // USAGE ID - Vendor defined
  0x15,0x00, // LOGICAL_MINIMUM (0)
  0x26,0x00, 0xFF, // LOGICAL_MAXIMUM (255)
  0x75,0x08, // REPORT_SIZE (8bit)
  0x95,0x40, // REPORT_COUNT (64Byte)
  0x81,0x02, // INPUT (Data,Var,Abs)

  // The Output report
  0x09,0x04, // USAGE ID - Vendor defined
  0x15,0x00, // LOGICAL_MINIMUM (0)
  0x26,0x00,0xFF, // LOGICAL_MAXIMUM (255)
  0x75,0x08, // REPORT_SIZE (8bit)
  0x95,0x40, // REPORT_COUNT (64Byte)
  0x91,0x02, // OUTPUT (Data,Var,Abs)
  0xC0    /*     END_COLLECTION             */
};

extern USBD_HandleTypeDef hUsbDeviceFS;

static int8_t CUSTOM_HID_Init_FS(void);
static int8_t CUSTOM_HID_DeInit_FS(void);
static int8_t CUSTOM_HID_OutEvent_FS(uint8_t event_idx, uint8_t state);


USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops_FS =
{
  CUSTOM_HID_ReportDesc_FS,
  CUSTOM_HID_Init_FS,
  CUSTOM_HID_DeInit_FS,
  CUSTOM_HID_OutEvent_FS
};

/**
  * @brief  Initializes the CUSTOM HID media low layer
  * @retval USBD_OK if all operations are OK else USBD_FAIL
  */
static int8_t CUSTOM_HID_Init_FS(void)
{
  return (USBD_OK);
}

/**
  * @brief  DeInitializes the CUSTOM HID media low layer
  * @retval 成功返回 USBD_OK 否则返回 USBD_FAIL
  */
static int8_t CUSTOM_HID_DeInit_FS(void)
{
  return (USBD_OK);
}   

/**
  * @brief  管理自定义HID事件
  * @param  event_idx: Event index
  * @param  state: Event state
  * @retval 成功返回 USBD_OK 否则返回 USBD_FAIL
  */
static int8_t CUSTOM_HID_OutEvent_FS(uint8_t event_idx, uint8_t state)
{
  /* USER CODE BEGIN 6 */
  return (USBD_OK);
}


/**
  * @brief  发送报告到主机
  * @param  report: The report to be sent
  * @param  len: The report length
  * @retval USBD_OK if all operations are OK else USBD_FAIL
  */

//static int8_t USBD_CUSTOM_HID_SendReport_FS(uint8_t *report, uint16_t len)
//{
//  return USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, report, len);
//}



