Esempio n. 1
0
int32_t HID_Open(void)
{
	int32_t i32Ret = 0;
	
	g_HID_sDevice.isReportProtocol = 1;

	g_HID_sDevice.device = (void *)DrvUSB_InstallClassDevice(&sHidUsbClass);
	
	g_HID_sDevice.au8DeviceDescriptor = g_HID_au8DeviceDescriptor;
	g_HID_sDevice.au8ConfigDescriptor = g_HID_au8ConfigDescriptor;
	
	g_HID_sDevice.pu8HIDDescriptor = g_HID_sDevice.au8ConfigDescriptor + LEN_CONFIG + LEN_INTERFACE;	
	g_HID_sDevice.pu8IntInEPDescriptor = g_HID_sDevice.au8ConfigDescriptor + LEN_CONFIG + LEN_INTERFACE + LEN_HID;
	
	g_HID_sDevice.sVendorInfo.psVendorStringDesc = &g_HID_sVendorStringDesc;
	g_HID_sDevice.sVendorInfo.psProductStringDesc = &g_HID_sProductStringDesc;
	g_HID_sDevice.sVendorInfo.u16VendorId = *(uint16_t *)&g_HID_sDevice.au8DeviceDescriptor[8];
	g_HID_sDevice.sVendorInfo.u16ProductId = *(uint16_t *)&g_HID_sDevice.au8DeviceDescriptor[10];

	i32Ret = DrvUSB_InstallCtrlHandler(g_HID_sDevice.device, g_asCtrlCallbackEntry, 
					sizeof(g_asCtrlCallbackEntry) / sizeof(g_asCtrlCallbackEntry[0]));



	return i32Ret;
}
Esempio n. 2
0
/*---------------------------------------------------------------------------------------------------------*/
int32_t HID_Open(void *pfGetInReport, void *pfSetOutReport)
{
    S_HID_DEVICE *psDevice = &g_HID_sDevice;
	
	if ((uint32_t)pfGetInReport != NULL)
        pfHID_GetInReport = (void(*)(uint8_t *))pfGetInReport;

    if ((uint32_t)pfSetOutReport != NULL)
        pfHID_SetOutReport = (void(*)(uint8_t *, uint32_t))pfSetOutReport;
	
	/* Install the virtual com to USB device */
	psDevice->device = (void *)DrvUSB_InstallClassDevice(&sHIDClass);
	
	/* Configure the descritors */
	psDevice->au8DeviceDescriptor = gau8DeviceDescriptor;
	psDevice->au8ConfigDescriptor = gau8ConfigDescriptor;			
	
	psDevice->pu8ReportDescriptor = gau8DeviceReportDescriptor;
	psDevice->u32ReportDescriptorSize = gu32DeviceReportDescriptorSize;

	psDevice->pu8Report = g_au8DeviceReport;
	psDevice->u32ReportSize = g_u32DeviceReportSize;
	
	/* Install the USB event callbacks */
	DrvUSB_InstallCtrlHandler(psDevice->device, g_asCtrlCallbackEntry, 
	    sizeof(g_asCtrlCallbackEntry) / sizeof(g_asCtrlCallbackEntry[0]));

	return E_SUCCESS;
}
Esempio n. 3
0
int32_t HID_Open(uint32_t inReportSize, void *pfGetInReport, void *pfSetOutReport)
{
    int32_t i32Ret = E_SUCCESS;

    if ((uint32_t)pfGetInReport != NULL)
        pfHID_GetInReport = (void(*)(uint8_t *))pfGetInReport;

    if ((uint32_t)pfSetOutReport != NULL)
        pfHID_SetOutReport = (void(*)(uint8_t *))pfSetOutReport;

    g_HID_sDevice.device = (void *)DrvUSB_InstallClassDevice(&sHidUsbClass);

    g_HID_sDevice.au8DeviceDescriptor = gau8DeviceDescriptor;
    g_HID_sDevice.au8ConfigDescriptor = gau8ConfigDescriptor;
    g_HID_sDevice.pu8HIDDescriptor = g_HID_sDevice.au8ConfigDescriptor + LEN_CONFIG + LEN_INTERFACE;
    g_HID_sDevice.pu8IntInEPDescriptor = g_HID_sDevice.au8ConfigDescriptor + LEN_CONFIG + LEN_INTERFACE + LEN_HID;

    g_HID_sDevice.u32ReportSize = inReportSize;


    i32Ret = DrvUSB_InstallCtrlHandler(g_HID_sDevice.device, g_asCtrlCallbackEntry,
                                       sizeof(g_asCtrlCallbackEntry) / sizeof(g_asCtrlCallbackEntry[0]));
    return i32Ret;
}