- Added Comments
This commit is contained in:
Nima Askari (نیما عسکری) 2024-04-01 23:18:53 +02:00 committed by GitHub
parent 8b59a6900c
commit 365ebe8fda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

62
ee.c
View File

@ -108,9 +108,9 @@
#ifndef EE_SIZE #ifndef EE_SIZE
#if (EE_ERASE == EE_ERASE_PAGE_NUMBER) || (EE_ERASE == EE_ERASE_PAGE_ADDRESS) #if (EE_ERASE == EE_ERASE_PAGE_NUMBER) || (EE_ERASE == EE_ERASE_PAGE_ADDRESS)
#define EE_SIZE FLASH_PAGE_SIZE #define EE_SIZE FLASH_PAGE_SIZE
#elif (EE_ERASE == EE_ERASE_SECTOR_NUMBER) #elif (EE_ERASE == EE_ERASE_SECTOR_NUMBER)
#define EE_SIZE FLASH_SECTOR_SIZE #define EE_SIZE FLASH_SECTOR_SIZE
#endif #endif
#endif #endif
@ -156,13 +156,13 @@ EE_HandleTypeDef eeHandle;
************************************************************************************************************/ ************************************************************************************************************/
/** /**
* @brief Initialize the EEPROM. * @brief Initializes the EEPROM emulation module.
* @note Assign a struct/array for storing your data * @note This function initializes the EEPROM emulation module to enable read and write operations.
* * @param StoragePointer: Pointer to the start address of the EEPROM emulation area.
* @param StoragePointer: Pointer to Storing data * @param Size: Size of the EEPROM emulation area in bytes.
* @param Size: Size of Storage, It should be equal or lower than latest sector/page of selected MCU * @return Boolean value indicating the success of the initialization:
* * - true: Initialization successful.
* @retval bool: true or false * - false: Initialization failed.
*/ */
bool EE_Init(void *StoragePointer, uint32_t Size) bool EE_Init(void *StoragePointer, uint32_t Size)
{ {
@ -185,10 +185,9 @@ bool EE_Init(void *StoragePointer, uint32_t Size)
/***********************************************************************************************************/ /***********************************************************************************************************/
/** /**
* @brief Get Capacity of EEPROM * @brief Retrieves the capacity of the EEPROM emulation area.
* @note It shall return the latest sector/page size * @note This function returns the total capacity of the EEPROM emulation area in bytes.
* * @return Capacity of the EEPROM emulation area in bytes.
* @retval uint32_t: Returned size in bytes
*/ */
uint32_t EE_Capacity(void) uint32_t EE_Capacity(void)
{ {
@ -198,12 +197,15 @@ uint32_t EE_Capacity(void)
/***********************************************************************************************************/ /***********************************************************************************************************/
/** /**
* @brief Get Capacity of EEPROM * @brief Formats the EEPROM emulation area.
* @note It shall return the latest sector/page size * @note This function formats the EEPROM emulation area,
* * optionally erasing its content.
* @param EraseBuffer: Erase data buffer of Storage or not * @param EraseBuffer Indicates whether to erase the content of the EEPROM emulation area:
* * - true: Erase the content of the EEPROM emulation area(In RAM).
* @retval bool: true or false * - false: Do not erase the content (only format Flash).
* @return bool Boolean value indicating the success of the operation:
* - true: Formatting successful.
* - false: Formatting failed.
*/ */
bool EE_Format(bool EraseBuffer) bool EE_Format(bool EraseBuffer)
{ {
@ -257,12 +259,9 @@ bool EE_Format(bool EraseBuffer)
/***********************************************************************************************************/ /***********************************************************************************************************/
/** /**
* @brief Read all data * @brief Reads data from the EEPROM emulation area.
* @note Read from flash memory and fill up the buffer * @note This function reads data from the EEPROM emulation area
* * and loads it into the specified storage pointer.
* @param none
*
* @retval none
*/ */
void EE_Read(void) void EE_Read(void)
{ {
@ -277,12 +276,13 @@ void EE_Read(void)
/***********************************************************************************************************/ /***********************************************************************************************************/
/** /**
* @brief Write Buffer to flash memory * @brief Writes data to the EEPROM emulation area.
* @note * @note This function writes data to the EEPROM emulation area.
* * Optionally, the area can be formatted first before writing.
* @param FormatFirst: Format the flash before writing * @param FormatFirst: Indicates whether to format the EEPROM emulation area before writing:
* * - true: Format the Flash area before writing.
* @retval bool: true or false * - false: Do not format the Flash area before writing.
* @retval true if the write operation is successful, false otherwise.
*/ */
bool EE_Write(bool FormatFirst) bool EE_Write(bool FormatFirst)
{ {