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 QM_BAE_review_1 by
Revision 77:66a1933f2dd9, committed 2016-12-07
- Comitter:
- azaddevarm
- Date:
- Wed Dec 07 10:50:28 2016 +0000
- Parent:
- 73:d1ed9113c3fd
- Commit message:
- Updated BCN.cpp to prevent resetting if BCN_SPND tc received during bcn transmission
Changed in this revision
| BCN.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/BCN.cpp Mon Dec 05 10:10:27 2016 +0000
+++ b/BCN.cpp Wed Dec 07 10:50:28 2016 +0000
@@ -255,29 +255,7 @@
wait(0.02);
timeout_count = 10e5;
- //extract values from short_beacon[]
- /*
- uint8_t Long_beacon[LONG_TX_DATA];
- for(int i = 0;i<LONG_TX_DATA;i++)
- {
- Long_beacon[i] = 0xFF;
-}
-
- 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[] = { 0xF3, 0x02, 0xFA, 0xC6, 0xD4, 0x28, 0x8A,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_counter;
@@ -285,8 +263,10 @@
uint8_t zerobyte[4] = {0x7E,0x59,0x41,0xB1};
for (byte_counter = 0; byte_counter <15 ; byte_counter++)
{
+ if(BCN_SPND_TX == 1) continue; //Check for flag update by COM
for(int j = 7; j >= 0 ; j--)
{
+ if(BCN_SPND_TX == 1) continue; //Check for flag update by COM
cs = 0;
spi.write(0xFF);
if((SHORT_HK_data[byte_counter] & (uint8_t) pow(2.0,j))!= pow(2.0,j))
@@ -336,15 +316,16 @@
//Check for fifoThresh
if(byte_counter > 0)
- {
- wait_ms(25);
- while( timeout_count --)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else if(timeout_count == 1) reset_rfm(1);
+ if(BCN_SPND_TX != 1) //Check for flag update by COM
{
- //pc_bcn.printf("w_f_empty\n");
- //reset_rfm(1);
+ wait_ms(25);
+ while( timeout_count --)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else if(timeout_count == 1) reset_rfm(1);
+ {
+ //pc_bcn.printf("w_f_empty\n");
+ //reset_rfm(1);
+ }
+ timeout_count = 10e5;
}
- timeout_count = 10e5;
- }
/* if(byte_counter%2==0 && byte_counter)
while(1)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00)break;else
@@ -356,6 +337,7 @@
for(byte_counter = 15;byte_counter<149;byte_counter++)
{
+ if(BCN_SPND_TX == 1) continue; //Check for flag update by COM
cs = 0;
spi.write(0xFF);
spi.write(LONG_HK_data[BCN_LONG_MSG_TYPE][byte_counter-15]);
@@ -365,92 +347,32 @@
{ //Check for fifoThresh
wait_ms(25);
while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else if(timeout_count == 1) reset_rfm(1);
- {
- //pc_bcn.printf("Reset\n");
- //reset_rfm(1);
- }
+
}
}
wait_ms(70);
+
+
//Check for fifoThresh
- while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00)break;else if(timeout_count == 1) reset_rfm(1);
- {
- pc_bcn.printf("Waiting for fifo to empty\r\n");
- }
+ while(timeout_count--)
+ if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00) break;
+ else if(timeout_count == 1)
+ if(BCN_SPND_TX != 1) reset_rfm(1);
+
//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);
+ while(timeout_count--)
+ if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) == 0x04) break;
+ else if(timeout_count == 1)
+ if(BCN_SPND_TX != 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
}
-#if 0
-void LONG_BCN_TX()
-{
- /*
- writereg(RF22_REG_6E_TX_DATA_RATE,0x04);
- 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
-
- uint8_t Long_beacon[LONG_TX_DATA];
- for(int i = 0;i<LONG_TX_DATA;i++)
- {
- Long_beacon[i] = 0xFF;
- }
-
- clearTxBuf();
- //writing data first time
- cs = 0;
- spi.write(0xFF);
- for(int i=0; i<64;i++)
- {
- spi.write(Long_beacon[i]);
- }
- cs = 1;
-
- //Set to Tx mode
- writereg(RF22_REG_07_OPERATING_MODE1,0x08);
- wait(0.1);//necessary
-
- //Check for fifoThresh
- while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else if(timeout_count == 1)
- {
- pc_bcn.printf("Reset\n");
- reset_rfm(1);
- }
- timeout_count=10e5;
-
- cs = 0;
- spi.write(0xFF);
- for(int i=64; i<127;i++)
- {
- spi.write(Long_beacon[i]);
- }
- cs = 1;
- wait(0.1);
- //Check for fifoThresh
- while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else if(timeout_count == 1)
- {
- pc_bcn.printf("Reset\n");
- reset_rfm(1);}
- timeout_count=10e5;
-
- //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("Long packet sent\r\n");
-
- writereg(RF22_REG_07_OPERATING_MODE1,0x00); //standby mode
-}
-#endif
+
void reset_rfm(uint8_t fl)
{
if (fl ==1 && ERROR_CHECK ==0)
