Gast
#836224
Hallo
Habe die libs von Roland Regel und kann die sd card im fat 16 lesen aber
nicht schreiben
struct partition_struct* partition = partition_open(sd_raw_read,
sd_raw_read_interval,
sd_raw_write,
sd_raw_write_interval,
0
);
if(!partition)
{
/* If the partition did not open, assume the storage device
* is a "superfloppy", i.e. has no MBR.
*/
partition = partition_open(sd_raw_read,
sd_raw_read_interval,
sd_raw_write,
sd_raw_write_interval,
-1
);
if(!partition)
{
uart_puts_p(PSTR("opening partition failed\n"));
return(0);
}
else
{
uart_puts_p(PSTR("opening partition OK\n"));
}
}
struct fat16_fs_struct* fs = fat16_open(partition);
if(!fs)
{
uart_puts_p(PSTR("opening filesystem failed\n"));
}
else
{
uart_puts_p(PSTR("opening filesystem OK\n"));
}
/* open root directory */
struct fat16_dir_entry_struct directory;
fat16_get_dir_entry_of_path(fs, "/", &directory);
struct fat16_dir_struct* dd = fat16_open_dir(fs, &directory);
if(!dd)
{
uart_puts_p(PSTR("opening root directory failed\n"));
}
else
{
uart_puts_p(PSTR("opening root directory OK\n"));
}
struct fat16_dir_entry_struct dir_entry;
while(fat16_read_dir(dd, &dir_entry))
{
uint8_t spaces = sizeof(dir_entry.long_name) -
strlen(dir_entry.long_name) + 4;
uart_puts(dir_entry.long_name);
uart_putc(dir_entry.attributes & FAT16_ATTRIB_DIR ? '/'
: ' ');
while(spaces--)
uart_putc(' ');
uart_putdw_dec(dir_entry.file_size);
uart_putc('\n');
}
struct fat16_dir_entry_struct file_entry;
if(!fat16_create_file(dd,"test.txt", &file_entry))
{
uart_puts_p(PSTR("error creating file: "));
uart_putc('\n');
}
else
{
uart_puts_p(PSTR("ok creating file: "));
uart_putc('\n');
} }
ales ergebnis kommt ok creating file.
aber auf der sd ist nichts drauf.