3 #include "kernel_id.h"
\r
4 #include "ecrobot_interface.h"
\r
6 /*--------------------------------------------------------------------------*/
\r
7 /* OSEK declarations */
\r
8 /*--------------------------------------------------------------------------*/
\r
9 DeclareEvent(BarrierEvent);
\r
10 DeclareCounter(SysTimerCnt);
\r
11 DeclareResource(mx);
\r
12 DeclareTask(LowTask);
\r
13 DeclareTask(HighTask);
\r
15 /*--------------------------------------------------------------------------*/
\r
17 /*--------------------------------------------------------------------------*/
\r
20 /*--------------------------------------------------------------------------*/
\r
21 /* Function to be invoked from a category 2 interrupt */
\r
22 /*--------------------------------------------------------------------------*/
\r
23 void user_1ms_isr_type2()
\r
26 SignalCounter( SysTimerCnt );
\r
30 /*--------------------------------------------------------------------------*/
\r
31 /* Task information: */
\r
32 /* ----------------- */
\r
33 /* Name : LowTask */
\r
35 /* Typ : EXTENDED TASK */
\r
36 /* Schedule: preemptive */
\r
37 /*--------------------------------------------------------------------------*/
\r
46 for (hcount = 0; hcount < 10; hcount++) {
\r
50 ecrobot_debug1(digits, lowtaskcount, hightaskcount);
\r
51 /* The following loop is to wait for the ISR triggered by ecrobot_debug
\r
52 * (or the specific I/O statement inside ecrobot_debug) to complete
\r
53 * This is a good example to show how explicit/implicit shared resource
\r
54 * is needed to be protected against concurrent accesses from multiple Tasks
\r
56 for (lcount = 0; lcount < 3200; lcount++) ;
\r
58 ReleaseResource(mx);
\r
67 /*--------------------------------------------------------------------------*/
\r
68 /* Task information: */
\r
69 /* ----------------- */
\r
70 /* Name : HighTask */
\r
72 /* Typ : EXTENDED TASK */
\r
73 /* Schedule: preemptive */
\r
74 /*--------------------------------------------------------------------------*/
\r
80 for (hcount = 0; hcount < 10; hcount++) {
\r
83 ecrobot_debug2(digits, hcount, 0);
\r
84 /* The following loop is to wait for the ISR triggered by ecrobot_debug
\r
85 * (or the specific I/O statement inside ecrobot_debug) to complete
\r
86 * This is a good example to show how explicit/implicit shared resource
\r
87 * is needed to be protected against concurrent accesses from multiple Tasks
\r
89 for (lcount = 0; lcount < 3200; lcount++) ;
\r
91 ReleaseResource(mx);
\r
93 WaitEvent(BarrierEvent);
\r
94 ClearEvent(BarrierEvent);
\r