[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] How define a function pointer array in program memory
From: |
Christian Ludlam |
Subject: |
Re: [avr-gcc-list] How define a function pointer array in program memory? |
Date: |
Mon, 23 Feb 2004 10:39:27 GMT |
User-agent: |
Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.05) POPstar/2.05 |
On 23 Feb Artur Lipowski wrote:
> Try this:
> typedef void (*FPtr)(void);
> FPtr Key_Protab[] = { keypro1, keypro2, keypro3 };
>
> and call:
> Key_Protab[functionID]();
>
> BTW> Your question has nothing in common to AVR-GCC, answer can be found
> reading any book about a C language.
It is specific to AVR-GCC, because the question was how to put such a table
in program memory. In that case you need to
typedef void (*FPtr)(void);
FPtr Key_Protab[] PROGMEM = { keypro1, keypro2, keypro3 };
and to call,
FPtr ptr = (FPtr) pgm_read_word(&Key_Protab[functionID]);
ptr();
--
Christian Ludlam
address@hidden
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list