EEPROM API 参考
EEPROM
-
struct wm_drv_eeprom_ops_t
instance api types
Public Members
-
int (*init)(wm_device_t *device)
initialize
-
int (*deinit)(wm_device_t *device)
deinitialize
-
int (*read)(wm_device_t *device, uint32_t offset, void *buf, uint32_t read_size)
read
-
int (*write)(wm_device_t *device, uint32_t offset, const void *data, uint32_t size)
write
-
int (*get_size)(wm_device_t *device)
get eeprom size
-
int (*set_wp)(wm_device_t *device, bool on)
set write protection
-
int (*init)(wm_device_t *device)
-
wm_device_t *wm_drv_eeprom_init(const char *eeprom_dev_name)
eeprom drvier initialize
- 参数:
eeprom_dev_name – [in] The eeprom name, defined in device table
- 返回:
!0 : eeprom device, return previous handle if called twice
NULL: fail
-
int wm_drv_eeprom_deinit(wm_device_t *eeprom_device)
eeprom drvier deinitialize
- 参数:
eeprom_device – [in] eeprom device,type of wm_device_t *
- 返回:
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
- 参数:
eeprom_device – [in] eeprom device,type of wm_device_t *
offset – [in] read offset
buf – [out] The read buffer
len – [in] The buffer size
- 返回:
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
- 参数:
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
- 返回:
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.
- 参数:
eeprom_device – [in] eeprom device,type of wm_device_t *
- 返回:
> 0: eeprom size
< 0: WM_ERR_INVALID_PARAM
-
int wm_drv_eeprom_set_wp(wm_device_t *eeprom_device, bool on)
set write protection
备注
The eeprom WP pin must connect to the gpio pin that configured in device table
备注
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.
- 参数:
eeprom_device – [in] eeprom device,type of wm_device_t *
on – [in] 1: write protection, 0: no write protection
- 返回:
WM_ERR_SUCCESS : deinitialize ok
WM_ERR_INVALID_PARAM: bad param