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_DataIn (
void *pudev, uint8_t EpID);
36 static uint8_t* USBD_HID_GetCfgDesc (uint8_t USBSpeed, uint16_t *len);
41 static uint32_t USBD_HID_AltSet = 0;
42 static uint32_t USBD_HID_Protocol = 0;
43 static uint32_t USBD_HID_IdleState = 0;
45 extern __IO uint8_t PrevXferComplete;
58 USBD_HID_GetClassDescriptor,
59 USBD_HID_ClassReqHandle,
60 USBD_HID_GetInterface,
61 USBD_HID_SetInterface,
71 const uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZE] =
74 USB_DESCTYPE_CONFIGURATION,
75 USB_HID_CONFIG_DESC_SIZE,
85 USB_DESCTYPE_INTERFACE,
102 USB_HID_REPORT_DESC_SIZE,
107 USB_DESCTYPE_ENDPOINT,
115 const uint8_t HID_ReportDesc[USB_HID_REPORT_DESC_SIZE] =
147 static uint8_t USBD_HID_Init (
void *pudev, uint8_t ConfigIndex)
172 static uint8_t USBD_HID_DeInit (
void *pudev, uint8_t ConfigIndex)
187 static uint8_t USBD_HID_ClassReqHandle (
void *pudev,
USB_DEVICE_REQ *req)
189 switch (req->bRequest)
196 USB_CtlTx (pudev, (uint8_t *)&USBD_HID_IdleState, 1);
200 USB_CtlTx (pudev, (uint8_t *)&USBD_HID_Protocol, 1);
208 USBD_HID_IdleState = (uint8_t)(req->wValue >> 8);
212 USBD_HID_Protocol = (uint8_t)(req->wValue);
229 static uint8_t USBD_HID_GetClassDescriptor (
void *pudev,
USB_DEVICE_REQ *req)
232 uint8_t *pbuf = NULL;
234 switch(req->wValue >> 8)
236 case HID_REPORT_DESCTYPE:
237 len = MIN(USB_HID_REPORT_DESC_SIZE, req->wLength);
238 pbuf = (uint8_t *)HID_ReportDesc;
242 len = MIN(USB_HID_DESC_SIZE, req->wLength);
243 pbuf = (uint8_t *)USBD_HID_CfgDesc + 0x12;
261 static uint8_t USBD_HID_GetInterface (
void *pudev,
USB_DEVICE_REQ *req)
263 USB_CtlTx (pudev, (uint8_t *)&USBD_HID_AltSet, 1);
274 static uint8_t USBD_HID_SetInterface (
void *pudev,
USB_DEVICE_REQ *req)
276 USBD_HID_AltSet = (uint8_t)(req->wValue);
293 if (pudev->dev.device_cur_status == USB_STATUS_CONFIGURED)
295 PrevXferComplete = 0;
297 USB_EP_Tx (pudev, HID_IN_EP, report, Len);
308 static uint8_t USBD_HID_DataIn (
void *pudev, uint8_t EpID)
310 PrevXferComplete = 1;
321 static uint8_t* USBD_HID_GetCfgDesc (uint8_t USBSpeed, uint16_t *len)
323 *len =
sizeof (USBD_HID_CfgDesc);
325 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.