// Zacus sd_storage — microSD mount for the Freenove ESP32-S3 master.
//
// The Freenove WROOM N16R8 exposes the card on the SDMMC peripheral in
// 1-bit mode (CMD=GPIO38, CLK=GPIO39, D0=GPIO40 — mirrors the Arduino
// `ui_freenove_allinone` FREENOVE_SDMMC_* pinout). Mounts FAT at /sdcard so
// media_manager and the asset endpoints can stage large assets off the 5 MB
// LittleFS partition (P4). Mount is best-effort: a missing card is not fatal.
#pragma once

#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SD_STORAGE_MOUNT_POINT "/sdcard"

// Mount the microSD card (SDMMC 1-bit) at /sdcard. Returns ESP_OK on success;
// ESP_ERR_NOT_FOUND / ESP_FAIL when no card is present or wiring is wrong.
esp_err_t sd_storage_mount(void);

// Unmount and release the card.
esp_err_t sd_storage_unmount(void);

// True once a card is mounted.
bool sd_storage_ready(void);

// Card capacity in MiB (0 when not mounted).
uint32_t sd_storage_capacity_mb(void);

#ifdef __cplusplus
}
#endif
