M H
/
prijimac-zaloha
prijimac-zaloha
main.cpp@0:0c03408de495, 2015-04-02 (annotated)
- Committer:
- homzovam
- Date:
- Thu Apr 02 10:27:28 2015 +0000
- Revision:
- 0:0c03408de495
vypis buferu, _buf a FIFA
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
homzovam | 0:0c03408de495 | 1 | #include "mbed.h" |
homzovam | 0:0c03408de495 | 2 | #include "RF22.h" |
homzovam | 0:0c03408de495 | 3 | |
homzovam | 0:0c03408de495 | 4 | |
homzovam | 0:0c03408de495 | 5 | |
homzovam | 0:0c03408de495 | 6 | RF22 r(PTD4 , PTD6, PTD7, PTD5, PTD2); |
homzovam | 0:0c03408de495 | 7 | //_slaveSelectPin(slaveSelectPin), _spi(mosi, miso, sclk), _interrupt(interrupt) |
homzovam | 0:0c03408de495 | 8 | |
homzovam | 0:0c03408de495 | 9 | Serial pc(USBTX, USBRX); |
homzovam | 0:0c03408de495 | 10 | |
homzovam | 0:0c03408de495 | 11 | |
homzovam | 0:0c03408de495 | 12 | int main() |
homzovam | 0:0c03408de495 | 13 | { |
homzovam | 0:0c03408de495 | 14 | |
homzovam | 0:0c03408de495 | 15 | uint8_t data[8];//dolni bity, horni bity, teplota, zrychleni |
homzovam | 0:0c03408de495 | 16 | uint8_t delka = 8; |
homzovam | 0:0c03408de495 | 17 | uint8_t *ptrdelka=&delka; |
homzovam | 0:0c03408de495 | 18 | |
homzovam | 0:0c03408de495 | 19 | r.init(); |
homzovam | 0:0c03408de495 | 20 | pc.printf("Mod zarizeni je: %d\n", r.mode()); |
homzovam | 0:0c03408de495 | 21 | |
homzovam | 0:0c03408de495 | 22 | r.setModeRx(); |
homzovam | 0:0c03408de495 | 23 | pc.printf("Mod zarizeni je: %d\n", r.mode()); |
homzovam | 0:0c03408de495 | 24 | r.setPromiscuous(true); |
homzovam | 0:0c03408de495 | 25 | while(1) |
homzovam | 0:0c03408de495 | 26 | { |
homzovam | 0:0c03408de495 | 27 | |
homzovam | 0:0c03408de495 | 28 | //r.obsluhapreruseni(); |
homzovam | 0:0c03408de495 | 29 | bool provedeno = r.recv(data, ptrdelka); |
homzovam | 0:0c03408de495 | 30 | r.obsluhapreruseni(); |
homzovam | 0:0c03408de495 | 31 | |
homzovam | 0:0c03408de495 | 32 | //pc.printf("Prijato:"); |
homzovam | 0:0c03408de495 | 33 | //pc.printf(provedeno ? "true\n" : "false\n"); |
homzovam | 0:0c03408de495 | 34 | |
homzovam | 0:0c03408de495 | 35 | if(provedeno == true) |
homzovam | 0:0c03408de495 | 36 | { |
homzovam | 0:0c03408de495 | 37 | r.vypisfifo(); |
homzovam | 0:0c03408de495 | 38 | short tlak = data[1]<<8; |
homzovam | 0:0c03408de495 | 39 | tlak = tlak + data[0]; |
homzovam | 0:0c03408de495 | 40 | float press= tlak * 1.25; |
homzovam | 0:0c03408de495 | 41 | pc.printf("\n\r Tlak je %f", press); |
homzovam | 0:0c03408de495 | 42 | |
homzovam | 0:0c03408de495 | 43 | short temp=data[2]-50; |
homzovam | 0:0c03408de495 | 44 | pc.printf("\n\r Teplota je %i", temp); |
homzovam | 0:0c03408de495 | 45 | |
homzovam | 0:0c03408de495 | 46 | float acc = (data[3]*0.5)-12; //udavany v g |
homzovam | 0:0c03408de495 | 47 | pc.printf("\n\r Zrychleni je %f", acc); |
homzovam | 0:0c03408de495 | 48 | pc.printf("\n\r Cislo paketu je:%i\n", data[4]); |
homzovam | 0:0c03408de495 | 49 | pc.printf("\n\r---------------------------------prijimac---------------------"); |
homzovam | 0:0c03408de495 | 50 | } |
homzovam | 0:0c03408de495 | 51 | |
homzovam | 0:0c03408de495 | 52 | //pc.printf("\r\n Obsah dat je: "); |
homzovam | 0:0c03408de495 | 53 | //for (int a =0; a<5; a++)pc.printf(" %i", data[a]); |
homzovam | 0:0c03408de495 | 54 | for(int a=0; a<8; a++) data[a]=0; |
homzovam | 0:0c03408de495 | 55 | wait_ms(500); |
homzovam | 0:0c03408de495 | 56 | |
homzovam | 0:0c03408de495 | 57 | } |
homzovam | 0:0c03408de495 | 58 | |
homzovam | 0:0c03408de495 | 59 | } |