OpenCores
URL https://opencores.org/ocsvn/usb_fpga_1_11/usb_fpga_1_11/trunk

Subversion Repositories usb_fpga_1_11

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /usb_fpga_1_11/trunk/examples/usb-1.0
    from Rev 2 to Rev 5
    Reverse comparison

Rev 2 → Rev 5

/flashdemo/FlashDemo.java
1,6 → 1,6
/*!
flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB Module 1.0
Copyright (C) 2009-2010 ZTEX e.K.
Copyright (C) 2009-2011 ZTEX GmbH.
http://www.ztex.de
 
This program is free software; you can redistribute it and/or modify
/flashdemo/flashdemo.c
1,6 → 1,6
/*!
flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB Module 1.0
Copyright (C) 2009-2010 ZTEX e.K.
Copyright (C) 2009-2011 ZTEX GmbH.
http://www.ztex.de
 
This program is free software; you can redistribute it and/or modify
28,7 → 28,7
// this product string is also used for identification by the host software
#define[PRODUCT_STRING]["Flash demo for UM 1.0"]
 
code char flash_string[] = "Hello World!";
__code char flash_string[] = "Hello World!";
 
// include the main part of the firmware kit, define the descriptors, ...
#include[ztex.h]
35,13 → 35,13
 
void main(void)
{
xdata DWORD sector;
__xdata DWORD sector;
 
init_USB(); // init everything
 
if ( flash_enabled ) {
flash_read_init( 0 ); // prepare reading sector 0
flash_read((xdata BYTE*) &sector, 4); // read the number of last sector
flash_read((__xdata BYTE*) &sector, 4); // read the number of last sector
flash_read_finish(flash_sector_size - 4); // dummy-read the rest of the sector + finish read operation
 
sector++;
49,13 → 49,15
sector = 1;
}
 
flash_write_init( 0 ); // prepare writing sector 0
flash_write((xdata BYTE*) &sector, 4); // write the current sector number
flash_write_finish(flash_sector_size - 4); // dummy-write the rest of the sector + finish write operation
flash_write_init( 0 ); // prepare writing sector 0
flash_write((__xdata BYTE*) &sector, 4); // write the current sector number
flash_write_finish_sector(flash_sector_size - 4); // dummy-write the rest of the sector + CRC
flash_write_finish(); // finish write operation
 
flash_write_init( sector ); // prepare writing sector sector
flash_write((xdata BYTE*) flash_string, sizeof(flash_string)); // write the string
flash_write_finish(flash_sector_size - sizeof(flash_string)); // dummy-write the rest of the sector + finish write operation
flash_write_init( sector ); // prepare writing sector sector
flash_write((__xdata BYTE*) flash_string, sizeof(flash_string)); // write the string
flash_write_finish_sector(flash_sector_size - sizeof(flash_string)); // dummy-write the rest of the sector + CRC
flash_write_finish(); // finish write operation
}
 
while (1) { } // twiddle thumbs
/flashbench/flashbench.sh
1,3 → 1,3
#make -C ../../ztex/java distclean all || exit
#make -C ../../../java distclean all || exit
#make distclean all || exit
java -cp FlashBench.jar FlashBench $@
/flashbench/FlashBench.java
1,6 → 1,6
/*!
flashbench -- Flash memory benchmark for ZTEX USB Module 1.0
Copyright (C) 2009-2010 ZTEX e.K.
Copyright (C) 2009-2011 ZTEX GmbH.
http://www.ztex.de
 
This program is free software; you can redistribute it and/or modify
56,29 → 56,31
// ******* testRW **************************************************************
// measures read + write performance
public double testRW ( int num ) throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf1 = new byte[flashSectorSize()];
byte[] buf2 = new byte[flashSectorSize()];
int secNum = 2048 / flashSectorSize();
byte[] buf1 = new byte[flashSectorSize() * secNum];
byte[] buf2 = new byte[flashSectorSize() * secNum];
int errors = 0;
 
long t0 = new Date().getTime();
 
for ( int i=0; i<num; i++ ) {
for ( int i=0; i<num; i+=secNum ) {
int l = Math.min(num-i,secNum);
int j=(int) Math.round(65535*Math.random());
for (int k=0; k<flashSectorSize(); k++) {
for (int k=0; k<flashSectorSize()*l; k++) {
buf1[k] = (byte) (j & 255);
j+=57;
}
 
System.out.print("Sector " + (i+1) + "/" + num+ " " + Math.round(10000.0*(i+1)/num)/100.0 + "% \r");
flashWriteSector(i,buf1);
flashReadSector(i,buf2);
System.out.print("Sector " + (i+l) + "/" + num+ " " + Math.round(10000.0*(i+1)/num)/100.0 + "% \r");
flashWriteSector(i,l,buf1);
flashReadSector(i,l,buf2);
 
int diffs=flashSectorSize();
for (int k=0; k<flashSectorSize(); k++)
int diffs=flashSectorSize()*l;
for (int k=0; k<flashSectorSize()*l; k++)
if ( buf1[k] == buf2[k] )
diffs -= 1;
if ( diffs!=0 && errors==0) {
System.out.print("Error occured: Sector " + i +": " + diffs + " differences: ");
if ( diffs!=0 /*&& errors==0 */) {
System.out.println("Error occured at sector " + i +": " + diffs + " differences");
}
if ( diffs!=0 )
errors+=1;
91,15 → 93,17
// ******* testW **************************************************************
// measures write performance
public double testW ( int num, int seed ) throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf = new byte[flashSectorSize()];
int secNum = 2048 / flashSectorSize();
byte[] buf = new byte[flashSectorSize() * secNum];
long t0 = new Date().getTime();
for ( int i=0; i<num; i++ ) {
System.out.print("Sector " + (i+1) + "/" + num+ " " + Math.round(10000.0*(i+1)/num)/100.0 + "% \r");
for (int k=0; k<flashSectorSize(); k++) {
for ( int i=0; i<num; i+=secNum ) {
int j = Math.min(num-i,secNum);
System.out.print("Sector " + (i+j) + "/" + num+ " " + Math.round(10000.0*(i+1)/num)/100.0 + "% \r");
for (int k=0; k<flashSectorSize()*j; k++) {
buf[k] = (byte) (seed & 255);
seed+=79;
}
flashWriteSector(i,buf);
flashWriteSector(i,j,buf);
}
return num*512.0/(new Date().getTime() - t0);
}
107,20 → 111,22
// ******* testR **************************************************************
// measures read performance
public double testR ( int num, int seed ) throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf = new byte[flashSectorSize()];
int secNum = 2048 / flashSectorSize();
byte[] buf = new byte[flashSectorSize() * secNum];
int errors = 0;
long t0 = new Date().getTime();
for ( int i=0; i<num; i++ ) {
System.out.print("Sector " + (i+1) + "/" + num+ " " + Math.round(10000.0*(i+1)/num)/100.0 + "% \r");
flashReadSector(i,buf);
int diffs = flashSectorSize();
for (int k=0; k<flashSectorSize(); k++) {
for ( int i=0; i<num; i+=secNum ) {
int j = Math.min(num-i,secNum);
System.out.print("Sector " + (i+j) + "/" + num+ " " + Math.round(10000.0*(i+1)/num)/100.0 + "% \r");
flashReadSector(i,j,buf);
int diffs = flashSectorSize()*j;
for (int k=0; k<flashSectorSize()*j; k++) {
if ( buf[k] == (byte) (seed & 255) )
diffs-=1;
seed+=79;
}
if ( diffs!=0 && errors==0 ) {
System.out.print("Error occured: Sector " + i +": " + diffs + " differences: ");
System.out.println("Error occured at sector " + i +": " + diffs + " differences");
}
if ( diffs!=0 )
errors+=1;
/flashbench/flashbench.c
1,6 → 1,6
/*!
flashbench -- Flash memory benchmark for ZTEX USB Module 1.0
Copyright (C) 2009-2010 ZTEX e.K.
Copyright (C) 2009-2011 ZTEX GmbH.
http://www.ztex.de
 
This program is free software; you can redistribute it and/or modify

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.