HPM SDK
HPMicro Software Development Kit
eeprom_emulation.h File Reference
#include <stdint.h>
#include "user_config.h"
#include "hpm_nor_flash.h"
#include "hpm_common.h"

Go to the source code of this file.

Data Structures

struct  e2p_header
 
struct  e2p_block
 
struct  e2p_config_t
 
struct  e2p_t
 

Macros

#define E2P_DEBUG_LEVEL_TRACE   (0)
 
#define E2P_DEBUG_LEVEL_INFO   (1)
 
#define E2P_DEBUG_LEVEL_WARN   (2)
 
#define E2P_DEBUG_LEVEL_ERROR   (3)
 
#define E2P_TRACE(fmt, ...)   printf("%s: %d: debug: "fmt"%s\n", __func__, __LINE__, __VA_ARGS__)
 
#define e2p_trace(...)   E2P_TRACE(__VA_ARGS__, "")
 
#define E2P_INFO(fmt, ...)   printf(""fmt"%s\n", __VA_ARGS__)
 
#define e2p_info(...)   E2P_INFO(__VA_ARGS__, "")
 
#define E2P_WARN(fmt, ...)   printf(""fmt"%s\n", __VA_ARGS__)
 
#define e2p_warn(...)   E2P_WARN(__VA_ARGS__, "")
 
#define E2P_ERR(fmt, ...)   printf(""fmt"%s\n", __VA_ARGS__)
 
#define e2p_err(...)   E2P_ERR(__VA_ARGS__, "")
 
#define E2P_MAX_VAR_CNT   (100)
 
#define E2P_MAGIC_ID   (0x48504D43) /*'H' 'P' 'M' 'C'*/
 
#define E2P_VALID_STATE   (0xFFFFFFF0)
 
#define E2P_EARSED_ID   (0xFFFFFFFF)
 
#define E2P_EARSED_VAR   (0xFF)
 
#define E2P_FLUSH_TRY   (0)
 
#define E2P_FLUSH_BEGIN   (1)
 
#define E2P_CRITICAL_ENTER()   e2p_enter_critical()
 
#define E2P_CRITICAL_EXIT()   e2p_exit_critical()
 

Enumerations

enum  {
  e2p_state_valid = 0 , e2p_state_finish = 8 , e2p_state_write = 12 , e2p_state_start = 14 ,
  e2p_state_invalid = 15
}
 
enum  e2p_valid_state { e2p_invalid = 0xCCCC , e2p_valid = 0xEEEE , e2p_earsed = 0xFFFF }
 
enum  {
  E2P_STATUS_OK = 0 , E2P_ERROR , E2P_ERROR_NO_MEM , E2P_ERROR_INIT_ERR ,
  E2P_ERROR_BAD_ID , E2P_ERROR_BAD_ADDR , E2P_ERROR_MUL_VAR
}
 

Functions

void e2p_enter_critical (void)
 
void e2p_exit_critical (void)
 
hpm_stat_t e2p_config (e2p_t *e2p)
 eeprom emulation config More...
 
hpm_stat_t e2p_flush (uint8_t flag)
 eeprom emulation flush whole area, remove redundancy More...
 
hpm_stat_t e2p_write (uint32_t block_id, uint16_t length, uint8_t *data)
 eeprom emulation write More...
 
hpm_stat_t e2p_read (uint32_t block_id, uint16_t length, uint8_t *data)
 eeprom emulation read More...
 
uint32_t e2p_generate_id (const char *name)
 generate custom id More...
 
void e2p_clear (void)
 format whole area, 0xFF More...
 
void e2p_show_info (void)
 show e2p instance info include config info and store info More...
 

Macro Definition Documentation

◆ E2P_CRITICAL_ENTER

#define E2P_CRITICAL_ENTER ( )    e2p_enter_critical()

◆ E2P_CRITICAL_EXIT

#define E2P_CRITICAL_EXIT ( )    e2p_exit_critical()

◆ E2P_DEBUG_LEVEL_ERROR

#define E2P_DEBUG_LEVEL_ERROR   (3)

◆ E2P_DEBUG_LEVEL_INFO

#define E2P_DEBUG_LEVEL_INFO   (1)

