#include #include #include #include void delay (void) { volatile uint32_t i; for (i=100000; i; i--) ; } void f0 (void) { PORTB = _BV (0); } void f1 (void) { PORTB = _BV (1); } void f2 (void) { PORTB = _BV (2); } void f3 (void) { PORTB = _BV (3); } void f4 (void) { PORTB = _BV (4); } void f5 (void) { PORTB = _BV (5); } void f6 (void) { PORTB = _BV (6); } void f7 (void) { PORTB = _BV (7); } typedef void (*func_t) (void); func_t func_list [] PROGMEM = { f0, f1, f2, f3, f4, f5, f6, f7, NULL }; int main (void) { func_t fp = (func_t) func_list; PORTB = 0xff; DDRB = 0xff; while (1) { volatile func_t func = (func_t) pgm_read_word (fp); if (func == NULL) break; func (); delay (); #if 0 fp++; #else fp += 2; /* <-- Notice that fp++ does not work! */ #endif } PORTB = 0xff; return 0; }