From: Michel Pollet Date: Tue, 31 Aug 2010 10:55:29 +0000 (+0100) Subject: ioport: Added an IRQ for the port pin direction changes X-Git-Tag: v1.0a5~1 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=2a64138243a89df06b0f6ab4c9ce47f130af53d9;p=sx%2Fsimavr.git ioport: Added an IRQ for the port pin direction changes New IRQ for client code (ie "board code") will be called when the AVR firmware changes the DDR register. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/avr_ioport.c b/simavr/sim/avr_ioport.c index be30652..010e62e 100644 --- a/simavr/sim/avr_ioport.c +++ b/simavr/sim/avr_ioport.c @@ -64,6 +64,18 @@ static void avr_ioport_pin_write(struct avr_t * avr, avr_io_addr_t addr, uint8_t avr_ioport_write(avr, p->r_port, avr->data[p->r_port] ^ v, param); } +/* + * This is a the callback for the DDR register. There is nothing much to do here, apart + * from triggering an IRQ in case any 'client' code is interested in the information. + */ +static void avr_ioport_ddr_write(struct avr_t * avr, avr_io_addr_t addr, uint8_t v, void * param) +{ + avr_ioport_t * p = (avr_ioport_t *)param; + + avr_raise_irq(p->io.irq + IOPORT_IRQ_DIRECTION_ALL, v); + avr_core_watch_write(avr, addr, v); +} + /* * this is our "main" pin change callback, it can be triggered by either the * AVR code, or any external piece of code that see fit to do it. @@ -172,5 +184,6 @@ void avr_ioport_init(avr_t * avr, avr_ioport_t * p) avr_register_io_write(avr, p->r_port, avr_ioport_write, p); avr_register_io_read(avr, p->r_pin, avr_ioport_read, p); avr_register_io_write(avr, p->r_pin, avr_ioport_pin_write, p); + avr_register_io_write(avr, p->r_ddr, avr_ioport_ddr_write, p); } diff --git a/simavr/sim/avr_ioport.h b/simavr/sim/avr_ioport.h index 1fc2ba4..06497e2 100644 --- a/simavr/sim/avr_ioport.h +++ b/simavr/sim/avr_ioport.h @@ -29,6 +29,7 @@ enum { IOPORT_IRQ_PIN1,IOPORT_IRQ_PIN2,IOPORT_IRQ_PIN3,IOPORT_IRQ_PIN4, IOPORT_IRQ_PIN5,IOPORT_IRQ_PIN6,IOPORT_IRQ_PIN7, IOPORT_IRQ_PIN_ALL, + IOPORT_IRQ_DIRECTION_ALL, IOPORT_IRQ_COUNT };