NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sdcard.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight 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.
8  *
9  * Ninjaflight 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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include <stdint.h>
21 #include <stdbool.h>
22 
23 typedef struct sdcardMetadata_t {
24  uint8_t manufacturerID;
25  uint16_t oemID;
26 
27  char productName[5];
28 
31  uint32_t productSerial;
32 
33  uint16_t productionYear;
34  uint8_t productionMonth;
35 
36  uint32_t numBlocks; /* Card capacity in 512-byte blocks*/
38 
39 typedef enum {
44 
45 typedef enum {
51 
52 typedef void(*sdcard_operationCompleteCallback_c)(sdcardBlockOperation_e operation, uint32_t blockIndex, uint8_t *buffer, uint32_t callbackData);
53 
54 typedef void(*sdcard_profilerCallback_c)(sdcardBlockOperation_e operation, uint32_t blockIndex, uint32_t duration);
55 
56 void sdcard_init(bool useDMA);
57 
58 bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData);
59 
60 sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount);
61 sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData);
62 
64 void sdcardInsertionDetectInit(void);
65 
66 bool sdcard_isInserted(void);
67 bool sdcard_isInitialized(void);
68 bool sdcard_isFunctional(void);
69 
70 bool sdcard_poll(void);
72 
bool sdcard_isInitialized(void)
void(* sdcard_profilerCallback_c)(sdcardBlockOperation_e operation, uint32_t blockIndex, uint32_t duration)
Definition: sdcard.h:54
Definition: sdcard.h:40
Definition: sdcard.h:46
Definition: sdcard.h:42
Definition: sdcard.h:41
uint8_t productRevisionMinor
Definition: sdcard.h:30
Definition: sdcard.h:23
uint16_t productionYear
Definition: sdcard.h:33
sdcardOperationStatus_e
Definition: sdcard.h:45
void sdcardInsertionDetectDeinit(void)
uint32_t productSerial
Definition: sdcard.h:31
char productName[5]
Definition: sdcard.h:27
sdcardOperationStatus_e sdcard_beginWriteBlocks(uint32_t blockIndex, uint32_t blockCount)
sdcardOperationStatus_e sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
Definition: sdcard.h:48
Definition: sdcard.h:49
bool sdcard_isFunctional(void)
struct sdcardMetadata_t sdcardMetadata_t
void sdcardInsertionDetectInit(void)
sdcardBlockOperation_e
Definition: sdcard.h:39
uint32_t numBlocks
Definition: sdcard.h:36
void(* sdcard_operationCompleteCallback_c)(sdcardBlockOperation_e operation, uint32_t blockIndex, uint8_t *buffer, uint32_t callbackData)
Definition: sdcard.h:52
void sdcard_init(bool useDMA)
bool sdcard_isInserted(void)
bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData)
uint16_t oemID
Definition: sdcard.h:25
uint8_t productionMonth
Definition: sdcard.h:34
void sdcard_setProfilerCallback(sdcard_profilerCallback_c callback)
bool sdcard_poll(void)
Definition: sdcard.h:47
uint8_t productRevisionMajor
Definition: sdcard.h:29
uint8_t manufacturerID
Definition: sdcard.h:24
const sdcardMetadata_t * sdcard_getMetadata(void)