APM:Libraries
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
EEPROMClass Class Reference

#include <EEPROM.h>

Public Types

typedef void(* func_t) (uint8_t page)
 

Public Member Functions

 EEPROMClass (void)
 
uint16_t init (uint32_t, uint32_t, uint32_t)
 
uint16_t format (void)
 Erases PAGE0 and PAGE1 and writes EEPROM_VALID_PAGE / 0 header to PAGE0. More...
 
uint16_t erases (uint16_t *)
 Returns the erase counter for current page. More...
 
uint16_t read (uint16_t address, uint16_t *data)
 Returns the last stored variable data, if found, which correspond to the passed virtual address. More...
 
uint16_t read (uint16_t address)
 Returns the last stored variable data, if found, which correspond to the passed virtual address. More...
 
uint16_t write (uint16_t address, uint16_t data)
 Writes/upadtes variable data in EEPROM. More...
 
uint16_t count (uint16_t *data)
 Return number of variable. More...
 
uint16_t maxcount (void)
 
uint16_t _CheckErasePage (uint32_t, uint16_t)
 Check page for blank and erase it. More...
 

Static Public Member Functions

static FLASH_Status write_16 (uint32_t addr, uint16_t data)
 
static FLASH_Status write_8 (uint32_t addr, uint8_t data)
 
static void FLASH_Lock_check ()
 
static void FLASH_Unlock_dis ()
 
static uint32_t read_16 (uint32_t addr)
 
static uint32_t read_32 (uint32_t addr)
 
static FLASH_Status _ErasePageByAddress (uint32_t Page_Address)
 Erases a specified FLASH page by address. More...
 
static void FLASH_OB_WRPConfig (uint32_t OB_WRP, FunctionalState NewState)
 

Private Member Functions

uint16_t _init (void)
 
uint16_t _format (void)
 Erases PAGE0 and PAGE1 and writes EEPROM_VALID_PAGE / 0 header to PAGE0. More...
 
FLASH_Status _ErasePage (uint32_t)
 Erase page with increment erase counter (page + 2) More...
 
uint16_t _CheckPage (uint32_t, uint16_t)
 Check page for blank. More...
 
uint16_t _Format (void)
 
uint32_t _FindValidPage (void)
 Find valid Page for write or read operation. More...
 
uint16_t _GetVariablesCount (uint32_t, uint16_t)
 Calculate unique variables in EEPROM. More...
 
uint16_t _PageTransfer (uint32_t, uint32_t, uint16_t)
 Transfers last updated variables data from the full Page to an empty one. More...
 
uint16_t _VerifyPageFullWriteVariable (uint16_t, uint16_t)
 Verify if active page is full and Writes variable in EEPROM. More...
 

Private Attributes

uint32_t PageBase0
 
uint32_t PageBase1
 
uint32_t PageSize
 
uint16_t _status
 

Detailed Description

Definition at line 29 of file EEPROM.h.

Member Typedef Documentation

◆ func_t

typedef void(* EEPROMClass::func_t) (uint8_t page)

Definition at line 32 of file EEPROM.h.

Constructor & Destructor Documentation

◆ EEPROMClass()

EEPROMClass::EEPROMClass ( void  )

Definition at line 24 of file EEPROM.cpp.

Member Function Documentation

◆ _CheckErasePage()

uint16_t EEPROMClass::_CheckErasePage ( uint32_t  pageBase,
uint16_t  req 
)

Check page for blank and erase it.

Parameters
pagebase address
Return values
Successor error
  • Flash error code: on write Flash error
  • EEPROM_BAD_FLASH: page not empty after erase
  • EEPROM_OK: page blank

Definition at line 193 of file EEPROM.cpp.

Referenced by _format(), _init(), _PageTransfer(), and read_32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _CheckPage()

uint16_t EEPROMClass::_CheckPage ( uint32_t  pageBase,
uint16_t  status 
)
private

Check page for blank.

Parameters
pagebase address
Return values
Successor error EEPROM_BAD_FLASH: page not empty after erase EEPROM_OK: page blank

Definition at line 110 of file EEPROM.cpp.

Referenced by _CheckErasePage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _ErasePage()

FLASH_Status EEPROMClass::_ErasePage ( uint32_t  pageBase)
private

Erase page with increment erase counter (page + 2)

Parameters
pagebase address
Return values
Successor error FLASH_COMPLETE: success erase
  • Flash error code: on write Flash error

Definition at line 163 of file EEPROM.cpp.

Referenced by _CheckErasePage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _ErasePageByAddress()

