add snes reset line sniffer and trigger watchdog reset
This commit is contained in:
parent
b375b0d510
commit
4fa167a61d
@ -33,13 +33,13 @@ ifeq ($(DEBUG),1)
|
|||||||
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
|
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 \
|
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 \
|
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
|
else
|
||||||
LDFLAGS = -Wl,-u
|
LDFLAGS = -Wl,-u
|
||||||
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
|
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 \
|
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 \
|
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
|
endif
|
||||||
|
|
||||||
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -33,11 +34,14 @@ extern uint32_t req_bank_size;
|
|||||||
void send_reset()
|
void send_reset()
|
||||||
{
|
{
|
||||||
info("Reset SNES\n");
|
info("Reset SNES\n");
|
||||||
|
cli();
|
||||||
snes_reset_on();
|
snes_reset_on();
|
||||||
snes_reset_lo();
|
snes_reset_lo();
|
||||||
_delay_ms(2);
|
_delay_ms(2);
|
||||||
snes_reset_hi();
|
snes_reset_hi();
|
||||||
snes_reset_off();
|
snes_reset_off();
|
||||||
|
sei();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_irq()
|
void send_irq()
|
||||||
|
|||||||
@ -6,4 +6,6 @@
|
|||||||
#define ROM_HUFFMAN_SIZE 0
|
#define ROM_HUFFMAN_SIZE 0
|
||||||
#define ROM_RLE_SIZE 31091
|
#define ROM_RLE_SIZE 31091
|
||||||
|
|
||||||
|
void irq_init();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -302,13 +302,13 @@ void boot_startup_rom()
|
|||||||
#if 0
|
#if 0
|
||||||
dump_memory(0x10000 - 0x100, 0x10000);
|
dump_memory(0x10000 - 0x100, 0x10000);
|
||||||
#endif
|
#endif
|
||||||
snes_reset_hi();
|
|
||||||
snes_reset_off();
|
|
||||||
snes_hirom();
|
snes_hirom();
|
||||||
snes_wr_disable();
|
snes_wr_disable();
|
||||||
snes_bus_active();
|
snes_bus_active();
|
||||||
info("Activate SNES bus\n");
|
info("Activate SNES bus\n");
|
||||||
|
_delay_ms(50);
|
||||||
send_reset();
|
send_reset();
|
||||||
|
_delay_ms(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void banner(){
|
void banner(){
|
||||||
@ -335,8 +335,11 @@ int main(void)
|
|||||||
stdout = &uart_stdout;
|
stdout = &uart_stdout;
|
||||||
banner();
|
banner();
|
||||||
system_init();
|
system_init();
|
||||||
|
snes_reset_hi();
|
||||||
|
snes_reset_off();
|
||||||
info("Boot startup rom\n");
|
info("Boot startup rom\n");
|
||||||
boot_startup_rom();
|
boot_startup_rom();
|
||||||
|
irq_init();
|
||||||
usbInit();
|
usbInit();
|
||||||
usb_connect();
|
usb_connect();
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -347,11 +350,9 @@ int main(void)
|
|||||||
snes_wr_disable();
|
snes_wr_disable();
|
||||||
sei();
|
sei();
|
||||||
info("USB poll\n");
|
info("USB poll\n");
|
||||||
while (req_state != REQ_STATUS_SNES) {
|
while ((req_state != REQ_STATUS_SNES)) {
|
||||||
usbPoll();
|
usbPoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
shared_memory_write(SHARED_MEM_TX_CMD_TERMINATE, 0);
|
shared_memory_write(SHARED_MEM_TX_CMD_TERMINATE, 0);
|
||||||
//shared_memory_scratchpad_region_tx_restore();
|
//shared_memory_scratchpad_region_tx_restore();
|
||||||
//shared_memory_scratchpad_region_rx_restore();
|
//shared_memory_scratchpad_region_rx_restore();
|
||||||
@ -363,7 +364,7 @@ int main(void)
|
|||||||
info("Activate SNES bus\n");
|
info("Activate SNES bus\n");
|
||||||
send_reset();
|
send_reset();
|
||||||
info("Poll USB\n");
|
info("Poll USB\n");
|
||||||
while (req_state != REQ_STATUS_AVR) {
|
while ((req_state != REQ_STATUS_AVR)) {
|
||||||
usbPoll();
|
usbPoll();
|
||||||
|
|
||||||
#ifdef DO_IRQ
|
#ifdef DO_IRQ
|
||||||
@ -402,6 +403,5 @@ int main(void)
|
|||||||
info("Boot startup rom\n");
|
info("Boot startup rom\n");
|
||||||
boot_startup_rom();
|
boot_startup_rom();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,6 @@
|
|||||||
uint32_t addr_current = 0;
|
uint32_t addr_current = 0;
|
||||||
uint32_t addr_stash = 0;
|
uint32_t addr_stash = 0;
|
||||||
|
|
||||||
|
|
||||||
void system_init(void)
|
void system_init(void)
|
||||||
{
|
{
|
||||||
/*-------------------------------------------------*/
|
/*-------------------------------------------------*/
|
||||||
@ -92,7 +91,6 @@ void system_init(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sreg_set(uint32_t addr)
|
void sreg_set(uint32_t addr)
|
||||||
{
|
{
|
||||||
uint8_t i = 24;
|
uint8_t i = 24;
|
||||||
|
|||||||
@ -171,6 +171,7 @@
|
|||||||
#define SNES_RESET_PORT PORTD
|
#define SNES_RESET_PORT PORTD
|
||||||
#define SNES_RESET_DIR DDRD
|
#define SNES_RESET_DIR DDRD
|
||||||
#define SNES_RESET_PIN PD3
|
#define SNES_RESET_PIN PD3
|
||||||
|
#define SNES_RESET_INP PIND
|
||||||
|
|
||||||
#define snes_reset_on() (SNES_RESET_DIR |= (1 << SNES_RESET_PIN))
|
#define snes_reset_on() (SNES_RESET_DIR |= (1 << SNES_RESET_PIN))
|
||||||
#define snes_reset_hi() (SNES_RESET_PORT |= (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_off() (SNES_RESET_DIR &= ~(1 << SNES_RESET_PIN))
|
||||||
#define snes_reset_lo() (SNES_RESET_PORT &= ~(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_PORT PORTB
|
||||||
#define MMC_DIR DDRB
|
#define MMC_DIR DDRB
|
||||||
|
|||||||
@ -29,6 +29,10 @@
|
|||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
|
#include "sram.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern uint8_t snes_reset_line;
|
||||||
|
|
||||||
#ifndef OCR1A
|
#ifndef OCR1A
|
||||||
#define OCR1A OCR1 // 2313 support
|
#define OCR1A OCR1 // 2313 support
|
||||||
@ -53,6 +57,7 @@ uint16_t volatile second; // count seconds
|
|||||||
ISR (SIG_OUTPUT_COMPARE1A)
|
ISR (SIG_OUTPUT_COMPARE1A)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
#if XTAL % DEBOUNCE // bei rest
|
#if XTAL % DEBOUNCE // bei rest
|
||||||
OCR1A = 20000000UL / DEBOUNCE - 1; // compare DEBOUNCE - 1 times
|
OCR1A = 20000000UL / DEBOUNCE - 1; // compare DEBOUNCE - 1 times
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user