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

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

 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

Slice - Slice Manager, aka State Machine.

A macro wrapped up state machine

 Code Snippet
// slice manager
// execute slices of a pie

// in this example, one 1 slice of my_large_task gets executed every loop

// define some macros for use as a state machine
#define mDefinePie unsigned int8
#define mSliceManager(slice,n)  slice++; if (slice > n) { slice = 1; } switch (slice)
#define mOrderSlice(sid,fn)     case sid: { fn; break; }
#define mPieIni(slice)          slice = 0;



// example code:

mDefinePie myPie;


void slice_ledOn(void) {
  mPwrLed_on();
}

void slice_ledOff(void) {
  mPwrLed_off();
}


void my_large_task(void)
{
  // manage 2 slices of the pie
  mSliceManager(myPie,2)
    {
    // define the order of the slices, (constant, function)
    mOrderSlice(1,slice_ledOn());
    mOrderSlice(2,slice_ledOff());
    }

}


void main(void)
{
  mPieIni(myPie);

  while(1)
    {
    my_large_task();
    }
}






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