Aug 24, 2022 #1 A adnan012 Advanced Member level 1 Joined Oct 6, 2006 Messages 468 Helped 2 Reputation 4 Reaction score 2 Trophy points 1,298 Activity points 4,923 What this piece of code is doing? Code: typedef enum { st_idle = 0, st_init = 1, st_run = 2, st_rst = 3, }state_t; typedef enum { ev_none = 0, ev_any = 1, ev_key_pressed = 2, ev_cmd = 3, ev_time_out = 4, }event_t; typedef struct { state_t current_event; event_t event; state_t next_state; }stateTranMatrix; static stateTranMatrix st_Matrix[] = { {st_idle , ev_none , st_init}, {st_init , ev_none , st_idle}, }; Regards! [moderator action: added CODE tags] Last edited by a moderator: Aug 24, 2022
What this piece of code is doing? Code: typedef enum { st_idle = 0, st_init = 1, st_run = 2, st_rst = 3, }state_t; typedef enum { ev_none = 0, ev_any = 1, ev_key_pressed = 2, ev_cmd = 3, ev_time_out = 4, }event_t; typedef struct { state_t current_event; event_t event; state_t next_state; }stateTranMatrix; static stateTranMatrix st_Matrix[] = { {st_idle , ev_none , st_init}, {st_init , ev_none , st_idle}, }; Regards! [moderator action: added CODE tags]
Aug 24, 2022 #2 D doraemon Super Moderator Staff member Joined Jun 21, 2009 Messages 1,257 Helped 292 Reputation 592 Reaction score 305 Trophy points 1,363 Location Japan Activity points 12,979 Hello! This piece of code is not doing much. It just defines enumerations (typedef enum), defines a structure and a matrix. That's about it. Without seeing the rest of the code, it's hard to predict what it will actually do. Dora. Upvote 0 Downvote
Hello! This piece of code is not doing much. It just defines enumerations (typedef enum), defines a structure and a matrix. That's about it. Without seeing the rest of the code, it's hard to predict what it will actually do. Dora.
Aug 24, 2022 #3 A adnan012 Advanced Member level 1 Joined Oct 6, 2006 Messages 468 Helped 2 Reputation 4 Reaction score 2 Trophy points 1,298 Activity points 4,923 A Function Pointer Based State Machine A step-by-step tutorial on building a function pointer based state machine. blog.mbedded.ninja What is the entry point of this state machine? How to call it from main()? Last edited by a moderator: Aug 24, 2022 Upvote 0 Downvote
A Function Pointer Based State Machine A step-by-step tutorial on building a function pointer based state machine. blog.mbedded.ninja What is the entry point of this state machine? How to call it from main()?
Aug 24, 2022 #4 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,478 Helped 14,756 Reputation 29,794 Reaction score 14,120 Trophy points 1,393 Location Bochum, Germany Activity points 298,338 According to blog the author provides a working example at github. Why don't you simply run it? Blog chapter 10 discusses how to call the state machine. Upvote 0 Downvote
According to blog the author provides a working example at github. Why don't you simply run it? Blog chapter 10 discusses how to call the state machine.