From: Michel Pollet Date: Fri, 24 Jul 2015 15:25:11 +0000 (+0100) Subject: ADC: Skip SRB register if not present X-Git-Tag: v1.3~14 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=919dacb22088a134db1058ee4afebf958f620730;p=sx%2Fsimavr.git ADC: Skip SRB register if not present the mega8/16/32 don't have ADCSRB, this lead to a crash when we tried to register a callback on it. Signed-off-by: Michel Pollet --- diff --git a/simavr/sim/avr_adc.c b/simavr/sim/avr_adc.c index a8cd7e0..3508bd0 100644 --- a/simavr/sim/avr_adc.c +++ b/simavr/sim/avr_adc.c @@ -343,6 +343,7 @@ 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); + // some ADCs don't have ADCSRB (atmega8/16/32) 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);