这个页面的 最新开发版本 可能比这个发布的 0.4.3 版本新。

Flash API

数据结构体

struct wm_drv_flash_info_t

flash infomation

Public Members

uint32_t flash_size

unit is byte

uint16_t sector_size

unit is byte

uint16_t page_size

unit is byte

uint8_t vendor_id

vendor ID

uint32_t unique_id[FLASH_UNIQUE_ID_SIZE / 4]

store flash unique id

相关API

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

警告

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

参数:
  • 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

返回:

  • 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

参数:
  • 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

返回:

  • 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

参数:
  • 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

返回:

  • 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

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

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

返回:

  • 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

参数:
  • dev[in] flash driver device

  • offset[in] the flash address will be erased

  • erase_len[in] erase length

返回:

  • 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

参数:
  • dev[in] flash driver device

  • sector_idx[in] the start index will be erased

  • sector_count[in] erase sector number

返回:

  • 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

参数:

dev[in] flash driver device

返回:

  • 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.

参数:

dev_name[in] flash name will be inititaled

返回:

  • flash device poiniter: succeed

  • NULL: invalid argument or failed

int wm_drv_flash_deinit(wm_device_t *dev)

deinit flash driver

参数:

dev[in] flash driver device

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed