两个独立的工程之间代码的共用(Boot+App)

void TestJumpDemo(uint32_t JumpToAddr);    //需要共用的函数
uint8_t KeyPassControl(uint32_t pins);

typedef void (*Appjumptest)(uint32_t addr);
typedef uint8_t (*keypass)(uint32_t pin);

typedef struct {
	Appjumptest jumpdemo;
	keypass keydemo;
}gFuncTableFunc;

//gFuncTableFunc  g_FuncTable;
__attribute__ ((section(".functiontable")))  //共用函数用来查询的表必须固定到指定地址
const gFuncTableFunc  g_FuncTable =
{
	&TestJumpDemo,
	&KeyPassControl
};

用来共用的函数一端;

typedef void (*Appjumptest)(uint32_t addr);
typedef uint8_t (*keypass)(uint32_t pin);

typedef struct {
	Appjumptest jumpdemo;
	keypass keydemo;
}gFuncTableFunc;

gFuncTableFunc  g_FuncTable;
//初始化调用表,注意初始化顺序必须与定义的一致
g_FuncTable.jumpdemo = (Appjumptest)*(uint32_t*)(tablebaseaddr);    //
g_FuncTable.keydemo = (keypass)*(uint32_t*)(tablebaseaddr+4);

用来调用的一端

调用方式

  keypassstatus = g_FuncTable.keydemo((pin13));
  if(1==keypassstatus)
  {
	  g_FuncTable.jumpdemo(FLASHCODESTARTADD);
  }