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 RAJANGAM_REVIEW_BAE_CODE by
Diff: BCN.cpp
- Revision:
- 82:9117fc24d09d
- Parent:
- 80:da657c390c27
- Child:
- 83:78b6a62cdf6a
diff -r bc0837c54fbf -r 9117fc24d09d BCN.cpp
--- a/BCN.cpp Sat Dec 10 14:42:56 2016 +0000
+++ b/BCN.cpp Sat Dec 10 15:07:13 2016 +0000
@@ -187,6 +187,14 @@
BCN_TX_STATUS = BCN_TX_SUCCESS;
BCN_TX_MAIN_STATUS = 0;
}
+ else if(BCN_SPND_TX == 1 )
+ {
+ timer_Set_BCN_TX_STATUS_SUSPENDED.reset();
+ timer_Set_BCN_TX_STATUS_SUSPENDED.start();
+ BCN_TX_STATUS = BCN_TX_SUSPENDED;
+ BCN_TX_MAIN_STATUS = 0;
+ timer_Set_BCN_TX_STATUS_SUSPENDED.stop();
+ }
else
{
BCN_TX_STATUS = BCN_TX_FAILURE;
@@ -251,35 +259,12 @@
void BCN_TX() // main function for transmitting
{
pc_bcn.printf("BCN_TX\n\r");
+
writereg(RF22_REG_6E_TX_DATA_RATE,0x0A);
writereg(RF22_REG_6F_TX_DATA_RATE,0x7C);//1280bps
-
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;
@@ -287,10 +272,18 @@
uint8_t zerobyte[4] = {0x7E,0x59,0x41,0xB1};
for (byte_counter = 0; byte_counter <15 ; byte_counter++) // include condition in the foor loop itself
{
- if(BCN_SPND_TX == 1) continue; //changed
+ if(BCN_SPND_TX == 1)
+ {
+ clearTxBuf();
+ break; //Check for flag update by COM
+ }
for(int j = 7; j >= 0; j--)
{
- if(BCN_SPND_TX == 1) continue; //changed
+ if(BCN_SPND_TX == 1)
+ {
+ clearTxBuf();
+ break; //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))
@@ -340,24 +333,16 @@
//Check for fifoThresh
if(byte_counter > 0)
- if(BCN_SPND_TX != 1) //Check for flag update by COM
- {
- wait_ms(25);
- while( timeout_count --)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x20) == 0x20)break;else if(timeout_count == 1) reset_rfm(1);
- { //loop corresponds to ??
+ if(BCN_SPND_TX != 1) //Check for flag update by COM
+ {
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;
-
- //pc_bcn.printf("w_f_empty\n");
- //reset_rfm(1);
}
- timeout_count = 10e5;
- }
/* if(byte_counter%2==0 && byte_counter)
while(1)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x40) == 0x00)break;else
@@ -369,13 +354,17 @@
for(byte_counter = 15;byte_counter<149;byte_counter++) // include it in the loop itself
{
- if(BCN_SPND_TX == 1) continue;
+ if(BCN_SPND_TX == 1)
+ {
+ clearTxBuf();
+ break; //Check for flag update by COM
+ }
cs = 0;
spi.write(0xFF);
spi.write(LONG_HK_data[BCN_LONG_MSG_TYPE][byte_counter-15]);
cs = 1;
- if((byte_counter-15)%32==0)
+ if((byte_counter-15)%32==0 && BCN_SPND_TX != 1)
{ //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);
@@ -411,70 +400,7 @@
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("Rst T1);
- reset_rfm(1); // if it reaches countdown
- }
- 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("Rst T2);
- 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)