◆ E2P_DEBUG_LEVEL_TRACE

#define E2P_DEBUG_LEVEL_TRACE   (0)

◆ E2P_DEBUG_LEVEL_WARN

#define E2P_DEBUG_LEVEL_WARN   (2)

◆ E2P_EARSED_ID

#define E2P_EARSED_ID   (0xFFFFFFFF)

◆ E2P_EARSED_VAR

#define E2P_EARSED_VAR   (0xFF)

◆ e2p_err

#define e2p_err (   ...)    E2P_ERR(__VA_ARGS__, "")

◆ E2P_ERR

#define E2P_ERR (   fmt,
  ... 
)    printf(""fmt"%s\n", __VA_ARGS__)

◆ E2P_FLUSH_BEGIN

#define E2P_FLUSH_BEGIN   (1)

◆ E2P_FLUSH_TRY

#define E2P_FLUSH_TRY   (0)

◆ e2p_info

#define e2p_info (   ...)    E2P_INFO(__VA_ARGS__, "")

◆ E2P_INFO

#define E2P_INFO (   fmt,
  ... 
)    printf(""fmt"%s\n", __VA_ARGS__)

◆ E2P_MAGIC_ID

#define E2P_MAGIC_ID   (0x48504D43) /*'H' 'P' 'M' 'C'*/

◆ E2P_MAX_VAR_CNT

#define E2P_MAX_VAR_CNT   (100)

◆ e2p_trace

#define e2p_trace (   ...)    E2P_TRACE(__VA_ARGS__, "")

◆ E2P_TRACE

#define E2P_TRACE (   fmt,
  ... 
)    printf("%s: %d: debug: "fmt"%s\n", __func__, __LINE__, __VA_ARGS__)

◆ E2P_VALID_STATE

#define E2P_VALID_STATE   (0xFFFFFFF0)

◆ e2p_warn

#define e2p_warn (   ...)    E2P_WARN(__VA_ARGS__, "")

◆ E2P_WARN

#define E2P_WARN (   fmt,
  ... 
)    printf(""fmt"%s\n", __VA_ARGS__)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
e2p_state_valid 
e2p_state_finish 
e2p_state_write 
e2p_state_start 
e2p_state_invalid 

◆ anonymous enum

anonymous enum
Enumerator
E2P_STATUS_OK 
E2P_ERROR 
E2P_ERROR_NO_MEM 
E2P_ERROR_INIT_ERR 
E2P_ERROR_BAD_ID 
E2P_ERROR_BAD_ADDR 
E2P_ERROR_MUL_VAR 

◆ e2p_valid_state

Enumerator
e2p_invalid 
e2p_valid 
e2p_earsed 

Function Documentation

◆ e2p_clear()

void e2p_clear ( void  )

format whole area, 0xFF

◆ e2p_config()

hpm_stat_t e2p_config ( e2p_t e2p)

eeprom emulation config

Parameters
e2pinstance context
Returns
hpm_stat_t

◆ e2p_enter_critical()

void e2p_enter_critical ( void  )

◆ e2p_exit_critical()

void e2p_exit_critical ( void  )

◆ e2p_flush()

hpm_stat_t e2p_flush ( uint8_t  flag)

eeprom emulation flush whole area, remove redundancy

Parameters
flagE2P_FLUSH_TRY - conditional flush, E2P_FLUSH_BEGIN - force flush
Returns
hpm_stat_t

◆ e2p_generate_id()

uint32_t e2p_generate_id ( const char *  name)

generate custom id

Parameters
name
Returns
uint32_t

◆ e2p_read()

hpm_stat_t e2p_read ( uint32_t  block_id,
uint16_t  length,
uint8_t *  data 
)

eeprom emulation read

Parameters
block_idcustom id
lengthdata length
data
Returns
hpm_stat_t

◆ e2p_show_info()

void e2p_show_info ( void  )

show e2p instance info include config info and store info

◆ e2p_write()

hpm_stat_t e2p_write ( uint32_t  block_id,
uint16_t  length,
uint8_t *  data 
)

eeprom emulation write

Parameters
block_idcustom id
lengthdata length
data
Returns
hpm_stat_t