Skip to content

Instantly share code, notes, and snippets.

@michaellin
Created December 2, 2015 21:38
Show Gist options
  • Save michaellin/5ab865a48a124089506f to your computer and use it in GitHub Desktop.
Save michaellin/5ab865a48a124089506f to your computer and use it in GitHub Desktop.
/****************************************************************************
Module
ES_Configure.h
Description
This file contains macro definitions that are edited by the user to
adapt the Events and Services framework to a particular application.
Notes
History
When Who What/Why
-------------- --- --------
10/11/15 18:00 jec added new event type ES_SHORT_TIMEOUT
10/21/13 20:54 jec lots of added entries to bring the number of timers
and services up to 16 each
08/06/13 14:10 jec removed PostKeyFunc stuff since we are moving that
functionality out of the framework and putting it
explicitly into the event checking functions
01/15/12 10:03 jec started coding
*****************************************************************************/
#ifndef CONFIGURE_H
#define CONFIGURE_H
/****************************************************************************/
// The maximum number of services sets an upper bound on the number of
// services that the framework will handle. Reasonable values are 8 and 16
// corresponding to an 8-bit(uint8_t) and 16-bit(uint16_t) Ready variable size
#define MAX_NUM_SERVICES 16
/****************************************************************************/
// This macro determines that nuber of services that are *actually* used in
// a particular application. It will vary in value from 1 to MAX_NUM_SERVICES
#define NUM_SERVICES 11
/****************************************************************************/
// These are the definitions for Service 0, the lowest priority service.
// Every Events and Services application must have a Service 0. Further
// services are added in numeric sequence (1,2,3,...) with increasing
// priorities
// the header file with the public function prototypes
#define SERV_0_HEADER "PipeSegment.h"
// the name of the Init function
#define SERV_0_INIT InitPipeSegment
// the name of the run function
#define SERV_0_RUN RunPipeSegment
// How big should this services Queue be?
#define SERV_0_QUEUE_SIZE 5
/****************************************************************************/
// The following sections are used to define the parameters for each of the
// services. You only need to fill out as many as the number of services
// defined by NUM_SERVICES
/****************************************************************************/
// These are the definitions for Service 1
#if NUM_SERVICES > 1
// the header file with the public function prototypes
#define SERV_1_HEADER "BucketService.h"
// the name of the Init function
#define SERV_1_INIT InitBucketService
// the name of the run function
#define SERV_1_RUN RunBucketService
// How big should this services Queue be?
#define SERV_1_QUEUE_SIZE 8
#endif
/****************************************************************************/
// These are the definitions for Service 2
#if NUM_SERVICES > 2
// the header file with the public function prototypes
#define SERV_2_HEADER "WrenchService.h"
// the name of the Init function
#define SERV_2_INIT InitializeWrenchService
// the name of the run function
#define SERV_2_RUN RunWrenchService
// How big should this services Queue be?
#define SERV_2_QUEUE_SIZE 5
#endif
/****************************************************************************/
// These are the definitions for Service 3
#if NUM_SERVICES > 3
// the header file with the public function prototypes
#define SERV_3_HEADER "Audio1.h"
// the name of the Init function
#define SERV_3_INIT InitAudio1
// the name of the run function
#define SERV_3_RUN RunAudio1
// How big should this services Queue be?
#define SERV_3_QUEUE_SIZE 5
#endif
/****************************************************************************/
// These are the definitions for Service 4
#if NUM_SERVICES > 4
// the header file with the public function prototypes
#define SERV_4_HEADER "UncleEdSM.h"
// the name of the Init function
#define SERV_4_INIT InitUncleEd
// the name of the run function
#define SERV_4_RUN RunUncleEd
// How big should this services Queue be?
#define SERV_4_QUEUE_SIZE 5
#endif
/****************************************************************************/
// These are the definitions for Service 5
#if NUM_SERVICES > 5
// the header file with the public function prototypes
#define SERV_5_HEADER "LCDService.h"
// the name of the Init function
#define SERV_5_INIT InitLCDService
// the name of the run function
#define SERV_5_RUN RunLCDService
// How big should this services Queue be?
#define SERV_5_QUEUE_SIZE 5
#endif
/****************************************************************************/
// These are the definitions for Service 6
#if NUM_SERVICES > 6
// the header file with the public function prototypes
#define SERV_6_HEADER "LCDMessage.h"
// the name of the Init function
#define SERV_6_INIT InitLCDMessage
// the name of the run function
#define SERV_6_RUN RunLCDMessage
// How big should this services Queue be?
#define SERV_6_QUEUE_SIZE 5
#endif
/****************************************************************************/
// These are the definitions for Service 7
#if NUM_SERVICES > 7
// the header file with the public function prototypes
#define SERV_7_HEADER "Pipe2ButtonDebounce.h"
// the name of the Init function
#define SERV_7_INIT InitPipe2ButtonDB
// the name of the run function
#define SERV_7_RUN RunPipe2ButtonDB
// How big should this services Queue be?
#define SERV_7_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 8
#if NUM_SERVICES > 8
// the header file with the public function prototypes
#define SERV_8_HEADER "Audio2.h"
// the name of the Init function
#define SERV_8_INIT InitAudio2
// the name of the run function
#define SERV_8_RUN RunAudio2
// How big should this services Queue be?
#define SERV_8_QUEUE_SIZE 5
#endif
/****************************************************************************/
// These are the definitions for Service 9
#if NUM_SERVICES > 9
// the header file with the public function prototypes
#define SERV_9_HEADER "Pipe1ButtonDebounce.h"
// the name of the Init function
#define SERV_9_INIT InitPipe1ButtonDB
// the name of the run function
#define SERV_9_RUN RunPipe1ButtonDB
// How big should this services Queue be?
#define SERV_9_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 10
#if NUM_SERVICES > 10
// the header file with the public function prototypes
#define SERV_10_HEADER "StartButtonDebounce.h"
// the name of the Init function
#define SERV_10_INIT InitStartButtonDB
// the name of the run function
#define SERV_10_RUN RunStartButtonDB
// How big should this services Queue be?
#define SERV_10_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 11
#if NUM_SERVICES > 11
// the header file with the public function prototypes
#define SERV_11_HEADER "TestHarnessService11.h"
// the name of the Init function
#define SERV_11_INIT InitTestHarnessService11
// the name of the run function
#define SERV_11_RUN RunTestHarnessService11
// How big should this services Queue be?
#define SERV_11_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 12
#if NUM_SERVICES > 12
// the header file with the public function prototypes
#define SERV_12_HEADER "TestHarnessService12.h"
// the name of the Init function
#define SERV_12_INIT InitTestHarnessService12
// the name of the run function
#define SERV_12_RUN RunTestHarnessService12
// How big should this services Queue be?
#define SERV_12_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 13
#if NUM_SERVICES > 13
// the header file with the public function prototypes
#define SERV_13_HEADER "TestHarnessService13.h"
// the name of the Init function
#define SERV_13_INIT InitTestHarnessService13
// the name of the run function
#define SERV_13_RUN RunTestHarnessService13
// How big should this services Queue be?
#define SERV_13_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 14
#if NUM_SERVICES > 14
// the header file with the public function prototypes
#define SERV_14_HEADER "TestHarnessService14.h"
// the name of the Init function
#define SERV_14_INIT InitTestHarnessService14
// the name of the run function
#define SERV_14_RUN RunTestHarnessService14
// How big should this services Queue be?
#define SERV_14_QUEUE_SIZE 3
#endif
/****************************************************************************/
// These are the definitions for Service 15
#if NUM_SERVICES > 15
// the header file with the public function prototypes
#define SERV_15_HEADER "TestHarnessService15.h"
// the name of the Init function
#define SERV_15_INIT InitTestHarnessService15
// the name of the run function
#define SERV_15_RUN RunTestHarnessService15
// How big should this services Queue be?
#define SERV_15_QUEUE_SIZE 3
#endif
/****************************************************************************/
// Name/define the events of interest
// Universal events occupy the lowest entries, followed by user-defined events
typedef enum { ES_NO_EVENT = 0,
ES_ERROR, /* used to indicate an error from the service */
ES_INIT, /* used to transition from initial pseudo-state */
ES_TIMEOUT, /* signals that the timer has expired */
ES_SHORT_TIMEOUT, /* signals that a short timer has expired */
/* User-defined events start here */
ES_LCD_PUTCHAR,
ES_LCD_COMMAND,
ES_LCD_RESET,
ES_NEW_KEY, /* signals a new key received from terminal */
ES_LOCK,
ES_UNLOCK,
/** Uncle Ed Module **/
ES_START_BUTTON_DOWN,
ES_START_BUTTON_UP,
ES_START_BUTTON_DBDOWN,
ES_START_MESSAGE,
ES_CELEB_MESSAGE,
ES_FAIL_MESSAGE,
/** Bucket Module **/
ES_DRIP_SERVO_AT_BUCKET,
ES_DRIP_SERVO_AT_BOTTOM,
ES_GAINED_POINT,
ES_LOST_POINT,
ES_PIPE_RECOVERED,
ES_PIPE_DOWN_LOST,
/** Wrench Module **/
ES_ReachedLED,
ES_NotReachedLED,
ES_WRENCH2GOAL,
/** Pipe Segment Module **/
ES_PIPE1_BUTTON_DOWN,
ES_PIPE1_BUTTON_UP,
ES_PIPE2_BUTTON_DOWN,
ES_PIPE2_BUTTON_UP,
ES_PIPE1_BUTTON_DBDOWN,
ES_PIPE2_BUTTON_DBDOWN,
/** Audio Module **/
ES_PLAY_TUNE,
ES_GAMEOVER
} ES_EventTyp_t ;
/****************************************************************************/
// These are the definitions for the Distribution lists. Each definition
// should be a comma separated list of post functions to indicate which
// services are on that distribution list.
#define NUM_DIST_LISTS 1
#if NUM_DIST_LISTS > 0
#define DIST_LIST0 PostPipeSegment, PostBucketService, PostWrenchService, PostAudio1, PostAudio2
#endif
#if NUM_DIST_LISTS > 1
#define DIST_LIST1 PostTemplateFSM
#endif
#if NUM_DIST_LISTS > 2
#define DIST_LIST2 PostTemplateFSM
#endif
#if NUM_DIST_LISTS > 3
#define DIST_LIST3 PostTemplateFSM
#endif
#if NUM_DIST_LISTS > 4
#define DIST_LIST4 PostTemplateFSM
#endif
#if NUM_DIST_LISTS > 5
#define DIST_LIST5 PostTemplateFSM
#endif
#if NUM_DIST_LISTS > 6
#define DIST_LIST6 PostTemplateFSM
#endif
#if NUM_DIST_LISTS > 7
#define DIST_LIST7 PostTemplateFSM
#endif
/****************************************************************************/
// This are the name of the Event checking funcion header file.
#define EVENT_CHECK_HEADER "EventCheckers.h"
/****************************************************************************/
// This is the list of event checking functions
#define EVENT_CHECK_LIST CheckStartButtonEvents, CheckPipe1ButtonEvents, CheckPipe2ButtonEvents, CheckWrenchEvents
/****************************************************************************/
// 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 timer, then you should use TIMER_UNUSED
// Unlike services, any combination of timers may be used and there is no
// priority in servicing them
#define TIMER_UNUSED ((pPostFunc)0)
#define TIMER0_RESP_FUNC TIMER_UNUSED
#define TIMER1_RESP_FUNC ES_PostList00
#define TIMER2_RESP_FUNC PostBucketService
#define TIMER3_RESP_FUNC PostUncleEd //ES_PostAll //Either post to all or post to all from Uncle Ed service
#define TIMER4_RESP_FUNC PostWrenchService
#define TIMER5_RESP_FUNC TIMER_UNUSED
#define TIMER6_RESP_FUNC PostBucketService
#define TIMER7_RESP_FUNC PostLCDMessage
#define TIMER8_RESP_FUNC PostAudio1
#define TIMER9_RESP_FUNC PostAudio2
#define TIMER10_RESP_FUNC PostUncleEd
#define TIMER11_RESP_FUNC PostUncleEd
#define TIMER12_RESP_FUNC TIMER_UNUSED
#define TIMER13_RESP_FUNC PostStartButton
#define TIMER14_RESP_FUNC PostPipe1Button
#define TIMER15_RESP_FUNC PostPipe2Button
/****************************************************************************/
// Give the timer numbers symbolc names to make it easier to move them
// to different timers if the need arises. Keep these definitions close to the
// definitions for the response functions to make it easier to check that
// the timer number matches where the timer event will be routed
// These symbolic names should be changed to be relevant to your application
/** Bucket Timers **/
#define DRIP_SETOFF_TIMER 6
#define DRIP_SPEED_TIMER 2
/** Pipe Timers **/
#define PIPE_TIMER 1
#define DB_PIPE1_TIMER 14
#define DB_PIPE2_TIMER 15
/** Audio Timers **/
#define AUDIO1_TIMER 8
#define AUDIO2_TIMER 9
/** Ed Timers **/
#define DB_START_TIMER 13
#define ED_TIMER 3
#define START_BUTTON_TIMER 10
#define LCD_TIMER 7
#define UNCLE_ED_INTERNAL_TIMER 11
/** Wrench Timer **/
#define WrenchOnLED 4
#endif /* CONFIGURE_H */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment