Пример #1
0
void sd_fs_init(void)
{
    /* SD卡中断初始化 */
		SDIO_NVIC_Configuration();		
		/* SD 卡硬件初始化,初始化盘符为0 */	 
    disk_initialize( 0 );	         
}
Пример #2
0
void Sd_fs_init(void)
{
    /* SD卡中断初始化 */
		SDIO_NVIC_Configuration();
		
		/* SD 卡硬件初始化,初始化盘符为0 */	 
   f_mount(0,&myfs[0]);	       
}
Пример #3
0
static void SDCARD_Configuration(void)
{
    /* SDCARD Periph clock enable */
    RCC_APB2PeriphClockCmd(SDCARD_EN_CLK, ENABLE);

    // NVIC configuration
    SDIO_NVIC_Configuration();

	// GPIO : PIN Init
	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Pin =  SDCARD_EN_PIN; // (DAC0 => PA04)
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOE, &GPIO_InitStructure);
}
Пример #4
0
void Sd_fs_test(void)
{
    int count=0;
		    
    SDIO_NVIC_Configuration();
    disk_initialize( 0 );	     /* SD 卡硬件初始化 */

    f_mount(0, &myfs[0]);
    myres = f_open( &myfsrc , "0:/my__Demo.TXT" ,/* FA_CREATE_NEW |*/ FA_WRITE);
    
    if ( myres == FR_OK )
    { 
        /* Write buffer to file */
        myres = f_write(&myfsrc, mystring, sizeof(mystring), &mybr);    
        f_close(&myfsrc);      
    }    
    else if ( myres == FR_EXIST )  //如果文件已经存在
    {	
    }    
    
    myres = f_open(&myfsrc, "0:/my__Demo.TXT", FA_OPEN_EXISTING | FA_READ); /* 打开文件 */	  //ok    
    mybr = 1;
    mya = 0;    
    
    for (;;) 
    {        
        for ( mya=0; mya<512; mya++ ) 	/* 清缓冲区 */
            mybuffer[mya]=0;
        
     	  myres = f_read( &myfsrc, mybuffer, sizeof(mybuffer), &mybr ); /* 将文件里面的内容读到缓冲区 */
        sprintf( (char*)&my_latest_buffer[count*512], "%s" , mybuffer );	  //打印到缓冲区        
        count++;							
        if (myres || mybr == 0) break;   // error or eof        	    	
    }    
    f_close(&myfsrc);	 /* 关闭打开的文件 */    	    
}
Пример #5
0
void Sd_fs_test(void)
{
    int count=0;
	
		printf("\r\n 这是一个MicroSD卡文件系统测试实验(FATFS R0.09)\n");
	
    SDIO_NVIC_Configuration();
    disk_initialize( 0 );	     /* SD 卡硬件初始化 */

    f_mount(0, &myfs[0]);
    myres = f_open( &myfsrc , "0:/my__Demo.TXT" , FA_CREATE_NEW | FA_WRITE);
	
		printf("\r\n my__Demo.TXT  创建成功\n");
	
    if ( myres == FR_OK )
    { 
        /* Write buffer to file */
        myres = f_write(&myfsrc, mystring, sizeof(mystring), &mybr);    
        f_close(&myfsrc);      
    }    
    else if ( myres == FR_EXIST )  //如果文件已经存在
    {	
    }    
    
    myres = f_open(&myfsrc, "0:/my__Demo.TXT", FA_OPEN_EXISTING | FA_READ); /* 打开文件 */	  //ok    
				
		printf("\r\n my__Demo.TXT 已存在,打开成功\n");

    mybr = 1;
    mya = 0; 
		
		printf("读取创建的TXT文件 ----\n");		
		
    for (;;) 
    {        
        for ( mya=0; mya<512; mya++ ) 	/* 清缓冲区 */
            mybuffer[mya]=0;
        
     	  myres = f_read( &myfsrc, mybuffer, sizeof(mybuffer), &mybr ); /* 将文件里面的内容读到缓冲区 */
//         sprintf( (char*)&my_latest_buffer[count*512], "%s" , mybuffer );	  //打印到缓冲区  
						printf("\r\n %s \n", mybuffer);											
						count++;							
        if (myres || mybr == 0) break;   // error or eof        	    	
    }   
		
		printf("\r\n %d ", count);
		count = 0;		
		
    f_close(&myfsrc);	 /* 关闭打开的文件 */
    
//   for (;;) 
// 	{
// 		for ( a=0; a<512; a++ ) 	                          /* 清缓冲区 */
// 			buffer[a]=0;
// 			 
//   	res = f_read( &fdst, buffer, sizeof(buffer), &br ); /* 将文件里面的内容读到缓冲区 */
// 		printf("\r\n %s ", buffer);						
//   	if (res || br == 0) break;                          /* 错误或者到了文件尾 */        	    	
//   }
// 	f_close(&fdst);	 		
		
//    Set_direction(0);		    
}