3
3
#define BUFFERSIZE (COUNTOF(wtext) -1 )
4
4
uint32_t file_size = 0 , seek_val = FALSE , peek_val = FALSE ;
5
5
uint32_t byteswritten, bytesread = 0 ;
6
- uint8_t wtext[] = " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
7
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
8
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
9
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
10
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
11
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
12
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
13
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
14
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
15
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
16
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
17
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n "
18
- " This is STM32 working with FatFs. It is to test Arduino based on STM32 HAL. \n " ; /* File write buffer */
6
+ /* File write buffer */
7
+ uint8_t wtext[] = " This is the OTTO SD Test working with FatFs. \n " ;
19
8
20
9
uint8_t rtext[BUFFERSIZE];
21
10
uint32_t i = 0 ;
@@ -29,16 +18,23 @@ void setup()
29
18
{
30
19
delay (10 );
31
20
}
21
+ Serial.begin (9600 );
22
+ while (!Serial);
32
23
33
24
/* Test mkdir() method */
25
+ Serial.println (" Creating 'STM32F4' directory" );
34
26
SD.mkdir (" STM32F4" );
27
+ Serial.println (" Creating 'ARDUINO' directory" );
35
28
SD.mkdir (" ARDUINO" );
29
+ Serial.println (" Creating 'ARDUINO/OTTO' directory" );
36
30
SD.mkdir (" ARDUINO/OTTO" );
37
31
/* Test open() method */
32
+ Serial.println (" opening 'STM32F4/Toremove.txt' file" );
38
33
SD.open (" STM32F4/Toremove.txt" , FILE_WRITE);
39
34
MyFile = SD.open (" ARDUINO/OTTO/ARDUINO_OTTO_TEXT.txt" , FILE_WRITE);
40
35
41
36
/* Test print() method */
37
+ Serial.println (" writing \" This is the OTTO SD Test working with FatFs.\" into Toremove.txt file" );
42
38
byteswritten = MyFile.print ((const char *)wtext);
43
39
MyFile.close ();
44
40
@@ -47,13 +43,18 @@ void setup()
47
43
for (i = 0 ; i<10 ; i++)
48
44
{
49
45
peek_val = MyFile.peek ();
46
+ Serial.print (" TEXT.txt peek: " );
47
+ Serial.println (peek_val);
50
48
}
51
49
52
50
/* Test size() method */
53
51
file_size = MyFile.size ();
54
-
52
+ Serial.print (" TEXT.txt size: " );
53
+ Serial.println (file_size);
55
54
/* Test seek method */
56
55
seek_val = MyFile.seek (100 );
56
+ Serial.print (" TEXT.txt seek value: " );
57
+ Serial.println (seek_val);
57
58
58
59
for (i = 0 ; i<10 ; i++)
59
60
{
@@ -62,9 +63,11 @@ void setup()
62
63
i = 0 ;
63
64
64
65
/* Test available() and read() methods */
66
+ Serial.print (" TEXT.txt content: " );
65
67
while (MyFile.available ())
66
68
{
67
69
rtext[i] = (uint8)MyFile.read ();
70
+ Serial.println (rtext[i]);
68
71
i++;
69
72
}
70
73
@@ -107,7 +110,7 @@ void setup()
107
110
MyFile = SD.open (" ARDUINO/OTTO/WRITE.txt" );
108
111
file_size = MyFile.size ();
109
112
bytesread = MyFile.read (rtext, file_size);
110
- MyFile.close ();
113
+ MyFile.close ();
111
114
}
112
115
113
116
void loop ()
0 commit comments