:: Home :: Code Snippets :: Drivers :: Projects :: About ::
 Main Menu
  Home
  Code Snippets
  About

 Open Drivers
 _build - Embedded build information
 PIC32 mcompat - PIC32 mcompat
 EA-DOGM - LCD Display Driver
 qTask - Queued Task Manager

 Open Projects
 SSX32 - Serial Servo Driver
 oLogic - Oscilloscope Logic Viewer
 oLogic 1.4 - NEW Logic Viewer



 Sources
Prototyping
  PicStuff
  Sparkfun

Equipment
  Saelig
  Tequipment

Supply House
  Jameco
  Mouser
  Digikey
  Allied Electronics
  Clearwater Technologies

Miscellaneous
  BCM
  N34D Blog

pTask - pTask - Priority task manager

pTask - priority (out of order) task manager

 Code Snippet
/*
          file: ptask.h
   description: priority (out of order) task manager
   written by : Michael Bradley

   Changelog:
      12/31/09 This file created

   This will allow you to run several tasks out of order, with the important
   tasks running more often than the others.

   Give each task a number from 1 to 255, the lower the number,
   the higher the priority the task has. (more often it runs)

   Basicaly, each task gets run the N'th time the task manager is entered

   example:

   // global define
   mpDefineTask mainTasks;

   void main(void)
   {

     mpTaskManager(mainTasks)
       {
       mpTask(mainTasks,  1, task_procGPS() );             // this task runs every time
       mpTask(mainTasks,  2, task_procMode() );            // this task runs every other time
       mpTask(mainTasks,  5, task_procTarget() );          // this task runs every 5th time
       mpTask(mainTasks, 12, task_termUpdate() );          // this task runs every 12th time
       }

   }

*/



#ifndef __PTASK_MANAGER
   #define __PTASK_MANAGER


#define mpDefineTask             unsigned int8
#define mpTaskManager(wtask)     wtask++;
#define mpTask(wtask,pri,fn)     if ( (wtask - ( (wtask/pri) * pri)) == 0 ) { fn; }

#endif








:: Home :: Resources :: PIC Microcontrollers ::
:: 10F :: 12F :: 16F :: 18F :: 24F :: 24H :: 30F :: 33F ::
(C) Copyright 2009 mculabs.com - contact: info@mculabs.com
0.0034751892089844