prijimac-zaloha

Dependencies:   mbed

main.cpp

Committer:
homzovam
Date:
2015-04-02
Revision:
0:0c03408de495

File content as of revision 0:0c03408de495:

#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);
        
        }
    
}