void img_sd_init(void)
{
int fireres;
char myfilename[20];
uint16 imgsize[] = {
CAMERA_H,
CAMERA_W,
//CAMERA_COLOR,
}; //高、宽、摄像头颜色类型
uint32 mybw;
uint32 Imag_num = 0;
f_mount(0, &firefs);
printf("DSS!\n");
do
{
Imag_num ++;
sprintf(myfilename, "0:/fire%d.sd", Imag_num);
fireres = f_open( &firesrc , myfilename, FA_CREATE_NEW | FA_WRITE);
if(firefs.fs_type == 0)
{
firesrc.fs = 0;
return;
}
}while(fireres == FR_EXIST); //如果文件存在,则命名继续加1
printf("DSS2!\n");
if ( fireres == FR_OK )
{
OLED_P6x8Str(10,1,"SD Card OK!");
printf("SD Card OK!\n");
fireres = f_write(&firesrc, imgsize, sizeof(imgsize),&mybw); //先写入高和宽,方便上位机处理
}
else
{
OLED_P6x8Str(10,1,"SD Card Error!");
printf("SD Card Error!\n");
f_close(&firesrc);
firesrc.fs = 0;
while(1);
}
}
程序运行到 do
{ Imag_num ++; sprintf(myfilename, "0:/fire%d.sd", Imag_num); fireres = f_open( &firesrc , myfilename, FA_CREATE_NEW | FA_WRITE);
if(firefs.fs_type == 0) { firesrc.fs = 0; return; } 就返回了,有人知道是为什么吗 硬件我检查了一下,没有问题。 SD卡使用,写入图像前,需要格式化或者新建文件吗
|