![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
for testing
Diff: main.cpp
- Revision:
- 3:3572f6b06485
- Parent:
- 2:9b4647a9558c
diff -r 9b4647a9558c -r 3572f6b06485 main.cpp --- a/main.cpp Wed Oct 28 13:31:18 2015 +0000 +++ b/main.cpp Wed Oct 28 14:41:35 2015 +0000 @@ -1,6 +1,6 @@ #include "beacon.h" #include <stdio.h> -//Takes approx. 4.3 sec in void FCTN_BCN_TX_MAIN() (temp.calc. + long_beacon + short_beacon) +//Takes max 4.3 sec in void FCTN_BCN_TX_MAIN() (temp.calc. + long_beacon + short_beacon) Serial pc(USBTX, USBRX); //tx,rx SPI spi(D11, D12, D13); // mosi, miso, sclk @@ -46,7 +46,7 @@ { //Measure and store BCN temperature in BCN_TS_BUFFER BCN_TS_BUFFER = check_Temperature(); - //pc.printf("\n\ntemperature = %d\n\n",BCN_TS_BUFFER); + pc.printf("\n\ntemperature = %d\n\n",BCN_TS_BUFFER); //Get BCN_HK data from BCN HW(SPI) //Store BCN_HK data in BCN_HK_BUFFER if(BCN_STANDBY == 1 ) { @@ -112,9 +112,11 @@ writereg(RF22_REG_6E_TX_DATA_RATE,0x01); writereg(RF22_REG_6F_TX_DATA_RATE,0x4F);//160bps writereg(RF22_REG_3E_PACKET_LENGTH,SHORT_TX_DATA); //short packet length - wait(0.02); - + wait(0.02); + + uint32_t timeout_count = 10e5; //extract values from short_beacon[] + struct Short_beacon { uint8_t Voltage[1]; @@ -165,11 +167,11 @@ writereg(RF22_REG_07_OPERATING_MODE1,0x09); wait(0.1); //Check for fifoThresh - while((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) != 0x20); - - + while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break; + timeout_count=10e5; + //Check for packet_sent - while((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) != 0x04); + while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) == 0x04)break; //pc.printf("Short packet sent\r\n"); @@ -182,7 +184,7 @@ writereg(RF22_REG_6F_TX_DATA_RATE,0xEA);//600 bps writereg(RF22_REG_3E_PACKET_LENGTH,LONG_TX_DATA); //long packet length wait(0.02); - + uint32_t timeout_count=10e5; //get long_beacon array @@ -210,8 +212,10 @@ //Set to Tx mode writereg(RF22_REG_07_OPERATING_MODE1,0x09); wait(0.1); + //Check for fifoThresh - while((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) != 0x20); + while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break; + timeout_count=10e5; cs = 0; spi.write(0xFF); @@ -222,10 +226,11 @@ cs = 1; wait(0.1); //Check for fifoThresh - while((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) != 0x20); + while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break; + timeout_count=10e5; //Check for packetsent interrupt - while((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) != 0x04); + while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) == 0x04)break; //pc.printf("Long packet sent\r\n");