title: Issue in the I2C communication - STM32 (HAL Library)
body: <p>I am facing an issue with the I2C communication.  During the first run the communication between the MCU and the sensor is okay then I can read and write in the sensor's registers without a problem.</p>
  <p>However, when I try to debug a second time I receive HAL_BUSY when I am trying to communicate with the sensor, the communication is just reestablished when the power supply of the board is cut and then fed again.</p>
  <p>The Code snippet to write to the register is the following:</p>
  <pre><code>HAL_StatusTypeDef MAX30105_WriteRegister(uint8_t reg_addr, uint8_t reg_value){
      HAL_StatusTypeDef returnValue = HAL_ERROR;
   
      //Check if the MAX30105 is ready in a trial of 5 times
      HAL_StatusTypeDef result = HAL_I2C_IsDeviceReady(&amp;hi2c1, MAX30105_ADDR, 5, 10);
      if (result == HAL_OK) // HAL_ERROR or HAL_BUSY or HAL_TIMEOUT
      {
          returnValue = HAL_I2C_Mem_Write(&amp;hi2c1, MAX30105_ADDR, reg_addr , 1, &amp;reg_value, sizeof(reg_value), 10);
          if(returnValue != HAL_OK)
              return returnValue;
      }
      return returnValue;
  }
  </code></pre>
  <p>The I2C setup is:</p>
  <pre><code>static void MX_I2C1_Init(void)
  {
   
    /* USER CODE BEGIN I2C1_Init 0 */
   
    /* USER CODE END I2C1_Init 0 */
   
    /* USER CODE BEGIN I2C1_Init 1 */
   
    /* USER CODE END I2C1_Init 1 */
    hi2c1.Instance = I2C1;
    hi2c1.Init.ClockSpeed = 100000;
    hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
    hi2c1.Init.OwnAddress1 = 0;
    hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
    hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
    hi2c1.Init.OwnAddress2 = 0;
    hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
    hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
    if (HAL_I2C_Init(&amp;hi2c1) != HAL_OK)
    {
      Error_Handler();
    }
    /* USER CODE BEGIN I2C1_Init 2 */
   
    /* USER CODE END I2C1_Init 2 */
   
  }
  </code></pre>
  <p>I tried in the boards STM32F407G and STM32F103 Blue Pill, both the same issue happened.</p>
  <p>The sensor is MAX30105 from Maxim.</p>
  <p>Is there something that I am missing for the I2C communication that results in such problem?</p>