add floating point timer and end address to bulk init
This commit is contained in:
parent
c55a66f90d
commit
690bfd6502
@ -91,7 +91,7 @@ usbdrv:
|
||||
cp -r ../../../usbdrv .
|
||||
|
||||
main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
|
||||
$(COMPILE) -o main.elf $(OBJECTS)
|
||||
$(COMPILE) -o main.elf $(OBJECTS) -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
main.hex: main.elf
|
||||
rm -f main.hex main.eep.hex
|
||||
|
||||
Binary file not shown.
@ -24,7 +24,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <usb.h> /* this is libusb */
|
||||
|
||||
#include "opendevice.h" /* common code moved to separate module */
|
||||
|
||||
#include "../requests.h" /* custom request numbers */
|
||||
@ -129,6 +131,9 @@ int main(int argc, char **argv)
|
||||
uint16_t step = 0;
|
||||
uint16_t crc = 0;
|
||||
uint8_t bank = 0;
|
||||
uint8_t bank_cnt = 0;
|
||||
uint32_t file_size = 0;
|
||||
struct stat st;
|
||||
|
||||
FILE *fp;
|
||||
usb_init();
|
||||
@ -164,13 +169,20 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Cannot open file %s ", argv[2]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fseek (fp, 0, SEEK_END);
|
||||
file_size = ftell (fp);
|
||||
fseek (fp, 0, SEEK_SET);
|
||||
bank_cnt = file_size / BANK_SIZE;
|
||||
printf("Transfer '%s' %i Bytes, %i Banks\n",argv[2],file_size,bank_cnt);
|
||||
|
||||
read_buffer = (unsigned char *) malloc(READ_BUFFER_SIZE);
|
||||
crc_buffer = (unsigned char *) malloc(0x1000);
|
||||
memset(crc_buffer, 0, 0x1000);
|
||||
addr = 0x000000;
|
||||
cnt = usb_control_msg(handle,
|
||||
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
|
||||
USB_BULK_UPLOAD_INIT, BANK_SIZE_SHIFT , 0, NULL, 0, 5000);
|
||||
USB_BULK_UPLOAD_INIT, BANK_SIZE_SHIFT , bank_cnt, NULL, 0, 5000);
|
||||
|
||||
if (cnt < 0) {
|
||||
fprintf(stderr, "USB error: %s\n", usb_strerror());
|
||||
|
||||
@ -23,9 +23,11 @@ uint8_t debug_level = ( DEBUG | DEBUG_USB | DEBUG_CRC );
|
||||
|
||||
uint8_t read_buffer[TRANSFER_BUFFER_SIZE];
|
||||
uint32_t req_addr = 0;
|
||||
uint32_t req_addr_end = 0;
|
||||
uint32_t req_size;
|
||||
uint8_t req_bank;
|
||||
uint16_t req_bank_size;
|
||||
uint16_t req_bank_cnt;
|
||||
uint8_t req_state = REQ_STATUS_IDLE;
|
||||
uint8_t rx_remaining = 0;
|
||||
uint8_t tx_remaining = 0;
|
||||
@ -108,10 +110,14 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
req_bank = 0;
|
||||
rx_remaining = 0;
|
||||
req_bank_size = (1 << rq->wValue.word) & 0xffff;
|
||||
req_bank_cnt = rq->wIndex.word;
|
||||
req_addr_end = (uint32_t)req_bank_size * req_bank_cnt;
|
||||
|
||||
sync_errors = 0;
|
||||
debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size);
|
||||
debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: bank_size=0x%x bank_cnt=0x%x end_addr=0x%08lx\n",
|
||||
req_bank_size, req_bank_cnt, req_addr_end);
|
||||
|
||||
if (req_addr == 0x000000){
|
||||
debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: timer_start\n");
|
||||
timer_start();
|
||||
}
|
||||
/*
|
||||
@ -127,7 +133,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||
rx_remaining = rq->wLength.word;
|
||||
|
||||
if (req_addr && req_addr % req_bank_size == 0) {
|
||||
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr= 0x%08lx time=%i\n",
|
||||
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr= 0x%08lx time=%.4f\n",
|
||||
req_bank, req_addr,timer_stop());
|
||||
req_bank++;
|
||||
timer_start();
|
||||
@ -316,6 +322,7 @@ int main(void)
|
||||
|
||||
}
|
||||
led_on();
|
||||
|
||||
usbDeviceConnect();
|
||||
printf("USB connect\n");
|
||||
|
||||
@ -332,7 +339,6 @@ int main(void)
|
||||
printf("Disable snes WR\n");
|
||||
snes_wr_disable();
|
||||
|
||||
|
||||
sei();
|
||||
printf("USB poll\n");
|
||||
while (req_state != REQ_STATUS_BOOT){
|
||||
@ -343,9 +349,9 @@ int main(void)
|
||||
usbDeviceDisconnect();
|
||||
printf("USB disconnect\n");
|
||||
|
||||
crc_check_bulk_memory(0x000000, 0x80000);
|
||||
crc_check_bulk_memory(0x000000, req_addr_end);
|
||||
|
||||
//dump_memory(0x7f00,0x8000);
|
||||
dump_memory(0x7f00,0x8000);
|
||||
|
||||
printf("IRQ off\n");
|
||||
snes_irq_lo();
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h> /* for sei() */
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#ifndef OCR1A
|
||||
#define OCR1A OCR1 // 2313 support
|
||||
@ -53,10 +56,10 @@ void timer_start( void )
|
||||
|
||||
}
|
||||
|
||||
uint16_t timer_stop(void)
|
||||
double timer_stop(void)
|
||||
{
|
||||
//cli();
|
||||
return second;
|
||||
double t = ((double)(DEBOUNCE - prescaler) / DEBOUNCE ) + second;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
uint16_t timer_start( void );
|
||||
uint16_t timer_stop( void );
|
||||
double timer_stop( void );
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user