2020-12-23 01:04 AM
I am using STM32F7508-DK kit and Using I2C as a slave whereas ESP32 is a master, By using HAL_I2C_Slave_Receive_IT and HAL_I2C_Slave_Transmit_IT API I am able to do one way communication either read or write, but in my application I required read and write both in sequence, here I am facing issue.
Below is my set up details:
STM32CubeIDE, Version: 1.3.0
STM32 ST-LINK Utility V4.5.0
STM32 CubeMX, Version5.6.1
Here is my I2C configuration:
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x20404768;
hi2c1.Init.OwnAddress1 = 214;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
Looking forward to hear from you.
2020-12-23 05:36 AM
I don't see a specific technical question here. The I2C needs to read and write at various points, you'll need to implement logic to call HAL_I2C_Slave_Receive_IT and HAL_I2C_Slave_Transmit_IT at those points.
There are I2C examples in the cube repository you can look at for guidance. For example:
I would suggest getting it working with polling mode first, then graduate to interrupt mode.
2020-12-23 09:30 PM
I have already used polling mode but I am getting more failure in polling mode compare to interrupt mode. and how would I know which function do I call HAL_I2C_Slave_Receive_IT or HAL_I2C_Slave_Transmit_IT because master can ask for any request either read or write. to check this I have read ADDR flag and DIR flag and then I am calling respective function but still it is not working.