-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdcard_init.cpp
46 lines (39 loc) · 952 Bytes
/
sdcard_init.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* sdcard.c
*
* Created on: Sep 8, 2021
* Author: Danylo Ulianych
*/
#include <stdio.h>
#include <string.h>
#include "sdcard.h"
#include "SD.h"
static void sdcard_print_info(fs::SDFS &fs);
void sdcard_init(fs::SDFS &fs) {
sdcard_print_info(fs);
sdcard_create_record_dir();
sdcard_log_start();
}
static void sdcard_print_info(fs::SDFS &fs) {
uint64_t total = fs.cardSize();
uint64_t used = fs.usedBytes();
uint64_t freeMb = (total - used) >> 20;
sdcard_type_t cardType = fs.cardType();
printf("Type: ");
switch (cardType) {
case CARD_MMC:
printf("MMC\n");
break;
case CARD_SD:
printf("SDSC\n");
break;
case CARD_SDHC:
printf("SDHC\n");
break;
default:
printf("UNKNOWN\n");
break;
}
printf("Size: %lluMB\n", total >> 20);
printf("Free: %lluMB\n", freeMb);
}