The latest development version of this page may be more current than this released 0.4.2 version.

Flash API

Structures

struct wm_drv_flash_info_t

flash infomation

API reference

int wm_drv_flash_write(wm_device_t *dev, uint32_t offset, uint8_t *in_buf, uint32_t in_buf_len)

write data to flash without erase

Warning

, must erase before call this API, othewise the write data maybe incorrert

Parameters:
  • dev[in] flash driver device

  • offset[in] point the flash address will be writed

  • in_buf[in] the source data address

  • in_buf_len[in] write data length

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_flash_write_with_erase(wm_device_t *dev, uint32_t offset, uint8_t *in_buf, uint32_t in_buf_len)

write data to flash with erase

Parameters:
  • dev[in] flash driver device

  • offset[in] point the flash address will be writed

  • in_buf[in] the source data address

  • in_buf_len[in] write data length

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_flash_read(wm_device_t *dev, uint32_t offset, uint8_t *out_buf, uint32_t out_len)

read data from flash

Parameters:
  • dev[in] flash driver device

  • offset[in] point the flash address will be read

  • out_buf[out] store read data address

  • out_len[in] read data length

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_flash_get_device_info(wm_device_t *dev, wm_drv_flash_info_t *flash_info)

get flash device information

Parameters:
  • dev[in] flash driver device, flash device information will store into dev->device_info

  • flash_info, store[out] get information about this flash

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_flash_erase_region(wm_device_t *dev, uint32_t offset, uint32_t erase_len)

erase flash begin with user’s specicy address

Parameters:
  • dev[in] flash driver device

  • offset[in] the flash address will be erased

  • erase_len[in] erase length

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_flash_erase_sector(wm_device_t *dev, uint32_t sector_idx, uint32_t sector_count)

erase flash by sector

Parameters:
  • dev[in] flash driver device

  • sector_idx[in] the start index will be erased

  • sector_count[in] erase sector number

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_flash_erase_chip(wm_device_t *dev)

erase flash all region

Parameters:

dev[in] flash driver device

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

wm_device_t *wm_drv_flash_init(char *dev_name)

Initialize flash driver.

Parameters:

dev_name[in] flash name will be inititaled

Returns:

  • flash device poiniter: succeed

  • NULL: invalid argument or failed

int wm_drv_flash_deinit(wm_device_t *dev)

deinit flash driver

Parameters:

dev[in] flash driver device

Returns:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed