Кстати, из С модифицировать SP - это нужно очень четко представлять, что произойдет.
#include
#include
#include
#include struct f_struct
{
int data;
void (*func1)(void);
void (*func2)(void);
void (*func3)(void);
};
void function1(void)
{
PORTB = 1;
}
void function2(void)
{
PORTB = 2;
}
void function3(void)
{
PORTB = 3;
}
PROGMEM const struct f_struct functions =
{
100, // this is data
function1,
function2,
function3
};
int main(void)
{
void (*fptr)(void);
for (;;)
{
fptr = (void (*)(void))pgm_read_word(&functions.func1); // read address
fptr(); // call
fptr = (void (*)(void))pgm_read_word(&functions.func2);
fptr();
fptr = (void (*)(void))pgm_read_word(&functions.func3);
fptr();
}
return 0;
}