FLASH_Status EEPROMClass::_ErasePageByAddress ( uint32_t  Page_Address)
static

Erases a specified FLASH page by address.

Parameters
Page_AddressThe page address to be erased.
Return values
FLASHStatus: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.

Definition at line 130 of file EEPROM.cpp.

Referenced by _ErasePage(), OSD_EEPROM::erasePageByAddress(), and read_32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _FindValidPage()

uint32_t EEPROMClass::_FindValidPage ( void  )
private

Find valid Page for write or read operation.

Parameters
Page0Page0 base address Page1: Page1 base address
Return values
Validpage address (PAGE0 or PAGE1) or NULL in case of no valid page was found

Definition at line 211 of file EEPROM.cpp.

Referenced by _VerifyPageFullWriteVariable(), count(), erases(), and read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _format()

uint16_t EEPROMClass::_format ( void  )
private

Erases PAGE0 and PAGE1 and writes EEPROM_VALID_PAGE / 0 header to PAGE0.

Parameters
PAGE0and PAGE1 base addresses
Return values
_statusof the last operation (Flash write or erase) done during EEPROM formating

Definition at line 574 of file EEPROM.cpp.

Referenced by _init(), and format().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _Format()

uint16_t EEPROMClass::_Format ( void  )
private

◆ _GetVariablesCount()

uint16_t EEPROMClass::_GetVariablesCount ( uint32_t  pageBase,
uint16_t  skipAddress 
)
private

Calculate unique variables in EEPROM.

Parameters
startaddress of first slot to check (page + 4)
endpage end address
address16 bit virtual address of the variable to excluse (or 0XFFFF)
Return values
countof variables

Definition at line 239 of file EEPROM.cpp.

Referenced by _init(), _VerifyPageFullWriteVariable(), and count().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _init()

uint16_t EEPROMClass::_init ( void  )
private

Definition at line 433 of file EEPROM.cpp.

Referenced by _FindValidPage(), init(), and write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _PageTransfer()

uint16_t EEPROMClass::_PageTransfer ( uint32_t  newPage,
uint32_t  oldPage,
uint16_t  SkipAddress 
)
private

Transfers last updated variables data from the full Page to an empty one.

Parameters
newPagenew page base address
oldPageold page base address
SkipAddress16 bit virtual address of the variable (or 0xFFFF)
Return values
Successor error status:
  • FLASH_COMPLETE: on success
  • EEPROM_OUT_SIZE: if valid new page is full
  • Flash error code: on write Flash error

Definition at line 274 of file EEPROM.cpp.

Referenced by _init(), and _VerifyPageFullWriteVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _VerifyPageFullWriteVariable()

uint16_t EEPROMClass::_VerifyPageFullWriteVariable ( uint16_t  Address,
uint16_t  Data 
)
private

Verify if active page is full and Writes variable in EEPROM.

Parameters
Address16 bit virtual address of the variable
Data16 bit data to be written as variable value
Return values
Successor error status:
  • FLASH_COMPLETE: on success
  • EEPROM_PAGE_FULL: if valid page is full (need page transfer)
  • EEPROM_NO_VALID_PAGE: if no valid page was found
  • EEPROM_OUT_SIZE: if EEPROM size exceeded
  • Flash error code: on write Flash error

Definition at line 351 of file EEPROM.cpp.

Referenced by write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ count()

uint16_t EEPROMClass::count ( uint16_t *  cnt)

Return number of variable.

Return values
Numberof variables

Definition at line 705 of file EEPROM.cpp.

Referenced by read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erases()

uint16_t EEPROMClass::erases ( uint16_t *  Erases)

Returns the erase counter for current page.

Parameters
DataGlobal variable contains the read variable value
Return values
Successor error status:
  • EEPROM_OK: if erases counter return.
  • EEPROM_NO_VALID_PAGE: if no valid page was found.

Definition at line 618 of file EEPROM.cpp.

Here is the call graph for this function:

◆ FLASH_Lock_check()

void EEPROMClass::FLASH_Lock_check ( )
static

Definition at line 92 of file EEPROM.cpp.

Referenced by _init(), OSD_EEPROM::FLASH_Lock_check(), format(), maxcount(), and write().

Here is the caller graph for this function:

◆ FLASH_OB_WRPConfig()

void EEPROMClass::FLASH_OB_WRPConfig ( uint32_t  OB_WRP,
FunctionalState  NewState 
)
static

Definition at line 41 of file EEPROM.cpp.

Referenced by read_32(), and reset_flash_errors().

Here is the caller graph for this function:

◆ FLASH_Unlock_dis()

void EEPROMClass::FLASH_Unlock_dis ( )
static

