Example #1
0
void mmcReadCached(u32 sector)
{
	//debug("mmcReadCached");
	//plotnext(toatarichar(' '));
	//plotnextnumber(sector);
	//debug("\n");
	if(sector==n_actual_mmc_sector) return;
	//debug("mmcReadREAL");
	//plotnext(toatarichar(' '));
	//plotnextnumber(sector);
	//debug("\n");

	u08 ret,retry;
	//predtim nez nacte jiny, musi ulozit soucasny
	// TODO mmcWriteCachedFlush();
	//az ted nacte novy
	retry=0; //zkusi to maximalne 256x
	do
	{
		ret = mmcRead(sector);	//vraci 0 kdyz ok
		retry--;
	} while (ret && retry);
	while(ret); //a pokud se vubec nepovedlo, tady zustane zablokovany cely SDrive!
	n_actual_mmc_sector=sector;
}
Example #2
0
void mmcTest(void)
{
	uint32_t sector=0;
	uint8_t buffer[0x200];
	int c;

	// initialize MMC interface
	mmcInit();

	// print new prompt
	rprintf("\r\ncmd>");

	// testing loop
	while(1)
	{
		// check for keypress
		if((c=uartGetByte()) != -1)
		{
			switch(c)
			{
			case 'i':
				// initialize card 
				rprintf("\r\nResetting MMC/SD Card\r\n");
				mmcReset();
				break;
			case 'r':
				// read current sector into buffer
				rprintf("\r\nRead Sector %d\r\n", sector);
				mmcRead(sector, buffer);
				// print buffer contents
				debugPrintHexTable(0x200, buffer);
				break;
			case 'w':
				// write current sector with data from buffer
				rprintf("\r\nWrite Sector %d\r\n", sector);
				mmcWrite(sector, buffer);
				break;
			// move to new sector
			case '+': sector++;		rprintf("\r\nSector = %d", sector); break;
			case '-': sector--;		rprintf("\r\nSector = %d", sector); break;
			case '*': sector+=512;	rprintf("\r\nSector = %d", sector); break;
			case '/': sector-=512;	rprintf("\r\nSector = %d", sector); break;
			case '\r':
			default:
				break;
			}
			// print new prompt
			rprintf("\r\ncmd>");
		}
	}

}
Example #3
0
DSTATUS disk_initialize (void)
{
	DSTATUS stat;

	//printf(" in init ");
	n_actual_mmc_sector = 0xffffffff;
	for(;;)
	{
		mmc_init();
		if (0==mmcRead(1))
			break;
	}

	//printf(" setting freq ");

	set_spi_clock_freq();

	stat = RES_OK;

	return stat;
}