LBDP-bootloader main functions are as follows:
1. Codes and check functions.
2. Functions Function library (including flash erase and program functions).
Library functions described in 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 application needs in the following statement:
#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) to achieve is very simple:
lbdp_map uint32_t (int index)
{
return * (uint32_t *) (* index + LBDP_FUNC_ENTRY. 4); // this embodiment, the library function entry LBDP_FUNC_ENTRY defined in the flash.
}