Closed wuyuanyi135 closed 2 years ago
My understanding is that a ThreadSafeFlag
may be triggered from any process. It is designed to work with truly asynchronous sources and does not rely on Python interpreter magic. For example on RP2 I have had a process running on core 1 trigger a ThreadSafeFlag
created on core 0. uasyncio
was running on core 0 with a task waiting on it. So I believe triggering it from a C ISR is valid.
The mechanics of how you pass the flag to a C ISR are beyond me - I have little experience of writing MicroPython C modules.
Thank you for your explanation!
Hello,
I want to implement a driver in micropython with the async interface. There are some time delay (100us to 1ms, varying) required within the communication slots therefore employing the
sleep_ms
may not be accurate enough. The desired way is to set a flag in the C code that was triggered by the ISR to notify the scheduler that the waiting ends. In the doc I found the way to useThreadSafeFlag
in a MPY ISR. I wonder what should I use to set up such a flag in the C ISR?Regards, YW