I am currently evaluating the k22 as a potential replacement for our current micro (which is more expensive), and I believe I have found a potential deal-breaker in the USB Host protocol stack that is used in the MCUXpresso demo applications (both the bare metal and the freertos implementations for the msd fatfs demo).
In usb_host_khci.c in the function _USB_HostKhciAttach() there is a NOP-based delay loop of about 120ms (133ms by my rough calculations based on the disassembly). There are also a few other smaller loops elsewhere in the file, but the 120ms loop is the worst offender. We use a simple cooperative task scheduler in our code base, so something like this is just not going to work when we have 100, 10, 5, and 1 ms tasks which will be blocked every time a USB device is attached.
I am thinking that this would probably force us to use an RTOS (which is arguably where we should be headed), but even in an RTOS the NOP-based delay is wasteful compared to a vTaskDelay() call (and the timing will be longer if the task is preempted).
Are there alternative USB stacks which better support a bare-metal/cooperative environment? I think it may in theory be possible to replace these delays with a state-machine-based delay mechanism, but if the stack was not designed for this use case then I am not sure if the effort would be worth it.
For reference, we are coming from a Tiva part, and as best I can tell the tivaware usb host library is implemented without loop-based delays. The delays I see are all using counters that assume a task call rate of 1ms, so they yield to the superloop/scheduler instead of holding up the processor for the entire delay.
Any advice is appreciated.