uint32_t USB_HostHubGetTotalThinkTime(usb_host_handle hostHandle, uint8_t parentHubNo)
{
usb_host_hub_instance_t *hubInstance;
uint32_t deviceAddress = 0U;
usb_host_hub_global_t *hubGlobal = USB_HostHubGetHubList(hostHandle);
if (hubGlobal == NULL)
{
return 0U;
}
hubInstance = hubGlobal->hubList;
/* get parentHubNo's hub instance handle */
while (hubInstance != NULL)
{
(void)USB_HostHelperGetPeripheralInformation(hubInstance->deviceHandle, (uint32_t)kUSB_HostGetDeviceAddress,
&deviceAddress);
if (parentHubNo == deviceAddress)
{
break;
}
hubInstance = hubInstance->next;
}
if (hubInstance != NULL)
{
return hubInstance->totalThinktime;
}
return 0;
}
I upped the queue length in the FreeRTOSConfig.h file to 105 so it would process the SOF's after it did the 100ms delay which seemed to work as now what happens is I get an attach event, reset device event, then a hub attached event and then it hardfaults at the function I posted above. I stepped through it and it seems that the hubInstance->next never equals null even though there is only 1 hub. So it ends trying to assign a garbage pointer to hubInstace and then hardfaults there. Trying to find where hubInstance->next should be assigned to null because it never does as far as I can tell.
I also found that when you create a new project with the latest SDK that the examples don't seem to match the version of FreeRTOS that the new projects have. I ran a file comparison on the FreeRTOSConfig.h and found some differences that I altered to make match.