#include <stdio.h>
#define u8 unsigned char
#define u16 unsigned int
void dumpHex(u8 *data,u8 len,const char *msg)
{
printf("\n%s HEX(%d):",msg,len);
for(int i=0;i<len;i++)
{
printf("%02x ",data[i]);
}
printf("\r\n");
}
void fun1()
{
printf("funtion1.\n");
}
void fun2()
{
printf("funtion2.\n");
}
void fun3()
{
printf("funtion3.\n");
}
void fun4()
{
printf("funtion4.\n");
}
typedef void (*exe_fun) ();
exe_fun fstart[]={fun1,fun2,fun3,fun4,0};
void exe_init(void)
{
exe_fun *fn;
for (fn = fstart; *fn!= NULL; fn++) {
(*fn)();
}
}
typedef struct module_s {
void (*init)();
void (*write)();
void (*read)();
} module_t;
module_t g_hal_md={
.init = fun1,
.write = fun2,
.read = fun3
};
int main(void) {
printf("-----------StartTest-----------\n");
exe_init();
g_hal_md.init();
g_hal_md.write();
g_hal_md.read();
printf(".......EndTest......\n");
return 0;
}
|