![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
while loop removed ( master cant send)
Fork of slave_working_obama by
Diff: main.cpp
- Revision:
- 12:f6b6954b65d6
- Parent:
- 11:907c02e9fb00
- Child:
- 13:fe24dd810078
--- a/main.cpp Thu Jan 22 14:32:28 2015 +0000 +++ b/main.cpp Sat Jan 24 11:50:04 2015 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "rtos.h" + void write_to_master(char); //function to write data to master Thread * ptr_t_i2c; I2CSlave slave(D14,D15); //configuring pins p27, p28 as I2Cslave @@ -22,7 +23,12 @@ Mail<i2c_data,16> i2c_data_receive; Mail<i2c_data,16> i2c_data_send; - +unsigned char* add_reg = (unsigned char*)0x40067000; + unsigned char* data_reg = (unsigned char*)0x40067004; + unsigned char* status_reg = (unsigned char*)0x40067003; + unsigned char* c1_reg = (unsigned char*)0x40067002; + unsigned char* c2_reg = (unsigned char*)0x40067005; + unsigned char* freq_reg = (unsigned char*)0x40067001; int receive_status =0; void FUNC_I2C_WRITE2CDMS(char *data, int length=1) { @@ -30,17 +36,13 @@ // printf("\nData is %c\n\r",*data); slave.address(0x20); - unsigned char* add_reg = (unsigned char*)0x40067000; - unsigned char* data_reg = (unsigned char*)0x40067004; - unsigned char* status_reg = (unsigned char*)0x40067003; - unsigned char* c1_reg = (unsigned char*)0x40067002; - unsigned char* c2_reg = (unsigned char*)0x40067005; - unsigned char* freq_reg = (unsigned char*)0x40067001; - while(slave_status && interrupt ==1) + + if(interrupt ==1) { //wait(2); + //printf("\nin int loop\n"); receive_status = slave.receive(); - + //printf("\n status %d \n",receive_status); if( receive_status==1) { // printf("\nslave receive b4: \n"); @@ -50,10 +52,12 @@ //printf("\nslave receive after: %d \n",slave.receive()); } + + else if( receive_status==3 || receive_status==2) { slave_status=slave.read(data,length); - // printf("\n\r read"); + } //printf("\n \r done while loop %d \n",slave.receive()); //printf("\n\r ahoy drhghhhhhhhhhhh\n"); @@ -139,10 +143,11 @@ int main() { + printf("\n slave started\n\r"); ptr_t_i2c = new Thread(T_I2C_BAE); - master_reset.fall(&FUNC_RESET); + interrupt.rise(&FUNC_INT); while(1) {