eive-obsw/bsp_q7s/memory/SdCardAccessManager.h

49 lines
1.2 KiB
C
Raw Normal View History

2021-07-05 12:09:31 +02:00
#ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_
#define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_
#include "definitions.h"
#include <cstdint>
class MutexIF;
/**
* @brief This class manages selecting and switching the active SD card, therefore also
* managing the redundancy of the SD cards
* @details
* This class will track the currently active users for a SD card. It is always used by the
* SD card access token automatically to get the currently active SD card in a thread safe way-
*/
class SdCardAccessManager {
friend class SdCardAccess;
public:
virtual ~SdCardAccessManager();
static void create();
/**
* Returns the single instance of the SD card manager.
*/
static SdCardAccessManager* instance();
sd::SdCard getPreferedSdCard() const;
/**
* Get current number of SD card users
* @param sdCard
* @return
*/
uint8_t getSdCardAccessors(sd::SdCard sdCard) const;
private:
SdCardAccessManager();
MutexIF* mutex;
uint8_t activeAccessesSdCard0 = 0;
uint8_t activeAccessesSdCard1 = 0;
static SdCardAccessManager* factoryInstance;
};
#endif /* BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ */