BK_FLASH

[English]

BK_FLASH API Status

API

bk_flash_init()

bk_flash_op_start()

bk_flash_erase_sector()

bk_flash_write_bytes()

bk_flash_read_bytes()

bk_flash_erase_block_32k()

bk_flash_show_info()

bk_flash_get_max_work_freq()

bk_flash_force_reboot()

BK_FLASH API Reference

Header File

Functions

void bk_flash_init(void)

sys flash init

(1)identify flash model (2)if flash support quard I/O fast read(0xEB), then switch to 4 line mode (3)set flash block protect bit, protest flash all block

void bk_flash_op_start(void)

flash operation(erase/write/read) start

if user use bk_flash_erase_sector/bk_flash_write_bytes/bk_flash_read_bytes funtion and pfn_cb!=NULL should use this funtion to start flash operation

int32_t bk_flash_erase_sector(uint32_t address, pfunc_bk_flash_cb_t pfn_cb, void *pv_arg)

flash sector erase

flash cmd is 0x20 If pfn_cb==NULL, flash write operate immediately. exit this funtion after the erase operation is completed If pfn_cb!=NULL, flash write operate no immediately. Exection pfn_cb funtion after the erase operation is completed

参数:
  • address[in] erase address

  • pfn_cb[in] callback function for async send. it can be NULL if you do not want async send

  • pv_arg[in] user give callback parameter

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t bk_flash_write_bytes(uint32_t address, uint8_t *pu1_buf, uint32_t size, pfunc_bk_flash_cb_t pfn_cb, void *pv_arg)

flash write data

If pfn_cb==NULL, flash write operate immediately. exit this funtion after the write operation is completed If pfn_cb!=NULL, flash write operate no immediately. Exection pfn_cb funtion after the write operation is completed

参数:
  • address[in] write address

  • pu1_buf[in] pointer to send data buffer

  • size[in] send data length

  • pfn_cb[in] callback function for async send. it can be NULL if you do not want async send

  • pv_arg[in] user give callback parameter

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t bk_flash_read_bytes(uint32_t address, uint8_t *pu1_buf, uint32_t size, pfunc_bk_flash_cb_t pfn_cb, void *pv_arg)

flash read data

flash cmd is 0x20 If pfn_cb==NULL, flash write operate immediately. exit this funtion after the data operation is completed If pfn_cb!=NULL, flash write operate no immediately. Exection pfn_cb funtion after the data operation is completed

参数:
  • address[in] read address

  • pu1_buf[in] pointer to receive data buffer

  • size[in] receive data length

  • pfn_cb[in] callback function for async send. it can be NULL if you do not want async send

  • pv_arg[in] user give callback parameter

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

int32_t bk_flash_erase_block_32k(uint32_t address, pfunc_bk_flash_cb_t pfn_cb, void *pv_arg)

flash sector erase

flash cmd is 0x20 If pfn_cb==NULL, flash write operate immediately. exit this funtion after the erase operation is completed If pfn_cb!=NULL, flash write operate no immediately. Exection pfn_cb funtion after the erase operation is completed

参数:
  • address[in] erase address

  • pfn_cb[in] callback function for async send. it can be NULL if you do not want async send

  • pv_arg[in] user give callback parameter

返回值:
  • 0 – success [BK_RET_OK]

  • other – fail

返回:

result

void bk_flash_show_info(void)

show flash information

返回:

N/A

uint16_t bk_flash_get_max_work_freq(void)

get current flash max work clock in Mhz.

返回:

max work frequency

Type Definitions

typedef void (*pfunc_bk_flash_cb_t)(uint32_t address, uint8_t *pu1_buf, uint16_t buf_len, void *pv_arg)