HPM SDK
HPMicro Software Development Kit
eeprom_emulation.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "eeprom_emulation.h"
#include "hpm_crc32.h"

Macros

#define E2P_OFFSET(TYPE, MEMBER)   ((uint32_t)(&(((TYPE *)0)->MEMBER)))
 
#define E2P_SWAP(a, b)
 

Functions

static E2P_ATTR void e2p_print_info (e2p_t *e2p)
 
static E2P_ATTR hpm_stat_t e2p_table_update (e2p_block *block)
 
static E2P_ATTR void e2p_format (e2p_t *e2p)
 
static E2P_ATTR void e2p_config_info (e2p_t *e2p)
 
static E2P_ATTR uint32_t e2p_data_crc_calc (uint16_t length, uint8_t *data)
 
static E2P_ATTR hpm_stat_t e2p_retrieve_info (uint32_t block_id, e2p_block *block)
 
static E2P_ATTR hpm_stat_t e2p_write_private (e2p_t *e2p, uint32_t block_id, uint16_t length, uint8_t *data)
 
static E2P_ATTR int e2p_info_table_sort (void)
 
static E2P_ATTR void e2p_dummy_config (e2p_t *e2p)
 
static E2P_ATTR void e2p_check_version (e2p_t *e2p)
 
static E2P_ATTR e2p_te2p_get_valid_context (e2p_t *e2p, uint8_t *flush)
 
E2P_ATTR hpm_stat_t e2p_config (e2p_t *e2p)
 eeprom emulation config More...
 
E2P_ATTR hpm_stat_t e2p_flush (uint8_t flag)
 eeprom emulation flush whole area, remove redundancy More...
 
E2P_ATTR hpm_stat_t e2p_write (uint32_t block_id, uint16_t length, uint8_t *data)
 eeprom emulation write More...
 
E2P_ATTR hpm_stat_t e2p_read (uint32_t block_id, uint16_t length, uint8_t *data)
 eeprom emulation read More...
 
E2P_ATTR void e2p_clear (void)
 format whole area, 0xFF More...
 
E2P_ATTR uint32_t e2p_generate_id (const char *name)
 generate custom id More...
 
E2P_ATTR void e2p_show_info (void)
 show e2p instance info include config info and store info More...
 

Variables

static e2p_t e2p_dummy
 
static e2p_te2p_raw
 
static e2p_te2p_valid_ctx
 
static e2p_block e2p_info_table [(100)]
 

Macro Definition Documentation

◆ E2P_OFFSET

#define E2P_OFFSET (   TYPE,
  MEMBER 
)    ((uint32_t)(&(((TYPE *)0)->MEMBER)))

◆ E2P_SWAP

#define E2P_SWAP (   a,
 
)
Value:
do {\
uint32_t tmp = (a);\
(a) = (b);\
(b) = tmp;\
} while (0)

Function Documentation

◆ e2p_check_version()

static E2P_ATTR void e2p_check_version ( e2p_t e2p)
static

◆ e2p_clear()

E2P_ATTR void e2p_clear ( void  )

format whole area, 0xFF

◆ e2p_config()

E2P_ATTR hpm_stat_t e2p_config ( e2p_t e2p)

eeprom emulation config

Parameters
e2pinstance context
Returns
hpm_stat_t

◆ e2p_config_info()

static E2P_ATTR void e2p_config_info ( e2p_t e2p)
static

◆ e2p_data_crc_calc()

static E2P_ATTR uint32_t e2p_data_crc_calc ( uint16_t  length,
uint8_t *  data 
)
static

◆ e2p_dummy_config()

static E2P_ATTR void e2p_dummy_config ( e2p_t e2p)
static

◆ e2p_flush()

E2P_ATTR 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_format()

static E2P_ATTR void e2p_format ( e2p_t e2p)
static

◆ e2p_generate_id()

E2P_ATTR uint32_t e2p_generate_id ( const char *  name)

generate custom id

Parameters
name
Returns
uint32_t

◆ e2p_get_valid_context()

static E2P_ATTR e2p_t* e2p_get_valid_context ( e2p_t e2p,
uint8_t *  flush 
)
static

◆ e2p_info_table_sort()

static E2P_ATTR int e2p_info_table_sort ( void  )
static

◆ e2p_print_info()

static E2P_ATTR void e2p_print_info ( e2p_t e2p)
static

◆ e2p_read()

E2P_ATTR 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_retrieve_info()

static E2P_ATTR hpm_stat_t e2p_retrieve_info ( uint32_t  block_id,
e2p_block block 
)
static

◆ e2p_show_info()

E2P_ATTR void e2p_show_info ( void  )

show e2p instance info include config info and store info

◆ e2p_table_update()

static E2P_ATTR hpm_stat_t e2p_table_update ( e2p_block block)
static

◆ e2p_write()

E2P_ATTR 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

◆ e2p_write_private()

static E2P_ATTR hpm_stat_t e2p_write_private ( e2p_t e2p,
uint32_t  block_id,
uint16_t  length,
uint8_t *  data 
)
static

Variable Documentation

◆ e2p_dummy

e2p_t e2p_dummy
static

◆ e2p_info_table

e2p_block e2p_info_table[(100)]
static

◆ e2p_raw

e2p_t* e2p_raw
static

◆ e2p_valid_ctx

e2p_t * e2p_valid_ctx
static