int main(void) { char buffer_name[10]; short int handler; alt_up_sd_card_dev *device_reference = NULL; int connected = 0; device_reference = alt_up_sd_card_open_dev("/dev/SD_Card"); if (device_reference != NULL) { while(1) { if ((connected == 0) && (alt_up_sd_card_is_Present())) { printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()) { printf("FAT16 file system detected.\n"); //Print out the list in the sd card handler = alt_up_sd_card_find_first("", buffer_name); printf("%s \n", buffer_name); while ((handler = alt_up_sd_card_find_next(buffer_name)) != -1) printf("%s \n", buffer_name); }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; } } } return 0; }
char openFileinSD(char* fileName, short int* file_handle_ptr){ short int file_handle; char status = -1; sd_card = alt_up_sd_card_open_dev("/dev/SD_Card"); if (sd_card != NULL){ while(1){ if (alt_up_sd_card_is_Present()){ printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()){ printf("FAT16 confirmed.\n"); file_handle = alt_up_sd_card_fopen( fileName, false ); if ( file_handle == -1 ) printf( "*** File cannot be opened.\n"); else if ( file_handle == -2 ) printf( "*** File already opeend.\n"); else { *file_handle_ptr = file_handle; status = 0; printf( "File obtained.\n"); return status; } printf("*** Error reading File.\n"); } else { printf("*** Not FAT16.\n"); } } } } printf("*** Storage Device may not found.\n"); return status; }
void save_level(char level) { short int handle; alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); if (device_reference != NULL && alt_up_sd_card_is_Present() && alt_up_sd_card_is_FAT16()) { handle = alt_up_sd_card_fopen("saves.txt",0); if (handle==-1) { printf("ITS BAD\n"); } /* char temp[4]; if (handle==-1){ printf("ITS BAD\n"); } sprintf(temp,"%d",level); if(!alt_up_sd_card_write(handle, temp[0])){ printf("NOT WORKING\n"); } alt_up_sd_card_write(handle, temp[2]); alt_up_sd_card_write(handle, temp[3]); alt_up_sd_card_write(handle, temp[4]);*/ alt_up_sd_card_write(handle,level); alt_up_sd_card_fclose(handle); } }
/* * Overview: exercise 3 reads sd_card and list its file. * */ void sd_card(void){ char file_name[10]; alt_up_sd_card_dev *device_reference = NULL; int connected = 0; device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); if (device_reference != NULL) { while(1) { if ((connected == 0) && (alt_up_sd_card_is_Present())) { //printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()) { //printf("FAT16 file system detected.\n"); if(alt_up_sd_card_find_first(".", (char*) file_name)==0){ //printf("%s\n",file_name); while(alt_up_sd_card_find_next((char*)file_name)==0) { //printf("%s\n", file_name); } } } 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; } break; } } else { //printf("Card could not be opened\n"); } //printf("sd_card function finished\n"); }
/* * init_sd : open connection to sd card port */ void init_sd() { alt_up_sd_card_dev *device_reference = NULL; char *interface = "/dev/Altera_UP_SD_Card_Avalon_Interface_0"; if ( ( device_reference = alt_up_sd_card_open_dev( interface ) ) == NULL ) { printf( "ERROR! SD card path is bad: %s\n", interface ); } else { if ( device_reference != NULL ) { if ( ( SD_CONNECTED == 0 ) && ( alt_up_sd_card_is_Present() ) ) { if ( alt_up_sd_card_is_FAT16() ) { printf( "< SD Initialized >\n" ); SD_CONNECTED = 1; } else { printf( "ERROR! Unknown file system on SD card\n" ); } } else if ( ( SD_CONNECTED == 1) && ( alt_up_sd_card_is_Present() == 0 ) ) { printf( "ERROR! card disconnected.\n" ); SD_CONNECTED = 0; } } else { printf( "ERROR! can't open sd card device\n" ); } } }
alt_up_sd_card_dev* get_device_reference(){ alt_up_sd_card_dev* device_reference = NULL; if ((device_reference = alt_up_sd_card_open_dev("/dev/Altera_UP_SD_Card_Avalon_Interface_0")) == NULL){ return NULL; } return device_reference; }
int openSdCard(){ sdDev = alt_up_sd_card_open_dev("/dev/Altera_UP_SD_Card_Avalon_Interface_0"); if(sdDev != NULL && alt_up_sd_card_is_FAT16()){ return 0; } else { return -1; } }
unsigned int* read_image(){ unsigned char* temp; unsigned int* image; short int handle; int k = 0; int i = 0; temp = calloc (FILE_SIZE , sizeof(char)); image = calloc (ARRAY_SIZE , sizeof(short int)); alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); if (device_reference != NULL && alt_up_sd_card_is_Present() && alt_up_sd_card_is_FAT16()) { handle = alt_up_sd_card_fopen("text2.txt",0); while(alt_up_sd_card_read(handle)!=-1){ *(temp+k)=(char)alt_up_sd_card_read(handle); k++; } k=0; i=0; while(*(temp+k)!='!'){ if(*(temp+k)=='0'){ k++; if(*(temp+k)=='x'){ k++; *(image+i) += (*(temp+k)); *(image+i) = *(image+i) << 4; k++; *(image+i) += (*(temp+k)); *(image+i) = *(image+i) << 4; k++; *(image+i) += (*(temp+k)); *(image+i) = *(image+i) << 4; k++; *(image+i) += (*(temp+k)); i++; k+=2; } } printf("%i\n",*(image+i)); k++; } if(614300>k){ printf("Something is wrong.\n"); } } free(temp); return image; }
//Initializes SD card, outputs filenames on sd card int init_sd(char * filenames[]){ int j; int i = 0; char thepath[] = AUD_DIRECT; //Directory for filenames we want to read short int check_file_name; for (j = 0; j < MAXFILES; j++) { filenames[j] = (char *)malloc(sizeof(char) * MAX_NAME_LEN); if (filenames[j] == NULL) printf("Error, out of memory (2)\n"); } alt_up_sd_card_dev * sd_card = NULL; int connected = 0; sd_card = alt_up_sd_card_open_dev("/dev/Interface"); if (sd_card != NULL) { while(1) { if ((connected == 0) && (alt_up_sd_card_is_Present())) { printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()) { printf("FAT16 file system detected.\n"); check_file_name = alt_up_sd_card_find_first(thepath,filenames[i]); if (check_file_name == 1) printf("Invalid Directory.\n"); else if (check_file_name == 2) printf("Invalid SD Card.\n"); else if (check_file_name == -1) printf("No files found.\n"); else { i++; } while(alt_up_sd_card_find_next(filenames[i]) != -1){ i++; } arr = (unsigned int ***)malloc(sizeof(unsigned int) * i); if (arr == NULL){ printf("Error, arr null\n"); } return i; //If card connected, returns amount of files } 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; } } } else { printf("Error.\n"); return -1; } }
int sdcard_init() { printf("Opening SDCard\n"); device_reference = alt_up_sd_card_open_dev(SDCARD_DEV); if (device_reference == NULL) { printf("Error: Could not open SDCard\n"); return 1; } printf("Opened SDCard\n"); return 0; }
bool loadSDCard(alt_up_sd_card_dev* device) { if((device = alt_up_sd_card_open_dev("/dev/SD_Card")) != NULL) { if (alt_up_sd_card_is_Present()) { printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()) { printf("FAT16 file system detected.\n"); return true; } else { printf("Unknown file system.\n"); } } } return false; }
int init_sd(char * filenames[]){ int i = 0; char thepath[] = "/"; short int check_file_name; alt_up_sd_card_dev * sd_card = NULL; int connected = 0; sd_card = alt_up_sd_card_open_dev("/dev/Interface"); if (sd_card != NULL) { while(1) { if ((connected == 0) && (alt_up_sd_card_is_Present())) { printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()) { printf("FAT16 file system detected.\n"); check_file_name = alt_up_sd_card_find_first(thepath,filenames[i]); if (check_file_name == 1) printf("Invalid Directory.\n"); else if (check_file_name == 2) printf("Invalid SD Card.\n"); else if (check_file_name == -1) printf("No files found.\n"); else { // printf("First file name = %s.\n", filenames[i]); i++; } while(alt_up_sd_card_find_next(filenames[i]) != -1){ // printf("Next file name = %s.\n", filenames[i]); i++; } return i; } 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; } } } else { printf("Error.\n"); return -1; } }
int readFromSDEncrypted(char* buffer, char* fileName, int bufferSize) { alt_up_sd_card_dev *device_reference = NULL; short int myFileHandle; int i; char tempChar[2]; tempChar[1] = '\0'; //printf("Opening SDCard\n"); if ((device_reference = alt_up_sd_card_open_dev( "/dev/Altera_UP_SD_Card_Avalon_Interface_0")) == NULL) { //printf("SDCard Open FAILED\n"); return -1; } else { //printf("SDCard Open PASSED\n"); } if (alt_up_sd_card_is_Present() && alt_up_sd_card_is_FAT16()) { myFileHandle = alt_up_sd_card_fopen(fileName, false); if (myFileHandle == -1) { myFileHandle = alt_up_sd_card_fopen(fileName, true); } if (myFileHandle != -1) { //printf("File Opened\n"); for (i = 0; i < bufferSize; i++) { tempChar[0] = alt_up_sd_card_read(myFileHandle); if (tempChar[0] < 0) { break; } strcat(buffer, tempChar); } //printf("Done!!!\n"); alt_up_sd_card_fclose(myFileHandle); printf("buffer %s", buffer); char *decryptedData = decryptData(buffer); printf("Decrypted after read: %s", decryptedData); strcpy(buffer, decryptedData); return 0; } else { //printf("File NOT Opened\n"); } } return -1; }
//initializes audio buffer int initAudio(char* fname) { alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(SD_CARD_NAME); open_sd(); av_config_setup(); init_audio_buff(ab); ab->audio = alt_up_audio_open_dev(AUDIO_0_NAME); alt_up_audio_reset_audio_core(ab->audio); file_handle = alt_up_sd_card_fopen(fname, 0); offset(file_handle, ab); fill_buff(file_handle, ab); return file_handle; }
void initSD() { int connected = 0; alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(SD_CARD_NAME); if (device_reference != NULL) { 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"); 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; } } }
int writeToSDEncrypted(char* buffer, char* fileName) { alt_up_sd_card_dev *device_reference = NULL; short int myFileHandle; int i; char *encryptedBuffer = encryptData(buffer); printf("\nebuffer %s\n", encryptedBuffer); printf("Opening SDCard\n"); if ((device_reference = alt_up_sd_card_open_dev( "/dev/Altera_UP_SD_Card_Avalon_Interface_0")) == NULL) { printf("SDCard Open FAILED\n"); return -1; } else { printf("SDCard Open PASSED\n"); } if (alt_up_sd_card_is_Present() && alt_up_sd_card_is_FAT16()) { if (alt_up_sd_card_is_Present() && alt_up_sd_card_is_FAT16()) { myFileHandle = alt_up_sd_card_fopen(fileName, false); if (myFileHandle == -1) { myFileHandle = alt_up_sd_card_fopen(fileName, true); } if (myFileHandle != -1) { printf("File Opened\n"); for (i = 0; i < strlen(encryptedBuffer); i++) { if (alt_up_sd_card_write(myFileHandle, encryptedBuffer[i]) == false) { printf("Error writing to file...\n"); return -1; } } printf("Done!!!\n"); alt_up_sd_card_fclose(myFileHandle); } else { printf("File NOT Opened\n"); } } } return 0; }
void initSD(){ int connected = 0; alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); if (device_reference != NULL) { 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"); 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; } } findDatabaseVersion(); setDatabase(0); }
*/void sound() { short int handle; //printf("SDCARD CONNECTION CHECK\n"); alt_up_sd_card_dev *device_reference=alt_up_sd_card_open_dev("/dev/Altera_UP_SD_Card_Avalon_Interface_0"); alt_up_audio_dev *audio; sdcardcheck(device_reference); //printf("AV CONFIG SETUP\n"); av_config_setup(); //printf("AUDIO OPEN\n"); audio=alt_up_audio_open_dev("/dev/audio"); unsigned int buffer[COIN_SIZE]; char *filename="coin.wav"; readCoin(buffer, filename, handle); play_audio(audio, buffer, handle); alt_up_sd_card_fclose(filename); }
/* * This function initializes the SD card for use. It must be run once and only once before any other functions within this file are used */ void sd_init(void){ alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); }
/* * Initialization for SD card controller */ void initializeSDCardController() { sd_card_reference = alt_up_sd_card_open_dev(SD_CARD_NAME); }
int main() { int i; //1 for receiving file from middleman, 2 for sending to middleman int mode; //Num char in filename array int numFileName; //Num bytes in file int numBytesFile; //Num characters in file array int numFile; char* listName; //File to send or receive (likely a piece of it) unsigned char fileName[MAX_FILENAME]; //variable to hold data received from uart unsigned char data; //parity bit for reading (not using parity atm, but still need the bit) unsigned char parity; short int handle; //handle for the file to create/access int connected = 0; //Variable to keep track of whether the SD CARD is connected or not. while (1) { alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); printf("UART Initialization\n"); alt_up_rs232_dev* uart = alt_up_rs232_open_dev("/dev/rs232_0"); if(!alt_up_sd_card_is_FAT16()){ printf("SD CARD is not FAT16 Format\n"); } if (device_reference != NULL) { while (alt_up_sd_card_is_Present()) { printf("Clearing read buffer to start\n"); while (alt_up_rs232_get_used_space_in_read_FIFO(uart)) { alt_up_rs232_read_data(uart, &data, &parity); } // Now receive the instruction from the Middleman printf("Waiting for instruction to come from the Middleman\n"); while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0) ; // First byte is the mode, 1 for receiving file from middleman, 2 for sending to middleman alt_up_rs232_read_data(uart, &data, &parity); mode = (int) data; //mode -= 48; printf("Mode:%d\n", mode); //Receive file from middleman and save to SD if (mode == 1) { printf("Waiting for num char:\n"); // The second byte is the number of characters in the file name while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0); alt_up_rs232_read_data(uart, &data, &parity); numFileName = (int) data; //numFileName -= 48; //Now receive the file name printf("About to receive %d characters:\n\n", numFileName); printf("Filename received:"); for (i = 0; i < numFileName; i++) { while (alt_up_rs232_get_used_space_in_read_FIFO(uart)== 0); alt_up_rs232_read_data(uart, &data, &parity); fileName[i] = data; printf("%c", data); } printf("\n"); fileName[i] = '.'; fileName[i+1] = 't'; fileName[i+2] = 'x'; fileName[i+3] = 't'; fileName[i+4]= '\0'; // // TODO: // USE THAT FILENAME TO MAKE A NEW FILE ON SD CARD HERE handle = alt_up_sd_card_fopen(fileName, 1); if(handle < 0){ //TODO: File can't be opened, do something about it printf("send had a neg handle \n\n"); } else{ // The 4 bytes after filename is the number of bytes in the file // // SHIFT BYTES LEFT AND CONCATENATE TO ACCOUNT FOR SEVERAL BYTES WORTH OF FILE // WRITE FIRST 4 BYTES OF FILE AS SIZE OF FILE IN BYTES while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0); alt_up_rs232_read_data(uart, &data, &parity); alt_up_sd_card_write(handle, data); numBytesFile = (int) data; numBytesFile = numBytesFile << 8; while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0); alt_up_rs232_read_data(uart, &data, &parity); alt_up_sd_card_write(handle, data); numBytesFile += (int) data; numBytesFile = numBytesFile << 8; while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0); alt_up_rs232_read_data(uart, &data, &parity); alt_up_sd_card_write(handle, data); numBytesFile += (int) data; numBytesFile = numBytesFile << 8; while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0); alt_up_rs232_read_data(uart, &data, &parity); alt_up_sd_card_write(handle, data); numBytesFile += (int) data; //WRITE BYTES TO SD CARD printf("About to receive %d file chars:\n\n",numBytesFile); for (i = 0; i < numBytesFile; i++) { while (alt_up_rs232_get_used_space_in_read_FIFO(uart)== 0); alt_up_rs232_read_data(uart, &data, &parity); alt_up_sd_card_write(handle, data); } printf("File done\n"); alt_up_sd_card_fclose(handle); } //This bracket ends receiving a file } //Send file to middleman from SD else if (mode == 2) { printf("Waiting for num char:\n"); // The second byte is the number of characters in the file name while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0) ; alt_up_rs232_read_data(uart, &data, &parity); numFileName = (int) data; //numFileName -= 48; //Now receive the file name printf("About to receive %d characters:\n\n", numFileName); printf("Filename received:"); for (i = 0; i < numFileName; i++) { while (alt_up_rs232_get_used_space_in_read_FIFO(uart) == 0) ; alt_up_rs232_read_data(uart, &data, &parity); fileName[i] = data; printf("%c", data); } printf("\n"); fileName[i] = '.'; fileName[i+1] = 't'; fileName[i+2] = 'x'; fileName[i+3] = 't'; fileName[i+4]= '\0'; handle = alt_up_sd_card_fopen(fileName, 0); if (handle == -1) { //SEND ANDROID AN ASCII 2 TO LET THEM KNOW TO RECEIVE FILE NAME alt_up_rs232_write_data(uart, 50); printf("neg handle"); if(alt_up_sd_card_find_first(".",listName) ==-1){ //SEND ANDROID AN ASCII 2 TO LET THEM KNOW THERES NO FILE NAMES alt_up_rs232_write_data(uart, 50); printf("no files"); } else{ //SEND ANDROID LIST OF FILE NAMES printf("some files"); i=0; for(i = 0; listName[i] != '.'; i++){ alt_up_rs232_write_data(uart, listName[i]); } alt_up_rs232_write_data(uart, 32); while(alt_up_sd_card_find_next(listName)!=-1){ i=0; for(i = 0; listName[i] != '.'; i++){ alt_up_rs232_write_data(uart, listName[i]); } alt_up_rs232_write_data(uart, 32); } alt_up_rs232_write_data(uart, 1); printf("done files"); } } else { //SEND ANDROID AN ASCII 1 TO LET THEM KNOW TO RECEIVE A FILE alt_up_rs232_write_data(uart, 49); // SHIFT BYTES LEFT AND CONCATENATE TO ACCOUNT FOR SEVERAL BYTES WORTH OF FILE // WRITE FIRST 4 BYTES OF FILE AS SIZE OF FILE IN BYTES data = alt_up_sd_card_read(handle); alt_up_rs232_write_data(uart, data); numFile = (int) data; numFile = numFile << 8; data = (int) alt_up_sd_card_read(handle); alt_up_rs232_write_data(uart, data); numFile += (int) data; numFile = numFile << 8; data = (int) alt_up_sd_card_read(handle); alt_up_rs232_write_data(uart, data); numFile += (int) data; numFile = numFile << 8; data = (int) alt_up_sd_card_read(handle); alt_up_rs232_write_data(uart, data); numFile += (int) data; printf("About to send %d file bytes\n", numFile); while (numFile > 0) { while(alt_up_rs232_get_available_space_in_write_FIFO(uart) == 0); data = alt_up_sd_card_read(handle); alt_up_rs232_write_data(uart, data); numFile--; } // WRITE A "FILE DONE" STRING OR WHATEVER WE DECIDE printf("sending end bits\n"); // alt_up_rs232_write_data(uart, 1); // // // alt_up_sd_card_fclose(handle); } //This bracket ends sending a file } //Something broke else { printf("Wrong mode, something broke, starting over\n"); } } } else { printf("Card Reader is not working\n"); } } return 0; //end main }
int main(void) { device_reference = alt_up_sd_card_open_dev("/dev/SD_Card"); if (device_reference != NULL) { while(1) { if ((connected == 0) && (alt_up_sd_card_is_Present())) { printf("Card connected.\n"); if (alt_up_sd_card_is_FAT16()) { printf("FAT16 file system detected.\n"); //Print out the list in the sd card handler = alt_up_sd_card_find_first("", buffer_name); printf("%s \n", buffer_name); //Read a file in SD card -needs to speed up(10 sec?) - needs array of int sd_fileh = alt_up_sd_card_fopen("TEST.WAV", false); if (sd_fileh < 0) printf("Problem reading file. Error %i\n", sd_fileh); else { printf("Reading file...\n"); audio_dev = alt_up_audio_open_dev (AUDIO_NAME); if ( audio_dev == NULL){ return; } av_config = alt_up_av_config_open_dev(AUDIO_AND_VIDEO_CONFIG_NAME); while(!alt_up_av_config_read_ready(av_config)); alt_up_audio_disable_read_interrupt(audio_dev); alt_up_audio_enable_write_interrupt(audio_dev); /* // Get information of number of channels //count = 0; char a, b; int d; short c; int index = 0; while (buffer_name[index] != "\0"){ a = alt_up_sd_card_read(sd_fileh); b = alt_up_sd_card_read(sd_fileh); c = ((unsigned char) a <<8) | (unsigned char) b; d = c; d = alt_up_audio_write_fifo(device_reference,d,) index++; } */ /* // printf("NumChannels "); byte1 = 0;byte2 = 0;total = 0; byte1 = alt_up_sd_card_read(sd_fileh); byte2 = alt_up_sd_card_read(sd_fileh); total = (byte1 & 0x00ff) | (byte2 << 8); NumChannels = total; // printf("%d\n",total); // printf("SampleRate "); byte1 = 0;byte2 = 0;byte3 = 0;byte4 = 0;long_total = 0; byte1 = alt_up_sd_card_read(sd_fileh); byte2 = alt_up_sd_card_read(sd_fileh); byte3 = alt_up_sd_card_read(sd_fileh); byte4 = alt_up_sd_card_read(sd_fileh); long_total = (byte4 << 24) | (byte3 << 16) | (byte2 << 8) | ( byte1 & 0x000000ff); sampleRate = long_total; // printf("%ld\n",long_total); */ /* count = 0; while (count < 16) // 44-byte header { alt_up_sd_card_read(sd_fileh); count++; } */ } //find next file while ((handler = alt_up_sd_card_find_next(buffer_name)) != -1) printf("%s \n", buffer_name); }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; } } } return 0; }
/** * Initializes the SD Card Driver */ void sdcard_Init(void) { alt_up_sd_card_dev *device_reference = NULL; device_reference = alt_up_sd_card_open_dev("/dev/Altera_UP_SD_Card_Avalon_Interface_0"); }