106 static void USBH_HID_ParseHIDDesc (
HID_DescTypeDef *desc, uint8_t *buf);
115 USBH_HID_InterfaceInit,
116 USBH_HID_InterfaceDeInit,
117 USBH_HID_ClassRequest,
147 interface =
USBH_FindInterface(phost, phost->pActiveClass->ClassCode, HID_BOOT_CODE, 0xFF);
149 if(interface == 0xFF)
152 USBH_DbgLog (
"Cannot Find the interface for %s class.", phost->pActiveClass->Name);
162 if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol ==
HID_KEYBRD_BOOT_CODE)
167 else if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bInterfaceProtocol ==
HID_MOUSE_BOOT_CODE)
180 HID_Handle->
ep_addr = phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].bEndpointAddress;
181 HID_Handle->
length = phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].wMaxPacketSize;
182 HID_Handle->
poll = phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].bInterval ;
192 max_ep = ( (phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bNumEndpoints <=
USBH_MAX_NUM_ENDPOINTS) ?
193 phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].bNumEndpoints :
198 for ( ;num < max_ep; num++)
200 if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[num].bEndpointAddress & 0x80)
202 HID_Handle->
InEp = (phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[num].bEndpointAddress);
204 USBH_AllocPipe(phost, HID_Handle->
InEp);
210 phost->device.address,
220 HID_Handle->
OutEp = (phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[num].bEndpointAddress);
222 USBH_AllocPipe(phost, HID_Handle->
OutEp);
228 phost->device.address,
252 if(HID_Handle->
InPipe != 0x00)
259 if(HID_Handle->
OutPipe != 0x00)
362 switch (HID_Handle->
state)
365 HID_Handle->
Init(phost);
387 #if (USBH_USE_OS == 1) 413 #if (USBH_USE_OS == 1) 454 #if (USBH_USE_OS == 1) 569 return USBH_CtlReq(phost, reportBuff , reportLen );
600 return USBH_CtlReq(phost, reportBuff , reportLen );
635 static void USBH_HID_ParseHIDDesc (
HID_DescTypeDef *desc, uint8_t *buf)
638 desc->
bLength = *(uint8_t *) (buf + 0);
691 return (HID_Handle->
poll);
732 for(i=0; i < nbytes; i++)
765 p = (
const uint8_t*) buf;
769 for(i=0; i < nbytes; i++)
USBH_StatusTypeDef USBH_InterruptReceiveData(USBH_HandleTypeDef *phost, uint8_t *buff, uint8_t length, uint8_t hc_num)
USBH_InterruptReceiveData Receives the Device Response to the Interrupt IN token. ...
#define HID_KEYBRD_BOOT_CODE
USBH_DeviceTypeDef device
USBH_StatusTypeDef USBH_HID_SetIdle(USBH_HandleTypeDef *phost, uint8_t duration, uint8_t reportId)
USBH_Set_Idle Set Idle State.
USBH_StatusTypeDef USBH_OpenPipe(USBH_HandleTypeDef *phost, uint8_t ch_num, uint8_t epnum, uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps)
USBH_Open_Pipe Open a pipe.
USBH_StatusTypeDef USBH_SelectInterface(USBH_HandleTypeDef *phost, uint8_t interface)
USBH_SelectInterface Select current interface.
USBH_StatusTypeDef USBH_HID_MouseInit(USBH_HandleTypeDef *phost)
USBH_HID_MouseInit The function init the HID mouse.
#define USB_HID_GET_REPORT
#define HOST_USER_CLASS_ACTIVE
HID_TypeTypeDef USBH_HID_GetDeviceType(USBH_HandleTypeDef *phost)
USBH_HID_GetDeviceType Return Device function.
USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost, uint8_t idx)
USBH_Free_Pipe Free the USB Pipe.
uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
USBH_FindInterface Find the interface index for a specific class.
USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, uint8_t ep_num)
USBH_ClrFeature This request is used to clear or disable a specific feature.
void(* pUser)(struct _USBH_HandleTypeDef *pHandle, uint8_t id)
This file contains all the prototypes for the usbh_hid.c.
#define USBH_MAX_NUM_ENDPOINTS
USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES]
USBH_StatusTypeDef USBH_HID_KeybdInit(USBH_HandleTypeDef *phost)
USBH_HID_KeybdInit The function init the HID keyboard.
USBH_CfgDescTypeDef CfgDesc
#define USB_REQ_RECIPIENT_INTERFACE
USBH_StatusTypeDef(* Init)(USBH_HandleTypeDef *phost)
USBH_StatusTypeDef USBH_CtlReq(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length)
USBH_CtlReq USBH_CtlReq sends a control request and provide the status after completion of the reques...
USBH_ClassTypeDef HID_Class
#define USB_DESC_HID_REPORT
void fifo_init(FIFO_TypeDef *f, uint8_t *buf, uint16_t size)
fifo_init Initialize FIFO.
#define USB_REQ_TYPE_STANDARD
__weak void USBH_HID_EventCallback(USBH_HandleTypeDef *phost)
The function is a callback about HID Data events.
uint16_t fifo_read(FIFO_TypeDef *f, void *buf, uint16_t nbytes)
fifo_read Read from FIFO.
USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t, uint8_t)
USBH_LL_SetToggle Set toggle for a pipe.
USBH_StatusTypeDef USBH_HID_SetReport(USBH_HandleTypeDef *phost, uint8_t reportType, uint8_t reportId, uint8_t *reportBuff, uint8_t reportLen)
USBH_HID_Set_Report Issues Set Report.
USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t)
USBH_LL_GetURBState Get a URB state from the low level driver.
uint8_t bReportDescriptorType
#define USB_HID_DESC_SIZE
USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost, uint8_t req_type, uint16_t value_idx, uint8_t *buff, uint16_t length)
USBH_GetDescriptor Issues Descriptor command to the device. Once the response received, it parses the descriptor and updates the status.
USBH_StatusTypeDef USBH_HID_SetProtocol(USBH_HandleTypeDef *phost, uint8_t protocol)
USBH_Set_Protocol Set protocol State.
__IO HOST_StateTypeDef gState
uint16_t fifo_write(FIFO_TypeDef *f, const void *buf, uint16_t nbytes)
fifo_write Read from FIFO.
uint8_t current_interface
#define USB_HID_SET_PROTOCOL
USBH_StatusTypeDef USBH_HID_GetReport(USBH_HandleTypeDef *phost, uint8_t reportType, uint8_t reportId, uint8_t *reportBuff, uint8_t reportLen)
USBH_HID_GetReport retreive Set Report.
#define USB_HID_SET_REPORT
USBH_StatusTypeDef USBH_HID_GetHIDDescriptor(USBH_HandleTypeDef *phost, uint16_t length)
USBH_Get_HID_Descriptor Issue HID Descriptor command to the device. Once the response received...
uint8_t bInterfaceProtocol
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
#define HID_MOUSE_BOOT_CODE
uint8_t Data[USBH_MAX_DATA_BUFFER]
USBH_ClassTypeDef * pActiveClass
HID_CtlStateTypeDef ctl_state
USBH_StatusTypeDef USBH_HID_GetHIDReportDescriptor(USBH_HandleTypeDef *phost, uint16_t length)
USBH_Get_HID_ReportDescriptor Issue report Descriptor command to the device. Once the response receiv...
struct _USB_Setup::_SetupPkt_Struc b
uint8_t USBH_HID_GetPollInterval(USBH_HandleTypeDef *phost)
USBH_HID_GetPollInterval Return HID device poll time.
USBH_StatusTypeDef USBH_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe_num)
USBH_ClosePipe Close a pipe.