- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The function alt_up_sd_card_find_first works perfectly, which can help me print out all the file names in the SD card. (So I think it's not any formatting and size problem of the SD card. It's 2GB and FAT16 anyways.)
But when I call alt_up_sd_card_fopen, it returns me -1, so I can't open, create, and write a file. Below is my simple code of creating a text file, and print out all the file names: alt_up_sd_card_dev *device_reference = NULL; int connected = 0; char* fileName; device_reference = alt_up_sd_card_open_dev(SD_CARD_NAME); short int handler; char buffer[10000] = "Testing Testing\0"; int index = 0; if (device_reference != NULL) { handler = alt_up_sd_card_fopen("test2.txt", false); if (handler >= 0){ while (buffer[index] != '\0'){ alt_up_sd_card_write(handler, buffer[index]); index++;} alt_up_sd_card_fclose(handler); } else printf("cannot open file: %d\n",handler); while (1) { if ((connected == 0) && (alt_up_sd_card_is_Present())) { printf("Card connected. \n"); printf("fat16: %d",alt_up_sd_card_is_FAT16()); if (alt_up_sd_card_is_FAT16()) { printf("FAT16 file system detected. \n"); if(alt_up_sd_card_find_first("",fileName)==0){ printf("Files detected: \n"); do{ printf("%s \n",fileName); }while(alt_up_sd_card_find_next(fileName)==0); } else if (alt_up_sd_card_find_first("",fileName)== -1) printf("No files. \n"); } else { printf("Unknown file system. \n"); } connected = 1; } else if ((connected == 1) && (alt_up_sd_card_is_Present() == false)) { printf("Card disconnected. \n"); connected = 0; } } } I found a similar thread about this issue. http://www.alteraforum.com/forum/showthread.php?t=34101 But I had the interface already... I don't know why it's still nothing changes??? Please help, thanks링크가 복사됨
0 응답
