Beispiel #1
0
/* Outputs a string on the debug UART */
void Board_UARTPutSTR(char *str)
{
#if defined(DEBUG_UART)
	while (*str != '\0') {
		Board_UARTPutChar(*str++);
	}
#endif
}
Beispiel #2
0
/* Function to do the read/write to USB Disk */
static void throughputTest(void)
{
	FRESULT rc;		/* Result code */
	UINT br;



	f_mount(0, &fatFS);		/* Register volume work area (never fails) */

	rc = f_open(&fileObj, "test.bin", FA_READ);
	if (rc) {
		DEBUGOUT("Unable to open big_file.bin from USB Disk\r\n");
		die(rc);
	}

	int frameReads;
	uint32_t readTimes[MAX_FRAME_READS];

	Chip_TIMER_Enable(RUNTIME_TIMER);

	for(frameReads = 0; frameReads < MAX_FRAME_READS; ++frameReads)
	{
		RUNTIME_TIMER->TC = 0;
		/* Read a chunk of file */
		rc = f_read(&fileObj, frameBuffer, FRAME_SIZE, &br);
		if(rc != FR_OK)
		{
			DEBUGOUT("Error reading from file\r\n");
			die(rc);
		}
		else if(br != FRAME_SIZE)
		{
			break;
		}
		readTimes[frameReads] = RUNTIME_TIMER->TC;
		Board_UARTPutChar('.');
	}

	f_close(&fileObj);

	uint64_t sum = 0;
	uint32_t min = UINT32_MAX;
	uint32_t max = 0;
	float ave;

	for(int i = 0; i < frameReads; ++i)
	{
		sum += readTimes[i];
		if(readTimes[i] < min)
			min = readTimes[i];
		if(readTimes[i] > max)
			max = readTimes[i];
	}
	ave = (float)sum / (float)frameReads;

	printf("\n----------------------------\n");
	printf("Test Results\n");
	printf("----------------------------\n");
	printf("\tFrames read: %d\n", frameReads);
	printf("\tFrame size: %.3fkB\n", (float)FRAME_SIZE / 1000.0);
	printf("\tMin time: %.3fus\n", (float)min * PCLK_US);
	printf("\tMax time: %.3fus\n", (float)max * PCLK_US);
	printf("\tAve time: %.3fus\n", (float)ave * PCLK_US);
	printf("\n----------------------------\n");
	printf("All times\n");
	printf("----------------------------\n");
	for(int i = 0; i < frameReads; ++i)
	{
		printf("\t%02d: %.3fus\n", i,  (float)readTimes[i] * PCLK_US);
	}
	printf("----------------------------\n\n");

	DEBUGOUT("\r\nTest completed.\r\n");
	USB_Host_SetDeviceConfiguration(FlashDisk_MS_Interface.Config.PortNumber, 0);
}