Jean Mercier / Mbed 2 deprecated jmPulse

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 LPC_GPIO_TypeDef *jmGPIO[5] ={LPC_GPIO0,LPC_GPIO1,LPC_GPIO2,LPC_GPIO3,LPC_GPIO4};
00018 
00019 // CLIG-INCLUDE
00020 #include "jmPulse.h"
00021 
00022 
00023 // Initializations
00024 void Inits(){
00025    InitCommandLineRingBuffer();
00026    InitMessages();
00027    cli_version();
00028 
00029    // CLIG-INIT
00030    PulseInit();
00031 
00032 }
00033 
00034 // EggTimer tickers for modules
00035 void eggTimers(){
00036    int i;
00037    // CLIG-TIMER
00038    // Module jmPulse
00039    for(i=0;i<pulseQty;i++)if(sPulse[i].eggTimer>0)sPulse[i].eggTimer--;
00040 
00041 }
00042 
00043 int main() {
00044    unsigned char c;
00045    Serial pc(USBTX, USBRX);          // communication medium
00046    pc.baud(115200);                  // 115200 bauds, 8bits, 1 stop, no control flow
00047    Ticker tick;                      // enable system ticks
00048    tick.attach_us(&eggTimers,1000);  // enable and select granularity for egg timers
00049    Inits();                          // initialization
00050 
00051    while(true){
00052      if( pc.readable()){             // something to read ?
00053         c= pc.getc();                // read one char   
00054 
00055         if(Echo) printf("%c",c);     // echo it ?
00056 
00057         switch(c){                   // process it
00058 
00059           case  8 : DelChar(pLine);  // remove last one
00060                     break;
00061           case 10 : Insert(c,pLine); // end of line
00062                          Interpret();// process line 
00063                     break;
00064           default : Insert(c,pLine); // insert char in command line buffer
00065         }
00066      } // if
00067 
00068      // CLIG-SM
00069      PulseSM();
00070 
00071 
00072    }// while
00073 }// main
00074 
00075 
00076