Forum Discussion
Altera_Forum
Honored Contributor
13 years agoHello! I write successfully in the SD Card!
But the alt_up_sd_card_write function available, writes a char based on the ASCII table (inputting a hexadecimal). Now I am thing a way to convert a double value to enter in this write function. But this is a C problem! But I will post here when I find the solution. This is a simple program that demonstrates the write function ****************************************** # include <stdio.h> # include <altera_up_sd_card_avalon_interface.h> # include <altera_avalon_pio_regs.h> int main(void){ alt_up_sd_card_dev *device_reference = NULL; int connected = 0; short int handler; short int att; char data = 0x00; int loop; printf("Insert the SD Card \n"); device_reference = alt_up_sd_card_open_dev("/dev/Altera_UP_SD_Card"); if (device_reference != NULL) { while(1){ if((connected ==0) && (alt_up_sd_card_is_Present())){ printf("SD Card Connected. \n"); IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE, 0xFFFF); if(alt_up_sd_card_is_FAT16()){ printf("FAT16 file system detected!!! \n"); /* Start to create a file */ handler = alt_up_sd_card_fopen ("file.txt", true); for(loop = 0; loop < 1000; loop++){ data++; alt_up_sd_card_write(handler, 0x33); alt_up_sd_card_write(handler, 0x20);/*0x20 = space , 0x0D = enter*/ } att = alt_up_sd_card_get_attributes(handler); printf ("get_attrubutes return: %d\n", att); alt_up_sd_card_fclose(handler); /* End */ } else{ printf("Unknown file system. \n"); } connected = 1; } else if ((connected == 1) && (alt_up_sd_card_is_Present() == false)){ printf("SD disconected. \n"); IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE, 0); connected = 0; } } } return 0; } ****************************************** This program only writes "3 3 3 3 3 3 3 3 3..." in the SD Card. I tried to write "0x0D" that means ENTER button to write a matrix, but this failed, but that is ok for me writing the number separated by spaces (or comas). Thank everyone! PS: Yes I am from Brazil! Oi! Tudo bem :)