Definition at line 98 of file EEPROM.cpp.

Referenced by OSD_EEPROM::FLASH_Unlock_dis(), and maxcount().

Here is the caller graph for this function:

◆ format()

uint16_t EEPROMClass::format ( void  )

Erases PAGE0 and PAGE1 and writes EEPROM_VALID_PAGE / 0 header to PAGE0.

Parameters
PAGE0and PAGE1 base addresses
Return values
_statusof the last operation (Flash write or erase) done during EEPROM formating

Definition at line 602 of file EEPROM.cpp.

Here is the call graph for this function:

◆ init()

uint16_t EEPROMClass::init ( uint32_t  pageBase0,
uint32_t  pageBase1,
uint32_t  pageSize 
)

Definition at line 424 of file EEPROM.cpp.

Here is the call graph for this function:

◆ maxcount()

uint16_t EEPROMClass::maxcount ( void  )
inline

Definition at line 93 of file EEPROM.h.

Referenced by _VerifyPageFullWriteVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read() [1/2]

uint16_t EEPROMClass::read ( uint16_t  Address,
uint16_t *  Data 
)

Returns the last stored variable data, if found, which correspond to the passed virtual address.

Parameters
AddressVariable virtual address
DataPointer to data variable
Return values
Successor error status:
  • EEPROM_OK: if variable was found
  • EEPROM_BAD_ADDRESS: if the variable was not found
  • EEPROM_NO_VALID_PAGE: if no valid page was found.

Definition at line 642 of file EEPROM.cpp.

Referenced by read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read() [2/2]

uint16_t EEPROMClass::read ( uint16_t  address)
inline

Returns the last stored variable data, if found, which correspond to the passed virtual address.

Parameters
AddressVariable virtual address
Return values
Datafor variable or EEPROM_DEFAULT_DATA, if any errors

Definition at line 70 of file EEPROM.h.

Here is the call graph for this function:

◆ read_16()

static uint32_t EEPROMClass::read_16 ( uint32_t  addr)
inlinestatic

Definition at line 100 of file EEPROM.h.

Referenced by _CheckPage(), _ErasePage(), _FindValidPage(), _format(), _GetVariablesCount(), _init(), _PageTransfer(), _VerifyPageFullWriteVariable(), erases(), and read().

Here is the caller graph for this function:

◆ read_32()

static uint32_t EEPROMClass::read_32 ( uint32_t  addr)
inlinestatic

Definition at line 104 of file EEPROM.h.

Referenced by _CheckPage(), _PageTransfer(), and _VerifyPageFullWriteVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write()

uint16_t EEPROMClass::write ( uint16_t  Address,
uint16_t  Data 
)

Writes/upadtes variable data in EEPROM.

Parameters
VirtAddressVariable virtual address
Data16 bit data to be written
Return values
Successor error status:
  • FLASH_COMPLETE: on success
  • EEPROM_BAD_ADDRESS: if address = 0xFFFF
  • EEPROM_PAGE_FULL: if valid page is full
  • EEPROM_NO_VALID_PAGE: if no valid page was found
  • EEPROM_OUT_SIZE: if no empty EEPROM variables
  • Flash error code: on write Flash error

Definition at line 682 of file EEPROM.cpp.

Referenced by read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_16()

FLASH_Status EEPROMClass::write_16 ( uint32_t  addr,
uint16_t  data 
)
static

Definition at line 64 of file EEPROM.cpp.

Referenced by _ErasePage(), _format(), _init(), _PageTransfer(), _VerifyPageFullWriteVariable(), maxcount(), and OSD_EEPROM::write_16().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_8()

FLASH_Status EEPROMClass::write_8 ( uint32_t  addr,
uint8_t  data 
)
static

Definition at line 77 of file EEPROM.cpp.

Referenced by maxcount(), and OSD_EEPROM::write_8().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _status

uint16_t EEPROMClass::_status
private

Definition at line 117 of file EEPROM.h.

Referenced by _FindValidPage(), _init(), and write().

◆ PageBase0

uint32_t EEPROMClass::PageBase0
private

Definition at line 114 of file EEPROM.h.

Referenced by _FindValidPage(), _format(), _init(), _VerifyPageFullWriteVariable(), and init().

◆ PageBase1

uint32_t EEPROMClass::PageBase1
private

Definition at line 115 of file EEPROM.h.

Referenced by _FindValidPage(), _format(), _init(), _VerifyPageFullWriteVariable(), and init().

◆ PageSize

uint32_t EEPROMClass::PageSize
private

The documentation for this class was generated from the following files: