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