cdms b4 check
Dependencies: SDFileSystem mbed-rtos mbed
Fork of CDMS_BAE_1 by
Diff: main.cpp
- Revision:
- 7:60e940b7a36b
- Parent:
- 6:ee97f01e6b7d
- Child:
- 8:4acac3bf5e9b
--- a/main.cpp Thu Feb 05 22:32:29 2015 +0000 +++ b/main.cpp Thu Feb 05 23:19:46 2015 +0000 @@ -1,28 +1,29 @@ #include "mbed.h" #include "rtos.h" #include "hk.h" - +#include "i2c.h" InterruptIn data_ready(D10); -InterruptIn data_ready1(D6); +InterruptIn data_ready1(D3); int init=0; char data_receive[25]; - +extern DigitalOut interrupt; +extern I2C master; Thread * ptr_t_hk; Thread * ptr_t_i2c1; - +/* void FUNC_HK_DATA() { storedata(data_receive,25); -} +}*/ void FUNC_SCIENCE_DATA() { printf("Saved Science in SD"); } -void T_I2C_HK(void const *args) +/*void T_I2C_HK(void const *args) { while(1) @@ -30,7 +31,7 @@ Thread::signal_wait(0x1); FUNC_HK_DATA(); } -} +}*/ void T_I2C_MASTER_FSLAVE1(void const *args) { @@ -40,6 +41,25 @@ FUNC_SCIENCE_DATA(); } } + +void T_I2C_MASTER_FSLAVE(void const *args) +{ + char data_receive[25]; + while(1) + { + Thread::signal_wait(0x1); + + + FUNC_I2C_MASTER_FSLAVE(data_receive,25); + /*i2c_data * i2c_data_r = i2c_data_receive.alloc(); + strcpy(i2c_data_r->data , data_receive); + i2c_data_r->length = 25; + i2c_data_receive.put(i2c_data_r);*/ + printf("\n Data received from slave is %s\n\r",data_receive); + //TC_DECODE(data_receive); + } +} + void FUNC_INT() { @@ -62,10 +82,24 @@ init_rtc(); init++; } - ptr_t_hk = new Thread (T_I2C_HK); + interrupt=0; + //ptr_t_hk = new Thread (T_I2C_HK); data_ready.rise(&FUNC_INT); ptr_t_i2c1= new Thread (T_I2C_MASTER_FSLAVE1); data_ready1.rise(&FUNC_INT1); + + //ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE); + // data_ready.rise(&FUNC_INT); + printf("\nstarted master\n"); + master.frequency(100000); + while(1) + { //Thread::wait(9000); + //interrupt = 1; + + FUNC_MASTER_WRITE(); + //interrupt = 0; + ; + } }