-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Closed
Labels
extmodRelates to extmod/ directory in sourceRelates to extmod/ directory in source
Description
This arose from this forum post. The following code sample only runs the task scheduled by the ISR when the one running task wakes up. Tested on a Pyboard 1.1 running firmware V1.13.
import uasyncio
from machine import Pin
import micropython
async def example_task():
print('example task running')
def task_launcher(_):
print('task_launcher running')
uasyncio.create_task(example_task())
def irq_handler(pin):
print('IRQ!', pin.value())
micropython.schedule(task_launcher, None)
trigger = Pin(Pin.board.X6, Pin.IN, Pin.PULL_UP)
trigger.irq(irq_handler, Pin.IRQ_FALLING | Pin.IRQ_RISING)
async def endless_loop():
while True:
print('Tick.')
await uasyncio.sleep(5)
print('Tock.')
await uasyncio.sleep(5)
uasyncio.run(endless_loop())
Given that #6106 is not merged, the problem can't be fixed with an Event.
Is there a way to interface uasyncio with an ISR other than a busy-wait loop?
Metadata
Metadata
Assignees
Labels
extmodRelates to extmod/ directory in sourceRelates to extmod/ directory in source