4 Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
31 #include "sim_vcd_file.h"
32 #include "i2c_eeprom.h"
39 int main(int argc, char *argv[])
42 const char * fname = "atmega48_i2ctest.axf";
44 printf("Firmware pathname is %s\n", fname);
45 elf_read_firmware(fname, &f);
47 printf("firmware %s f=%d mmcu=%s\n", fname, (int)f.frequency, f.mmcu);
49 avr = avr_make_mcu_by_name(f.mmcu);
51 fprintf(stderr, "%s: AVR '%s' now known\n", argv[0], f.mmcu);
55 avr_load_firmware(avr, &f);
57 // initialize our 'peripheral'
58 i2c_eeprom_init(avr, &ee, 0xa0, 0xfe, NULL, 1024);
60 i2c_eeprom_attach(avr, &ee, AVR_IOCTL_TWI_GETIRQ(0));
63 // even if not setup at startup, activate gdb if crashing
66 //avr->state = cpu_Stopped;
71 * VCD file initialization
73 * This will allow you to create a "wave" file and display it in gtkwave
74 * Pressing "r" and "s" during the demo will start and stop recording
77 avr_vcd_init(avr, "gtkwave_output.vcd", &vcd_file, 100000 /* usec */);
78 avr_vcd_add_signal(&vcd_file,
79 avr_io_getirq(avr, AVR_IOCTL_TWI_GETIRQ(0), TWI_IRQ_STATUS), 8 /* bits */ ,
82 printf( "Demo launching:\n");
85 int state = avr_run(avr);
86 if ( state == cpu_Done || state == cpu_Crashed)