CASE statement here quite appropriate, I dont see anything to gain by using f() pointer.
That being said would be instructive to write it both ways and see if compiler is more
efficient with f() pointer references versus standard CASE.
I had a problem where I was running out of code space in an application, so did a program
wide conversion to pointers for values. Compiler gave me back ~ 25% freed up code space.
So makes me wonder how compiler does with f() pointers......is there less stack thrashing
for example that would impact ISR servicing or general thruput......
That being said I confess to never having used a f() pointer, although I can think of a couple
of applications where I should have investigated their use in hindsight.
I am not an expert here in C or any of the other languages I have used, for your information.
As an aside here is another way of doing traffic light state machine (on ARM) :
This used a tiny fraction of this SOC's resources......
Regards, Dana.