simavr icon indicating copy to clipboard operation
simavr copied to clipboard

register_notify for entry Port

Open ricardojlrufino opened this issue 5 years ago • 3 comments

is there any way to optimize the code below? instead of registering pin by pin, monitor all?

	// connect all the pins on port B to our callback
	for (int i = 0; i < 8; i++){
		avr_irq_register_notify(
			avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), i),pins_portB_hook, NULL
		);

		avr_irq_register_notify(
			avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), i),pins_portC_hook, NULL
		);

		avr_irq_register_notify(
			avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('D'), i),pins_portD_hook, NULL
		);
	}

ricardojlrufino avatar Jun 09 '20 16:06 ricardojlrufino

Sure, therie is a IOPORT_ALL in ioport.h, that will send you a byte with all pins for that port...

buserror avatar Jun 09 '20 17:06 buserror

IOPORT_IRQ_PIN_ALL ?!

ricardojlrufino avatar Jun 09 '20 17:06 ricardojlrufino

Yarp!

buserror avatar Jun 09 '20 19:06 buserror