From 67e02fb38e6d3bad5bf8625a8960ee1ccae78c29 Mon Sep 17 00:00:00 2001 From: optixx Date: Sun, 18 Oct 2009 14:05:47 +0200 Subject: [PATCH] finish system status --- avr/usbload/command.c | 25 +- avr/usbload/command.h | 3 - avr/usbload/config.h | 6 +- avr/usbload/main.c | 25 +- avr/usbload/shell.c | 14 +- avr/usbload/system.c | 44 ++- avr/usbload/system.h | 3 + quickdev16.tmproj | 651 +++++------------------------------------- todo.txt | 4 + 9 files changed, 164 insertions(+), 611 deletions(-) diff --git a/avr/usbload/command.c b/avr/usbload/command.c index 34d6876..e991c72 100644 --- a/avr/usbload/command.c +++ b/avr/usbload/command.c @@ -35,6 +35,7 @@ extern usb_transaction_t usb_trans; +extern system_t system; extern const char *_rom[]; extern const char _rom01[]; @@ -57,7 +58,6 @@ void usb_connect() } - void send_reset() { info_P(PSTR("Reset SNES\n")); @@ -90,14 +90,23 @@ void set_rom_mode() } } - void boot_startup_rom(uint16_t init_delay) { uint8_t i; uint32_t addr = 0x000000; + info_P(PSTR("Fetch loader rom\n")); + system_set_bus_avr(); system_snes_irq_off(); system_set_rom_lorom(); + + //info_P(PSTR("Activate AVR bus\n")); + //avr_bus_active(); + //info_P(PSTR("IRQ off\n")); + //snes_irq_lo(); + //snes_irq_off(); + //snes_lorom(); + for (i=0; iSwitch TO SNES\n")); set_rom_mode(); snes_wr_disable(); @@ -297,6 +308,7 @@ int main(void) info_P(PSTR("Activate SNES bus\n")); irq_stop(); send_reset(); +*/ info_P(PSTR("Poll USB\n")); while ((usb_trans.req_state != REQ_STATUS_AVR)) { usbPoll(); @@ -304,15 +316,18 @@ int main(void) shell_run(); #endif } - info_P(PSTR("-->Switch TO AVR\n")); + //info_P(PSTR("-->Switch TO AVR\n")); shared_memory_init(); - irq_init(); if(usb_trans.loader_enabled) { boot_startup_rom(500); } else { - avr_bus_active(); - send_reset(); + system_set_bus_avr(); + system_send_snes_reset(); + //avr_bus_active(); + //send_reset(); + } + irq_init(); } return 0; } diff --git a/avr/usbload/shell.c b/avr/usbload/shell.c index 2b9dedc..2be38a8 100644 --- a/avr/usbload/shell.c +++ b/avr/usbload/shell.c @@ -39,6 +39,7 @@ #include "crc.h" #include "command.h" #include "shared_memory.h" +#include "system.h" @@ -196,6 +197,7 @@ enum cmds { CMD_DUMP, CMD_LOADER, CMD_RECONNECT, CMD_STATUS, + CMD_SYS, CMD_HELP }; @@ -216,6 +218,7 @@ uint8_t cmdlist[][CMD_HELP] PROGMEM = { {"LOADER"}, {"RECONNECT"}, {"STATUS"}, + {"SYS"}, {"HELP"}, }; @@ -266,7 +269,8 @@ void shell_run(void) }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_EXIT]) == 0) { leave_application(); }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_RESET]) == 0) { - send_reset(); + //send_reset(); + system_send_snes_reset(); }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_IRQ]) == 0) { info_P(PSTR("Send IRQ\n")); snes_irq_on(); @@ -321,16 +325,12 @@ void shell_run(void) usb_connect(); }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_STATUS]) == 0) { transaction_status(); + }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_SYS]) == 0) { + system_status(); }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_HELP]) == 0) { shell_help(); } prompt(); - /* - dias - set irq vector - set reset vector - dump cart header - */ } diff --git a/avr/usbload/system.c b/avr/usbload/system.c index f9e7ab2..2223108 100644 --- a/avr/usbload/system.c +++ b/avr/usbload/system.c @@ -104,16 +104,22 @@ void system_set_bus_avr() avr_bus_active(); info_P(PSTR("Activate AVR bus\n")); system.bus_mode = MODE_AVR; +} + +void system_set_wr_disable(){ snes_wr_disable(); system.wr_line = WR_DISABLE; info_P(PSTR("Disable SNES WR\n")); } +void system_set_wr_enable(){ + snes_wr_enable(); + system.wr_line = WR_ENABLE; + info_P(PSTR("Enable SNES WR\n")); +} + void system_set_bus_snes() { - snes_wr_disable(); - system.wr_line = WR_DISABLE; - info_P(PSTR("Disable SNES WR\n")); snes_bus_active(); system.bus_mode = MODE_SNES; info_P(PSTR("Activate SNES bus\n")); @@ -146,3 +152,35 @@ void system_set_rom_hirom() system.rom_mode = HIROM; info_P(PSTR("Set SNES hirom \n")); } + +char* system_status_helper(uint8_t val){ + if (val) + return "ON"; + else + return "OFF"; +} + +char* system_status_bus(uint8_t val){ + if (val) + return "SNES"; + else + return "AVR"; +} + +char* system_status_rom(uint8_t val){ + if (val) + return "HIROM"; + else + return "LOROM"; +} + +void system_status(){ + info_P(PSTR("\nBus Mode %s\n"),system_status_bus(system.bus_mode)); + info_P(PSTR("Rom Mode %s\n"),system_status_rom(system.rom_mode)); + info_P(PSTR("Reset Line %s\n"),system_status_helper(system.reset_line)); + info_P(PSTR("IRQ Line %s\n"),system_status_helper(system.irq_line)); + info_P(PSTR("WR Line %s\n"),system_status_helper(system.wr_line)); + info_P(PSTR("Reset IRQ %s\n"),system_status_helper(system.reset_irq)); + info_P(PSTR("SNES Reset 0x%02x\n"),system.snes_reset_count); + info_P(PSTR("AVR Reset 0x%02x\n"),system.avr_reset_count); +} \ No newline at end of file diff --git a/avr/usbload/system.h b/avr/usbload/system.h index a145518..39d62e6 100644 --- a/avr/usbload/system.h +++ b/avr/usbload/system.h @@ -49,6 +49,9 @@ void system_set_rom_mode(usb_transaction_t *usb_trans); void system_set_rom_hirom(void); void system_set_rom_lorom(void); void system_snes_irq_off(void); +void system_set_wr_disable(void); +void system_set_wr_enable(void); +void system_status(); #endif diff --git a/quickdev16.tmproj b/quickdev16.tmproj index ee46526..ba0bfc0 100644 --- a/quickdev16.tmproj +++ b/quickdev16.tmproj @@ -26,30 +26,14 @@ caret column - 0 + 18 line - 88 + 42 - columnSelection - firstVisibleColumn 0 firstVisibleLine - 56 - selectFrom - - column - 0 - line - 56 - - selectTo - - column - 0 - line - 88 - + 95 avr/usbload/command.h @@ -65,347 +49,49 @@ firstVisibleLine 0 - avr/usbload/config.h - - caret - - column - 5 - line - 45 - - firstVisibleColumn - 0 - firstVisibleLine - 10 - - avr/usbload/crc.c - - caret - - column - 0 - line - 59 - - firstVisibleColumn - 0 - firstVisibleLine - 15 - - avr/usbload/debug.c - - caret - - column - 5 - line - 26 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - avr/usbload/debug.h - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 2 - - avr/usbload/dump.c - - caret - - column - 15 - line - 28 - - firstVisibleColumn - 0 - firstVisibleLine - 36 - - avr/usbload/dump.h - - caret - - column - 0 - line - 3 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - avr/usbload/irq.c - - caret - - column - 1 - line - 62 - - firstVisibleColumn - 0 - firstVisibleLine - 24 - - avr/usbload/irq.h - - caret - - column - 19 - line - 26 - - columnSelection - - firstVisibleColumn - 0 - firstVisibleLine - 0 - selectFrom - - column - 5 - line - 26 - - selectTo - - column - 22 - line - 26 - - - avr/usbload/loader.c caret column 0 line - 0 + 54 firstVisibleColumn 0 firstVisibleLine - 734 + 26 avr/usbload/main.c caret column - 0 + 18 line - 299 + 269 columnSelection firstVisibleColumn 0 firstVisibleLine - 190 + 247 selectFrom column - 0 + 8 line - 292 + 269 selectTo column - 0 - line - 299 - - - avr/usbload/pwm.c - - caret - - column - 0 - line - 100 - - firstVisibleColumn - 0 - firstVisibleLine - 33 - - avr/usbload/pwm.h - - caret - - column - 20 - line - 33 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - avr/usbload/requests.h - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 13 - - avr/usbload/rle.c - - caret - - column - 40 - line - 99 - - firstVisibleColumn - 0 - firstVisibleLine - 55 - - avr/usbload/rle.h - - caret - - column - 0 - line - 0 - - columnSelection - - firstVisibleColumn - 0 - firstVisibleLine - 0 - selectFrom - - column - 17 - line - 21 - - selectTo - - column - 0 - line - 0 - - - avr/usbload/shared_memory.c - - caret - - column - 14 - line - 235 - - firstVisibleColumn - 0 - firstVisibleLine - 210 - - avr/usbload/shared_memory.h - - caret - - column - 52 - line - 50 - - firstVisibleColumn - 0 - firstVisibleLine - 29 - - avr/usbload/shell.c - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 289 - - avr/usbload/shell.h - - caret - - column - 22 - line 23 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - avr/usbload/sram.c - - caret - - column - 9 line - 36 + 269 - firstVisibleColumn - 0 - firstVisibleLine - 3 - - avr/usbload/sram.h - - caret - - column - 9 - line - 198 - - firstVisibleColumn - 0 - firstVisibleLine - 178 avr/usbload/system.c @@ -414,152 +100,56 @@ column 0 line - 85 + 119 firstVisibleColumn 0 firstVisibleLine - 48 + 78 avr/usbload/system.h caret column - 0 + 12 line - 25 + 33 + columnSelection + firstVisibleColumn 0 firstVisibleLine - 0 - - avr/usbload/timer.c - - caret + 1 + selectFrom column - 6 - line - 80 - - firstVisibleColumn - 0 - firstVisibleLine - 47 - - avr/usbload/timer.h - - caret - - column - 0 - line - 29 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - avr/usbload/uart.c - - caret - - column - 0 - line - 20 - - firstVisibleColumn - 0 - firstVisibleLine - 26 - - avr/usbload/usb_bulk.c - - caret - - column - 14 - line - 71 - - firstVisibleColumn - 0 - firstVisibleLine - 36 - - avr/usbload/usb_bulk.h - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - avr/usbload/usbconfig.h - - caret - - column - 42 - line - 129 - - firstVisibleColumn - 0 - firstVisibleLine - 88 - - avr/usbload/util.c - - caret - - column - 0 - line - 116 - - firstVisibleColumn - 0 - firstVisibleLine - 84 - - avr/usbload/util.h - - caret - - column - 1 - line - 29 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - scripts/check_rle.py - - caret - - column - 14 - line 9 + line + 33 + + selectTo + + column + 19 + line + 33 + + + scripts/conv_rle.py + + caret + + column + 0 + line + 86 firstVisibleColumn 0 firstVisibleLine - 0 + 49 snes/banktest/LoadGraphics.asm @@ -589,149 +179,16 @@ firstVisibleLine 211 - tools/qdinc/opendevice.h - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/qdinc/qdinc.c - - caret - - column - 0 - line - 26 - - firstVisibleColumn - 0 - firstVisibleLine - 15 - - tools/qdinc/qdinc.h - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 3 - - tools/ucon64/src/backup/quickdev16.c - - caret - - column - 30 - line - 71 - - firstVisibleColumn - 0 - firstVisibleLine - 181 - - tools/ucon64/src/backup/smsgg-pro.h - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/ucon64/src/console/snes.c - - caret - - column - 0 - line - 2695 - - columnSelection - - firstVisibleColumn - 0 - firstVisibleLine - 3814 - selectFrom - - column - 1 - line - 2887 - - selectTo - - column - 0 - line - 2695 - - openDocuments - avr/usbload/sram.c + scripts/conv_rle.py avr/usbload/main.c - tools/qdinc/qdinc.c - tools/qdinc/opendevice.h - tools/qdinc/qdinc.h - avr/usbload/system.h - avr/usbload/sram.h - avr/usbload/usb_bulk.c - avr/usbload/usbconfig.h - avr/usbload/requests.h - avr/usbload/debug.h - avr/usbload/shell.c - tools/ucon64/src/backup/smsgg-pro.h - tools/ucon64/src/console/snes.c - tools/ucon64/src/backup/quickdev16.c - avr/usbload/config.h - avr/usbload/timer.c - avr/usbload/rle.c - avr/usbload/pwm.c - avr/usbload/loader.c - scripts/check_rle.py - avr/usbload/pwm.h - avr/usbload/shared_memory.c - avr/usbload/system.c - avr/usbload/command.c avr/usbload/command.h + avr/usbload/system.c + avr/usbload/system.h + avr/usbload/command.c avr/usbload/irq.c - avr/usbload/irq.h - avr/usbload/crc.c - avr/usbload/dump.c - avr/usbload/debug.c - avr/usbload/dump.h - avr/usbload/uart.c - avr/usbload/util.c - avr/usbload/timer.h - avr/usbload/util.h - avr/usbload/usb_bulk.h - avr/usbload/rle.h - avr/usbload/shell.h - avr/usbload/shared_memory.h showFileHierarchyDrawer @@ -760,6 +217,21 @@ + packages + + isExpanded + + subItems + + huffman + + isExpanded + + subItems + + + + scripts isExpanded @@ -767,6 +239,13 @@ subItems + snes + + isExpanded + + subItems + + tools isExpanded diff --git a/todo.txt b/todo.txt index 4bcf907..8bbc73c 100644 --- a/todo.txt +++ b/todo.txt @@ -1,2 +1,6 @@ SDcard header Add structs for machine state +Shell: dump cart header +Shell: dump and set irq vector +Shell: Dump and set reset vector +verbose system status values