Advertisement
RobertBerger

fsm

Nov 5th, 2021
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /* traffic light FSM */
  2. void vTask2(void *pvParameters) {
  3. const char *pcTaskName = "Task 2 is running\n";
  4. int *pxPedestrianMessage;
  5. int pedestrianVal;
  6. current_state = STATE_0;
  7.  
  8. /* As per most tasks, this task is implemented in an infinite loop. */
  9. for (;;) {
  10. /* Print out the name of this task. */
  11. vPrintString(pcTaskName);
  12. /* here we are in STATE_0 */
  13. long_delay();
  14. FSM(EVENT_FOR_STATE_1);
  15. short_delay();
  16. FSM(EVENT_FOR_STATE_2);
  17. short_delay();
  18. FSM(EVENT_FOR_STATE_3);
  19. short_delay();
  20. FSM(EVENT_FOR_STATE_4);
  21. long_delay();
  22. FSM(EVENT_FOR_STATE_5);
  23. short_delay();
  24. FSM(EVENT_FOR_STATE_6);
  25. short_delay();
  26. #if 0
  27. /* don't block on message */
  28. if (xQueueReceive( xQPedestrian, &( pxPedestrianMessage ), ( portTickType ) 0 )) {
  29. /* pxPedestrianMessage either enables or disables
  30. * the pedestrian functionality
  31. */
  32. if ((int) pxPedestrianMessage == 1) {
  33. FSM(EVENT_FOR_STATE_8);
  34. long_delay();
  35. FSM(EVENT_FOR_STATE_9);
  36. short_delay();
  37. }
  38. }
  39. #endif
  40. FSM(EVENT_FOR_STATE_7);
  41. short_delay();
  42. FSM(EVENT_FOR_STATE_0);
  43. /* here we are back to STATE_0
  44. * let's re-enable the shell in case it was disabled before
  45. */
  46. if (GetUseInputVal() == 0) {
  47. SetUseInputVal(1);
  48. }
  49. }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement