i2c slave or master ???two carts stm32
hello i need to use i2c to exchange data between two stm32f103c8 ,
one sends datas the other blinks and in both sides sends and receive to each other , i use a simple exemple but in one side it works one is master transmitting then slave is receing byy interrupt
exemple stm(cart1) master trnsmits to slave -------------------------------> stm (cart2) slave receive ITby interrupts
but how to make boths sides
stm(cart1) transmit master receive slave or recieve master IT ----->stm(cart1)transmit master or slave and recieve
<-----slave or master
i cannot make it fullduplex wit same lines data and clk:
HAL_I2C_Slave_Receive_IT(&hi2c2,0,(uint8_t *)aRxBuffer,1);//ENABLE RECEIVE IC2 INTERRUPT
data_master[0]=i;
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c)
{if (hi2c->Instance == I2C2 ) {HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);//blink led if we received an interrupt byte from i2c line
HAL_I2C_Slave_Receive_IT(&hi2c2,(uint8_t *)aRxBuffer,1);//ENABLE RECEIVE IC2 INTERRUPT
}
}while(1)
{
HAL_I2C_Master_Transmit(&hi2c2,0,data_master,1,50);
HAL_Delay(50);
}
it bugs and i dont have any result both sides or one side ,
can you advice me one device can only be master or slave or can switch from one to another ,,, just i need to know how to send and receieve same time ???
