Add write test

This commit is contained in:
Mario Hüttel 2020-02-26 23:51:51 +01:00
parent a2256acd94
commit bea543269e

33
main.c
View File

@ -22,11 +22,15 @@ volatile uint32_t sdio_wait;
int initreq = 0xFF;
int main() {
char buff[1024];
//const char *write_string = "This is a write test. Okay... Writing seems to work. Let's close the file\n";
char buff[8192*6];
int main()
{
int i;
char *name;
FILINFO fno;
char *write_string = "This is a write test. Okay... Writing seems to work. Let's close the file\n";
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
__DSB();
@ -41,24 +45,17 @@ int main() {
initreq = f_mount(&SDfs, "0:/", 1);
while(initreq);
initreq = f_opendir(&root, "/");
if (initreq == FR_OK) {
if (!f_readdir(&root, &fno))
{
name = fno.fname;
initreq = f_open(&file, name, FA_READ);
if (initreq == FR_OK) {
f_gets(buff, sizeof(buff), &file);
printf("%s:\r\n%s\r\n",name, buff);
f_close(&file);
}
}
}
for (i = 0; i < 8192*6; i++)
buff[i] = 'A';
initreq = f_open(&file, "foo.txt", FA_OPEN_APPEND | FA_WRITE);
if (initreq == FR_OK) {
initreq = f_write(&file, write_string, strlen(write_string), NULL);
for (i = 0; i < 100; i++) {
initreq = f_write(&file, buff, 8192*6, NULL);
if (initreq) {
initreq++;
}
}
initreq = f_close(&file);
}