Module Design Guidelines for Real-Time Systems by David Janik Example 1: APPLICATION -include -abc.h -xyz.h -pdq.h -ABC -abc.c /* #include "pdq.h" to use services of module PDQ */ -abc_appSpec.h -XYZ -xyz.c /* #include "pdq.h" to use services of module PDQ */ -xyz_appSpec.h -PDQ -pdq.c -pdq_appSpec.h Example 2: APPLICATION -include -abc.h -xyz.h -pdq.h ABC -abc.c -abc_appSpec.h -abc_map.h -abc_internal.c -abc_internal.h -XYZ -xyz.c -xyz_appSpec.h -PDQ -pdq.c -pdq_appSpec.h Example 3: APPLICATION -include -abc.h -xyz.h -pdq.h ABC -abcMessage.c -abcControl.c -abc_appSpec.h -abc_map.h -abc_task.c -abc_task.h -abc_utilities.c -abc_utilities.h -XYZ -xyz.c -xyz_appSpec.h -PDQ -pdq.c -pdq_appSpec.h Listing One (a) /* Name: abc.c */ /* Description: */ /* Developer: */ #include abc.h #include abc_appSpec.h #include pdq.h /* prototype for pdqAction() */ #include rtos.h /* prototype for rtosStartTask() */ /*** Protected Data ***/ typedef { int mode; int *device; }abc_struct abc_struct abc_data[ABC_INSTANCES]; /*** Internal Functions Prototypes ***/ int abc_instanceCheck(int instance); int abc_messageCheck(int message); /*** Internal Functions ***/ int abc_instanceCheck(int instance) { int result = ABC_ERROR; if (instance < ABC_INSTANCE) { result = ABC_OK; } return (result); } /*** ***/ int abc_messageCheck(int message) { int result = ABC_ERROR; if (message == ABC_MESSAGE_1 || message == ABC_MESSAGE_2) { result = ABC_OK; } return (result); /*** External Functions ***/ int abcInit() { int i; for (i=0; i= ABC_INSTANCE) { instance = 0; } } } (c) /* Name: abc_internal.h */ /* Description: */ /* Developer: */ /*** Internal Functions ***/ int abc_instanceCheck(int instance); int abc_messageCheck(int message); int abc_task(void); (d) /* Name: abc_map.h */ /* Description: */ /* Developer: */ /*** Protected Data ***/ typedef { int mode; int *device; }abc_struct extern abc_struct abc_data[ABC_INSTANCES]; (e) /* Name: abc.h */ /* Description: */ /* Developer: */ #define ABC_ERROR 1 #define ABC_OK 0 #define ABC_MESSAGE_1 1 #define ABC_MESSAGE_2 2 int abcInit(void); int abcModeGet(int instance, int *mode); int abcMessageSend(int instance, int message); (f) /* Name: abc_appSpec..h */ /* Description: */ /* Developer: */ #define ABC_INSTANCES 10 #define ABC_BASE_ADDRESS 0x1230 #define ABC_IRQ 7 #define ABC_PRIORITY 5 #define ABC_PAUSE 100 /* 1 second */ Listing Three (a) /* Name: abcControl.c */ /* Description: */ /* Developer: */ #include abc.h #include abc_appSpec.h #include abc_utilities.h #include abc_map.h #include abc_task.h #include pdq.h /* prototype for pdqAction() */ #include rtos.h /* prototype for rtosStartTask() */ /*** Protected Data ***/ abc_struct abc_data[ABC_INSTANCES]; /* declare Protected Data Structure */ /*** External Functions ***/ int abcInit() { int i; for (i=0; i= ABC_INSTANCE) { instance = 0; } } } (g) /* Name: abc_task.h */ /* Description: */ /* Developer: */ /*** Internal Functions ***/ int abc_task(void); (h) /* Name: abc_map.h */ /* Description: */ /* Developer: */ /*** Protected Data ***/ typedef { int mode; int *device; }abc_struct extern abc_struct abc_data[ABC_INSTANCES]; (i) /* Name: abc_appSpec..h */ /* Description: */ /* Developer: */ #define ABC_INSTANCES 10 #define ABC_BASE_ADDRESS 0x1230 #define ABC_IRQ 7 #define ABC_PRIORITY 5 #define ABC_PAUSE 100 /* 1 second */ 10