29 static uint8_t USBD_HID_Init (
void *pudev, uint8_t ConfigIndex);
30 static uint8_t USBD_HID_DeInit (
void *pudev, uint8_t ConfigIndex);
31 static uint8_t USBD_HID_GetClassDescriptor (
void *pudev,
USB_DEVICE_REQ *req);
32 static uint8_t USBD_HID_ClassReqHandle (
void *pudev,
USB_DEVICE_REQ *req);
33 static uint8_t USBD_HID_GetInterface (
void *pudev,
USB_DEVICE_REQ *req);
34 static uint8_t USBD_HID_SetInterface (
void *pudev,
USB_DEVICE_REQ *req);
35 static uint8_t* USBD_HID_GetCfgDesc (uint8_t USBSpeed, uint16_t *len);
40 static uint32_t USBD_HID_AltSet = 0;
41 static uint32_t USBD_HID_Protocol = 0;
42 static uint32_t USBD_HID_IdleState = 0;
55 USBD_HID_GetClassDescriptor,
56 USBD_HID_ClassReqHandle,
57 USBD_HID_GetInterface,
58 USBD_HID_SetInterface,
68 const uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZE] =
71 USB_DESCTYPE_CONFIGURATION,
72 USB_HID_CONFIG_DESC_SIZE,
82 USB_DESCTYPE_INTERFACE,
99 USB_HID_REPORT_DESC_SIZE,
104 USB_DESCTYPE_ENDPOINT,
112 const uint8_t HID_ReportDesc[USB_HID_REPORT_DESC_SIZE] =
144 static uint8_t USBD_HID_Init (
void *pudev, uint8_t ConfigIndex)
169 static uint8_t USBD_HID_DeInit (
void *pudev, uint8_t ConfigIndex)
184 static uint8_t USBD_HID_ClassReqHandle (
void *pudev,
USB_DEVICE_REQ *req)
186 switch (req->bRequest)
193 USB_CtlTx (pudev, (uint8_t *)&USBD_HID_IdleState, 1);
197 USB_CtlTx (pudev, (uint8_t *)&USBD_HID_Protocol, 1);
205 USBD_HID_IdleState = (uint8_t)(req->wValue >> 8);
209 USBD_HID_Protocol = (uint8_t)(req->wValue);
226 static uint8_t USBD_HID_GetClassDescriptor (
void *pudev,
USB_DEVICE_REQ *req)
229 uint8_t *pbuf = NULL;
231 switch(req->wValue >> 8)
233 case HID_REPORT_DESCTYPE:
234 len = MIN(USB_HID_REPORT_DESC_SIZE, req->wLength);
235 pbuf = (uint8_t *)HID_ReportDesc;
239 len = MIN(USB_HID_DESC_SIZE, req->wLength);
240 pbuf = (uint8_t *)USBD_HID_CfgDesc + 0x12;
258 static uint8_t USBD_HID_GetInterface (
void *pudev,
USB_DEVICE_REQ *req)
260 USB_CtlTx (pudev, (uint8_t *)&USBD_HID_AltSet, 1);
271 static uint8_t USBD_HID_SetInterface (
void *pudev,
USB_DEVICE_REQ *req)
273 USBD_HID_AltSet = (uint8_t)(req->wValue);
290 if (pudev->dev.device_cur_status == USB_STATUS_CONFIGURED)
292 USB_EP_Tx (pudev, HID_IN_EP, report, Len);
304 static uint8_t* USBD_HID_GetCfgDesc (uint8_t USBSpeed, uint16_t *len)
306 *len =
sizeof (USBD_HID_CfgDesc);
308 return (uint8_t *)USBD_HID_CfgDesc;
uint8_t USBD_HID_SendReport(USB_DEVICE_HANDLE *pudev, uint8_t *report, uint16_t Len)
Send mouse report.
USB device class callback type define.
void USB_EP_Tx(USB_CORE_HANDLE *pudev, uint8_t EpAddr, uint8_t *pbuf, uint16_t BufLen)
Endpoint prepare to transmit data.
USB mouse (USB HID device) header file.
void USB_EP_DeInit(USB_CORE_HANDLE *pudev, uint8_t EpAddr)
Configure the endpoint when it is disabled.
void USB_EP_Init(USB_CORE_HANDLE *pudev, uint8_t EpAddr, uint8_t EpType, uint16_t EpMps)
Endpoint initialization.
uint8_t USB_CtlTx(USB_CORE_HANDLE *pudev, uint8_t *pbuf, uint16_t Len)
Transmit data on the control pipe.
#define USB_SNG_BUFTYPE
USB endpoint kind.
void USB_EP_BufConfig(USB_CORE_HANDLE *pudev, uint8_t EpAddr, uint8_t EpKind, uint32_t BufAddr)
Configure buffer for endpoint.
void USBD_EnumError(USB_DEVICE_HANDLE *pudev, USB_DEVICE_REQ *req)
Handle usb enumeration error event.
USB standard device request struct.