mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Updates to testusbhostFAT
This commit is contained in:
parent
f93c9d8a9a
commit
0169e99af7
1 changed files with 139 additions and 137 deletions
|
@ -30,6 +30,7 @@
|
||||||
#if WANT_HUB_TEST
|
#if WANT_HUB_TEST
|
||||||
#include <usbhub.h>
|
#include <usbhub.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <RTClib.h>
|
||||||
#include <masstorage.h>
|
#include <masstorage.h>
|
||||||
#include <message.h>
|
#include <message.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
@ -41,9 +42,12 @@
|
||||||
#if HAVE_XMEM
|
#if HAVE_XMEM
|
||||||
#define GOD_MODE 0
|
#define GOD_MODE 0
|
||||||
#endif
|
#endif
|
||||||
static FILE mystdout;
|
static FILE tty_stdio;
|
||||||
|
static FILE tty_stderr;
|
||||||
|
USB Usb;
|
||||||
|
|
||||||
|
#define LED 13 // the pin that the LED is attached to
|
||||||
|
|
||||||
int led = 13; // the pin that the LED is attached to
|
|
||||||
volatile int brightness = 0; // how bright the LED is
|
volatile int brightness = 0; // how bright the LED is
|
||||||
volatile int fadeAmount = 80; // how many points to fade the LED by
|
volatile int fadeAmount = 80; // how many points to fade the LED by
|
||||||
volatile uint8_t current_state = 1;
|
volatile uint8_t current_state = 1;
|
||||||
|
@ -63,13 +67,18 @@ PCPartition *PT;
|
||||||
|
|
||||||
#if WANT_HUB_TEST
|
#if WANT_HUB_TEST
|
||||||
#define MAX_HUBS 2
|
#define MAX_HUBS 2
|
||||||
static USBHub *Hubs[MAX_HUBS];
|
USBHub *Hubs[MAX_HUBS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PFAT *Fats[_VOLUMES];
|
static PFAT *Fats[_VOLUMES];
|
||||||
static part_t parts[_VOLUMES];
|
static part_t parts[_VOLUMES];
|
||||||
static storage_t sto[_VOLUMES];
|
static storage_t sto[_VOLUMES];
|
||||||
|
|
||||||
|
/*make sure this is a power of two. */
|
||||||
|
#define mbxs 128
|
||||||
|
static uint8_t My_Buff_x[mbxs]; /* File read buffer */
|
||||||
|
|
||||||
|
|
||||||
#define prescale1 ((1 << WGM12) | (1 << CS10))
|
#define prescale1 ((1 << WGM12) | (1 << CS10))
|
||||||
#define prescale8 ((1 << WGM12) | (1 << CS11))
|
#define prescale8 ((1 << WGM12) | (1 << CS11))
|
||||||
#define prescale64 ((1 << WGM12) | (1 << CS10) | (1 << CS11))
|
#define prescale64 ((1 << WGM12) | (1 << CS10) | (1 << CS11))
|
||||||
|
@ -78,85 +87,99 @@ static storage_t sto[_VOLUMES];
|
||||||
|
|
||||||
extern "C" unsigned int freeHeap();
|
extern "C" unsigned int freeHeap();
|
||||||
|
|
||||||
/*
|
static int tty_stderr_putc(char c, FILE *t) {
|
||||||
unsigned int getHeapend(){
|
USB_HOST_SERIAL.write(c);
|
||||||
extern unsigned int __heap_start;
|
|
||||||
|
|
||||||
if ((unsigned int)__brkval == 0) {
|
|
||||||
return (unsigned int)&__heap_start;
|
|
||||||
} else {
|
|
||||||
return (unsigned int)__brkval;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int freeHeap() {
|
static int tty_std_putc(char c, FILE *t) {
|
||||||
if (SP < (unsigned int)__malloc_heap_start) {
|
|
||||||
return ((unsigned int)__malloc_heap_end - getHeapend());
|
|
||||||
} else {
|
|
||||||
return (SP - getHeapend());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
static int my_putc(char c, FILE *t) {
|
|
||||||
Serial.write(c);
|
Serial.write(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tty_std_getc(FILE *t) {
|
||||||
|
while (!Serial.available());
|
||||||
|
return Serial.read();
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
boolean serr = false;
|
||||||
for (int i = 0; i < _VOLUMES; i++) {
|
for (int i = 0; i < _VOLUMES; i++) {
|
||||||
Fats[i] = NULL;
|
Fats[i] = NULL;
|
||||||
|
sto[i].private_data = new pvt_t;
|
||||||
|
((pvt_t *)sto[i].private_data)->B = 255; // impossible
|
||||||
}
|
}
|
||||||
// Set this to higher values to enable more debug information
|
// Set this to higher values to enable more debug information
|
||||||
// minimum 0x00, maximum 0xff
|
// minimum 0x00, maximum 0xff
|
||||||
UsbDEBUGlvl = 0x51;
|
UsbDEBUGlvl = 0x51;
|
||||||
// declare pin 9 to be an output:
|
// make LED pin as an output:
|
||||||
pinMode(led, OUTPUT);
|
pinMode(LED, OUTPUT);
|
||||||
pinMode(2, OUTPUT);
|
pinMode(2, OUTPUT);
|
||||||
|
// Ensure TX is off
|
||||||
|
_SFR_BYTE(UCSR0B) &= ~_BV(TXEN0);
|
||||||
// Initialize 'debug' serial port
|
// Initialize 'debug' serial port
|
||||||
Serial.begin(115200);
|
USB_HOST_SERIAL.begin(115200);
|
||||||
|
// Do not start primary Serial port if already started.
|
||||||
|
if (bit_is_clear(UCSR0B, TXEN0)) {
|
||||||
|
Serial.begin(115200);
|
||||||
|
serr = true;
|
||||||
|
}
|
||||||
|
|
||||||
//fdevopen(&my_putc, 0);
|
// Set up stdio/stderr
|
||||||
// too bad we can't tinker with iob directly, oh well.
|
tty_stdio.put = tty_std_putc;
|
||||||
mystdout.put = my_putc;
|
tty_stdio.get = tty_std_getc;
|
||||||
mystdout.get = NULL;
|
tty_stdio.flags = _FDEV_SETUP_RW;
|
||||||
mystdout.flags = _FDEV_SETUP_WRITE;
|
tty_stdio.udata = 0;
|
||||||
mystdout.udata = 0;
|
stdout = &tty_stdio;
|
||||||
stdout = &mystdout;
|
stdin = &tty_stdio;
|
||||||
|
|
||||||
// Blink pin 9:
|
tty_stderr.put = tty_stderr_putc;
|
||||||
|
tty_stderr.get = NULL;
|
||||||
|
tty_stderr.flags = _FDEV_SETUP_WRITE;
|
||||||
|
tty_stderr.udata = 0;
|
||||||
|
stderr = &tty_stderr;
|
||||||
|
|
||||||
|
// Blink LED
|
||||||
delay(500);
|
delay(500);
|
||||||
analogWrite(led, 255);
|
analogWrite(LED, 255);
|
||||||
delay(500);
|
delay(500);
|
||||||
analogWrite(led, 0);
|
analogWrite(LED, 0);
|
||||||
delay(500);
|
delay(500);
|
||||||
analogWrite(led, 255);
|
|
||||||
delay(500);
|
|
||||||
analogWrite(led, 0);
|
|
||||||
delay(500);
|
|
||||||
analogWrite(led, 255);
|
|
||||||
delay(500);
|
|
||||||
analogWrite(led, 0);
|
|
||||||
printf_P(PSTR("\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nStart\r\n"));
|
printf_P(PSTR("\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nStart\r\n"));
|
||||||
printf_P(PSTR("Current UsbDEBUGlvl %02x\r\n"), UsbDEBUGlvl);
|
printf_P(PSTR("Current UsbDEBUGlvl %02x\r\n"), UsbDEBUGlvl);
|
||||||
printf_P(PSTR("'+' and '-' increase/decrease by 0x01\r\n"));
|
printf_P(PSTR("'+' and '-' increase/decrease by 0x01\r\n"));
|
||||||
printf_P(PSTR("'.' and ',' increase/decrease by 0x10\r\n"));
|
printf_P(PSTR("'.' and ',' increase/decrease by 0x10\r\n"));
|
||||||
printf_P(PSTR("'t' will run a 10MB write/read test and print out the time it took.\r\n"));
|
printf_P(PSTR("'t' will run a 10MB write/read test and print out the time it took.\r\n"));
|
||||||
printf_P(PSTR("'e' will toggle vbus off for a few moments.\r\n"));
|
printf_P(PSTR("'e' will toggle vbus off for a few moments.\r\n\r\n"));
|
||||||
printf_P(PSTR("\r\n\r\nLong filename support: "
|
printf_P(PSTR("Long filename support: "
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
"Enabled"
|
"Enabled"
|
||||||
#else
|
#else
|
||||||
"Disabled"
|
"Disabled"
|
||||||
#endif
|
#endif
|
||||||
"\r\n"));
|
"\r\n"));
|
||||||
analogWrite(led, 255);
|
if (serr) {
|
||||||
|
fprintf_P(stderr, PSTR("\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nStart\r\n"));
|
||||||
|
fprintf_P(stderr, PSTR("Current UsbDEBUGlvl %02x\r\n"), UsbDEBUGlvl);
|
||||||
|
fprintf_P(stderr, PSTR("Long filename support: "
|
||||||
|
#if _USE_LFN
|
||||||
|
"Enabled"
|
||||||
|
#else
|
||||||
|
"Disabled"
|
||||||
|
#endif
|
||||||
|
"\r\n"));
|
||||||
|
}
|
||||||
|
analogWrite(LED, 255);
|
||||||
delay(500);
|
delay(500);
|
||||||
analogWrite(led, 0);
|
analogWrite(LED, 0);
|
||||||
|
delay(500);
|
||||||
|
analogWrite(LED, 255);
|
||||||
|
delay(500);
|
||||||
|
analogWrite(LED, 0);
|
||||||
|
delay(500);
|
||||||
|
analogWrite(LED, 255);
|
||||||
|
delay(500);
|
||||||
|
analogWrite(LED, 0);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
delay(100);
|
|
||||||
analogWrite(led, 255);
|
|
||||||
delay(100);
|
|
||||||
analogWrite(led, 0);
|
|
||||||
LEDnext_time = millis() + 1;
|
LEDnext_time = millis() + 1;
|
||||||
#ifdef EXT_RAM
|
#ifdef EXT_RAM
|
||||||
printf_P(PSTR("Total EXT RAM banks %i\r\n"), xmem::getTotalBanks());
|
printf_P(PSTR("Total EXT RAM banks %i\r\n"), xmem::getTotalBanks());
|
||||||
|
@ -263,8 +286,8 @@ ISR(TIMER3_COMPA_vect) {
|
||||||
if (millis() >= LEDnext_time) {
|
if (millis() >= LEDnext_time) {
|
||||||
LEDnext_time = millis() + 30;
|
LEDnext_time = millis() + 30;
|
||||||
|
|
||||||
// set the brightness of pin 9:
|
// set the brightness of LED
|
||||||
analogWrite(led, brightness);
|
analogWrite(LED, brightness);
|
||||||
|
|
||||||
// change the brightness for next time through the loop:
|
// change the brightness for next time through the loop:
|
||||||
brightness = brightness + fadeAmount;
|
brightness = brightness + fadeAmount;
|
||||||
|
@ -281,7 +304,6 @@ ISR(TIMER3_COMPA_vect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isfat(uint8_t t) {
|
bool isfat(uint8_t t) {
|
||||||
return (t == 0x01 || t == 0x04 || t == 0x06 || t == 0x0b || t == 0x0c || t == 0x0e || t == 0x1);
|
return (t == 0x01 || t == 0x04 || t == 0x06 || t == 0x0b || t == 0x0c || t == 0x0e || t == 0x1);
|
||||||
}
|
}
|
||||||
|
@ -289,17 +311,10 @@ bool isfat(uint8_t t) {
|
||||||
void die(FRESULT rc) {
|
void die(FRESULT rc) {
|
||||||
printf_P(PSTR("Failed with rc=%u.\r\n"), rc);
|
printf_P(PSTR("Failed with rc=%u.\r\n"), rc);
|
||||||
//for (;;);
|
//for (;;);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*make sure this is a power of two. */
|
|
||||||
#define mbxs 128
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
uint8_t My_Buff_x[mbxs]; /* File read buffer */
|
|
||||||
FIL My_File_Object_x; /* File object */
|
FIL My_File_Object_x; /* File object */
|
||||||
DIR My_Dir_Object_x; /* Directory object */
|
|
||||||
FILINFO My_File_Info_Object_x; /* File information object */
|
|
||||||
|
|
||||||
// Print a heap status report about every 10 seconds.
|
// Print a heap status report about every 10 seconds.
|
||||||
if (millis() >= HEAPnext_time) {
|
if (millis() >= HEAPnext_time) {
|
||||||
|
@ -342,16 +357,6 @@ void loop() {
|
||||||
printf_P(PSTR("USB state = %x\r\n"), current_state);
|
printf_P(PSTR("USB state = %x\r\n"), current_state);
|
||||||
if (current_state == USB_STATE_RUNNING) {
|
if (current_state == USB_STATE_RUNNING) {
|
||||||
fadeAmount = 30;
|
fadeAmount = 30;
|
||||||
/*
|
|
||||||
partsready = false;
|
|
||||||
for (int i = 0; i < cpart; i++) {
|
|
||||||
if (Fats[i] != NULL)
|
|
||||||
delete Fats[i];
|
|
||||||
}
|
|
||||||
fatready = false;
|
|
||||||
notified = false;
|
|
||||||
cpart = 0;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if (current_state == USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) {
|
if (current_state == USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) {
|
||||||
fadeAmount = 80;
|
fadeAmount = 80;
|
||||||
|
@ -365,17 +370,6 @@ void loop() {
|
||||||
notified = false;
|
notified = false;
|
||||||
cpart = 0;
|
cpart = 0;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (current_state == 0xa0) {
|
|
||||||
printf_P(PSTR("VBUS off\r\n"));
|
|
||||||
// safe to do here
|
|
||||||
Usb.gpioWr(0x00);
|
|
||||||
digitalWrite(2, 0);
|
|
||||||
usbon = false;
|
|
||||||
usbon_time = millis() + 2000;
|
|
||||||
change = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
last_state = current_state;
|
last_state = current_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +380,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is horrible, and needs to be moved elsewhere!
|
// This is horrible, and needs to be moved elsewhere!
|
||||||
for (int B = 0; B < MAX_DRIVERS; B++) {
|
for (int B = 0; B < MAX_USB_MS_DRIVERS; B++) {
|
||||||
if (!partsready && Bulk[B]->GetAddress() != NULL) {
|
if (!partsready && Bulk[B]->GetAddress() != NULL) {
|
||||||
// Build a list.
|
// Build a list.
|
||||||
int ML = Bulk[B]->GetbMaxLUN();
|
int ML = Bulk[B]->GetbMaxLUN();
|
||||||
|
@ -395,9 +389,8 @@ void loop() {
|
||||||
for (int i = 0; i < ML; i++) {
|
for (int i = 0; i < ML; i++) {
|
||||||
if (Bulk[B]->LUNIsGood(i)) {
|
if (Bulk[B]->LUNIsGood(i)) {
|
||||||
partsready = true;
|
partsready = true;
|
||||||
sto[i].private_data = &info[i];
|
((pvt_t *)sto[i].private_data)->lun = i;
|
||||||
info[i].lun = i;
|
((pvt_t *)sto[i].private_data)->B = B;
|
||||||
info[i].B = B;
|
|
||||||
sto[i].Read = *PRead;
|
sto[i].Read = *PRead;
|
||||||
sto[i].Write = *PWrite;
|
sto[i].Write = *PWrite;
|
||||||
sto[i].Reads = *PReads;
|
sto[i].Reads = *PReads;
|
||||||
|
@ -477,7 +470,6 @@ void loop() {
|
||||||
if (fatready) {
|
if (fatready) {
|
||||||
FRESULT rc; /* Result code */
|
FRESULT rc; /* Result code */
|
||||||
UINT bw, br, i;
|
UINT bw, br, i;
|
||||||
ULONG ii, wt, rt, start, end;
|
|
||||||
|
|
||||||
if (!notified) {
|
if (!notified) {
|
||||||
fadeAmount = 5;
|
fadeAmount = 5;
|
||||||
|
@ -488,7 +480,7 @@ void loop() {
|
||||||
else {
|
else {
|
||||||
printf_P(PSTR("\r\nType the file content.\r\n"));
|
printf_P(PSTR("\r\nType the file content.\r\n"));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
rc = f_read(&My_File_Object_x, &(My_Buff_x[0]), mbxs, &br); /* Read a chunk of file */
|
rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &br); /* Read a chunk of file */
|
||||||
if (rc || !br) break; /* Error or end of file */
|
if (rc || !br) break; /* Error or end of file */
|
||||||
for (i = 0; i < br; i++) {
|
for (i = 0; i < br; i++) {
|
||||||
/* Type the data */
|
/* Type the data */
|
||||||
|
@ -528,55 +520,67 @@ void loop() {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
outdir:
|
outdir:
|
||||||
printf_P(PSTR("\r\nOpen root directory.\r\n"));
|
{
|
||||||
rc = f_opendir(&My_Dir_Object_x, "0:/");
|
#if _USE_LFN
|
||||||
if (rc) {
|
char lfn[_MAX_LFN + 1];
|
||||||
die(rc);
|
FILINFO My_File_Info_Object_x; /* File information object */
|
||||||
goto out;
|
My_File_Info_Object_x.lfname = lfn;
|
||||||
}
|
#endif
|
||||||
|
DIR My_Dir_Object_x; /* Directory object */
|
||||||
printf_P(PSTR("\r\nDirectory listing...\r\n"));
|
printf_P(PSTR("\r\nOpen root directory.\r\n"));
|
||||||
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
|
rc = f_opendir(&My_Dir_Object_x, "0:/");
|
||||||
for (;;) {
|
if (rc) {
|
||||||
rc = f_readdir(&My_Dir_Object_x, &My_File_Info_Object_x); /* Read a directory item */
|
die(rc);
|
||||||
if (rc || !My_File_Info_Object_x.fname[0]) break; /* Error or end of dir */
|
goto out;
|
||||||
|
|
||||||
if (My_File_Info_Object_x.fattrib & AM_DIR) {
|
|
||||||
Serial.write('d');
|
|
||||||
} else {
|
|
||||||
Serial.write('-');
|
|
||||||
}
|
|
||||||
Serial.write('r');
|
|
||||||
|
|
||||||
if (My_File_Info_Object_x.fattrib & AM_RDO) {
|
|
||||||
Serial.write('-');
|
|
||||||
} else {
|
|
||||||
Serial.write('w');
|
|
||||||
}
|
|
||||||
if (My_File_Info_Object_x.fattrib & AM_HID) {
|
|
||||||
Serial.write('h');
|
|
||||||
} else {
|
|
||||||
Serial.write('-');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (My_File_Info_Object_x.fattrib & AM_SYS) {
|
printf_P(PSTR("\r\nDirectory listing...\r\n"));
|
||||||
Serial.write('s');
|
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
|
||||||
} else {
|
for (;;) {
|
||||||
Serial.write('-');
|
#if _USE_LFN
|
||||||
}
|
My_File_Info_Object_x.lfsize = _MAX_LFN;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (My_File_Info_Object_x.fattrib & AM_ARC) {
|
rc = f_readdir(&My_Dir_Object_x, &My_File_Info_Object_x); /* Read a directory item */
|
||||||
Serial.write('a');
|
if (rc || !My_File_Info_Object_x.fname[0]) break; /* Error or end of dir */
|
||||||
} else {
|
|
||||||
Serial.write('-');
|
if (My_File_Info_Object_x.fattrib & AM_DIR) {
|
||||||
}
|
Serial.write('d');
|
||||||
|
} else {
|
||||||
|
Serial.write('-');
|
||||||
|
}
|
||||||
|
Serial.write('r');
|
||||||
|
|
||||||
|
if (My_File_Info_Object_x.fattrib & AM_RDO) {
|
||||||
|
Serial.write('-');
|
||||||
|
} else {
|
||||||
|
Serial.write('w');
|
||||||
|
}
|
||||||
|
if (My_File_Info_Object_x.fattrib & AM_HID) {
|
||||||
|
Serial.write('h');
|
||||||
|
} else {
|
||||||
|
Serial.write('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (My_File_Info_Object_x.fattrib & AM_SYS) {
|
||||||
|
Serial.write('s');
|
||||||
|
} else {
|
||||||
|
Serial.write('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (My_File_Info_Object_x.fattrib & AM_ARC) {
|
||||||
|
Serial.write('a');
|
||||||
|
} else {
|
||||||
|
Serial.write('-');
|
||||||
|
}
|
||||||
|
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
if (*My_File_Info_Object_x.lfname)
|
if (*My_File_Info_Object_x.lfname)
|
||||||
printf_P(PSTR(" %8lu %s (%s)\r\n"), My_File_Info_Object_x.fsize, My_File_Info_Object_x.fname, My_File_Info_Object_x.lfname);
|
printf_P(PSTR(" %8lu %s (%s)\r\n"), My_File_Info_Object_x.fsize, My_File_Info_Object_x.fname, My_File_Info_Object_x.lfname);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
printf_P(PSTR(" %8lu %s\r\n"), My_File_Info_Object_x.fsize, &(My_File_Info_Object_x.fname[0]));
|
printf_P(PSTR(" %8lu %s\r\n"), My_File_Info_Object_x.fsize, &(My_File_Info_Object_x.fname[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (rc) die(rc);
|
if (rc) die(rc);
|
||||||
|
@ -584,18 +588,17 @@ out:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (runtest) {
|
if (runtest) {
|
||||||
|
ULONG ii, wt, rt, start, end;
|
||||||
runtest = false;
|
runtest = false;
|
||||||
|
f_unlink("0:/10MB.bin");
|
||||||
printf_P(PSTR("\r\nCreate a new 10MB test file (10MB.bin).\r\n"));
|
printf_P(PSTR("\r\nCreate a new 10MB test file (10MB.bin).\r\n"));
|
||||||
for (bw = 0; bw < mbxs; bw++) My_Buff_x[bw] = bw & 0xff;
|
|
||||||
rc = f_open(&My_File_Object_x, "0:/10MB.bin", FA_WRITE | FA_CREATE_ALWAYS);
|
rc = f_open(&My_File_Object_x, "0:/10MB.bin", FA_WRITE | FA_CREATE_ALWAYS);
|
||||||
if (rc) goto failed;
|
if (rc) goto failed;
|
||||||
|
for (bw = 0; bw < mbxs; bw++) My_Buff_x[bw] = bw & 0xff;
|
||||||
start = millis();
|
start = millis();
|
||||||
for (ii = 10485760 / mbxs; ii > 0; ii--) {
|
for (ii = 10485760LU / mbxs; ii > 0LU; ii--) {
|
||||||
rc = f_write(&My_File_Object_x, &My_Buff_x[0], mbxs, &bw);
|
rc = f_write(&My_File_Object_x, My_Buff_x, mbxs, &bw);
|
||||||
if (rc || !bw) goto failed;
|
if (rc || !bw) goto failed;
|
||||||
}
|
}
|
||||||
rc = f_close(&My_File_Object_x);
|
rc = f_close(&My_File_Object_x);
|
||||||
|
@ -607,7 +610,7 @@ out:
|
||||||
start = millis();
|
start = millis();
|
||||||
if (rc) goto failed;
|
if (rc) goto failed;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
rc = f_read(&My_File_Object_x, &My_Buff_x[0], mbxs, &bw); /* Read a chunk of file */
|
rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &bw); /* Read a chunk of file */
|
||||||
if (rc || !bw) break; /* Error or end of file */
|
if (rc || !bw) break; /* Error or end of file */
|
||||||
}
|
}
|
||||||
end = millis();
|
end = millis();
|
||||||
|
@ -617,7 +620,6 @@ out:
|
||||||
rt = end - start;
|
rt = end - start;
|
||||||
printf_P(PSTR("Time to read 10485760 bytes: %lu ms (%lu sec)\r\nDelete test file\r\n"), rt, (500 + rt) / 1000UL);
|
printf_P(PSTR("Time to read 10485760 bytes: %lu ms (%lu sec)\r\nDelete test file\r\n"), rt, (500 + rt) / 1000UL);
|
||||||
failed:
|
failed:
|
||||||
rc = f_unlink("0:/10MB.bin");
|
|
||||||
if (rc) die(rc);
|
if (rc) die(rc);
|
||||||
printf_P(PSTR("10MB timing test finished.\r\n"));
|
printf_P(PSTR("10MB timing test finished.\r\n"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue