Jean Mercier / Mbed 2 deprecated jmStepperAxis

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*************************************************************************
00002  * @file         main.cpp
00003  *                  
00004  * @version      1.0
00005  * @date         Feb 12, 2011
00006 */
00007 
00008 #include "mbed.h"
00009 
00010 // Basic includes
00011 #include "jmInterpreter.h"
00012 #include "jmRingBuffer.h"
00013 #include "jmCommands.h"
00014 #include "jmMessages.h"
00015 #include "LPC17xx.h"
00016 
00017 
00018 LPC_GPIO_TypeDef *jmGPIO[5] ={LPC_GPIO0,LPC_GPIO1,LPC_GPIO2,LPC_GPIO3,LPC_GPIO4};
00019 
00020 // CLIG-INCLUDE
00021 #include "jmStepper.h"
00022 #include "jmStepperAxis.h"
00023 #include "jmSwitch.h"
00024 
00025 
00026 // Initializations
00027 void Inits(){
00028    InitCommandLineRingBuffer();
00029    InitMessages();
00030    cli_version();
00031 
00032    // CLIG-INIT
00033    StepperInit();
00034    StepperAxisInit();
00035    SwitchModuleReset();   
00036 
00037 }
00038 
00039 // EggTimer tickers for modules
00040 void eggTimers(){
00041    int i;
00042    // CLIG-TIMER
00043    // Module jmStepper
00044    for(i=0;i<stepperQty;i++)if(sStepper[i].eggTimer>0)sStepper[i].eggTimer--;
00045    // Module jmSwitch
00046    for(i=0;i<switchQty;i++)if(sSwitch[i].eggTimer>0)sSwitch[i].eggTimer--;
00047 
00048 }
00049 
00050 int main() {
00051    unsigned char c;
00052    Serial pc(USBTX, USBRX);          // communication medium
00053    pc.baud(115200);                  // 115200 bauds, 8bits, 1 stop, no control flow
00054    Ticker tick;                      // enable system ticks
00055    tick.attach_us(&eggTimers,1000);  // enable and select granularity for egg timers
00056    Inits();                          // initialization
00057 
00058    while(true){
00059      if( pc.readable()){             // something to read ?
00060         c= pc.getc();                // read one char   
00061 
00062         if(Echo) printf("%c",c);     // echo it ?
00063 
00064         switch(c){                   // process it
00065 
00066           case  8 : DelChar(pLine);  // remove last one
00067                     break;
00068           case 10 : Insert(c,pLine); // end of line
00069                          Interpret();// process line 
00070                     break;
00071           default : Insert(c,pLine); // insert char in command line buffer
00072         }
00073      } // if
00074 
00075      // CLIG-SM
00076      StepperSM();
00077      StepperAxisSM();
00078      SwitchEdgeDetect();
00079 
00080 
00081    }// while
00082 }// main
00083 
00084 
00085