//#define TEST #include #include #include // the headers to access the GPIO subsystem #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "inc/hw_sysctl.h" // the headers to access the TivaWare Library #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/gpio.h" #include "driverlib/timer.h" #include "driverlib/interrupt.h" #include "ES_Configure.h" #include "ES_Framework.h" #include "ES_Timers.h" #include "ES_Port.h" #include "ES_Types.h" #include "termio.h" #include "EnablePA25_PB23_PD7_PF0.h" #include "Master.h" #include "PassageOfTime.h" #include "Servo.h" #include "ADMulti.h" //IcebergUpAngle is the servo angle polar bear is raised //TimeToRise is the time for polar bear to rise to that position //IntervalBetweenFalls is the time between polar bear's falling //AngleChange is the change of angle every time the polar bear falls #define IcebergUpAngle 90 #define TimeToRise 1000 #define IntervalBetweenFalls 4000 #define AngleChange -3 static uint8_t MyPriority; static POTState_t CurrentState; static uint8_t CurrentAngle; //Init function for POT bool InitPassageOfTime(uint8_t Priority) { //set MyPriority //send BeforeInit event to this service } //post function for POT bool PostPOT(ES_Event_t ThisEvent) { //use MyPriority to post ThisEvent } //Run function for POT ES_Event_t RunPOT(ES_Event_t ThisEvent ){ //check CurrentState //switch CurrentState //case BeforeInit //if receive ES_INIT //set servo to start position //start timer for rising //set CurrentState to raising //case Raising //if rsing timeout //set CurrentState to Welcome_POT //set CurrentAngle to up position angle //case Welcome_POT //if receive GAME_START //set CurrentState to Falling //start timer for falling Interval //set servo angle to lower polar bear //case Falling: //if receive timeout //update servo angle //start timer for falling Interval //set servo angle to lower polar bear //if receive GAME_OVER //stop falling timer //set CurrentState to celebration //if receive RESET //set servo to start position //start timer for rising //set CurrentState to raising //case Celebration_POT //if receive RESET //set servo to start position //start timer for rising //set CurrentState to raising //return ReturnEvent }