3 #include <avr/pgmspace.h>
4 #include <avr/eeprom.h>
8 #include "../monitor.h"
12 /* variables mirrored in EEPROM */
13 uint8_t ee_slots[8] EEMEM;
16 uint8_t menu_main(void)
18 uint8_t need_save = 0;
22 printf_P(PSTR("\nAVR Monitor\n===========\n"));
23 printf_P(PSTR("\t(1) Change Slot Configuration\n"));
24 printf_P(PSTR("\t(2) Load IHEX file to memory\n"));
25 printf_P(PSTR("\t(3) Reset System\n"));
26 printf_P(PSTR("\t(9) Exit\n"));
27 printf_P(PSTR("Select: "));
28 sel = uart_getc(NULL);
29 printf_P(PSTR("\n\n"));
32 case '1': if(menu_slots() != 0) need_save = 1; break;
33 case '2': menu_ihex(); break;
34 case '3': bus_reset(); break;
36 default: printf_P(PSTR("Invalid Entry!\n")); break;
44 /* clear break flag and turn on serial echo */
49 /* run main menu and save if changes happened and user wishes */
51 printf_P(PSTR("Settings have been changed. Save [y/N]? "));
52 int res = uart_getc(NULL);
56 printf_P(PSTR("\n\tSaving..."));
57 for(uint8_t i = 0; i < 8; i++)
58 eeprom_update_byte(&ee_slots[i], slots[i]);
59 printf_P(PSTR("done.\n"));
62 printf_P(PSTR("\n\tSettings have NOT been saved.\n"));
65 /* turn off serial echo */
68 printf_P(PSTR("Returning to system.\n"));
74 uint8_t run_monitor = 0;
76 /* read variables from EEPROM */
77 for(uint8_t i = 0; i < 8; i++)
78 slots[i] = eeprom_read_byte(&ee_slots[i]);
80 /* check for valid values */
81 for(uint8_t i = 0; i < 8; i++)
85 /* run monitor if necessary */
87 printf_P(PSTR("\nEEPROM contains invalid entries.\n"));