Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/storage/sd.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2023 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef SD_H
19
#define SD_H
20
21
#include <storage/sdmmc.h>
22
#include <storage/sdmmc_driver.h>
23
#include <libs/fatfs/ff.h>
24
25
#define SD_BLOCKSIZE SDMMC_DAT_BLOCKSIZE
26
27
enum
28
{
29
SD_INIT_FAIL = 0,
30
SD_1BIT_HS25 = 1,
31
SD_4BIT_HS25 = 2,
32
SD_UHS_SDR82 = 3,
33
SD_UHS_SDR104 = 4,
34
#ifdef BDK_SDMMC_UHS_DDR200_SUPPORT
35
SD_UHS_DDR208 = 5
36
#endif
37
38
};
39
40
enum
41
{
42
SD_ERROR_INIT_FAIL = 0,
43
SD_ERROR_RW_FAIL = 1,
44
SD_ERROR_RW_RETRY = 2
45
};
46
47
extern sdmmc_t sd_sdmmc;
48
extern sdmmc_storage_t sd_storage;
49
extern FATFS sd_fs;
50
51
void sd_error_count_increment(u8 type);
52
u16 *sd_get_error_count();
53
bool sd_get_card_removed();
54
bool sd_get_card_initialized();
55
bool sd_get_card_mounted();
56
u32 sd_get_mode();
57
int sd_init_retry(bool power_cycle);
58
bool sd_initialize(bool power_cycle);
59
bool sd_mount();
60
void sd_unmount();
61
void sd_end();
62
bool sd_is_gpt();
63
void *sd_file_read(const char *path, u32 *fsize);
64
int sd_save_to_file(const void *buf, u32 size, const char *filename);
65
66
#endif
67