params1.interval = round(0.5 * 1e8) params1.event = EVENT1 # start cores core0.run() core1.run() def handle_events(): while True: event = intc.out_event[IRQ] if event < 0: break intc.ev_clear_one(event) print("event", event) def irq_callback(): irq.irq_recv() handle_events() intc.out_enable_one(IRQ) loop.add_reader(irq.fileno(), irq_callback) intc.out_enable_one(IRQ) try: loop.run_forever() except KeyboardInterrupt: pass
params0.event = EVENT0 params1 = core1.dram.map( Params ) params1.interval = round( 0.5 * 1e8 ) params1.event = EVENT1 # start cores core0.run() core1.run() def handle_events(): while True: event = intc.out_event[ IRQ ] if event < 0: break intc.ev_clear_one( event ) print( "event", event ) def irq_callback(): irq.irq_recv() handle_events() intc.out_enable_one( IRQ ) loop.add_reader( irq.fileno(), irq_callback ) intc.out_enable_one( IRQ ) try: loop.run_forever() except KeyboardInterrupt: pass
# map and set parameters class Params(ctypes.Structure): _fields_ = [ ("interval", ctypes.c_uint32), # in 10ns units ("event", ctypes.c_uint8), ] params0 = core0.dram.map(Params) params0.interval = round(1.0 * 1e8) params0.event = EVENT0 params1 = core1.dram.map(Params) params1.interval = round(0.5 * 1e8) params1.event = EVENT1 # start cores core0.run() core1.run() fd = irq.fileno() os.set_inheritable(fd, True) os.environ['uio:mem:pruss-intc'] = f'{fd},0,{0x20000}' os.environ['uio-pruss:irq:test'] = f'{fd},{IRQ}' exec_path = 'intc-test-c++/intc-test-c++' os.execl(exec_path, exec_path.split('/')[-1])
#!/usr/bin/python3 import asyncio from uio.device import Uio loop = asyncio.get_event_loop() pin = Uio("/dev/uio/gpio-irq", blocking=False) pin.irq_enable() def irq_callback(): pin.irq_recv() print("Ping!") # If the irq is level-triggered instead of edge-triggered, you should # ensure that it is no longer asserted before reenabling it, otherwise # it will just immediately trigger again. pin.irq_enable() loop.add_reader(pin.fileno(), irq_callback) loop.run_forever()
#!/usr/bin/python3 import asyncio from uio.device import Uio loop = asyncio.get_event_loop() pin = Uio( "/dev/uio/gpio-irq", blocking=False ) pin.irq_enable() def irq_callback(): pin.irq_recv() print( "Ping!" ) # If the irq is level-triggered instead of edge-triggered, you should # ensure that it is no longer asserted before reenabling it, otherwise # it will just immediately trigger again. pin.irq_enable() loop.add_reader( pin.fileno(), irq_callback ) loop.run_forever()