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_5thJan_azad by
Revision 18:3662058a7c10, committed 2016-05-14
- Comitter:
- lakshya
- Date:
- Sat May 14 11:19:13 2016 +0000
- Parent:
- 17:fc782f7548c6
- Child:
- 19:79e69017c855
- Commit message:
- bcn working no hanging; ; rtos timer used for calling bcn_fen ; ( spi connection valid if it waits for too long then maybe BCN_hw is commented make sure it sets the spi ); ; both short and long beacon working; ; also ACS (modifed version as earlier)
Changed in this revision
--- a/ACS.cpp Fri May 13 11:56:49 2016 +0000
+++ b/ACS.cpp Sat May 14 11:19:13 2016 +0000
@@ -408,8 +408,14 @@
wait_ms(1);
//_______________________________________________________________________________//
-/*stop as of now this approach i.e pass through state*/
-/*
+/*start as of now this approach i.e pass through state*/
+/*
+ cmd[0]=0x35;//event status
+ i2c.write(SLAVE_ADDR,cmd,1);
+ i2c.read(SLAVE_ADDR_READ,&status,1);
+ wait_ms(1);
+ pc_acs.printf("\n\rEvent Status at start is %x\n \r",(int)status);
+
cmd[0]=ALGO_CTRL; //When 0x00 is written to ALGO CONTROL register we get scaled sensor values
cmd[1]=0x01;//Places sentral in standby state
i2c.write(SLAVE_ADDR,cmd,2);
@@ -428,7 +434,13 @@
wait_ms(1);
printf("\n\r the value of the pass through status register is = %x",(int)store);
+ cmd[0]=0x35;//event status
+ i2c.write(SLAVE_ADDR,cmd,1);
+ i2c.read(SLAVE_ADDR_READ,&status,1);
+ wait_ms(1);
+ pc_acs.printf("\n\rEvent Status at end initialization is %x\n \r",(int)status);
*/
+
//_______________________________________________________________________________//
ACS_INIT_STATUS = 'c'; //set ACS_INIT_STATUS flag
@@ -453,6 +465,7 @@
if(((int)status&40)==40){ //when both work
/// if((int)status==8){ //for just mag
/// if((int)status == 36){ //for just gyro as status 24(in binary) = 36 in decimal
+/// if((int)status==___yet to be decided___){ //for pass through state see how it tworks
/*don't ask for info if the gyro cupped as interrupt makes it go haywire that is enables the pins for gyro*/
cmd[0]=GYRO_XOUT_H; //0x22 gyro LSB of x
@@ -481,35 +494,35 @@
i2c.write(SLAVE_ADDR,cmd,1);
i2c.read(SLAVE_ADDR_READ,&status,1);
wait_ms(1);
- pc_acs.printf("\n\rEvent Status at the end is %x\n \r",(int)status);
+ pc_acs.printf("\n\rEvent Status at the end is %x",(int)status);
cmd[0]=0x33;//enable events
i2c.write(SLAVE_ADDR,cmd,1);
i2c.read(SLAVE_ADDR_READ,&status,1);
wait_ms(1);
- pc_acs.printf("\n\rEnable events is %x\n \r",(int)status);
+ pc_acs.printf("\n\rEnable events is %x",(int)status);
cmd[0]=0x57;//gyro rate
i2c.write(SLAVE_ADDR,cmd,1);
i2c.read(SLAVE_ADDR_READ,&status,1);
wait_ms(1);
- pc_acs.printf("\n\rgyro rate is %x\n \r",(int)status);
+ pc_acs.printf("\n\rgyro rate is %x",(int)status);
cmd[0]=0x55;//mag rate 0x00 indicate value lost
i2c.write(SLAVE_ADDR,cmd,1);
i2c.read(SLAVE_ADDR_READ,&status,1);
wait_ms(1);
- pc_acs.printf("\n\rmag rate is %x\n \r",(int)status);
+ pc_acs.printf("\n\rmag rate is %x",(int)status);
cmd[0]=0x36;//sensorstatus
i2c.write(SLAVE_ADDR,cmd,1);
i2c.read(SLAVE_ADDR_READ,&status,1);
wait_ms(1);
- pc_acs.printf("\n\rsensor Status is %x\n \r",(int)status);
+ pc_acs.printf("\n\rsensor Status is %x",(int)status);
cmd[0]=0x50;//error register
--- a/BCN.cpp Fri May 13 11:56:49 2016 +0000
+++ b/BCN.cpp Sat May 14 11:19:13 2016 +0000
@@ -25,14 +25,16 @@
{
pc_bcn.printf("FCTN_BCN_INIT\n");
BCN_INIT_STATUS = 1;
- if(BCN_FEN == 0)
- rf_sl_timeout.attach(&FCTN_BCN_FEN, 30);
+/// if(BCN_FEN == 0)
+/// rf_sl_timeout.attach(&FCTN_BCN_FEN, 70);//actually 30 \\ so basically not able to call the interrupt .!! is it so?
+/// FCTN_BCN_FEN();
+
Init_BEACON_HW();
BCN_INIT_STATUS = 0;
}
-void FCTN_BCN_FEN()
+void FCTN_BCN_FEN(void const *args)
{
- pc_bcn.printf("FCTN_FEN\n");
+ printf("\n\n\rFCTN_FEN\n");
BCN_FEN = 1;//write this value to flash
}
void FCTN_BCN_TX_MAIN()
@@ -60,7 +62,7 @@
else
{
//transmit short beacon and long beacon
- //SHORT_BCN_TX();
+ SHORT_BCN_TX();
LONG_BCN_TX();
if(Check_ACK_RECEIVED() == 1)
@@ -116,6 +118,8 @@
writereg(RF22_REG_6F_TX_DATA_RATE,0x50);//160bps
writereg(RF22_REG_3E_PACKET_LENGTH,SHORT_TX_DATA); //short packet length
wait(0.02);
+
+ printf("\n\rstage 1");
uint32_t timeout_count = 10e5;
//extract values from short_beacon[]
@@ -175,10 +179,10 @@
//Check for packet_sent
while(timeout_count--)if((readreg(RF22_REG_03_INTERRUPT_STATUS1) & 0x04) == 0x04)break;
- //pc_bcn.printf("Short packet sent\r\n");
+ pc_bcn.printf("Short packet sent\r\n");
writereg(RF22_REG_07_OPERATING_MODE1,0x00); //standby mode
-
+
}
void LONG_BCN_TX()
{
--- a/main.cpp Fri May 13 11:56:49 2016 +0000
+++ b/main.cpp Sat May 14 11:19:13 2016 +0000
@@ -37,6 +37,11 @@
uint8_t ACS_ATS_ENABLE = 1;
uint8_t ACS_DATA_ACQ_ENABLE = 1;
uint8_t ACS_STATE = 4;
+/*added for removing the stuck/hang problem*/
+/*does it work? now doing it in main*/
+extern uint8_t BCN_FEN;
+extern void FCTN_BCN_FEN(void const *args);
+Timeout timeout_bcn;
//.....................eps...................//
//eps init
@@ -350,6 +355,8 @@
PWM3 = 0; //clear pwm pins
}
} //else for acs control off
+///
+ printf("\n\rlow power crossed and pwm no hang");
ACS_MAIN_STATUS = 0; //clear ACS_MAIN_STATUS flag
}
@@ -637,14 +644,22 @@
if(schedcount%2==0)
{
- // F_EPS();
+ printf("\n\rreached scheduler part2 ");
+ //F_EPS();
+ //F_BCN();
}
+ printf("\n\rexited scheduler part2 ");
if(schedcount%3==0)
- { // F_ACS();
- // F_BCN();
+ {
+ printf("\n\rreached scheduler part3 ");
+ //F_ACS();
+ F_BCN();
}
schedcount++;
- printf("\n\r exited scheduler");
+ //t_start.start();
+ printf("\n\r did increment %d",schedcount);
+ printf("\n\r ex h");
+ printf("\n\r time taken %f",t_start.read());
}
Timer t_flag;
@@ -776,7 +791,7 @@
//............................//
FCTN_ACS_INIT();
FCTN_EPS_INIT();
- //FCTN_BCN_INIT();
+ FCTN_BCN_INIT();
FLAG();
@@ -828,6 +843,22 @@
t_start.start();
pc.printf("\n\rStarted scheduler %f\n\r",t_start.read());
+
+ RtosTimer bcn_start_timer(FCTN_BCN_FEN,osTimerOnce);
+ /*later change it to 30 min 1800 seconds*/
+ bcn_start_timer.start(10000);
+
+ /*for calling bcn_fen function after 30 min as of now say 40 sec*/
+ /*but it will be called again and again */
+
+/// even this doesn't work if(t_start.read()>38 && t_start.read()<43)
+/// if(BCN_FEN==0)
+/// {
+/// FCTN_BCN_FEN();
+/// printf("\n\r entered the condition \n");
+/// }
+
+// it won't work timeout_bcn.attach(&FCTN_BCN_FEN,42.0);
//FCTN_BAE_INIT();
while(1); //required to prevent main from terminating
--- a/pni.h Fri May 13 11:56:49 2016 +0000 +++ b/pni.h Sat May 14 11:19:13 2016 +0000 @@ -32,6 +32,6 @@ #define BIT_GYRO_RES 0x20 #define BIT_GYROODR 0x0F//0x0F #define BIT_MAGODR 0x64//0x64 -#define BIT_RUN_ENB 0x01 +#define BIT_RUN_ENB 0x01//0x01 #define BIT_ALGO_RAW 0x02 #define BIT_EVT_ENB 0X2A// 0x2A \ No newline at end of file
