Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of workinQM_10thDec by
Diff: BCN.cpp
- Revision:
- 27:61c856be467e
- Parent:
- 20:949d13045431
- Child:
- 33:76f2b8735501
diff -r 950dbe9fbeb8 -r 61c856be467e BCN.cpp --- a/BCN.cpp Fri Jul 01 18:14:34 2016 +0000 +++ b/BCN.cpp Sat Jul 02 14:06:34 2016 +0000 @@ -2,7 +2,7 @@ #include <stdio.h> #include "pin_config.h" //Check the pin names -//Takes max 4.3 sec in void FCTN_BCN_TX_MAIN() (temp.calc. + long_beacon + short_beacon) +//Takes max 4 sec in void FCTN_BCN_TX_MAIN() (temp.calc. + long_beacon + short_beacon) Serial pc_bcn(USBTX, USBRX); //tx,rx SPI spi(D11, D12, D13); // mosi, miso, sclk @@ -50,7 +50,7 @@ BCN_FEN = 1;//write this value to flash uint32_t FLASH_DATA; FLASH_DATA = FCTN_BAE_RD_FLASH_ENTITY(0); - FLASH_DATA = (FLASH_DATA | 0x00001000);//see if uint8 to uint32 conversion works + FLASH_DATA = (FLASH_DATA | 0x00000800);//see if uint8 to uint32 conversion works FCTN_BAE_WR_FLASH(0,FLASH_DATA); } void FCTN_BCN_TX_MAIN() @@ -84,15 +84,6 @@ begintx = t_i.read_us(); BCN_TX(); endtx = t_i.read_us(); - /* - begins = t_i.read_us(); - SHORT_BCN_TX(); - //ends = t_i.read_us(); - - beginl = t_i.read_us(); - LONG_BCN_TX(); - endl = t_i.read_us(); - */ if(Check_ACK_RECEIVED() == 1) { @@ -101,7 +92,7 @@ } else { - Set_BCN_TX_STATUS(BCN_TX_FAILURE); + //Set_BCN_TX_STATUS(BCN_TX_FAILURE); BCN_FAIL_COUNT++; Init_BEACON_HW(); BCN_TX_MAIN_STATUS = 0; @@ -148,151 +139,6 @@ temperature = (float)temperature*0.5 - 64; return temperature; } -#if 0 -void SHORT_BCN_TX() -{ - /* - writereg(RF22_REG_6E_TX_DATA_RATE,0x01); - writereg(RF22_REG_6F_TX_DATA_RATE,0x50);//160bps - */ - writereg(RF22_REG_6E_TX_DATA_RATE,0x0A); - writereg(RF22_REG_6F_TX_DATA_RATE,0x7C);//1280bps - - //writereg(RF22_REG_3E_PACKET_LENGTH,1); //short packet length - wait(0.02); - - uint32_t timeout_count = 10e5; - //extract values from short_beacon[] - - struct Short_beacon - { - uint8_t Voltage[1]; - uint8_t AngularSpeed[2]; - uint8_t SubsystemStatus[1]; - uint8_t Temp[3]; - uint8_t ErrorFlag[1]; - }Shortbeacon = { {0xFF}, {0xFF, 0xFF} , {0xFF},{0xFF,0xFF,0xFF}, {0xFF} }; - - //filling hk data - //uint8_t short_beacon[] = { 0xAB, 0x8A, 0xE2, 0xBB, 0xB8, 0xA2, 0x8E,Shortbeacon.Voltage[0],Shortbeacon.AngularSpeed[0], Shortbeacon.AngularSpeed[1],Shortbeacon.SubsystemStatus[0],Shortbeacon.Temp[0],Shortbeacon.Temp[1],Shortbeacon.Temp[2],Shortbeacon.ErrorFlag[0]}; - uint8_t short_beacon[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,Shortbeacon.Voltage[0],Shortbeacon.AngularSpeed[0], Shortbeacon.AngularSpeed[1],Shortbeacon.SubsystemStatus[0],Shortbeacon.Temp[0],Shortbeacon.Temp[1],Shortbeacon.Temp[2],Shortbeacon.ErrorFlag[0]}; - - //writereg(RF22_REG_07_OPERATING_MODE1,0x01); //ready mode ?? - clearTxBuf(); //writing data first time - - int byte_count=0; - uint8_t onebyte[4] = {0x81,0xA6,0xBE,0x4E}; - uint8_t zerobyte[4] = {0x7E,0x59,0x41,0xB1}; - for (int byte_counter = 0; byte_counter <15 ; byte_counter++) - { - //pc_bcn.printf("byte-counter=%d\r\n", byte_counter); - /* - for(int j = 3; j >= 0 ; j--) - { - if((short_beacon[byte_counter] & (uint8_t) pow(2.0,(j*2+1)))!= pow(2.0,(j*2+1))) - { - byte=0x00; - } - else - { - byte=0xF0; - } - if((short_beacon[byte_counter] & (uint8_t) pow(2.0,j*2))!= pow(2.0,j*2)) - { - byte=byte | 0x00; - } - else - { - byte=byte | 0x0F; - } - cs = 0; - spi.write(0xFF); - spi.write(byte); - cs = 1;1 - } - */ - for(int j = 7; j >= 0 ; j--) - { - cs = 0; - spi.write(0xFF); - if((short_beacon[byte_counter] & (uint8_t) pow(2.0,j))!= pow(2.0,j)) - { - //byte=0x00; - spi.write(zerobyte[0]); - spi.write(zerobyte[1]); - spi.write(zerobyte[2]); - spi.write(zerobyte[3]); - } - else - { - //byte=0xFF; - spi.write(onebyte[0]); - spi.write(onebyte[1]); - spi.write(onebyte[2]); - spi.write(onebyte[3]); - } - cs = 1; - /* - spi.write(byte); - spi.write(byte); - spi.write(byte); - spi.write(byte); //Each bit is written 32 times - */ - byte_count+=4; - - } - - if(byte_counter == 1) - { - - //Set to Tx mode - writereg(RF22_REG_07_OPERATING_MODE1,0x08); //txon - wait(0.1);// takes time to set to tx mode hence the delay of 0.1. - - } - //testing level - /*if(byte_counter > 0) - while(1)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00)break;else - { - pc_bcn.printf("w_f_empty1\n\r"); - //reset_rfm(1); - }*/ - - - //Check for fifoThresh - - if(byte_counter > 0) - {wait_ms(25); - while(1)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else - { - //pc_bcn.printf("w_f_empty\n"); - //reset_rfm(1); - } - } - - /* if(byte_counter%2==0 && byte_counter) - while(1)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00)break;else - { - pc_bcn.printf("W = %d\r\n",byte_counter); - }*/ - pc_bcn.printf("W = %d\r\n",byte_counter); - } - - //Check for fifoThresh - while(1)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00)break;else - { - pc_bcn.printf("Waiting for fifo to empty\r\n"); - } - - //Check for packetsent interrupt - while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) == 0x04)break;else if(timeout_count == 1) reset_rfm(1); - - pc_bcn.printf("Short packet sent, bytes written = %d\r\n",byte_count); - - writereg(RF22_REG_07_OPERATING_MODE1,0x00); //standby mode - -} -#endif void BCN_TX() { printf("BCN_TX\n\r");