cancel
Showing results for 
Search instead for 
Did you mean: 

Example or instructions on HAL_I2C_Slave_Seq_* functions.

HoangHung
Associate

HAL_I2C_Slave_Seq_Transmit_* and HAL_I2C_Slave_Seq_Receive_* functions

I have to program an I2C slave which during communication the transfer direction switch. The HAL driver manual does not go into too much details. Are there example code anywhere? 

Thank in advance.

2 REPLIES 2
MOBEJ
ST Employee

Hello @HoangHung , 

We recommend checking out the examples provided in the STM32CubeF1 package, specifically for the STM32F103RB-Nucleo board. There are examples demonstrating how to handle I2C data buffer transmission and reception between two boards in different modes, such as polling, DMA, and interrupt.

You can find these examples in the STM32CubeF1 in GitHub . Exploring these examples should give you a clearer understanding and help resolve your issue.

Br

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Saket_Om
ST Employee

Hello @HoangHung 

It is possible to check the transfer direction on the HAL_I2C_AddrCallback() function.

HAL_I2C_EnableListen_IT(&hi2cx);

void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode)
{
  if (TransferDirection == Tx)
  {
    HAL_I2C_Slave_Seq_Transmit_*();
  }
  else
  {
    HAL_I2C_Slave_Seq_Receive_*();
  }
}

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om