From eee46acd8c68d2576d4851d3f24fa22ced608f1e Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Sun, 20 Dec 2009 23:05:38 +0000 Subject: [PATCH] ADC: Placeholder IO module Not doing anything for now, but the IO blocks are filled in the core definitiond already. Signed-off-by: Michel Pollet --- simavr/sim/avr_adc.c | 45 ++++++++++++++++++++++++++++++++++ simavr/sim/avr_adc.h | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 simavr/sim/avr_adc.c create mode 100644 simavr/sim/avr_adc.h diff --git a/simavr/sim/avr_adc.c b/simavr/sim/avr_adc.c new file mode 100644 index 0000000..4b9a7bd --- /dev/null +++ b/simavr/sim/avr_adc.c @@ -0,0 +1,45 @@ +/* + avr_adc.c + + Copyright 2008, 2009 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . + */ + + +#include +#include +#include +#include "avr_adc.h" + +/* + * PLACEHOLDER ADC MODULE + */ + +static avr_io_t _io = { + .kind = "adc", +}; + +void avr_adc_init(avr_t * avr, avr_adc_t * p) +{ + p->io = _io; + + avr_register_io(avr, &p->io); + avr_register_vector(avr, &p->adc); + +// avr_register_io_write(avr, p->r_eecr, avr_eeprom_write, p); +} + diff --git a/simavr/sim/avr_adc.h b/simavr/sim/avr_adc.h new file mode 100644 index 0000000..e756871 --- /dev/null +++ b/simavr/sim/avr_adc.h @@ -0,0 +1,57 @@ +/* + avr_adc.h + + Copyright 2008, 2009 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . + */ + +#ifndef __AVR_ADC_H___ +#define __AVR_ADC_H___ + +#include "sim_avr.h" + +typedef struct avr_adc_t { + avr_io_t io; + + uint8_t r_admux; + // if the last bit exists in the mux, we are an extended ADC + avr_regbit_t mux[5]; + avr_regbit_t ref[3]; // reference voltage + avr_regbit_t adlar; // left/right adjustment bit + + uint8_t r_adcsra; // ADC Control and Status Register A + avr_regbit_t aden; // ADC Enabled + avr_regbit_t adsc; // ADC Start Conversion + avr_regbit_t adate; // ADC Auto Trigger Enable + + avr_regbit_t adps[3]; // Prescaler bits. Note that it's a frequency bit shift + + uint8_t r_adcl, r_adch; // Data Registers + + uint8_t r_adcsrb; // ADC Control and Status Register B + avr_regbit_t adts[3]; // Timing Source + avr_regbit_t bin; // Bipolar Input Mode (tinyx5 have it) + avr_regbit_t ipr; // Input Polarity Reversal (tinyx5 have it) + + + // use ADIF and ADIE bits + avr_int_vector_t adc; +} avr_adc_t; + +void avr_adc_init(avr_t * avr, avr_adc_t * port); + +#endif /* __AVR_ADC_H___ */ -- 2.39.5