Open FFBoard
Open source force feedback firmware
EEPROM_Emulation

Functions

static uint16_t EE_FindValidPage (uint8_t Operation)
 Find valid Page for write or read operation. More...
 
static uint16_t EE_VerifyPageFullWriteVariable (uint16_t VirtAddress, uint16_t Data)
 Verify if active page is full and Writes variable in EEPROM. More...
 
static uint16_t EE_PageTransfer (uint16_t VirtAddress, uint16_t Data)
 Transfers last updated variables data from the full Page to an empty one. More...
 
static uint16_t EE_VerifyPageFullyErased (uint32_t Address)
 Verify if specified page is fully erased. More...
 
uint16_t EE_Init (void)
 Restore the pages to a known good state in case of page's status corruption after a power loss. More...
 
uint16_t EE_ReadVariable (uint16_t VirtAddress, uint16_t *Data)
 Returns the last stored variable data, if found, which correspond to the passed virtual address. More...
 
uint16_t EE_WriteVariable (uint16_t VirtAddress, uint16_t Data)
 Writes/upadtes variable data in EEPROM. More...
 
HAL_StatusTypeDef EE_Format (void)
 Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE. More...
 

Variables

uint16_t DataVar = 0
 

Detailed Description

Function Documentation

◆ EE_FindValidPage()

static uint16_t EE_FindValidPage ( uint8_t  Operation)
static

Find valid Page for write or read operation.

Parameters
Operationoperation to achieve on the valid page. This parameter can be one of the following values:
  • READ_FROM_VALID_PAGE: read operation from valid page
  • WRITE_IN_VALID_PAGE: write operation from valid page
Return values
Validpage number (PAGE or PAGE1) or NO_VALID_PAGE in case of no valid page was found

Definition at line 505 of file eeprom.c.

◆ EE_Format()

HAL_StatusTypeDef EE_Format ( void  )

Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE.

Parameters
None
Return values
Statusof the last operation (Flash write or erase) done during EEPROM formating

Definition at line 453 of file eeprom.c.

◆ EE_Init()

uint16_t EE_Init ( void  )

Restore the pages to a known good state in case of page's status corruption after a power loss.

Parameters
None.
Return values
-Flash error code: on write Flash error
  • FLASH_COMPLETE: on success

Definition at line 79 of file eeprom.c.

◆ EE_PageTransfer()

static uint16_t EE_PageTransfer ( uint16_t  VirtAddress,
uint16_t  Data 
)
static

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

Parameters
VirtAddress16 bit virtual address of the variable
Data16 bit data to be written as variable value
Return values
Successor error status:
  • FLASH_COMPLETE: on success
  • PAGE_FULL: if valid page is full
  • NO_VALID_PAGE: if no valid page was found
  • Flash error code: on write Flash error

Definition at line 638 of file eeprom.c.

◆ EE_ReadVariable()

uint16_t EE_ReadVariable ( uint16_t  VirtAddress,
uint16_t *  Data 
)

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

Parameters
VirtAddressVariable virtual address
DataGlobal variable contains the read variable value
Return values
Successor error status:
  • 0: if variable was found
  • 1: if the variable was not found
  • NO_VALID_PAGE: if no valid page was found.

Definition at line 370 of file eeprom.c.

◆ EE_VerifyPageFullWriteVariable()

static uint16_t EE_VerifyPageFullWriteVariable ( uint16_t  VirtAddress,
uint16_t  Data 
)
static

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

Parameters
VirtAddress16 bit virtual address of the variable
Data16 bit data to be written as variable value
Return values
Successor error status:
  • FLASH_COMPLETE: on success
  • PAGE_FULL: if valid page is full
  • NO_VALID_PAGE: if no valid page was found
  • Flash error code: on write Flash error

Definition at line 577 of file eeprom.c.

◆ EE_VerifyPageFullyErased()

uint16_t EE_VerifyPageFullyErased ( uint32_t  Address)
static

Verify if specified page is fully erased.

Parameters
Addresspage address This parameter can be one of the following values:
  • PAGE0_BASE_ADDRESS: Page0 base address
  • PAGE1_BASE_ADDRESS: Page1 base address
Return values
pagefully erased status:
  • 0: if Page not erased
  • 1: if Page erased

Definition at line 332 of file eeprom.c.

◆ EE_WriteVariable()

uint16_t EE_WriteVariable ( uint16_t  VirtAddress,
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
  • PAGE_FULL: if valid page is full
  • NO_VALID_PAGE: if no valid page was found
  • Flash error code: on write Flash error

Definition at line 429 of file eeprom.c.

Variable Documentation

◆ DataVar

uint16_t DataVar = 0

Definition at line 59 of file eeprom.c.