add snes reset line sniffer and trigger watchdog reset

This commit is contained in:
optixx 2009-08-27 22:05:43 +02:00
parent b375b0d510
commit 4fa167a61d
7 changed files with 22 additions and 11 deletions

View File

@ -33,13 +33,13 @@ ifeq ($(DEBUG),1)
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o \
command.o testing.o
irq.o command.o testing.o
else
LDFLAGS = -Wl,-u
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o \
uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o \
info.o shared_memory.o command.o
info.o shared_memory.o command.o irq.o
endif
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)

View File

@ -19,6 +19,7 @@
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdlib.h>
@ -33,11 +34,14 @@ extern uint32_t req_bank_size;
void send_reset()
{
info("Reset SNES\n");
cli();
snes_reset_on();
snes_reset_lo();
_delay_ms(2);
snes_reset_hi();
snes_reset_off();
sei();
}
void send_irq()

View File

@ -6,4 +6,6 @@
#define ROM_HUFFMAN_SIZE 0
#define ROM_RLE_SIZE 31091
void irq_init();
#endif

View File

@ -302,13 +302,13 @@ void boot_startup_rom()
#if 0
dump_memory(0x10000 - 0x100, 0x10000);
#endif
snes_reset_hi();
snes_reset_off();
snes_hirom();
snes_wr_disable();
snes_bus_active();
info("Activate SNES bus\n");
_delay_ms(50);
send_reset();
_delay_ms(50);
}
void banner(){
@ -335,8 +335,11 @@ int main(void)
stdout = &uart_stdout;
banner();
system_init();
snes_reset_hi();
snes_reset_off();
info("Boot startup rom\n");
boot_startup_rom();
irq_init();
usbInit();
usb_connect();
while (1) {
@ -347,11 +350,9 @@ int main(void)
snes_wr_disable();
sei();
info("USB poll\n");
while (req_state != REQ_STATUS_SNES) {
while ((req_state != REQ_STATUS_SNES)) {
usbPoll();
}
shared_memory_write(SHARED_MEM_TX_CMD_TERMINATE, 0);
//shared_memory_scratchpad_region_tx_restore();
//shared_memory_scratchpad_region_rx_restore();
@ -363,7 +364,7 @@ int main(void)
info("Activate SNES bus\n");
send_reset();
info("Poll USB\n");
while (req_state != REQ_STATUS_AVR) {
while ((req_state != REQ_STATUS_AVR)) {
usbPoll();
#ifdef DO_IRQ
@ -402,6 +403,5 @@ int main(void)
info("Boot startup rom\n");
boot_startup_rom();
}
return 0;
}

View File

@ -34,7 +34,6 @@
uint32_t addr_current = 0;
uint32_t addr_stash = 0;
void system_init(void)
{
/*-------------------------------------------------*/
@ -92,7 +91,6 @@ void system_init(void)
}
void sreg_set(uint32_t addr)
{
uint8_t i = 24;

View File

@ -171,6 +171,7 @@
#define SNES_RESET_PORT PORTD
#define SNES_RESET_DIR DDRD
#define SNES_RESET_PIN PD3
#define SNES_RESET_INP PIND
#define snes_reset_on() (SNES_RESET_DIR |= (1 << SNES_RESET_PIN))
#define snes_reset_hi() (SNES_RESET_PORT |= (1 << SNES_RESET_PIN))
@ -178,6 +179,7 @@
#define snes_reset_off() (SNES_RESET_DIR &= ~(1 << SNES_RESET_PIN))
#define snes_reset_lo() (SNES_RESET_PORT &= ~(1 << SNES_RESET_PIN))
#define snes_reset_test() ((SNES_RESET_INP & (1 << SNES_RESET_PIN)) == 0)
#define MMC_PORT PORTB
#define MMC_DIR DDRB

View File

@ -29,7 +29,11 @@
#include "debug.h"
#include "info.h"
#include "sram.h"
extern uint8_t snes_reset_line;
#ifndef OCR1A
#define OCR1A OCR1 // 2313 support
#endif
@ -52,6 +56,7 @@ uint16_t volatile second; // count seconds
ISR (SIG_OUTPUT_COMPARE1A)
{
#if XTAL % DEBOUNCE // bei rest
OCR1A = 20000000UL / DEBOUNCE - 1; // compare DEBOUNCE - 1 times