kiishor / UML-State-Machine-in-C

A minimalist UML State machine framework for finite state machine and hierarchical state machine in C
MIT License
170 stars 47 forks source link

building for embedded targets #36

Open SergeTauger opened 3 years ago

SergeTauger commented 3 years ago

Could you please provide a hint on how to build for AVR or STM32? Cmakelists in demo folder have set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") string. Is it enough to add platform-dependent headers, throw away pthreads and add if(dispatch_event(State_Machines, 1) == EVENT_UN_HANDLED){...} to firmware infinite loop?

kiishor commented 3 years ago

Hi Sergey,

I haven't used cmake to generate a build for any embedded platform. Anyway, you don't need pthread to use the state machine framework. In the demo, it is a way to simulate an interrupt to generate events for the framework on windows OS.

Hence, you can remove pthread and add if(dispatch_event(State_Machines, 1) == EVENT_UN_HANDLED){...} to firmware infinite loop. Use interrupts to generate events for the state machine framework. The framework contains only two files hsm.c & hsm.h. It is platform & OS independendent.

If you need further support on how to use this framework for the embedded platform, feel free to share your repository (or create a demo repo).

Regards, Nandkishor