Skip to content

Commit 30424b2

Browse files
committed
Code indentation only
1 parent d6168f3 commit 30424b2

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

libraries/tests/mbed/dir_sd/main.cpp

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,56 @@
11
#include "mbed.h"
22
#include "SDFileSystem.h"
33

4-
void led_blink(PinName led) {
4+
void led_blink(PinName led)
5+
{
56
DigitalOut myled(led);
7+
68
while (1) {
79
myled = !myled;
810
wait(1.0);
911
}
1012
}
1113

12-
void notify_completion(bool success) {
13-
if (success) {
14+
void notify_completion(bool success)
15+
{
16+
if (success)
1417
printf("{success}\n");
15-
} else {
18+
else
1619
printf("{failure}\n");
17-
}
18-
20+
1921
printf("{end}\n");
2022
led_blink(success ? LED1 : LED4);
2123
}
2224

2325
#define TEST_STRING "Hello World!"
2426

25-
FILE* test_open(char* path, const char* mode) {
27+
FILE *test_open(char *path, const char *mode)
28+
{
2629
FILE *f;
30+
2731
f = fopen(path, mode);
2832
if (f == NULL) {
2933
printf("Error opening file\n");
3034
notify_completion(false);
3135
}
32-
36+
3337
return f;
3438
}
3539

36-
void test_write(FILE* f, const char* str) {
40+
void test_write(FILE *f, const char *str)
41+
{
3742
int n = fprintf(f, str);
43+
3844
if (n != strlen(str)) {
3945
printf("Error writing file\n");
4046
notify_completion(false);
4147
}
4248
}
4349

44-
void test_close(FILE* f) {
50+
void test_close(FILE *f)
51+
{
4552
int rc = fclose(f);
53+
4654
if (rc != 0) {
4755
printf("Error closing file\n");
4856
notify_completion(false);
@@ -51,52 +59,52 @@ void test_close(FILE* f) {
5159

5260
DigitalOut led2(LED2);
5361

54-
int main() {
62+
int main()
63+
{
5564
#if defined(TARGET_KL25Z)
5665
SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
5766
#elif defined(TARGET_nRF51822)
5867
//SDFileSystem sd(p20, p22, p25, p24, "sd");
59-
SDFileSystem sd(p12, p13, p15, p14, "sd");
68+
SDFileSystem sd(p12, p13, p15, p14, "sd");
6069
#elif defined(TARGET_NUCLEO_F103RB) || \
6170
defined(TARGET_NUCLEO_L152RE) || \
6271
defined(TARGET_NUCLEO_F302R8) || \
6372
defined(TARGET_NUCLEO_F030R8) || \
6473
defined(TARGET_NUCLEO_F401RE) || \
6574
defined(TARGET_NUCLEO_L053R8)
66-
SDFileSystem sd(D11, D12, D13, D10, "sd");
75+
SDFileSystem sd(D11, D12, D13, D10, "sd");
6776
#else
6877
SDFileSystem sd(p11, p12, p13, p14, "sd");
6978
#endif
70-
led2=1;
71-
wait(0.5);
79+
led2 = 1;
80+
wait(0.5);
7281
FILE *f;
73-
char* str = TEST_STRING;
74-
char* buffer = (char*) malloc(sizeof(unsigned char)*strlen(TEST_STRING));
82+
char *str = TEST_STRING;
83+
char *buffer = (char *)malloc(sizeof(unsigned char) * strlen(TEST_STRING));
7584
int str_len = strlen(TEST_STRING);
76-
85+
7786
printf("Write files\n");
7887
char filename[32];
79-
for (int i=0; i<10; i++) {
88+
for (int i = 0; i < 10; i++) {
8089
sprintf(filename, "/sd/test_%d.txt", i);
8190
printf("Creating file: %s\n", filename);
8291
f = test_open(filename, "w");
83-
led2=0;
92+
led2 = 0;
8493
test_write(f, str);
8594
test_close(f);
8695
}
87-
96+
8897
printf("List files:\n");
8998
DIR *d = opendir("/sd");
9099
if (d == NULL) {
91100
printf("Error opening directory\n");
92101
notify_completion(false);
93102
}
94-
103+
95104
struct dirent *p;
96-
while((p = readdir(d)) != NULL) {
105+
while ((p = readdir(d)) != NULL)
97106
printf("%s\n", p->d_name);
98-
}
99107
closedir(d);
100-
108+
101109
notify_completion(true);
102110
}

0 commit comments

Comments
 (0)