e3d473bf42
* get rid of BSP layer * sector_cache: init in any case * new sd-spi driver: init * Delete stm32_adafruit_sd.c.old * Delete spi_sd_hal.c.old * Storage: faster api lock primitive * Threads: priority control * Flags: correct error code * Spi: dma mode * SD-card: use DMA for big blocks of SPI data * Fix wrong SD_TOKEN_START_DATA_MULTIPLE_BLOCK_WRITE value * do not memset cache if it is NULL * remove top-level timeouts * sd hal: disable debug * Furi HAL: DMA * Furi HAL RFID: use furi_hal_dma * Furi HAL DMA: tests * Furi HAL DMA: docs * rollback "Furi HAL RFID: use furi_hal_dma" * 4 channels taken from DMA manager for core HAL. * Furi HAL DMA: live fast, die young * RPC tests: increase message buffer * SPI HAL: use second DMA instance * sd hal: new CID getter * SPI hal: use non-DMA version if kernel is not running * IR hal: generalize DMA definition * storage: add CID data to sd info * RFID hal: generalize DMA definition * SUBGHZ hal: generalize DMA definition. Core hal moved to DMA2. * Storage: small optimizations, removal of extra mutex * Storage: redundant macro * SD hal: more timeouts * SPI hal: DMA init * Target: make furi_hal_spi_dma_init symbol private * Update F18 api symbols Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
79 lines
2.3 KiB
C
79 lines
2.3 KiB
C
#pragma once
|
|
|
|
#include <furi.h>
|
|
#include "filesystem_api_internal.h"
|
|
#include <m-list.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum { ST_EXT = 0, ST_INT = 1, ST_ANY, ST_ERROR } StorageType;
|
|
|
|
typedef struct StorageData StorageData;
|
|
|
|
typedef struct {
|
|
void (*tick)(StorageData* storage);
|
|
} StorageApi;
|
|
|
|
typedef struct {
|
|
File* file;
|
|
StorageType type;
|
|
void* file_data;
|
|
FuriString* path;
|
|
} StorageFile;
|
|
|
|
typedef enum {
|
|
StorageStatusOK, /**< storage ok */
|
|
StorageStatusNotReady, /**< storage not ready (not initialized or waiting for data storage to appear) */
|
|
StorageStatusNotMounted, /**< datastore appeared, but we cannot mount it */
|
|
StorageStatusNoFS, /**< datastore appeared and mounted, but does not have a file system */
|
|
StorageStatusNotAccessible, /**< datastore appeared and mounted, but not available */
|
|
StorageStatusErrorInternal, /**< any other internal error */
|
|
} StorageStatus;
|
|
|
|
void storage_file_init(StorageFile* obj);
|
|
void storage_file_init_set(StorageFile* obj, const StorageFile* src);
|
|
void storage_file_set(StorageFile* obj, const StorageFile* src);
|
|
void storage_file_clear(StorageFile* obj);
|
|
|
|
void storage_data_init(StorageData* storage);
|
|
StorageStatus storage_data_status(StorageData* storage);
|
|
const char* storage_data_status_text(StorageData* storage);
|
|
void storage_data_timestamp(StorageData* storage);
|
|
uint32_t storage_data_get_timestamp(StorageData* storage);
|
|
|
|
LIST_DEF(
|
|
StorageFileList,
|
|
StorageFile,
|
|
(INIT(API_2(storage_file_init)),
|
|
SET(API_6(storage_file_init_set)),
|
|
INIT_SET(API_6(storage_file_set)),
|
|
CLEAR(API_2(storage_file_clear))))
|
|
|
|
struct StorageData {
|
|
const FS_Api* fs_api;
|
|
StorageApi api;
|
|
void* data;
|
|
StorageStatus status;
|
|
StorageFileList_t files;
|
|
uint32_t timestamp;
|
|
};
|
|
|
|
bool storage_has_file(const File* file, StorageData* storage_data);
|
|
bool storage_path_already_open(FuriString* path, StorageFileList_t files);
|
|
|
|
void storage_set_storage_file_data(const File* file, void* file_data, StorageData* storage);
|
|
void* storage_get_storage_file_data(const File* file, StorageData* storage);
|
|
|
|
void storage_push_storage_file(
|
|
File* file,
|
|
FuriString* path,
|
|
StorageType type,
|
|
StorageData* storage);
|
|
bool storage_pop_storage_file(File* file, StorageData* storage);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|