Exemple #1
0
void Test_SDI(void)
{
	ULONG save_rGPEUP, save_rGPECON;

    RCA=0;
    MMC=0;
    block=3072;   //3072Blocks=1.5MByte, ((2Block=1024Byte)*1024Block=1MByte)

	save_rGPEUP=rGPEUP;
	save_rGPECON=rGPECON;

    rGPEUP  = 0xf83f;     // SDCMD, SDDAT[3:0] => PU En.
    rGPECON = 0xaaaaaaaa;	//SDCMD, SDDAT[3:0]


    Uart_Printf("\nSDI Card Write and Read Test\n");

    if(!SD_card_init())
	return;

    TR_Buf_new();

    Wt_Block();

    Rd_Block();
    View_Rx_buf();

    if(MMC)
	TR_Buf_new();

    if(MMC)
    {
		rSDICON |=(1<<5);    // YH 0519, MMC Type SDCLK

		Wt_Stream();
		Rd_Stream();
		View_Rx_buf();
    }

    Card_sel_desel(0);	// Card deselect

    if(!CMD9())
	Uart_Printf("Get CSD fail!!!\n");
    rSDIDCON=0;//tark???
    rSDICSTA=0xffff;
	rGPEUP=save_rGPEUP;
	rGPECON=save_rGPECON;
}
Exemple #2
0
void Test_SDI(void)
{
	U32 save_rGPEUP, save_rGPECON;
	
	RCA=0;
	MMC=0;
	block=3072;   //3072Blocks=1.5MByte, ((2Block=1024Byte)*1024Block=1MByte)

	save_rGPEUP=GPEUP;
	save_rGPECON=GPECON;
	
	GPEUP  = 0xf83f;     // SDCMD, SDDAT[3:0] => PU En.
	GPECON = 0xaaaaaaaa;	//SDCMD, SDDAT[3:0]


	//Uart_Printf("\nSDI Card Write and Read Test\n");

	if(!SD_card_init())
		return;

	TR_Buf_new();

	Wt_Block();
	
	Rd_Block();
	View_Rx_buf();

	Card_sel_desel(0);	// Card deselect

	if(!CMD9())
	//Uart_Printf("Get CSD fail!!!\n");
	SDIDCON=0;//tark???
	SDICSTA=0xffff;
	GPEUP=save_rGPEUP;
	GPECON=save_rGPECON;
}
void BMP_data_from_flash(unsigned long int data_addr,unsigned long int flash_page_addr)
{
	unsigned int i;
	unsigned int j;
	unsigned char remainder_number;
	unsigned char remainder[3];

	unsigned int page_number;
	unsigned int page_addr;
	unsigned int file_size; 
	unsigned int header_size;
	
	unsigned short int n;
	unsigned int fat_page_addr;
	unsigned int current_sector_addr;
	unsigned int next_sector_addr;
	unsigned int sector_num;	
	unsigned short int FAT[256];
	
	
	
	page_addr=flash_page_addr;
	block=1;
	Rd_Block(page_addr*512);           //Flash_page_read(page_addr);
	View_Rx_buf();

	file_size=Data_buffer[5];
	file_size=(file_size<<8)+Data_buffer[4];	
   	file_size=(file_size<<8)+Data_buffer[3];
   	file_size=(file_size<<8)+Data_buffer[2];
   
	header_size=Data_buffer[13];
   	header_size=(header_size<<8)+Data_buffer[12];
   	header_size=(header_size<<8)+Data_buffer[11];
   	header_size=(header_size<<8)+Data_buffer[10];
	page_number=(file_size/512)+1;
		

	for (i=header_size;i<512-2;i=i+3)
	{
		//Image_data[data_addr]=Data_buffer[i+2];
   		//Image_data[data_addr]=(Image_data[data_addr]<<8)+Data_buffer[i+1];
   		//Image_data[data_addr]=(Image_data[data_addr]<<8)+Data_buffer[i];
   		Image_data[data_addr]=Data_buffer[i+2];
   		Image_data[data_addr]=(Image_data[data_addr]<<8)+Data_buffer[i+1];
   		Image_data[data_addr]=(Image_data[data_addr]<<8)+Data_buffer[i];
		data_addr++;
	}

	remainder_number=(512-header_size)%3; 
	for (i=0;i<remainder_number;i++)
	{
		remainder[i]=Data_buffer[512-remainder_number+i];                       //Data_buffer[510]//
		                                                                        //Data_buffer[511]//把被隔断的象素处理到下一簇
	}
	while(1)
	{	
		for(n=0;n<SecPerClus-1;n++)
		{
			
			page_addr=page_addr+1;       //page_addr++;    
			block=1;
			Rd_Block(page_addr*512);         //Flash_page_read(page_addr);		
			
			switch(remainder_number)
			{
				case 0:
				{
					for (j=0;j<512-2;j=j+3)
					{
						//Image_data[data_addr]=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
						*(Image_data+data_addr)=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
	   					data_addr++;
					}
					remainder_number=2;
					remainder[0]=Data_buffer[510];
					remainder[1]=Data_buffer[511];
				}
				break;
				case 1:
				{
					//Image_data[data_addr]=(Data_buffer[1]<<16)+(Data_buffer[0]<<8)+remainder[0];
	   				*(Image_data+data_addr)=(Data_buffer[1]<<16)+(Data_buffer[0]<<8)+remainder[0];
	   				data_addr++;
					for (j=2;j<512-2;j=j+3)
					{
						*(Image_data+data_addr)=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
						data_addr++;
					}
					remainder_number=0;
				}
				break;
				case 2:
				{				
					*(Image_data+data_addr)=(Data_buffer[0]<<16)+(remainder[1]<<8)+remainder[0];
	 				data_addr++;
					for (j=1;j<512-2;j=j+3)
					{
						*(Image_data+data_addr)=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
						data_addr++;
					}
					remainder_number=1;
					remainder[0]=Data_buffer[511];
				}
				break;
				default:;
			}		
		}
		current_sector_addr=(page_addr-Data_start_Addr+46)/SecPerClus;	//512M(32)/1G(46)YYS
		fat_page_addr=RsvdSec+current_sector_addr/256+249;//512M(231)/1G(249)YYS
		sector_num=(current_sector_addr%256);
		block=1; 
		Rd_Block(fat_page_addr*512);     //Flash_page_read(fat_page_addr);
		/*for(i=0;i<256;i++)
		{
			FAT[i]=Data_buffer[2*i]+Data_buffer[2*i+1]*256;
		}
		next_sector_addr=(FAT[sector_num])&(0x0000ffff);*/
		next_sector_addr=(Data_buffer[2*sector_num]+256*Data_buffer[2*sector_num+1])&(0x0000ffff);
		if(next_sector_addr==0xffff)  goto end;
		page_addr=SecPerClus*next_sector_addr+Data_start_Addr-46;//512M(32)/1G(46)YYS	
		block=1; 
		Rd_Block(page_addr*512);     //Flash_page_read(page_addr);				
		switch(remainder_number)
		{
			case 0:
			{
				for (j=0;j<512-2;j=j+3)
				{
					*(Image_data+data_addr)=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
   					data_addr++;
				}
				remainder_number=2;
				remainder[0]=Data_buffer[510];
				remainder[1]=Data_buffer[511];
			}
			break;
			case 1:
			{
				*(Image_data+data_addr)=(Data_buffer[1]<<16)+(Data_buffer[0]<<8)+remainder[0];
   				data_addr++;
				for (j=2;j<512-2;j=j+3)
				{
					*(Image_data+data_addr)=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
					data_addr++;
				}
				remainder_number=0;
			}
			break;
			case 2:
			{
				
				*(Image_data+data_addr)=(Data_buffer[0]<<16)+(remainder[1]<<8)+remainder[0];
 				data_addr++;
				for (j=1;j<512-2;j=j+3)
				{
					*(Image_data+data_addr)=(Data_buffer[j+2]<<16)+(Data_buffer[j+1]<<8)+Data_buffer[j];
					data_addr++;
				}
				remainder_number=1;
				remainder[0]=Data_buffer[511];
			}
			break;
			default:;
		}
		
	}
	end:;      //Image_data[0X33176FFF]//800*480
}