2010-06-23 01:56 AM
ST USB_LIBS 3.2.0
2011-05-17 04:55 AM
Personally I agree the use of systick instead of ''bare count'' because the old method depends strongly on CPU speed and load and could be very variable. Besides, it is a blocking process (other tasks are blocked when delay is running) while systick can be used with interrupt.
Since you use the Systick for your application, you can combine both functionalities using local/global variables (tokens). Or you can modify the uDelay function to use a Timer instead of systick.2011-05-17 04:55 AM
the use of a interrupt delay is not so simple.... almost all the function used in the usb stack are called from OTG irq.
The SYSTICK timer is used for istance in the FreeRTOS realtime kernel for the contest switch... and this timer is the obvious one to use for this scope.2011-05-17 04:55 AM
If you already have a ms tick count maintained by systick then why not use this for the delay e.g.
void delay_ms(u32 delay_ms) { u32 start = systick_ms; while ((systick_ms - start) < delay_ms) { . // maybe do other stuff here . } } sytick_ms needs to be volatile.2011-05-17 04:55 AM
I already have a function like the one you suggest me,
I use this function in my code! The problem to use this delay function in USB stack is that the USB functions are called from inside the USB IRQ HANDLER! There is a nesting irq problem to solve in order to use a interrupt driven delay. I have a couple of Real Time OS that use the SYSTICK as system tick source.... I criticize the use of SYSTICK in this way because you loose a timer for a delay function!