move commands to own file and remove unsed usb methods
This commit is contained in:
parent
b6d5d1b571
commit
decb810bcc
@ -30,11 +30,16 @@ SIZE = avr-size
|
|||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
LDFLAGS = -Wl,-u,vfprintf -lprintf_flt
|
LDFLAGS = -Wl,-u,vfprintf -lprintf_flt
|
||||||
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
|
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
|
||||||
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
|
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
|
||||||
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 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
|
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
|
||||||
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)
|
||||||
|
|||||||
61
avr/usbload/command.c
Normal file
61
avr/usbload/command.c
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* ________ .__ __ ________ ____ ________
|
||||||
|
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
|
||||||
|
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
|
||||||
|
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
|
||||||
|
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
|
||||||
|
* \__> \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* www.optixx.org
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 07/21/2009 03:32:16 PM
|
||||||
|
* Author: david@optixx.org
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "requests.h"
|
||||||
|
#include "sram.h"
|
||||||
|
#include "info.h"
|
||||||
|
|
||||||
|
extern uint32_t req_bank_size;
|
||||||
|
|
||||||
|
|
||||||
|
void send_reset()
|
||||||
|
{
|
||||||
|
info("Reset Snes\n");
|
||||||
|
snes_reset_on();
|
||||||
|
snes_reset_lo();
|
||||||
|
_delay_ms(2);
|
||||||
|
snes_reset_hi();
|
||||||
|
snes_reset_off();
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_irq()
|
||||||
|
{
|
||||||
|
snes_irq_on();
|
||||||
|
snes_irq_lo();
|
||||||
|
_delay_us(20);
|
||||||
|
snes_irq_hi();
|
||||||
|
snes_irq_off();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_rom_mode()
|
||||||
|
{
|
||||||
|
if (req_bank_size == 0x8000) {
|
||||||
|
snes_lorom();
|
||||||
|
info("Set Snes lowrom \n");
|
||||||
|
} else {
|
||||||
|
snes_hirom();
|
||||||
|
info("Set Snes hirom \n");
|
||||||
|
}
|
||||||
|
}
|
||||||
29
avr/usbload/command.h
Normal file
29
avr/usbload/command.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* ________ .__ __ ________ ____ ________
|
||||||
|
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
|
||||||
|
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
|
||||||
|
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
|
||||||
|
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
|
||||||
|
* \__> \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* www.optixx.org
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 07/21/2009 03:32:16 PM
|
||||||
|
* Author: david@optixx.org
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __CRC_H__
|
||||||
|
#define __CRC_H__
|
||||||
|
|
||||||
|
void send_reset();
|
||||||
|
void send_irq();
|
||||||
|
void set_rom_mode();
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -21,16 +21,16 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h> /* for sei() */
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h> /* for _delay_ms() */
|
#include <util/delay.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <avr/pgmspace.h> /* required by usbdrv.h */
|
#include <avr/pgmspace.h>
|
||||||
#include <avr/eeprom.h>
|
#include <avr/eeprom.h>
|
||||||
|
|
||||||
#include "usbdrv.h"
|
#include "usbdrv.h"
|
||||||
#include "oddebug.h" /* This is also an example for using debug macros */
|
#include "oddebug.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "requests.h" /* The custom request numbers we use */
|
#include "requests.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "sram.h"
|
#include "sram.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -74,76 +74,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
|
|
||||||
usbRequest_t *rq = (void *) data;
|
usbRequest_t *rq = (void *) data;
|
||||||
uint8_t ret_len = 0;
|
uint8_t ret_len = 0;
|
||||||
/*
|
|
||||||
* -------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
if (rq->bRequest == USB_UPLOAD_INIT) {
|
|
||||||
|
|
||||||
if (req_state != REQ_STATUS_IDLE) {
|
if (rq->bRequest == USB_BULK_UPLOAD_INIT) {
|
||||||
debug(DEBUG_USB,
|
|
||||||
"USB_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
req_bank = 0;
|
|
||||||
rx_remaining = 0;
|
|
||||||
req_bank_size = (uint32_t) 1 << rq->wValue.word;
|
|
||||||
sync_errors = 0;
|
|
||||||
crc = 0;
|
|
||||||
debug(DEBUG_USB, "USB_UPLOAD_INIT: bank_size=0x%08lx\n", req_bank_size);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* -------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
} else if (rq->bRequest == USB_UPLOAD_ADDR) {
|
|
||||||
|
|
||||||
req_state = REQ_STATUS_UPLOAD;
|
|
||||||
req_addr = rq->wValue.word;
|
|
||||||
req_addr = req_addr << 16;
|
|
||||||
req_addr = req_addr | rq->wIndex.word;
|
|
||||||
if (rx_remaining) {
|
|
||||||
sync_errors++;
|
|
||||||
debug
|
|
||||||
(DEBUG_USB,
|
|
||||||
"USB_UPLOAD_ADDR: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n",
|
|
||||||
req_addr, rx_remaining, rq->wLength.word, sync_errors);
|
|
||||||
ret_len = 0;
|
|
||||||
}
|
|
||||||
rx_remaining = rq->wLength.word;
|
|
||||||
ret_len = USB_MAX_TRANS;
|
|
||||||
|
|
||||||
|
|
||||||
if (req_addr && (req_addr % 0x1000) == 0) {
|
|
||||||
debug(DEBUG_USB,
|
|
||||||
"USB_UPLOAD_ADDR: bank=0x%02x addr=0x%08lx crc=%04x\n",
|
|
||||||
req_bank, req_addr, crc_check_bulk_memory(req_addr - 0x1000,
|
|
||||||
req_addr,
|
|
||||||
req_bank_size));
|
|
||||||
|
|
||||||
}
|
|
||||||
if (req_addr && req_addr % req_bank_size == 0) {
|
|
||||||
debug(DEBUG_USB, "USB_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx\n",
|
|
||||||
req_bank, req_addr);
|
|
||||||
|
|
||||||
req_bank++;
|
|
||||||
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS,req_bank);
|
|
||||||
}
|
|
||||||
ret_len = USB_MAX_TRANS;
|
|
||||||
/*
|
|
||||||
* -------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
} else if (rq->bRequest == USB_DOWNLOAD_INIT) {
|
|
||||||
debug(DEBUG_USB, "USB_DOWNLOAD_INIT\n");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* -------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
} else if (rq->bRequest == USB_DOWNLOAD_ADDR) {
|
|
||||||
debug(DEBUG_USB, "USB_DOWNLOAD_ADDR\n");
|
|
||||||
/*
|
|
||||||
* -------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
} else if (rq->bRequest == USB_BULK_UPLOAD_INIT) {
|
|
||||||
|
|
||||||
req_bank = 0;
|
req_bank = 0;
|
||||||
rx_remaining = 0;
|
rx_remaining = 0;
|
||||||
@ -382,46 +314,7 @@ void test_crc()
|
|||||||
test_non_zero_memory(0x000000, 0x10000);
|
test_non_zero_memory(0x000000, 0x10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t read_byte_pgm(uint16_t addr)
|
|
||||||
{
|
|
||||||
return pgm_read_byte((PGM_VOID_P) addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t read_byte_ee(uint16_t addr)
|
|
||||||
{
|
|
||||||
return eeprom_read_byte((uint8_t *) addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void send_reset()
|
|
||||||
{
|
|
||||||
info("Reset Snes\n");
|
|
||||||
snes_reset_on();
|
|
||||||
snes_reset_lo();
|
|
||||||
_delay_ms(2);
|
|
||||||
snes_reset_hi();
|
|
||||||
snes_reset_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
void send_irq()
|
|
||||||
{
|
|
||||||
snes_irq_on();
|
|
||||||
snes_irq_lo();
|
|
||||||
_delay_us(20);
|
|
||||||
snes_irq_hi();
|
|
||||||
snes_irq_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_rom_mode()
|
|
||||||
{
|
|
||||||
if (req_bank_size == 0x8000) {
|
|
||||||
snes_lorom();
|
|
||||||
info("Set Snes lowrom \n");
|
|
||||||
} else {
|
|
||||||
snes_hirom();
|
|
||||||
info("Set Snes hirom \n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void usb_connect()
|
void usb_connect()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user