M H
/
prijimac-zaloha
prijimac-zaloha
Diff: main.cpp
- Revision:
- 0:0c03408de495
diff -r 000000000000 -r 0c03408de495 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Apr 02 10:27:28 2015 +0000 @@ -0,0 +1,59 @@ +#include "mbed.h" +#include "RF22.h" + + + +RF22 r(PTD4 , PTD6, PTD7, PTD5, PTD2); +//_slaveSelectPin(slaveSelectPin), _spi(mosi, miso, sclk), _interrupt(interrupt) + +Serial pc(USBTX, USBRX); + + +int main() +{ + + uint8_t data[8];//dolni bity, horni bity, teplota, zrychleni + uint8_t delka = 8; + uint8_t *ptrdelka=&delka; + + r.init(); + pc.printf("Mod zarizeni je: %d\n", r.mode()); + + r.setModeRx(); + pc.printf("Mod zarizeni je: %d\n", r.mode()); + r.setPromiscuous(true); + while(1) + { + + //r.obsluhapreruseni(); + bool provedeno = r.recv(data, ptrdelka); + r.obsluhapreruseni(); + + //pc.printf("Prijato:"); + //pc.printf(provedeno ? "true\n" : "false\n"); + + if(provedeno == true) + { + r.vypisfifo(); + short tlak = data[1]<<8; + tlak = tlak + data[0]; + float press= tlak * 1.25; + pc.printf("\n\r Tlak je %f", press); + + short temp=data[2]-50; + pc.printf("\n\r Teplota je %i", temp); + + float acc = (data[3]*0.5)-12; //udavany v g + pc.printf("\n\r Zrychleni je %f", acc); + pc.printf("\n\r Cislo paketu je:%i\n", data[4]); + pc.printf("\n\r---------------------------------prijimac---------------------"); + } + + //pc.printf("\r\n Obsah dat je: "); + //for (int a =0; a<5; a++)pc.printf(" %i", data[a]); + for(int a=0; a<8; a++) data[a]=0; + wait_ms(500); + + } + +}