
CDMS integrated with pyld b4 checking
Dependencies: SDFileSystem mbed-rtos mbed-src mbed
Fork of cdms_i2csdrtc by
Revision 2:fa5a3ff74b74, committed 2015-04-13
- Comitter:
- greenroshks
- Date:
- Mon Apr 13 18:03:51 2015 +0000
- Parent:
- 1:59da9694681e
- Commit message:
- CDMS integrated with PAYLOAD b4 checking
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 59da9694681e -r fa5a3ff74b74 main.cpp --- a/main.cpp Fri Apr 10 16:13:02 2015 +0000 +++ b/main.cpp Mon Apr 13 18:03:51 2015 +0000 @@ -1,18 +1,20 @@ #include "mbed.h" #include "SDFileSystem.h" - +#define PYLD_ADD 0x48 +#define BAE_ADD 0x20 /************************Include the required Header files for the code *******************************/ -#include "mbed.h" +//#include "mbed.h" #include "string.h" #include "rtos.h" #include "pin_config.h" -const int addr = 0x20; //slave address +//const int addr = 0x20; //slave address I2C master (PIN72,PIN71); //configure pins p27,p28 as I2C master Serial pc (USBTX,USBRX); DigitalOut interrupt(PIN4); InterruptIn data_ready(PIN39); - +InterruptIn data_ready_pyld(PIN40); //to be changed for i2c comm. between pyld and bae +void store_data(char*); int reset; Timer t; @@ -30,6 +32,7 @@ Mail<i2c_data,16> i2c_data_send; Thread * ptr_t_i2c; +int switchflag = -1; // to switch between BAE and PYLD void FUNC_I2C_MASTER_FSLAVE(char * data,int length) { @@ -39,9 +42,12 @@ interrupt = 1; t1.start(); //wait_ms(20); - ack0 = master.read(addr|1,data,length); + if(switchflag == 0) + ack0 = master.read(BAE_ADD|1,data,length); + else if (switchflag==1) + ack0 = master.read(PYLD_ADD|1,data,length); t1.stop(); - + store_data(data); if(!ack0) { @@ -53,7 +59,7 @@ t1.reset(); interrupt=0; - + switchflag = -1; } typedef struct { @@ -129,9 +135,18 @@ } } -void FUNC_INT() +void FUNC_INT_BAE() { - + + switchflag = 0; + ptr_t_i2c->signal_set(0x1); + +} + +void FUNC_INT_PYLD() +{ + + switchflag = 1; ptr_t_i2c->signal_set(0x1); } @@ -164,8 +179,11 @@ i2c_data *i2c_data_s = (i2c_data*)evt.value.p; writedata = i2c_data_s -> data; t.stop(); - //t3.start(); - master_status_write = (bool) master.write(addr|0x00,&writedata,1); + //t3.start(); + if(data%2) + master_status_write = (bool) master.write(BAE_ADD|0x00,&writedata,1); + else + master_status_write = (bool) master.write(PYLD_ADD|0x00,&writedata,1); t3.stop(); if(master_status_write==0) { @@ -321,16 +339,16 @@ /******************************************END OF RTC CODE ****************************************/ -char count = 10; -void store_data() +//char count = 10; +void store_data(char *hkdata) { FUNC_CDMS_Gettime(); - char hk_data[25]; - count++; - strcpy(hk_data,"hk_Data "); - strcat(hk_data,"!@@#"); - hk_data[10] = count; + //char hk_data[25]; +// count++; + //strcpy(hk_data,"hk_Data "); + //strcat(hk_data,"!@@#"); +// hk_data[10] = count; //storedata(hk_data); mkdir("/sd/hk", 0777); char add[20]; @@ -345,7 +363,7 @@ else { - fprintf(fp, "%s ",hk_data); + fprintf(fp, "%s ",hkdata); fclose(fp); printf("\n File stored in SD card\n"); //printf("\n Reading from the file .... \n Data is %s\n",hk_data); @@ -381,13 +399,15 @@ Ticker tx; int main() -{ interrupt=0; +{ + interrupt=0; ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE); - master.frequency(100000); + master.frequency(100000); printf("IITMSAT - CDMS\n"); - + data_ready.rise(&FUNC_INT_BAE); + data_ready_pyld.rise(&FUNC_INT_PYLD); FUNC_CDMS_init_values(); - tx.attach(&store_data, 20.0); + //tx.attach(&store_data, 20); while(1) { FUNC_MASTER_WRITE();