cleanup
This commit is contained in:
87
1 software design/components/drivers/nvm/com/nvm.cpp
Normal file
87
1 software design/components/drivers/nvm/com/nvm.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file nvm.cpp
|
||||
* @brief NVM driver component implementation
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#include "nvm.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
static const char* TAG = "NvmDriver";
|
||||
|
||||
NvmDriver::NvmDriver()
|
||||
: m_isInitialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
NvmDriver::~NvmDriver()
|
||||
{
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool NvmDriver::initialize()
|
||||
{
|
||||
// TODO: Implement NVM initialization
|
||||
m_isInitialized = true;
|
||||
ASF_LOGI(TAG, 3200, asf::logger::Criticality::LOW, "NVM driver initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NvmDriver::deinitialize()
|
||||
{
|
||||
if (!m_isInitialized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Implement NVM deinitialization
|
||||
m_isInitialized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
NvmResult NvmDriver::read(const char* key, void* value, size_t* length)
|
||||
{
|
||||
if (!m_isInitialized || key == nullptr || value == nullptr || length == nullptr)
|
||||
{
|
||||
return NvmResult::ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
// TODO: Implement NVM read
|
||||
(void)key;
|
||||
(void)value;
|
||||
(void)length;
|
||||
return NvmResult::OK;
|
||||
}
|
||||
|
||||
NvmResult NvmDriver::write(const char* key, const void* value, size_t length)
|
||||
{
|
||||
if (!m_isInitialized || key == nullptr || value == nullptr)
|
||||
{
|
||||
return NvmResult::ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
// TODO: Implement NVM write
|
||||
(void)key;
|
||||
(void)value;
|
||||
(void)length;
|
||||
return NvmResult::OK;
|
||||
}
|
||||
|
||||
NvmResult NvmDriver::erase(const char* key)
|
||||
{
|
||||
if (!m_isInitialized || key == nullptr)
|
||||
{
|
||||
return NvmResult::ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
// TODO: Implement NVM erase
|
||||
(void)key;
|
||||
return NvmResult::OK;
|
||||
}
|
||||
|
||||
bool NvmDriver::isInitialized() const
|
||||
{
|
||||
return m_isInitialized;
|
||||
}
|
||||
49
1 software design/components/drivers/nvm/com/nvm.hpp
Normal file
49
1 software design/components/drivers/nvm/com/nvm.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file nvm.hpp
|
||||
* @brief NVM driver component header - Non-volatile memory management
|
||||
* @author Mahmoud Elmohtady
|
||||
* @company Nabd solutions - ASF
|
||||
* @copyright Copyright (c) 2025
|
||||
*/
|
||||
|
||||
#ifndef NVM_HPP
|
||||
#define NVM_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
/**
|
||||
* @brief NVM result enumeration
|
||||
*/
|
||||
enum class NvmResult
|
||||
{
|
||||
OK,
|
||||
ERROR_INVALID_PARAM,
|
||||
ERROR_NOT_FOUND,
|
||||
ERROR_FAIL
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief NVM driver class
|
||||
*
|
||||
* Provides non-volatile memory management functionality.
|
||||
*/
|
||||
class NvmDriver
|
||||
{
|
||||
public:
|
||||
NvmDriver();
|
||||
~NvmDriver();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
NvmResult read(const char* key, void* value, size_t* length);
|
||||
NvmResult write(const char* key, const void* value, size_t length);
|
||||
NvmResult erase(const char* key);
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
bool m_isInitialized;
|
||||
};
|
||||
|
||||
#endif // NVM_HPP
|
||||
|
||||
Reference in New Issue
Block a user