The latest development version of this page may be more current than this released 2.3-beta.2 version.

EEPROM API Reference

EEPROM

struct wm_drv_eeprom_ops_t

instance api types

wm_device_t *wm_drv_eeprom_init(const char *eeprom_dev_name)

eeprom drvier initialize

Parameters:

eeprom_dev_name[in] The eeprom name, defined in device table

Returns:

  • !0 : eeprom device, return previous handle if called twice

  • NULL: fail

int wm_drv_eeprom_deinit(wm_device_t *eeprom_device)

eeprom drvier deinitialize

Parameters:

eeprom_device[in] eeprom device,type of wm_device_t *

Returns:

  • WM_ERR_SUCCESS : deinitialize ok

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_eeprom_read(wm_device_t *eeprom_device, uint32_t offset, void *buf, uint32_t len)

read data from eeprom device

Parameters:
  • eeprom_device[in] eeprom device,type of wm_device_t *

  • offset[in] read offset

  • buf[out] The read buffer

  • len[in] The buffer size

Returns:

  • WM_ERR_SUCCESS : read ok

  • WM_ERR_FAILED : read fail

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_eeprom_write(wm_device_t *eeprom_device, uint32_t offset, const void *data, uint32_t len)

write data to eeprom device

Parameters:
  • eeprom_device[in] eeprom device,type of wm_device_t *

  • offset[in] write offset

  • data[in] The write data

  • len[in] The size of write data

Returns:

  • WM_ERR_SUCCESS : read ok

  • WM_ERR_FAILED : read fail

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_eeprom_get_size(wm_device_t *eeprom_device)

Get eeprom size, the size is configured in device table.

Parameters:

eeprom_device[in] eeprom device,type of wm_device_t *

Returns:

  • > 0: eeprom size

  • < 0: WM_ERR_INVALID_PARAM

int wm_drv_eeprom_set_wp(wm_device_t *eeprom_device, bool on)

set write protection

Note

The eeprom WP pin must connect to the gpio pin that configured in device table

Note

If the write protection function is enabled, the wm_drv_eeprom_write function will automatically turn off write protection before writing, and then turn on write protection after writing.

Parameters:
  • eeprom_device[in] eeprom device,type of wm_device_t *

  • on[in] 1: write protection, 0: no write protection

Returns:

  • WM_ERR_SUCCESS : deinitialize ok

  • WM_ERR_INVALID_PARAM: bad param