4. Software Structure
32-bit MCU Current Sensing Board Design Guide
14
Figure 10. Example Code 1/2 showing StateMachine Function Structure
Figure 10 shows the first half of example code that is implemented in the StateMachine function. The
example code operates as follows:
1.
When the StateMachine function is called, the event and current State is stored as parameters.
2.
During the current State, next State is set according to the event. For example, when the
current State is S_OFF, if a button is pressed, an event = E_ON and Next_State = S_ON.
3.
The event is classified by the length how long it is pressed.