From 8b7739b4a78f594ce7cf011f5031836c4c62c72f Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Thu, 2 Sep 2010 13:00:48 +0100 Subject: [PATCH] IOs: Use new IRQ alloc function All converted to the brand new way... Signed-off-by: Michel Pollet --- simavr/sim/avr_adc.c | 7 ++----- simavr/sim/avr_extint.c | 8 +++----- simavr/sim/avr_ioport.c | 7 ++----- simavr/sim/avr_spi.c | 8 ++------ simavr/sim/avr_timer.c | 12 +++++------- simavr/sim/avr_twi.c | 4 +--- simavr/sim/avr_uart.c | 8 +++----- 7 files changed, 18 insertions(+), 36 deletions(-) diff --git a/simavr/sim/avr_adc.c b/simavr/sim/avr_adc.c index 7dafdbb..3e010c9 100644 --- a/simavr/sim/avr_adc.c +++ b/simavr/sim/avr_adc.c @@ -221,13 +221,10 @@ void avr_adc_init(avr_t * avr, avr_adc_t * p) { p->io = _io; - // allocate this module's IRQ - p->io.irq_count = ADC_IRQ_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_ADC_GETIRQ; - avr_register_io(avr, &p->io); avr_register_vector(avr, &p->adc); + // allocate this module's IRQ + avr_io_setirqs(&p->io, AVR_IOCTL_ADC_GETIRQ, ADC_IRQ_COUNT, NULL); avr_register_io_write(avr, p->r_adcsra, avr_adc_write, p); avr_register_io_read(avr, p->r_adcl, avr_adc_read_l, p); diff --git a/simavr/sim/avr_extint.c b/simavr/sim/avr_extint.c index 4d1ce65..5a900fc 100644 --- a/simavr/sim/avr_extint.c +++ b/simavr/sim/avr_extint.c @@ -78,13 +78,11 @@ void avr_extint_init(avr_t * avr, avr_extint_t * p) { p->io = _io; - // allocate this module's IRQ - p->io.irq_count = EXTINT_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_EXTINT_GETIRQ(); - avr_register_io(avr, &p->io); for (int i = 0; i < EXTINT_COUNT; i++) avr_register_vector(avr, &p->eint[i].vector); + + // allocate this module's IRQ + avr_io_setirqs(&p->io, AVR_IOCTL_EXTINT_GETIRQ(), EXTINT_COUNT, NULL); } diff --git a/simavr/sim/avr_ioport.c b/simavr/sim/avr_ioport.c index 010e62e..cb238eb 100644 --- a/simavr/sim/avr_ioport.c +++ b/simavr/sim/avr_ioport.c @@ -172,14 +172,11 @@ void avr_ioport_init(avr_t * avr, avr_ioport_t * p) // p->name, p->r_pin, // p->name, p->r_ddr, // p->name, p->r_port); - - // allocate this module's IRQ - p->io.irq_count = IOPORT_IRQ_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_IOPORT_GETIRQ(p->name); avr_register_io(avr, &p->io); avr_register_vector(avr, &p->pcint); + // allocate this module's IRQ + avr_io_setirqs(&p->io, AVR_IOCTL_IOPORT_GETIRQ(p->name), IOPORT_IRQ_COUNT, NULL); avr_register_io_write(avr, p->r_port, avr_ioport_write, p); avr_register_io_read(avr, p->r_pin, avr_ioport_read, p); diff --git a/simavr/sim/avr_spi.c b/simavr/sim/avr_spi.c index 141eb1e..3b35328 100644 --- a/simavr/sim/avr_spi.c +++ b/simavr/sim/avr_spi.c @@ -90,15 +90,11 @@ static avr_io_t _io = { void avr_spi_init(avr_t * avr, avr_spi_t * p) { p->io = _io; + avr_register_io(avr, &p->io); avr_register_vector(avr, &p->spi); - - //printf("%s SPI%c init\n", __FUNCTION__, p->name); - // allocate this module's IRQ - p->io.irq_count = SPI_IRQ_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_SPI_GETIRQ(p->name); + avr_io_setirqs(&p->io, AVR_IOCTL_SPI_GETIRQ(p->name), SPI_IRQ_COUNT, NULL); avr_register_io_write(avr, p->r_spdr, avr_spi_write, p); avr_register_io_read(avr, p->r_spdr, avr_spi_read, p); diff --git a/simavr/sim/avr_timer.c b/simavr/sim/avr_timer.c index be21338..f019952 100644 --- a/simavr/sim/avr_timer.c +++ b/simavr/sim/avr_timer.c @@ -392,10 +392,12 @@ void avr_timer_init(avr_t * avr, avr_timer_t * p) { p->io = _io; + avr_register_io(avr, &p->io); + avr_register_vector(avr, &p->overflow); + avr_register_vector(avr, &p->icr); + // allocate this module's IRQ - p->io.irq_count = TIMER_IRQ_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_TIMER_GETIRQ(p->name); + avr_io_setirqs(&p->io, AVR_IOCTL_TIMER_GETIRQ(p->name), TIMER_IRQ_COUNT, NULL); // marking IRQs as "filtered" means they don't propagate if the // new value raised is the same as the last one.. in the case of the @@ -403,10 +405,6 @@ void avr_timer_init(avr_t * avr, avr_timer_t * p) p->io.irq[TIMER_IRQ_OUT_PWM0].flags |= IRQ_FLAG_FILTERED; p->io.irq[TIMER_IRQ_OUT_PWM1].flags |= IRQ_FLAG_FILTERED; - avr_register_io(avr, &p->io); - avr_register_vector(avr, &p->overflow); - avr_register_vector(avr, &p->icr); - if (p->wgm[0].reg) // these are not present on older AVRs avr_register_io_write(avr, p->wgm[0].reg, avr_timer_write, p); avr_register_io_write(avr, p->cs[0].reg, avr_timer_write, p); diff --git a/simavr/sim/avr_twi.c b/simavr/sim/avr_twi.c index cc521d0..668070a 100644 --- a/simavr/sim/avr_twi.c +++ b/simavr/sim/avr_twi.c @@ -122,9 +122,7 @@ void avr_twi_init(avr_t * avr, avr_twi_t * p) //printf("%s TWI%c init\n", __FUNCTION__, p->name); // allocate this module's IRQ - p->io.irq_count = TWI_IRQ_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_TWI_GETIRQ(p->name); + avr_io_setirqs(&p->io, AVR_IOCTL_TWI_GETIRQ(p->name), TWI_IRQ_COUNT, NULL); avr_register_io_write(avr, p->r_twdr, avr_twi_write, p); avr_register_io_read(avr, p->r_twdr, avr_twi_read, p); diff --git a/simavr/sim/avr_uart.c b/simavr/sim/avr_uart.c index c1e82f6..3a7c6ae 100644 --- a/simavr/sim/avr_uart.c +++ b/simavr/sim/avr_uart.c @@ -219,11 +219,6 @@ void avr_uart_init(avr_t * avr, avr_uart_t * p) // printf("%s UART%c UDR=%02x\n", __FUNCTION__, p->name, p->r_udr); - // allocate this module's IRQ - p->io.irq_count = UART_IRQ_COUNT; - p->io.irq = avr_alloc_irq(0, p->io.irq_count); - p->io.irq_ioctl_get = AVR_IOCTL_UART_GETIRQ(p->name); - p->flags = AVR_UART_FLAG_POOL_SLEEP|AVR_UART_FLAG_STDIO; avr_register_io(avr, &p->io); @@ -231,6 +226,9 @@ void avr_uart_init(avr_t * avr, avr_uart_t * p) avr_register_vector(avr, &p->txc); avr_register_vector(avr, &p->udrc); + // allocate this module's IRQ + avr_io_setirqs(&p->io, AVR_IOCTL_UART_GETIRQ(p->name), UART_IRQ_COUNT, NULL); + avr_register_io_write(avr, p->r_udr, avr_uart_write, p); avr_register_io_read(avr, p->r_udr, avr_uart_read, p); // monitor code that reads the rxc flag, and delay it a bit -- 2.39.5