STM32CubeF3 V1.11.6 HAL GPIO source. Exact SHA256 in toolchain-and-validation.json.

GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
  GPIO_PinState bitstatus;

  /* Check the parameters */
  assert_param(IS_GPIO_PIN(GPIO_Pin));

  if((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
  {
    bitstatus = GPIO_PIN_SET;
  }
  else
  {
    bitstatus = GPIO_PIN_RESET;
  }
  return bitstatus;
}

void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
{
  /* Check the parameters */
  assert_param(IS_GPIO_PIN(GPIO_Pin));
  assert_param(IS_GPIO_PIN_ACTION(PinState));

  if(PinState != GPIO_PIN_RESET)
  {
    GPIOx->BSRR = (uint32_t)GPIO_Pin;
  }
  else
  {
    GPIOx->BRR = (uint32_t)GPIO_Pin;
  }
}

void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
  uint32_t odr;

  /* Check the parameters */
  assert_param(IS_GPIO_PIN(GPIO_Pin));

  /* get current Output Data Register value */
  odr = GPIOx->ODR;

  /* Set selected pins that were at low level, and reset ones that were high */
  GPIOx->BSRR = ((odr & GPIO_Pin) << GPIO_NUMBER) | (~odr & GPIO_Pin);
}

/* USER CODE BEGIN PD */
#define DEBOUNCE_MS 20U
/* USER CODE END PD */

/* USER CODE BEGIN PV */
volatile uint32_t raw_changes = 0U;
volatile uint32_t debounced_presses = 0U;
volatile GPIO_PinState raw_level = GPIO_PIN_SET;
volatile GPIO_PinState stable_level = GPIO_PIN_SET;
uint32_t raw_changed_at = 0U;
/* USER CODE END PV */

/* USER CODE BEGIN 2 */
  raw_level = HAL_GPIO_ReadPin(USER_BUTTON_GPIO_Port, USER_BUTTON_Pin);
  stable_level = raw_level;
  raw_changed_at = HAL_GetTick();
  HAL_GPIO_WritePin(USER_LED_GPIO_Port, USER_LED_Pin, GPIO_PIN_RESET);
  /* USER CODE END 2 */

/* USER CODE BEGIN 3 */
    GPIO_PinState sample = HAL_GPIO_ReadPin(USER_BUTTON_GPIO_Port, USER_BUTTON_Pin);
    uint32_t now = HAL_GetTick();

    if (sample != raw_level)
    {
      raw_level = sample;
      raw_changes++;
      raw_changed_at = now;
    }

    if ((raw_level != stable_level) &&
        ((uint32_t)(now - raw_changed_at) >= DEBOUNCE_MS))
    {
      stable_level = raw_level;
      if (stable_level == GPIO_PIN_RESET)
      {
        debounced_presses++;
        HAL_GPIO_TogglePin(USER_LED_GPIO_Port, USER_LED_Pin);
      }
    }
  }
  /* USER CODE END 3 */

ReadPin samples IDR. This F3 HAL WritePin uses BSRR to SET and BRR to RESET. TogglePin first reads ODR then writes BSRR; simultaneous toggle callers are not guaranteed an atomic toggle. A BSRR write itself does not require a software ODR read/modify/write.

Pin fields: PB6 MODER[13:12]=01, OTYPER[6]=0, OSPEEDR[13:12]=00, PUPDR[13:12]=00; PA3 MODER[7:6]=00, PUPDR[7:6]=00. PA3 IDR bit3, PB6 ODR bit6, BSRR set bit6/reset bit22; BRR reset bit6. These are configuration interpretations, not live register reads.
