finish system status
This commit is contained in:
@@ -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; i<ROM_BUFFER_CNT; i++){
|
||||
addr += rle_decode(_rom[i], _rom_size[i], addr);
|
||||
}
|
||||
@@ -110,8 +119,15 @@ void boot_startup_rom(uint16_t init_delay)
|
||||
info(PSTR("crc=%x\n"),crc);
|
||||
#endif
|
||||
|
||||
system_set_rom_hirom();
|
||||
//snes_irq_lo();
|
||||
//snes_irq_off();
|
||||
//snes_hirom();
|
||||
//snes_wr_disable();
|
||||
|
||||
system_set_bus_snes();
|
||||
system_set_rom_hirom();
|
||||
system_set_wr_disable();
|
||||
system_snes_irq_off();
|
||||
system_send_snes_reset();
|
||||
_delay_ms(init_delay);
|
||||
}
|
||||
@@ -143,4 +159,5 @@ void transaction_status(){
|
||||
info_P(PSTR("TX buffer %02i\n"),usb_trans.tx_remaining);
|
||||
info_P(PSTR("RX buffer %02i\n"),usb_trans.rx_remaining);
|
||||
info_P(PSTR("Syncerr %02i\n"),usb_trans.sync_errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
#ifndef __COMMAND_H__
|
||||
#define __COMMAND_H__
|
||||
|
||||
void send_reset();
|
||||
void send_irq();
|
||||
void set_rom_mode();
|
||||
void usb_connect();
|
||||
void boot_startup_rom(uint16_t init_delay);
|
||||
void banner();
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
|
||||
#define DO_CRC_CHECK_LOADER 0
|
||||
#define DO_CRC_CHECK 0
|
||||
#define DO_SHM_SCRATCHPAD 1
|
||||
#define DO_SHM 1
|
||||
#define DO_TIMER 1
|
||||
#define DO_SHM_SCRATCHPAD 0
|
||||
#define DO_SHM 0
|
||||
#define DO_TIMER 0
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,7 +56,7 @@ extern FILE uart_stdout;
|
||||
#endif
|
||||
extern system_t system;
|
||||
|
||||
uint8_t debug_level = (DEBUG | DEBUG_USB | DEBUG_CRC | DEBUG_SHM );
|
||||
uint8_t debug_level = (DEBUG | DEBUG_CRC);
|
||||
|
||||
|
||||
usb_transaction_t usb_trans;
|
||||
@@ -263,10 +263,15 @@ int main(void)
|
||||
usb_connect();
|
||||
sei();
|
||||
while (1) {
|
||||
|
||||
system_set_bus_avr();
|
||||
system_set_wr_disable();
|
||||
/*
|
||||
avr_bus_active();
|
||||
info_P(PSTR("Activate AVR bus\n"));
|
||||
info_P(PSTR("Disable SNES WR\n"));
|
||||
snes_wr_disable();
|
||||
*/
|
||||
info_P(PSTR("USB poll\n"));
|
||||
while (usb_trans.req_state != REQ_STATUS_SNES) {
|
||||
usbPoll();
|
||||
@@ -289,6 +294,12 @@ int main(void)
|
||||
crc_check_bulk_memory(0x000000, usb_trans.req_bank_size * usb_trans.req_bank_cnt, usb_trans.req_bank_size);
|
||||
#endif
|
||||
|
||||
system_set_rom_mode(&usb_trans);
|
||||
system_set_wr_disable();
|
||||
system_set_bus_snes();
|
||||
system_send_snes_reset();
|
||||
irq_stop();
|
||||
/*
|
||||
info_P(PSTR("-->Switch 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user