2022-03-03 23:50:19 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-09-03 23:29:07 +02:00
|
|
|
typedef enum SDUtilsStatus {
|
2022-03-03 23:50:19 +01:00
|
|
|
SDUTILS_RESULT_SUCCESS = 0,
|
2022-09-03 23:29:07 +02:00
|
|
|
SDUTILS_RESULT_MODULE_NOT_FOUND = -0x1,
|
|
|
|
SDUTILS_RESULT_MODULE_MISSING_EXPORT = -0x2,
|
|
|
|
SDUTILS_RESULT_MAX_CALLBACKS = -0x3,
|
|
|
|
SDUTILS_RESULT_NOT_FOUND = -0x4,
|
|
|
|
SDUTILS_RESULT_INVALID_ARGUMENT = -0x5,
|
|
|
|
SDUTILS_RESULT_FAILED = -0x10,
|
|
|
|
SDUTILS_RESULT_LIB_UNINITIALIZED = -0x20,
|
|
|
|
SDUTILS_RESULT_UNSUPPORTED_VERSION = -0x99,
|
|
|
|
SDUTILS_RESULT_UNKNOWN_ERROR = -0x1000,
|
|
|
|
} SDUtilsStatus;
|
2022-03-03 23:50:19 +01:00
|
|
|
|
2022-04-28 19:47:16 +02:00
|
|
|
typedef uint32_t SDUtilsVersion;
|
2022-09-03 21:51:38 +02:00
|
|
|
#define SD_UTILS_MODULE_VERSION_ERROR 0xFFFFFFFF
|
2022-04-28 19:47:16 +02:00
|
|
|
|
2022-09-03 23:29:07 +02:00
|
|
|
typedef enum SDUtilsAttachStatus {
|
2022-03-03 23:50:19 +01:00
|
|
|
SDUTILS_ATTACH_MOUNTED = 1,
|
|
|
|
SDUTILS_ATTACH_UNMOUNTED = 0,
|
2022-09-03 23:29:07 +02:00
|
|
|
} SDUtilsAttachStatus;
|
2022-03-03 23:50:19 +01:00
|
|
|
|
|
|
|
typedef void (*SDAttachHandlerFn)(SDUtilsAttachStatus status);
|
|
|
|
|
2022-04-28 19:47:43 +02:00
|
|
|
typedef void (*SDCleanUpHandlesHandlerFn)();
|
|
|
|
|
2022-03-03 23:50:19 +01:00
|
|
|
/**
|
|
|
|
* Initializes the SDUtils library. This must be call before any other function can be called
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success, the functions of this lib can be used
|
|
|
|
* SDUTILS_RESULT_MODULE_NOT_FOUND when the SDHotSwapModule is not loaded
|
|
|
|
* SDUTILS_RESULT_MODULE_MISSING_EXPORT when the SDHotSwapModule does not export the expected functions.
|
|
|
|
*/
|
2022-09-03 19:08:41 +02:00
|
|
|
SDUtilsStatus SDUtils_InitLibrary();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deinitializes the SDUtils library, must be called before exiting the application
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success
|
|
|
|
*/
|
|
|
|
SDUtilsStatus SDUtils_DeInitLibrary();
|
2022-03-03 23:50:19 +01:00
|
|
|
|
2022-04-28 19:47:16 +02:00
|
|
|
/**
|
2022-09-03 21:51:38 +02:00
|
|
|
* Retrieves the API Version of the loaded SDUtils.<br>
|
|
|
|
* <br>
|
|
|
|
* @param outVersion pointer to the variable where the version will be stored.
|
|
|
|
*
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS: The API version has been store in the version ptr.<br>
|
|
|
|
* SDUTILS_RESULT_MODULE_NOT_FOUND: The module could not be found. Make sure the module is loaded.<br>
|
|
|
|
* SDUTILS_RESULT_MODULE_MISSING_EXPORT: The module is missing an expected export.<br>
|
|
|
|
* SDUTILS_RESULT_INVALID_ARGUMENT: Invalid version pointer.<br>
|
|
|
|
* SDUTILS_RESULT_UNKNOWN_ERROR: Retrieving the module version failed.
|
2022-04-28 19:47:16 +02:00
|
|
|
*/
|
2022-09-03 21:51:38 +02:00
|
|
|
SDUtilsStatus SDUtils_GetVersion(SDUtilsVersion *outVersion);
|
2022-03-03 23:50:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a callback which will be called whenever a sd card will be inserted or ejected.
|
|
|
|
* This is only true for future events, if the sd card is already inserted before registering
|
|
|
|
* a callback, the callback is only called on the next ejecting but not for the initial
|
|
|
|
* insertion that happened in the past.
|
|
|
|
*
|
|
|
|
* Any previously registered callbacks will be removed when the currently running application
|
|
|
|
* is closing.
|
|
|
|
*
|
|
|
|
* @param fn callback that will be called
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success
|
|
|
|
* SDUTILS_RESULT_MAX_CALLBACKS when registering the callback has failed because the
|
|
|
|
* maximum amount of callback has been reached
|
2022-04-28 19:47:43 +02:00
|
|
|
* SDUTILS_RESULT_LIB_UNINITIALIZED if the lib was not initialized properly
|
2022-03-03 23:50:19 +01:00
|
|
|
*/
|
|
|
|
SDUtilsStatus SDUtils_AddAttachHandler(SDAttachHandlerFn fn);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removed a previously registered callback
|
|
|
|
*
|
|
|
|
* @param fn
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success
|
|
|
|
* SDUTILS_RESULT_NOT_FOUND when the given callback was not registered.
|
2022-04-28 19:47:43 +02:00
|
|
|
* SDUTILS_RESULT_LIB_UNINITIALIZED if the lib was not initialized properly
|
2022-03-03 23:50:19 +01:00
|
|
|
*/
|
|
|
|
SDUtilsStatus SDUtils_RemoveAttachHandler(SDAttachHandlerFn fn);
|
|
|
|
|
2022-04-28 19:47:43 +02:00
|
|
|
/**
|
|
|
|
* Registers a callback which will be called whenever a sd card will be ejected and before
|
|
|
|
* the SDUtils_AddAttachHandler. This callback is supposed to be used to clean up any open
|
|
|
|
* file handles before the sd card gets unmounted.
|
|
|
|
* This is only true for future events, if the sd card is already ejected before registering
|
|
|
|
* a callback, the callback is only called on the next ejecting.
|
|
|
|
*
|
|
|
|
* Any previously registered callbacks will be removed when the currently running application
|
|
|
|
* is closing.
|
|
|
|
*
|
|
|
|
* @param fn callback that will be called
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success
|
|
|
|
* SDUTILS_RESULT_MAX_CALLBACKS when registering the callback has failed because the
|
|
|
|
* maximum amount of callback has been reached
|
|
|
|
* SDUTILS_RESULT_LIB_UNINITIALIZED if the lib was not initialized properly
|
|
|
|
*/
|
|
|
|
SDUtilsStatus SDUtils_AddCleanUpHandlesHandler(SDCleanUpHandlesHandlerFn fn);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removed a previously registered callback
|
|
|
|
*
|
|
|
|
* @param fn
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success
|
|
|
|
* SDUTILS_RESULT_NOT_FOUND when the given callback was not registered.
|
|
|
|
* SDUTILS_RESULT_LIB_UNINITIALIZED if the lib was not initialized properly
|
|
|
|
*/
|
|
|
|
SDUtilsStatus SDUtils_RemoveCleanUpHandlesHandler(SDCleanUpHandlesHandlerFn fn);
|
|
|
|
|
2022-03-03 23:50:19 +01:00
|
|
|
/**
|
|
|
|
* Checks if a FAT32 formatted SD Card is inserted, mounted and available via `fs:/vol/external01`
|
|
|
|
*
|
|
|
|
* @param outStatus stores the result of the function
|
|
|
|
* @return SDUTILS_RESULT_SUCCESS on success
|
|
|
|
* SDUTILS_RESULT_INVALID_ARGUMENT when an invalid ptr has been given
|
|
|
|
*/
|
|
|
|
SDUtilsStatus SDUtils_IsSdCardMounted(bool *outStatus);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|