示例#1
0
void system_set_rom_mode(usb_transaction_t * usb_trans)
{
    if (usb_trans->req_bank_size == 0x8000) {
        snes_lorom();
        my_system.rom_mode = LOROM;
        info_P(PSTR("Set SNES lorom \n"));
    } else {
        snes_hirom();
        my_system.rom_mode = HIROM;
        info_P(PSTR("Set SNES hirom \n"));
    }
}
示例#2
0
uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
{
    uint8_t *ptr;
    uint8_t i;

    if (len > usb_trans.rx_remaining) {
        info_P(PSTR
               ("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n"),
               usb_trans.rx_remaining, len);
        len = usb_trans.rx_remaining;
    }
    if (usb_trans.req_state == REQ_STATUS_BULK_UPLOAD) {

        usb_trans.rx_remaining -= len;
        debug_P(DEBUG_USB_TRANS,
                PSTR
                ("usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n"),
                usb_trans.req_addr, len, usb_trans.rx_remaining);
        ptr = data;
        i = len;
        while (i--) {
            sram_bulk_write(*ptr++);
            sram_bulk_write_next();
        }
    }
    return len;
}
示例#3
0
void system_status()
{
    info_P(PSTR("\nBus Mode       %s\n"), system_status_bus(my_system.bus_mode));
    info_P(PSTR("Rom Mode       %s\n"), system_status_rom(my_system.rom_mode));
    info_P(PSTR("Reset Line     %s\n"),
           system_status_helper(my_system.reset_line));
    info_P(PSTR("IRQ Line       %s\n"), system_status_helper(my_system.irq_line));
    info_P(PSTR("WR Line        %s\n"), system_status_helper(my_system.wr_line));
    info_P(PSTR("Reset IRQ      %s\n"), system_status_helper(my_system.reset_irq));
    info_P(PSTR("SNES Reset     0x%02x\n"), my_system.snes_reset_count);
    info_P(PSTR("AVR Reset      0x%02x\n"), my_system.avr_reset_count);
}
示例#4
0
void system_send_snes_reset()
{
    info_P(PSTR("Reset SNES\n"));
    cli();
    snes_reset_on();
    snes_reset_lo();
    _delay_ms(2);
    snes_reset_hi();
    snes_reset_off();
    sei();
    my_system.snes_reset_count++;
}
示例#5
0
int main(void)
{

#ifndef NO_DEBUG
    uart_init();
    stdout = &uart_stdout;
    banner();
#endif
    shared_memory_init();
    system_init();
    sram_init();
    pwm_init();
    irq_init();
    boot_startup_rom(50);
    globals_init();
    pwm_stop();
    usbInit();
    usb_connect();
    sei();
    while (1) {
        system_set_bus_avr();
        system_set_wr_disable();
        while (usb_trans.req_state != REQ_STATUS_SNES) {
            usbPoll();
#if DO_SHELL
#ifndef NO_DEBUG
            shell_run();
#endif
#endif
        }

#if DO_SHM
        shared_memory_write(SHARED_MEM_TX_CMD_TERMINATE, 0);
#endif

#if DO_SHM_SCRATCHPAD
        shared_memory_scratchpad_region_tx_restore();
        shared_memory_scratchpad_region_rx_restore();
#endif

#if DO_CRC_CHECK
        info_P(PSTR("-->CRC Check\n"));
        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();
        while ((usb_trans.req_state != REQ_STATUS_AVR)) {
            usbPoll();
#if DO_SHELL
#ifndef NO_DEBUG
            shell_run();
#endif
#endif
        }
        info_P(PSTR("-->Switch TO AVR\n"));
        shared_memory_init();
        irq_init();
        if (usb_trans.loader_enabled) {
            boot_startup_rom(50);
        } else {
            system_set_bus_avr();
            system_send_snes_reset();
        }
        globals_init();
    }
    return 0;
}
示例#6
0
void system_set_rom_hirom()
{
    snes_hirom();
    my_system.rom_mode = HIROM;
    info_P(PSTR("Set SNES hirom \n"));
}
示例#7
0
void system_set_rom_lorom()
{
    snes_lorom();
    my_system.rom_mode = LOROM;
    info_P(PSTR("Set SNES lorom \n"));
}
示例#8
0
void system_set_bus_snes()
{
    snes_bus_active();
    my_system.bus_mode = MODE_SNES;
    info_P(PSTR("Activate SNES bus\n"));
}
示例#9
0
void system_set_wr_enable()
{
    snes_wr_enable();
    my_system.wr_line = WR_ENABLE;
    info_P(PSTR("Enable SNES WR\n"));
}
示例#10
0
void system_set_wr_disable()
{
    snes_wr_disable();
    my_system.wr_line = WR_DISABLE;
    info_P(PSTR("Disable SNES WR\n"));
}
示例#11
0
void system_set_bus_avr()
{
    avr_bus_active();
    info_P(PSTR("Activate AVR bus\n"));
    my_system.bus_mode = MODE_AVR;
}