cancel
Showing results for 
Search instead for 
Did you mean: 

Function Tables

kim2
Associate II
Posted on June 23, 2006 at 08:10

Function Tables

1 REPLY 1
kim2
Associate II
Posted on June 23, 2006 at 08:10

Can someone help me resolve calls to a function table which can pass parameters, I am struggling with this.

Mik

~~~~~~~~~~~~~~~ CODE ~~~~~~~~~~~~~~~~~

// Start of Test module

typedef void (*fptr)(void);

typedef unsigned char u8;

// Prototype functions

void NoBuz2(void);

u8 NoBuz04(void);

void BuzEngTone_Rpt(u8);

u8 BuzTask(u8);

void ExBuzz(u8);

// Define function table

const fptr Buzz_tbl[] = // Define Executive Routines here

{

NoBuz2,

NoBuz04(),

BuzEngTone_Rpt(0x05),

u8 BuzTask(0x01,0xff)

};

// Create functions in the functions table

void NoBuz2(void)

{

}

u8 NoBuz04(void)

{

return 0x04;

}

void BuzEngTone_Rpt(u8 test)

{

test+=2;

}

u8 BuzTask(u8 test)

{

test+=2;

return test;

}

//Call functions from the function table

void ExBuzz(u8 task)

{

Buzz_tbl[task]();

}

// End of Code