2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
23 typedef struct sdcardMetadata_t
{
24 uint32_t numBlocks
; /* Card capacity in 512-byte blocks*/
26 uint8_t manufacturerID
;
30 uint32_t productSerial
;
31 uint8_t productRevisionMajor
;
32 uint8_t productRevisionMinor
;
34 uint16_t productionYear
;
35 uint8_t productionMonth
;
39 SDCARD_BLOCK_OPERATION_READ
,
40 SDCARD_BLOCK_OPERATION_WRITE
,
41 SDCARD_BLOCK_OPERATION_ERASE
,
42 } sdcardBlockOperation_e
;
45 SDCARD_OPERATION_IN_PROGRESS
,
46 SDCARD_OPERATION_BUSY
,
47 SDCARD_OPERATION_SUCCESS
,
48 SDCARD_OPERATION_FAILURE
49 } sdcardOperationStatus_e
;
51 typedef void(*sdcard_operationCompleteCallback_c
)(sdcardBlockOperation_e operation
, uint32_t blockIndex
, uint8_t *buffer
, uint32_t callbackData
);
53 void sdcard_init(void);
55 bool sdcard_readBlock(uint32_t blockIndex
, uint8_t *buffer
, sdcard_operationCompleteCallback_c callback
, uint32_t callbackData
);
57 sdcardOperationStatus_e
sdcard_beginWriteBlocks(uint32_t blockIndex
, uint32_t blockCount
);
58 sdcardOperationStatus_e
sdcard_writeBlock(uint32_t blockIndex
, uint8_t *buffer
, sdcard_operationCompleteCallback_c callback
, uint32_t callbackData
);
60 void sdcardInsertionDetectDeinit(void);
61 void sdcardInsertionDetectInit(void);
63 bool sdcard_isInserted(void);
64 bool sdcard_isInitialized(void);
65 bool sdcard_isFunctional(void);
67 bool sdcard_poll(void);
68 const sdcardMetadata_t
* sdcard_getMetadata(void);