From f65ac1a207cc940757cd33dc05346adb7a9c60b9 Mon Sep 17 00:00:00 2001 From: bsekisser Date: Sun, 26 Apr 2015 08:34:36 -0400 Subject: [PATCH] adc: check r_adcsrb is valid before init fix issue #118 modified: simavr/sim/avr_adc.c --- simavr/sim/avr_adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simavr/sim/avr_adc.c b/simavr/sim/avr_adc.c index 712bfb7..b1c5f55 100644 --- a/simavr/sim/avr_adc.c +++ b/simavr/sim/avr_adc.c @@ -326,7 +326,8 @@ void avr_adc_init(avr_t * avr, avr_adc_t * p) avr_io_setirqs(&p->io, AVR_IOCTL_ADC_GETIRQ, ADC_IRQ_COUNT, NULL); avr_register_io_write(avr, p->r_adcsra, avr_adc_write_adcsra, p); - avr_register_io_write(avr, p->r_adcsrb, avr_adc_write_adcsrb, p); + if (p->r_adcsrb) + avr_register_io_write(avr, p->r_adcsrb, avr_adc_write_adcsrb, p); avr_register_io_read(avr, p->r_adcl, avr_adc_read_l, p); avr_register_io_read(avr, p->r_adch, avr_adc_read_h, p); } -- 2.39.5