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
Diff: main.cpp
- Revision:
- 3:0931a8800543
- Parent:
- 2:3d9ca9554adf
- Child:
- 4:65a2d0b97d01
--- a/main.cpp Thu Apr 09 15:12:12 2015 +0000
+++ b/main.cpp Wed May 13 06:19:25 2015 +0000
@@ -12,12 +12,15 @@
InterruptIn interrupt(PIN97); //I2c interrupt from CDMS
DigitalOut data_ready(PIN90); //Sends interrupt to CDMS
+//InterruptIn interrupt(D9); //I2c interrupt from CDMS
+//DigitalOut data_ready(D10);
Timer t; //To know the time of execution each thread
Timer t1; //To know the time of entering of each thread
Timer t2; //To check the time sync in i2c communication
Timer t3; //To know the time taken by i2c read/write function
-
+Timer i1;
+Timer i2;
/*****************************************************************Threads USed***********************************************************************************/
Thread *ptr_t_hk_acq;
Thread *ptr_t_acs;
@@ -26,8 +29,8 @@
Thread *ptr_t_wdt;
/****************************************************************configuring I2c*********************************************************************************/
-I2CSlave slave(PIN72,PIN71); //configuring pins p27, p28 as I2Cslave
-
+I2CSlave slave(PIN1,PIN2); //configuring pins p27, p28 as I2Cslave
+//I2CSlave slave (D14,D15);
int i2c_status=0; //read or write mode for i2c 0: write2slave 1: write2master
typedef struct //structure of i2c data
{
@@ -84,7 +87,7 @@
printf("\n\rEntered ACS %f\n",t1.read());
t.start();
FUNC_ACS_MAG_EXEC(mag_field);
- printf("\n\r check");
+ //printf("\n\r check");
for(int i=0; i<3; i++)
{
printf("%f\t",mag_field[i]);
@@ -198,8 +201,14 @@
void FUNC_I2C_WRITE2CDMS(char *data, int length=1)
{
int slave_status = 1;
- if(interrupt ==1)
- {
+ int inter_test = interrupt;
+ int slr = slave.receive();
+ wait_ms(20);
+ //printf("\n\r time is %d\n",t2.read_us());
+ //if(interrupt ==1)
+ //{
+ //printf("\n\r slave status %d",slave.receive());
+ //t2.stop();
if(slave.receive() == 0)
t2.stop();
if( slave.receive()==1)
@@ -216,10 +225,14 @@
slave_status=slave.read(data,length);
t3.stop();
}
- }
- printf("\n\r%d\r",t2.read_us());
+ //}
+ // printf("\n\r time taken to receive intrpt 4m cdms %d",i1.read_us());
+ //i1.reset();
+ printf("\n\r slave status %d %d %d",slave.receive(),t2.read_us(),t3.read_us());
+ // printf("\n\r time taken from interrupt to reach i2c fn %d",t2.read_us());
+ t2.stop();
t2.reset();
- printf("\n\r%d\r",t3.read_us());
+ //printf("\n\r time to execute i2c function %d",t3.read_us());
t3.reset();
}
@@ -229,9 +242,12 @@
while(1)
{
Thread::signal_wait(0x4);
+ int something = interrupt;
+ // printf("\n\r interrupt %d",interrupt);
if(i2c_status == 0 )
+
{
- wait_ms(23);
+ // wait_ms(23);
FUNC_I2C_WRITE2CDMS(&data_receive,1);
/*i2c_data * i2c_data_r = i2c_data_receive.alloc();
i2c_data_r->data = data_receive;
@@ -248,7 +264,8 @@
{
i2c_data *i2c_data_s = (i2c_data*)evt.value.p;
strcpy(data_send,i2c_data_s -> data);
- wait_ms(29);
+ // wait_ms(13);
+
FUNC_I2C_WRITE2CDMS(data_send,25);
printf("\n\rData sent to CDMS is %s\n\r",data_send);
@@ -264,12 +281,13 @@
void FUNC_I2C_INT()
{
+ //i1.stop();
- t2.start();
// t3.start();
ptr_t_i2c->signal_set(0x4);
-
-
+ //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()
@@ -307,6 +325,7 @@
i2c_data_s->length = 25;
i2c_data_send.put(i2c_data_s);
data_ready=1;
+ // i1.start();
//temp = i2c_status;
}
@@ -343,7 +362,7 @@
if(schedcount%1==0)
{
- ptr_t_acs -> signal_set(0x1);
+ //ptr_t_acs -> signal_set(0x1);
//ptr_t_wdt -> signal_set(0x5);
}
if(schedcount%2==0)
@@ -369,11 +388,11 @@
{
t1.start();
printf("\n\rIITMSAT BAE Activated \n");
- INIT_PNI(); // Initializing mnm blue
- FUNC_ACS_MAG_INIT(); // Initializing magnetometer
+ //INIT_PNI(); // Initializing mnm blue
+ //FUNC_ACS_MAG_INIT(); // Initializing magnetometer
//FUNC_ACS_INIT_GYR(); // Initializing Gyroscope
slave.address(0x20); // setting slave address for BAE for I2C communication
-
+ //init_beacon();
ptr_t_hk_acq = new Thread(T_HK_ACQ);
ptr_t_acs = new Thread(T_ACS);
ptr_t_bea = new Thread(T_BEA);
