STMicroelectronics / stm32u5xx-hal-driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32U5 series.
BSD 3-Clause "New" or "Revised" License
8 stars 11 forks source link

Handling of `Wake up from Stop 3` interrupt #11

Open stef333 opened 2 months ago

stef333 commented 2 months ago

In the void HAL_PWREx_S3WU_IRQHandler(uint32_t WakeUpPin) callback is called with the WakeUpPin parameter, which does not indicate that specific interrupt occurred. Instead, it only forwards the WakeUpPin variable which contains information about which pins should trigger the handler. Also since wake up flag is cleared in the HAL_PWREx_S3WU_IRQHandler we can't check it later.

Proposed Change

Invoke the callback with the pin that triggered the interrupt:

...

  if ((WakeUpPin & PWR_WAKEUP_PIN1) != 0U)
  {
    if (READ_BIT(PWR->WUSR, PWR_WUSR_WUF1) != 0U)
    {
      /* Clear PWR wake up flag line 1 */
      SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF1);

      /* PWR S3WU interrupt user callback */
      HAL_PWREx_S3WUCallback(PWR_WAKEUP_PIN1); // instead of   HAL_PWREx_S3WUCallback(WakeUpPin);
    }
  }

...

or call callback for all interrupts at once:


...

  uint32_t local_wkp = 0;

  if ((WakeUpPin & PWR_WAKEUP_PIN1) != 0U)
  {
    if (READ_BIT(PWR->WUSR, PWR_WUSR_WUF1) != 0U)
    {
      /* Clear PWR wake up flag line 1 */
      SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF1);

      /* PWR S3WU interrupt user callback */
       local_wkp |= PWR_WAKEUP_PIN1;
    }
  }

  if ((WakeUpPin & PWR_WAKEUP_PIN2) != 0U)
  {
    if (READ_BIT(PWR->WUSR, PWR_WUSR_WUF2) != 0U)
    {
      /* Clear PWR wake up flag line 2 */
      SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF2);

      /* PWR S3WU interrupt user callback */
      local_wkp |= PWR_WAKEUP_PIN2;
    }
  }

    HAL_PWREx_S3WUCallback(local_wkp); 

}
TOUNSTM commented 1 month ago

ST Internal Reference: 192355