11 #include <avr/interrupt.h>
12 #include <avr/eeprom.h>
13 #include <avr/sleep.h>
16 * This demonstrate how to use the avr_mcu_section.h file
17 * The macro adds a section to the ELF file with useful
18 * information for the simulator
20 #include "avr_mcu_section.h"
21 AVR_MCU(F_CPU, "atmega88");
23 /* declare this in a .eeprom ELF section */
24 uint32_t value EEMEM = 0xdeadbeef;
26 static int uart_putchar(char c, FILE *stream) {
28 uart_putchar('\r', stream);
29 loop_until_bit_is_set(UCSR0A, UDRE0);
34 static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
42 // read the eeprom value
43 uint32_t c = eeprom_read_dword((void*)&value);
44 printf("Read from eeprom 0x%08lx -- should be 0xdeadbeef\n", c);
46 eeprom_write_dword((void*)&value, 0xcafef00d);
48 c = eeprom_read_dword((void*)&value);
49 printf("Read from eeprom 0x%08lx -- should be 0xcafef00d\n", c);
51 // this quits the simulator, since interupts are off
52 // this is a "feature" that allows running tests cases and exit