Correct way to implement a state machine in an ISR | Cypress Semiconductor
Correct way to implement a state machine in an ISR
Just getting started with the PSoC5LP (although I have used other devices for many years) and I'm not sure the best way to implement a state machine inside my ISR.
The situation is that I have a UART that is talking to a WiFi device that transfers 'packets' in each direction between the processor and the device. I want to set up a state machine (on the Rx side) that looks for the start of a packet, builds the packet (taking into account 'escape' values etc.) and sets a flag (for now) to indicate a packet has been received.
As the ISR code is the only thing that needs to know about the state values, buffers etc. with a couple of access functions, I would normally declare these things at the top of the ISR C file. As the ISR code is re-written by the IDE, I can see where I should put the definitions so they are maintained across the new versions. However I want to be able to initialise the state machine and typically that code whould go into the xx_ISR_Start() or xxx_ISR_Enable() functions but they do not have the code protection mechanisms in them.
The alternative is to add my own 'init' function but I cannot see how to add the declaration into the ".h" file as, again, there do not seem to be any of the code protection markers. (I could use 'extern' declarations but I think they are ugly in that I could update the header/c files and forget to update the 'extern' declaractions.)
What is the way this is supopsed to be done?