函数指针
void Temp_function() { Uart_Printf("\nPlease input 1-16 to select test!!!\n"); }struct {
void (*fun)(void);
char *tip;
}CmdTip[] = {
{ Temp_function, "Please input 1-16 to select test" } ,
{ BUZZER_PWM_Test, "Test PWM" } ,
{ RTC_Display, "RTC time display" } ,
{ Test_Adc, "Test ADC" } ,
{ KeyScan_Test, "Test interrupt and key scan" } ,
{ Test_Touchpanel, "Test Touchpanel" } ,
{ TFT_LCD_Test, "Test TFT-LCD or VGA1024x768 module" } ,
{ Test_Iic, "Test IIC EEPROM, if use QQ2440, please remove the LCD" } ,
{ PlayMusicTest, "UDA1341 play music" } ,
{ Test_SDI, "Test SD Card" } ,
{ Camera_Test, "Test CMOS Camera"},
{ 0, 0}
};
while(1)
{
U8 idx;
Uart_Printf("\nPlease select function : \n");
for(i=0; CmdTip[i].fun!=0; i++)
Uart_Printf("%d : %s\n", i, CmdTip[i].tip);
idx = Uart_GetIntNum_GJ() ;
if(idx<i)
{
(*CmdTip[idx].fun)();
Delay(20);
Uart_Init( 0,115200 );
}
}
}
谁能总结下函数指针的用法?