avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Table of function pointers


From: Guy Robinson
Subject: Re: [avr-gcc-list] Table of function pointers
Date: Fri, 4 May 2001 12:04:30 +1200

Hi Jon,
When I tried this the array was in SRAM. I don't think Avr-gcc understands
the const type as standard. I'm new to C but I think you have to use the
progmem
macros(progmem.h). I want the array of pointers to functions in the program
memory it's just how to get it there.

Still trying,

Guy


----- Original Message -----
From: "Jon Bertrand" <address@hidden>
To: <address@hidden>
Sent: Friday, May 04, 2001 2:29 AM
Subject: RE: [avr-gcc-list] Table of function pointers


You have some stuff I'm not familar with.

Here is how I do arrays of pointers to functions:

/* prototypes for the actual functions */
void Cmd1(TByte bCmd);
void Cmd2(TByte bCmd);
void Cmd3(TByte bCmd);

/* the actual functions all must match the type TFunctionPtr */
typedef void (*TFunctionPtr)(TByte bCmd);

/* the array */
const TFunctionPtr CommandArray[] =
{
  Cmd1,
  Cmd2,
  Cmd3
};

/* how to call a function */
main()
{
  CommandArray[bIndex](bParameter);
}

Jon B.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]