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.
Fork of pcb_test_vr1_1_2 by
Revision 4:65a2d0b97d01, committed 2015-05-14
- Comitter:
- gkumar
- Date:
- Thu May 14 10:22:50 2015 +0000
- Parent:
- 3:0931a8800543
- Commit message:
- Commentted BAE code
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 13 06:19:25 2015 +0000
+++ b/main.cpp Thu May 14 10:22:50 2015 +0000
@@ -22,7 +22,7 @@
Timer i1;
Timer i2;
/*****************************************************************Threads USed***********************************************************************************/
-Thread *ptr_t_hk_acq;
+Thread *ptr_t_hk_acq; //pointer:::::::::to read state of one thread from another
Thread *ptr_t_acs;
Thread *ptr_t_bea;
Thread *ptr_t_i2c;
@@ -47,19 +47,19 @@
//--------------------------------------------------------------------------------------------------------------------------------------------------
char hk_data[25];
-extern SensorDataQuantised SensorQuantised;
+extern SensorDataQuantised SensorQuantised; /// SensorDataQuantised: struct instance :SensorQuantised
void T_HK_ACQ(void const *args)
{
while(1)
{
- Thread::signal_wait(0x2);
+ Thread::signal_wait(0x2); // 0x2 random should be same in master n slave
SensorQuantised.power_mode='3'; //default power mode(dummy)
printf("\n\rTHIS IS HK %f\n\r",t1.read());
t.start();
- FUNC_HK_FAULTS(); // !Actual fault management is not implemented
- FUNC_HK_POWER(SensorQuantised.power_mode); // !The power mode algorithm is yet to be obtained
- FUNC_HK_MAIN(); //Collecting HK data
+ FUNC_HK_FAULTS(); // !Actual fault management is not implemented : polling
+ FUNC_HK_POWER(SensorQuantised.power_mode); // !The power mode algorithm is yet to be obtained // status of power modde will decide actions
+ FUNC_HK_MAIN(); //Collecting HK data for ADC n
FUNC_I2C_IR2CDMS(); //sending HK data to CDMS
t.stop();
printf("The time to execute hk_acq is %f seconds\n\r",t.read());
@@ -71,12 +71,12 @@
//TASK 1 : ACS
//---------------------------------------------------------------------------------------------------------------------------------------
-int acs_pflag = 1;
+int acs_pflag = 1; // power mode decision flag for ACS
void T_ACS(void const *args)
{
- float mag_field[3];
- float omega[3];
- float *mnm_data;
+ float mag_field[3]; // rm3000
+ float omega[3]; //mpu3300
+ float *mnm_data; //
float mag_field1[3];
float omega1[3];
float tauc1[3];
@@ -86,13 +86,13 @@
Thread::signal_wait(0x1);
printf("\n\rEntered ACS %f\n",t1.read());
t.start();
- FUNC_ACS_MAG_EXEC(mag_field);
+ FUNC_ACS_MAG_EXEC(mag_field); ///rm3000
//printf("\n\r check");
for(int i=0; i<3; i++)
{
printf("%f\t",mag_field[i]);
}
- FUNC_ACS_EXEC_GYR(omega);
+ FUNC_ACS_EXEC_GYR(omega); // mpu3300
acs_pflag =1; //to be removed later
omega[0] = 1.0;
omega[1] = 1.0;
@@ -100,7 +100,7 @@
- /* mnm_data=EXECUTE_PNI(); //the angular velocity is stored in the first 3 values and magnetic field values in next 3
+ mnm_data=EXECUTE_PNI(); //the angular velocity is stored in the first 3 values and magnetic field values in next 3
printf("\n\rmnm gyro values\n"); //printing the angular velocity and magnetic field values
for(int i=0; i<3; i++)
{
@@ -119,8 +119,8 @@
{
mag_field1[i-3] = mnm_data[i];
}
- */
- if(acs_pflag == 1)
+
+ if(acs_pflag == 1)
{
FUNC_ACS_CNTRLALGO(mag_field,omega,tauc1);
@@ -143,7 +143,8 @@
//---------------------------------------------------BEACON--------------------------------------------------------------------------------------------
-int beac_flag=0; //To receive telecommand from ground.
+int beac_flag=0; //To receive telecommand from ground. Beacon stopped when telecomand recieved durring
+
/*void T_BEA_TELECOMMAND(void const *args)
@@ -166,7 +167,7 @@
printf("\n\rTHIS IS BEACON %f\n\r",t1.read());
t.start();
FUNC_BEA();
- if(beac_flag==1)
+ if(beac_flag==1) // use scheduler instead
{
Thread::wait(600000);
beac_flag = 0;
@@ -178,19 +179,19 @@
-extern SensorDataQuantised SensorQuantised;
+extern SensorDataQuantised SensorQuantised; // ????????
/*-------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------WATCHDOG----------------------------------------------------------------------------*/
DigitalOut trigger(PIN63); // has to be changed
void T_WDT(void const * args)
{
- trigger = 1;
+ trigger = 1; // gpio to WD input
while(true)
{
Thread::signal_wait(0x5); //signal set from scheduler or sthing. r RTOS timer nce the timing is finalized
printf("\n\rEntered WD\n\r");
- trigger = !trigger;
+ trigger = !trigger; /// falling edge triggered
}
}
@@ -198,7 +199,7 @@
//TASK 5 : i2c data
//---------------------------------------------------------------------------------------------------------------------------------------------------
-void FUNC_I2C_WRITE2CDMS(char *data, int length=1)
+void FUNC_I2C_WRITE2CDMS(char *data, int length=1) /// BAE to CDMS read/write
{
int slave_status = 1;
int inter_test = interrupt;
@@ -209,16 +210,16 @@
//{
//printf("\n\r slave status %d",slave.receive());
//t2.stop();
- if(slave.receive() == 0)
+ if(slave.receive() == 0) // 0 when not ack refer doc.
t2.stop();
- if( slave.receive()==1)
+ if( slave.receive()==1) // slave to master
{
t2.stop();
t3.start();
- slave_status=slave.write(data,length);
+ slave_status=slave.write(data,length); // ack to
t3.stop();
}
- else if( slave.receive()==3 || slave.receive()==2)
+ else if( slave.receive()==3 || slave.receive()==2) // master to slave
{
t2.stop();
t3.start();
@@ -244,7 +245,7 @@
Thread::signal_wait(0x4);
int something = interrupt;
// printf("\n\r interrupt %d",interrupt);
- if(i2c_status == 0 )
+ if(i2c_status == 0 ) // read from CDMS (master)
{
// wait_ms(23);
@@ -254,22 +255,22 @@
i2c_data_r->length = 1;
i2c_data_receive.put(i2c_data_r);*/
printf("\n\r Data received from CDMS is %c \n\r",data_receive);
- FUNC_I2C_TC_EXECUTE(data_receive); // This has to be done from a differen thread
+ FUNC_I2C_TC_EXECUTE(data_receive); // telecommand // This has to be done from a differen thread
}
else if(i2c_status ==1)
{
- osEvent evt = i2c_data_send.get();
- if (evt.status == osEventMail)
+ osEvent evt = i2c_data_send.get(); //
+ if (evt.status == osEventMail) //
{
- i2c_data *i2c_data_s = (i2c_data*)evt.value.p;
- strcpy(data_send,i2c_data_s -> data);
+ i2c_data *i2c_data_s = (i2c_data*)evt.value.p; //syntax recieving address of data from queue and storing it in struct
+ strcpy(data_send,i2c_data_s -> data); // -> data from pointer
// wait_ms(13);
- FUNC_I2C_WRITE2CDMS(data_send,25);
+ FUNC_I2C_WRITE2CDMS(data_send,25);
printf("\n\rData sent to CDMS is %s\n\r",data_send);
- i2c_data_send.free(i2c_data_s);
+ i2c_data_send.free(i2c_data_s); // freeing the memory location from queue
i2c_status = 0;
}
}
@@ -279,19 +280,19 @@
-void FUNC_I2C_INT()
+void FUNC_I2C_INT() // ISR from CDMS to BAE
{
//i1.stop();
// t3.start();
- ptr_t_i2c->signal_set(0x4);
+ ptr_t_i2c->signal_set(0x4); // printf dosen't work....why??????????????????
//printf("\n ceckh\n");
t2.start();
// printf("\n\r time taken from interrupt to reach i2c fn %d",t2.read_us());
}
void FUNC_I2C_IR2CDMS()
-{
+{ // structure cannot sent via i2c so struct quantized to string n send to cdms n store in SD
data_ready=0;
//char data[25];
strcpy(hk_data,"hk_Data");
@@ -320,7 +321,7 @@
//data = pcslave.getc();
i2c_status=1;
- i2c_data * i2c_data_s = i2c_data_send.alloc();
+ i2c_data * i2c_data_s = i2c_data_send.alloc(); // writing to queue _____ dynamic memory allocation
strcpy(i2c_data_s->data,hk_data);
i2c_data_s->length = 25;
i2c_data_send.put(i2c_data_s);
@@ -347,7 +348,7 @@
//------------------------------------------------------------------------------------------------------------------------------------------------
-//SCHEDULER
+//SCHEDULER RTOS timer can be called periodically
//------------------------------------------------------------------------------------------------------------------------------------------------
int beacon_sc = 3;
uint16_t schedcount=1;
@@ -355,7 +356,7 @@
{
//DRDY=0;
printf("The value of i in scheduler is %d\n\r",schedcount);
- if(schedcount == 65532) //to reset the counter
+ if(schedcount == 65532) //to reset the counter // when it reaches here back to intial state
{
schedcount = 0;
}
@@ -400,7 +401,7 @@
//ptr_t_sc = new Thread(T_SC);
ptr_t_wdt = new Thread(T_WDT);
- interrupt_fault(); // Dummy function called when a fault interrupt is detected
+ interrupt_fault(); // Dummy function called when a fault interrupt is detected // intrrupt based fault
ptr_t_acs->set_priority(osPriorityAboveNormal);
ptr_t_i2c->set_priority(osPriorityHigh);
@@ -414,14 +415,14 @@
printf("\n\r T_ACS priority is %d",ptr_t_acs->get_priority());
printf("\n\r T_HK_ACQ priority is %d",ptr_t_hk_acq->get_priority());
printf("\n\r T_BEA priority is %d",ptr_t_bea->get_priority());
- RtosTimer t_sc_timer(T_SC,osTimerPeriodic);
+ RtosTimer t_sc_timer(T_SC,osTimerPeriodic); //values -3 tpo +3
t_sc_timer.start(10000);
printf("\n\r%f\n\r",t1.read());
interrupt.rise(&FUNC_I2C_INT); //interrupt received from CDMS
while(1) //required to prevent main from terminating
{
- Thread::wait(5000);
+ Thread::wait(5000); // main by default a thread of priority 0
}
}
