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

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

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



 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
/vhost/mculabs/snippet_db/ptask/ptask.h
    1 /*
    2           file: ptask.h
    3    description: priority (out of order) task manager
    4    written by : Michael Bradley
    5 
    6    Changelog:
    7       12/31/09 This file created
    8 
    9    This will allow you to run several tasks out of order, with the important
   10    tasks running more often than the others.
   11 
   12    Give each task a number from 1 to 255, the lower the number,
   13    the higher the priority the task has. (more often it runs)
   14 
   15    Basicaly, each task gets run the N'th time the task manager is entered
   16 
   17    example:
   18 
   19    // global define
   20    mpDefineTask mainTasks;
   21 
   22    void main(void)
   23    {
   24 
   25      mpTaskManager(mainTasks)
   26        {
   27        mpTask(mainTasks,  1, task_procGPS() );             // this task runs every time
   28        mpTask(mainTasks,  2, task_procMode() );            // this task runs every other time
   29        mpTask(mainTasks,  5, task_procTarget() );          // this task runs every 5th time
   30        mpTask(mainTasks, 12, task_termUpdate() );          // this task runs every 12th time
   31        }
   32 
   33    }
   34 
   35 */
   36 
   37 
   38 
   39 #ifndef __PTASK_MANAGER
   40    #define __PTASK_MANAGER
   41 
   42 
   43 #define mpDefineTask             unsigned int8
   44 #define mpTaskManager(wtask)     wtask++;
   45 #define mpTask(wtask,pri,fn)     if ( (wtask - ( (wtask/pri) * pri)) == 0 ) { fn; }
   46 
   47 #endif
   48 
   49 






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