/* Free a device structure, all reports, and all fields.  */
void hid_free_device(HidDev_t *HidDev)
/* Free a device structure, all reports, and all fields.  */
void hid_free_device(HidDev_t *HidDev)
{
    unsigned int i = 0;
    unsigned int j = 0;
    for (i = 0; i < USB_HID_REPORT_TYPES; i++) {
        usbHidReportEnum_t *report_enum = HidDev->HidReportEnum + i;
        for (j = 0; j < 256; j++) {
            usbHidReport_t *report = report_enum->Report[j];
            if (report){
                report_enum->ReportNum  -= 1;
                hid_free_report(report);
                report_enum->Report[j] = NULL;
            }
        }
    }
    if(HidDev->collection){
        hal_free(HidDev->collection);
        HidDev->collection = NULL;
    }
    return ;
}