Native equivalent of Thread.Sleep()

Hi guys,

I am playing with interrop code to extend the possibilities of my Fez Cerbuino and I need some advice/help.

Actually, I’ve added some native librairies to my TinyClr build to build a native driver for an LCD Display. I have a C# class with a few OutputPorts wich calls into native code.
In this native code, i’ve found the way to get the managed object and call the CPU_GPIO_SetPinState function to set the state of my outputports.

Now i’m trying to add a delay in native code between two of those calls to CPU_GPIO_SetPinState. So i’ve looked for the native implementation of Thread.Sleep() and finaly got it, but i don’t quite understant it fully.
From what I’ve seen, Thread.Sleep() gets called multiple times a,d depending on the value of the managed stack’s “custom state”, it either calls the scheduler to go to sleep or returns an error or ok.

I still have trouble understanding how it works and how I could apply this to my native code. I would like to be able to put a delay in native code wich uses the scheduler so other managed thread would go on while I’m waiting.

So does any one of you could tell me if it is possible ? How could I adapt the native Thread.Sleep() implementation to problem ? And more generally how to interact with the scheduler from native code…

Any help is very much appreciated, thanks.

PS : I know this subject could go to NETMF forums but you’ve helped me a lot before so I’m hopping you still can.

Take a look at one wire code please. There are many ways to add delays.

Ho I’ll look at this tonight.
Thanks

Ok so i looked at the code of onewire and found the usDelay method wich uses in turn HAL_Time_Sleep_MicroSeconds().

I found the implementation of this method in the STM32_Time_Functions.cpp.

That’s the key, thanks som much.