mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 09:16:07 +03:00
Basic SDCard block read / write (minimal timeout/error handling)
This commit is contained in:
parent
3941c6c252
commit
84d3cc6175
11 changed files with 927 additions and 7 deletions
|
@ -221,3 +221,48 @@ uint16_t SD_GetStatus(void);
|
|||
|
||||
uint8_t SD_WriteByte(uint8_t byte);
|
||||
uint8_t SD_ReadByte(void);
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct sdcard_metadata_t {
|
||||
uint8_t manufacturerID;
|
||||
uint16_t oemID;
|
||||
|
||||
char productName[5];
|
||||
|
||||
uint8_t productRevisionMajor;
|
||||
uint8_t productRevisionMinor;
|
||||
uint32_t productSerial;
|
||||
|
||||
uint16_t productionYear;
|
||||
uint8_t productionMonth;
|
||||
|
||||
uint32_t numBlocks; /* Card capacity in 512-byte blocks*/
|
||||
} sdcardMetadata_t;
|
||||
|
||||
typedef enum {
|
||||
SDCARD_NO_OPERATION,
|
||||
SDCARD_OPERATION_IN_PROGRESS,
|
||||
SDCARD_OPERATION_SUCCESS,
|
||||
SDCARD_OPERATION_ERROR,
|
||||
} sdcardOperationStatus_e;
|
||||
|
||||
typedef enum {
|
||||
SDCARD_BLOCK_OPERATION_READ,
|
||||
SDCARD_BLOCK_OPERATION_WRITE,
|
||||
SDCARD_BLOCK_OPERATION_ERASE,
|
||||
} sdcardBlockOperation_e;
|
||||
|
||||
typedef void(*sdcard_operationCompleteCallback_c)(sdcardBlockOperation_e operation, uint32_t blockIndex, uint8_t *buffer, uint32_t callbackData);
|
||||
|
||||
bool sdcard_init();
|
||||
|
||||
bool sdcard_writeBlock(uint32_t blockIndex, uint8_t *buffer);
|
||||
bool sdcard_readBlock(uint32_t blockIndex, uint8_t *buffer, sdcard_operationCompleteCallback_c callback, uint32_t callbackData);
|
||||
|
||||
void sdcard_poll();
|
||||
bool sdcard_isReady();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue