GitLab system status is available here and here

Commit 7971a736 authored by Singaravelavan Rajesh's avatar Singaravelavan Rajesh
Browse files

Actual PArt 6

parent 64198602
......@@ -20,7 +20,7 @@
//defines for keyboard input
//#define USE_KEYBOARD_INPUT
//What State machine are we testing
//#define POSTFUNCTION_FOR_KEYBOARD_INPUT PostTemplateService
//#define POSTFUNCTION_FOR_KEYBOARD_INPUT PostTemplateFSM
//define for TattleTale
#define USE_TATTLETALE
......@@ -46,7 +46,6 @@ typedef enum {
/* User-defined events start here */
BATTERY_CONNECTED,
BATTERY_DISCONNECTED,
NUMBEROFEVENTS,
LIGHT,
DARK,
FRONT,
......@@ -55,7 +54,9 @@ typedef enum {
FL,
BR,
BL,
NB
NB,
NUMBEROFEVENTS,
} ES_EventTyp_t;
static const char *EventNames[] = {
......@@ -71,7 +72,6 @@ static const char *EventNames[] = {
"ES_TIMERSTOPPED",
"BATTERY_CONNECTED",
"BATTERY_DISCONNECTED",
"NUMBEROFEVENTS",
"LIGHT",
"DARK",
"FRONT",
......@@ -80,6 +80,8 @@ static const char *EventNames[] = {
"FL",
"BR",
"BL",
"NB",
"NUMBEROFEVENTS",
};
......@@ -87,18 +89,20 @@ static const char *EventNames[] = {
/****************************************************************************/
// This are the name of the Event checking function header file.
#define EVENT_CHECK_HEADER "TemplateEventChecker.h"
//#define EVENT_CHECK_HEADER "TemplateEventChecker.h"
#define EVENT_CHECK_HEADER "TemplateEventChecker.h"
#define EVENT_CHECK_LIST TemplateCheckBattery, CheckLight
/****************************************************************************/
// This is the list of event checking functions
#define EVENT_CHECK_LIST TemplateCheckBattery, CheckLight
//#define EVENT_CHECK_LIST TemplateCheckBattery, CheckLight
/****************************************************************************/
// These are the definitions for the post functions to be executed when the
// corresponding timer expires. All 16 must be defined. If you are not using
// a timers, then you can use TIMER_UNUSED
#define TIMER_UNUSED ((pPostFunc)0)
#define TIMER0_RESP_FUNC PostTemplateService
//#define TIMER0_RESP_FUNC PostTemplateService
#define TIMER0_RESP_FUNC PostTemplateService
#define TIMER1_RESP_FUNC TIMER_UNUSED
#define TIMER2_RESP_FUNC TIMER_UNUSED
#define TIMER3_RESP_FUNC TIMER_UNUSED
......
This diff is collapsed.
/*
* File: TemplateFSM.c
* Author: J. Edward Carryer
* Modified: Gabriel H Elkaim
*
* Template file to set up a Flat State Machine to work with the Events and Services
* Frameword (ES_Framework) on the Uno32 for the CMPE-118/L class. Note that this file
* will need to be modified to fit your exact needs, and most of the names will have
* to be changed to match your code.
*
* This is provided as an example and a good place to start.
*
*Generally you will just be modifying the statenames and the run function
*However make sure you do a find and replace to convert every instance of
* "Template" to your current state machine's name
* History
* When Who What/Why
* -------------- --- --------
* 09/13/13 15:17 ghe added tattletail functionality and recursive calls
* 01/15/12 11:12 jec revisions for Gen2 framework
* 11/07/11 11:26 jec made the queue static
* 10/30/11 17:59 jec fixed references to CurrentEvent in RunTemplateSM()
* 10/23/11 18:20 jec began conversion from SMTemplate.c (02/20/07 rev)
*/
/*******************************************************************************
* MODULE #INCLUDE *
******************************************************************************/
#include "ES_Configure.h"
#include "ES_Framework.h"
#include "roach.h"
#include "TemplateFSM.h"
#include <BOARD.h>
//Uncomment these for the Roaches
//#include "roach.h"
//#include "RoachFrameworkEvents.h"
#include <stdio.h>
/*******************************************************************************
* MODULE #DEFINES *
******************************************************************************/
/*******************************************************************************
* PRIVATE FUNCTION PROTOTYPES *
******************************************************************************/
/* Prototypes for private functions for this machine. They should be functions
relevant to the behavior of this state machine.*/
/*******************************************************************************
* PRIVATE MODULE VARIABLES *
******************************************************************************/
/* You will need MyPriority and the state variable; you may need others as well.
* The type of state variable should match that of enum in header file. */
typedef enum {
InitPState,
FirstState,
} TemplateFSMState_t;
static const char *StateNames[] = {
"InitPState",
"FirstState",
};
static TemplateFSMState_t CurrentState = InitPState; // <- change enum name to match ENUM
static uint8_t MyPriority;
/*******************************************************************************
* PUBLIC FUNCTIONS *
******************************************************************************/
/**
* @Function InitTemplateFSM(uint8_t Priority)
* @param Priority - internal variable to track which event queue to use
* @return TRUE or FALSE
* @brief This will get called by the framework at the beginning of the code
* execution. It will post an ES_INIT event to the appropriate event
* queue, which will be handled inside RunTemplateFSM function. Remember
* to rename this to something appropriate.
* Returns TRUE if successful, FALSE otherwise
* @author J. Edward Carryer, 2011.10.23 19:25 */
uint8_t InitTemplateFSM(uint8_t Priority)
{
MyPriority = Priority;
// put us into the Initial PseudoState
CurrentState = InitPState;
// post the initial transition event
if (ES_PostToService(MyPriority, INIT_EVENT) == TRUE) {
return TRUE;
} else {
return FALSE;
}
}
/**
* @Function PostTemplateFSM(ES_Event ThisEvent)
* @param ThisEvent - the event (type and param) to be posted to queue
* @return TRUE or FALSE
* @brief This function is a wrapper to the queue posting function, and its name
* will be used inside ES_Configure to point to which queue events should
* be posted to. Remember to rename to something appropriate.
* Returns TRUE if successful, FALSE otherwise
* @author J. Edward Carryer, 2011.10.23 19:25 */
uint8_t PostTemplateFSM(ES_Event ThisEvent)
{
return ES_PostToService(MyPriority, ThisEvent);
}
/**
* @Function RunTemplateFSM(ES_Event ThisEvent)
* @param ThisEvent - the event (type and param) to be responded.
* @return Event - return event (type and param), in general should be ES_NO_EVENT
* @brief This function is where you implement the whole of the flat state machine,
* as this is called any time a new event is passed to the event queue. This
* function will be called recursively to implement the correct order for a
* state transition to be: exit current state -> enter next state using the
* ES_EXIT and ES_ENTRY events.
* @note Remember to rename to something appropriate.
* Returns ES_NO_EVENT if the event have been "consumed."
* @author J. Edward Carryer, 2011.10.23 19:25 */
ES_Event RunTemplateFSM(ES_Event ThisEvent)
{
uint8_t makeTransition = FALSE; // use to flag transition
TemplateFSMState_t nextState; // <- need to change enum type here
ES_Tattle(); // trace call stack
switch (CurrentState) {
case InitPState: // If current state is initial Psedudo State
if (ThisEvent.EventType == ES_INIT)// only respond to ES_Init
{
// this is where you would put any actions associated with the
// transition from the initial pseudo-state into the actual
// initial state
// now put the machine into the actual initial state
nextState = FirstState;
makeTransition = TRUE;
ThisEvent.EventType = ES_NO_EVENT;
}
break;
case FirstState: // in the first state, replace this with appropriate state
break;
default: // all unhandled states fall into here
break;
} // end switch on Current State
if (makeTransition == TRUE) { // making a state transition, send EXIT and ENTRY
// recursively call the current state with an exit event
RunTemplateFSM(EXIT_EVENT);
CurrentState = nextState;
RunTemplateFSM(ENTRY_EVENT);
}
ES_Tail(); // trace call stack end
return ThisEvent;
}
/*******************************************************************************
* PRIVATE FUNCTIONS *
******************************************************************************/
/*
* File: TemplateFSM.h
* Author: J. Edward Carryer
* Modified: Gabriel H Elkaim
*
* Template file to set up a Flat State Machine to work with the Events and Services
* Framework (ES_Framework) on the Uno32 for the CMPE-118/L class. Note that this file
* will need to be modified to fit your exact needs, and most of the names will have
* to be changed to match your code.
*
* This is provided as an example and a good place to start.
*
* Created on 23/Oct/2011
* Updated on 16/Sep/2013
* Modified by MaxL on 8/11/2014
*/
#ifndef FSM_Template_H // <- This should be changed to your own guard on both
#define FSM_Template_H // of these lines
/*******************************************************************************
* PUBLIC #INCLUDES *
******************************************************************************/
#include "ES_Configure.h" // defines ES_Event, INIT_EVENT, ENTRY_EVENT, and EXIT_EVENT
/*******************************************************************************
* PUBLIC #DEFINES *
******************************************************************************/
/*******************************************************************************
* PUBLIC TYPEDEFS *
******************************************************************************/
/*******************************************************************************
* PUBLIC FUNCTION PROTOTYPES *
******************************************************************************/
/**
* @Function InitTemplateFSM(uint8_t Priority)
* @param Priority - internal variable to track which event queue to use
* @return TRUE or FALSE
* @brief This will get called by the framework at the beginning of the code
* execution. It will post an ES_INIT event to the appropriate event
* queue, which will be handled inside RunTemplateFSM function. Remember
* to rename this to something appropriate.
* Returns TRUE if successful, FALSE otherwise
* @author J. Edward Carryer, 2011.10.23 19:25 */
uint8_t InitTemplateFSM(uint8_t Priority);
/**
* @Function PostTemplateFSM(ES_Event ThisEvent)
* @param ThisEvent - the event (type and param) to be posted to queue
* @return TRUE or FALSE
* @brief This function is a wrapper to the queue posting function, and its name
* will be used inside ES_Configure to point to which queue events should
* be posted to. Remember to rename to something appropriate.
* Returns TRUE if successful, FALSE otherwise
* @author J. Edward Carryer, 2011.10.23 19:25 */
uint8_t PostTemplateFSM(ES_Event ThisEvent);
/**
* @Function RunTemplateFSM(ES_Event ThisEvent)
* @param ThisEvent - the event (type and param) to be responded.
* @return Event - return event (type and param), in general should be ES_NO_EVENT
* @brief This function is where you implement the whole of the flat state machine,
* as this is called any time a new event is passed to the event queue. This
* function will be called recursively to implement the correct order for a
* state transition to be: exit current state -> enter next state using the
* ES_EXIT and ES_ENTRY events.
* @note Remember to rename to something appropriate.
* Returns ES_NO_EVENT if the event have been "consumed."
* @author J. Edward Carryer, 2011.10.23 19:25 */
ES_Event RunTemplateFSM(ES_Event ThisEvent);
#endif /* FSM_Template_H */
......@@ -157,16 +157,15 @@ ES_Event RunTemplateService(ES_Event ThisEvent) {
curEvent = NB;
if (curEvent != lastEvent) { // check for change from last time
thisEvent.EventType = curEvent;
thisEvent.EventParam = currentBumper;
thisEvent.EventParam = BumperArray[0];
lastEvent = curEvent; // update history
ReturnEvent = thisEvent;
ReturnEvent = thisEvent;PostTemplateService(ReturnEvent);
//PostTemplateService(ReturnEvent);
}
}
#ifndef SIMPLESERVICE_TEST // keep this as is for test harness
PostGenericService(ReturnEvent);
#else
PostTemplateService(ReturnEvent);
#endif
}
break;
......
......@@ -4,14 +4,14 @@
<memory name="program">
<units>bytes</units>
<length>126464</length>
<used>30444</used>
<free>96020</free>
<used>30536</used>
<free>95928</free>
</memory>
<memory name="data">
<units>bytes</units>
<length>16384</length>
<used>3526</used>
<free>12858</free>
<used>3566</used>
<free>12818</free>
</memory>
</executable>
</project>
#
#Thu Mar 31 18:01:59 PDT 2022
#Thu Mar 31 19:38:12 PDT 2022
default.languagetoolchain.version=3.01
default.Pack.dfplocation=C\:\\Program Files\\Microchip\\MPLABX\\v5.50\\packs\\Microchip\\PIC32MX_DFP\\1.5.259
conf.ids=default
default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc32\\v3.01\\bin
default.com-microchip-mplab-nbide-toolchain-xc32-XC32LanguageToolchain.md5=a8d1477a0cbdce4f518d7c31ceeffdbe
host.id=31qg-ualp-6h
configurations-xml=a558afe2aa85f7a91a677007b8fde2de
configurations-xml=66f3adc896abf1073cac88fb2f4e0505
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=5232c20b48df3223daf8c79e5b83e9a8
user-defined-mime-resolver-xml=faa6c52c2e6d09892654f2df3f012679
proj.dir=C\:\\Users\\sirajesh\\Desktop\\ECE118\\ece118-lab-0\\Lab0.X
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment