Problems with compilation of MODSERIAL

Dependencies:   mbed PwmIn

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Example PwmIn class to detect PWM inputs, sford
00002 //  - Note: uses InterruptIn, so not available on p19/p20
00003 
00004 #include "mbed.h"
00005 #include "PwmIn.h"
00006 #include "MODSERIAL.h"
00007 
00008 #define BAUD 115200
00009 #define TX_PIN p9
00010 #define RX_PIN p10
00011 
00012  DigitalOut led1(LED1);
00013  DigitalOut led2(LED2);
00014  DigitalOut led3(LED3);
00015  DigitalOut led4(LED4);
00016  
00017  Serial pc(USBTX, USBRX);
00018  MODSERIAL uart(TX_PIN, RX_PIN);
00019  
00020  bool newpacket = false;
00021 
00022 PwmIn a(p21);
00023 PwmIn b(p22), c(p23), d(p24), e(p25);
00024 
00025 int  yaw=0,pitch=0,roll=0, Dyaw=0,Dpitch=0,Droll=0,chk=0;
00026 
00027 int main() 
00028 {   char  ileB=0,kan1=0,kan2=0;
00029      pc.baud(BAUD);
00030      uart.baud(BAUD);
00031     // uart.attach(&rxCallback, MODSERIAL::RxIrq);
00032     pc.printf("Start\n\r");
00033     
00034   while(1)
00035   { while( uart.rxBufferGetCount() < 21);
00036   
00037     {    led1 = 1; // Show start of sending with LED1.
00038         if(uart.getc()=='s')
00039         { led2 =1;
00040            if(uart.getc()=='n')
00041               if(uart.getc()=='p')
00042                  if(uart.getc()==0xB7)
00043                  {  uart.scanf("%c%c%c%2d%2d%2d%2d%2d%2d%2d", ileB,kan1,kan2, yaw,pitch,roll, Dyaw,Dpitch,Droll,chk);
00044                     led3=1; newpacket=1;
00045                  }
00046         }         
00047     }
00048     pc.printf("Bajty= %2d, YPR = %5d  %5d  %5d  Delty = %5d  %5d  %5d        Chk %3d\n\r", ileB, yaw,pitch,roll, Dyaw,Dpitch,Droll,chk);
00049     pc.printf("Kanaly=  %5.3f  %5.3f  %5.3f %5.3f %5.3f\n\r", a.pulsewidth()*1000, a.pulsewidth()*1000, b.pulsewidth()*1000, c.pulsewidth()*1000, d.pulsewidth()*1000, e.pulsewidth()*1000);
00050     wait(1);
00051       
00052   }
00053 }
00054 
00055      // higher than "uart" baud rate below.