The code for an extended Task that contains activities A21 and A22 will resemble the following:
cgSingleBuffer_TASK2.eventMask = 0xff;
WaitEvent(cgSingleBuffer_TASK2.eventMask);
ClearEvent(cgSingleBuffer_TASK2.eventMask);
cgSingleBuffer_TASK2.eventMask = 0xff;
cgGlobalFlags &= ~BITSUPERSTEP_TASK2;
if(cgDoubleBufferNew_TASK2.cg_Events)
cgGlobalFlags |= BITSUPERSTEP_TASK2;
cgDoubleBufferOld_TASK2 = cgDoubleBufferNew_TASK2;
cgDoubleBufferNew_TASK2.cg_Events = 0;
} while ( (cgGlobalFlags & BITSUPERSTEP_TASK2) != 0);
WaitEvent(cgSingleBuffer_TASK2.eventMask);
GetEvent(TASK2, &cgSingleBuffer_TASK2.eventsBuff);
ClearEvent(cgSingleBuffer_TASK2.eventMask);
If the Task is periodic, with a period of 10 ticks, the code will resemble the following:
SetRelAlarm(TASK2_ALARM, 1, 10);
cgSingleBuffer_TASK2.eventMask = 0xff;
cgGlobalFlags &= ~BITSUPERSTEP_TASK2;
if(cgDoubleBufferNew_TASK2.cg_Events)
cgGlobalFlags |= BITSUPERSTEP_TASK2;
cgDoubleBufferOld_TASK2 = cgDoubleBufferNew_TASK2;
cgDoubleBufferNew_TASK2.cg_Events = 0;
} while ( (cgGlobalFlags & BITSUPERSTEP_TASK2) != 0);
WaitEvent(cgSingleBuffer_TASK2.eventMask);
GetEvent(TASK2, &cgSingleBuffer_TASK2.eventsBuff);
ClearEvent(cgSingleBuffer_TASK2.eventMask);