如何调用LBDP-bootloader中的库函数

库函数说明在lbdp.h中

#define LBDP_FUNC_ENTRY 0x8002B80

typedef void (*p_lbdp_remap)(void);

typedef void (*p_lbdp_writeFlash)(uint16_t addr,uint16_t writeFlashData);

typedef void (*p_lbdp_eraseFlash)(uint8_t page);

应用程序需要在main.c中声明如下:

#include "lbdp.h"

p_lbdp_eraseFlash ex_lbdp_eraseFlash;

p_lbdp_writeFlash ex_lbdp_writeFlash;

//p_lbdp_remap ex_lbdp_remap;

ex_lbdp_eraseFlash = (p_lbdp_eraseFlash)lbdp_map(2);

ex_lbdp_writeFlash = (p_lbdp_writeFlash)lbdp_map(3);

lbdp_map(int index)实现很简单:

uint32_t lbdp_map(int index)
{
return *(uint32_t*)(LBDP_FUNC_ENTRY +index*4);  //本例中,库函数入口在LBDP_FUNC_ENTRY定义的flash中。
}

原文地址:https://www.cnblogs.com/shlb/p/12242086.html