Pawel Stepien
/
PwmIn_ModSerial
Problems with compilation of MODSERIAL
main.cpp
- Committer:
- kinemax
- Date:
- 2011-04-08
- Revision:
- 0:177adc0899a6
File content as of revision 0:177adc0899a6:
// Example PwmIn class to detect PWM inputs, sford // - Note: uses InterruptIn, so not available on p19/p20 #include "mbed.h" #include "PwmIn.h" #include "MODSERIAL.h" #define BAUD 115200 #define TX_PIN p9 #define RX_PIN p10 DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); Serial pc(USBTX, USBRX); MODSERIAL uart(TX_PIN, RX_PIN); bool newpacket = false; PwmIn a(p21); PwmIn b(p22), c(p23), d(p24), e(p25); int yaw=0,pitch=0,roll=0, Dyaw=0,Dpitch=0,Droll=0,chk=0; int main() { char ileB=0,kan1=0,kan2=0; pc.baud(BAUD); uart.baud(BAUD); // uart.attach(&rxCallback, MODSERIAL::RxIrq); pc.printf("Start\n\r"); while(1) { while( uart.rxBufferGetCount() < 21); { led1 = 1; // Show start of sending with LED1. if(uart.getc()=='s') { led2 =1; if(uart.getc()=='n') if(uart.getc()=='p') if(uart.getc()==0xB7) { uart.scanf("%c%c%c%2d%2d%2d%2d%2d%2d%2d", ileB,kan1,kan2, yaw,pitch,roll, Dyaw,Dpitch,Droll,chk); led3=1; newpacket=1; } } } pc.printf("Bajty= %2d, YPR = %5d %5d %5d Delty = %5d %5d %5d Chk %3d\n\r", ileB, yaw,pitch,roll, Dyaw,Dpitch,Droll,chk); 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); wait(1); } } // higher than "uart" baud rate below.