nobody wrote on Friday, December 16, 2005:
Here’s my actual code for the tick hook - I
thought this could be useful for someone else:
I put this in tasks.c since that was the easiet place to put it:
#if ( configUSE_TICK_HOOK == 1 )
// #define prvReadyTask( xTaskHandle pxTaskToResume )
#define prvReadyTask( pxTaskToResume )
{
tskTCB *pxTCB;
pxTCB = ( tskTCB * ) pxTaskToResume;
vListRemove ( &( pxTCB->xGenericListItem ) );
prvAddTaskToReadyQueue( pxTCB );
}
// our 16 tasks that we want to control relative to one another:
extern xTaskHandle xpcolHandle1;
extern xTaskHandle xpcolHandle2;
extern xTaskHandle xpcolHandle3;
extern xTaskHandle xpcolHandle4;
extern xTaskHandle xpcolHandle5;
extern xTaskHandle xpcolHandle6;
extern xTaskHandle xpcolHandle7;
extern xTaskHandle xpcolHandle8;
extern xTaskHandle xpcolHandle9;
extern xTaskHandle xpcolHandle10;
extern xTaskHandle xpcolHandle11;
extern xTaskHandle xpcolHandle12;
extern xTaskHandle xpcolHandle13;
extern xTaskHandle xpcolHandle14;
extern xTaskHandle xpcolHandle15;
extern xTaskHandle xpcolHandle16;
void vTaskTickHook(void);
#endif
/*-----------------------------------------------------------*/
// vTaskTickHook
/*-----------------------------------------------------------*/
#if ( configUSE_TICK_HOOK == 1 )
void vTaskTickHook( void )
{
static portBASE_TYPE xCallCount = 0;
/* We know the frequency at which this function is called. */
/* Is it time to start a task? */
// assumption - time here is in ms - note we can fix this using our
// port definitions…
switch ( xCallCount )
{
case 0: prvReadyTask( xpcolHandle1 );
break;
case 25: prvReadyTask( xpcolHandle2 );
break;
case 50: prvReadyTask( xpcolHandle3 );
break;
case 75: prvReadyTask( xpcolHandle4 );
break;
case 100: prvReadyTask( xpcolHandle5 );
break;
case 125: prvReadyTask( xpcolHandle6 );
break;
case 150: prvReadyTask( xpcolHandle7 );
break;
case 175: prvReadyTask( xpcolHandle8 );
break;
case 200: prvReadyTask( xpcolHandle9 );
break;
case 225: prvReadyTask( xpcolHandle10 );
break;
case 250: prvReadyTask( xpcolHandle11 );
break;
case 275: prvReadyTask( xpcolHandle12 );
break;
case 300: prvReadyTask( xpcolHandle13 );
break;
case 325: prvReadyTask( xpcolHandle14 );
break;
case 350: prvReadyTask( xpcolHandle15 );
break;
case 375: prvReadyTask( xpcolHandle16 );
break;
case 499: /* When we start task C
we reset the call count
so TaskA is started again
in 5 ticks. */
// prvReadyTask( xpcolHandle1 );
// we bias xCallCount to -1 since xCallCount gets
// incremented below the switch and we start our cycle
// with case 0:
xCallCount = -1;
break;
default: // post error condition - maybe not
break;
} // end switch
xCallCount++; //
} // end vTaskTickHook()
#endif
in FreeRTOSConfig.h:
#define configUSE_TICK_HOOK 1
in the tick isr:
#if configUSE_TICK_HOOK == 1
call #vTaskTickHook
#endif
Regards…