/** * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration * information for the PVD. * @note Refer to the electrical characteristics of your device datasheet for * more details about the voltage threshold corresponding to each * detection level. * @retval None */ void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD) { /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); /* Set PLS[7:5] bits according to PVDLevel value */ MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel); /* Configure the EXTI 16 interrupt */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_RISING)) { __HAL_PVD_EXTI_ENABLE_IT(PWR_EXTI_LINE_PVD); } /* Configure the rising edge */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_RISING)) { EXTI->RTSR |= PWR_EXTI_LINE_PVD; } /* Configure the falling edge */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_FALLING)) { EXTI->FTSR |= PWR_EXTI_LINE_PVD; } }
/** * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration * information for the PVD. * @note Refer to the electrical characteristics of your device datasheet for * more details about the voltage threshold corresponding to each * detection level. * @retval None */ void HAL_PWR_PVDConfig(PWR_PVDTypeDef * sConfigPVD) { /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); /* Set PLS[7:5] bits according to PVDLevel value */ MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel); /* Clear any previous config. Keep it clear if no event or IT mode is selected */ __HAL_PWR_PVD_EXTI_DISABLE_EVENT(); __HAL_PWR_PVD_EXTI_DISABLE_IT(); __HAL_PWR_PVD_EXTI_CLEAR_EGDE_TRIGGER(); /* Configure interrupt mode */ if ((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT) { __HAL_PWR_PVD_EXTI_ENABLE_IT(); } /* Configure event mode */ if ((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT) { __HAL_PWR_PVD_EXTI_ENABLE_EVENT(); } /* Configure the edge */ if ((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE) { __HAL_PWR_PVD_EXTI_SET_RISING_EDGE_TRIGGER(); } if ((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE) { __HAL_PWR_PVD_EXTI_SET_FALLING_EGDE_TRIGGER(); } }
/** * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration * information for the PVD. * @note Refer to the electrical characteristics of your device datasheet for * more details about the voltage threshold corresponding to each * detection level. * @retval None */ void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); tmpreg = PWR->CR; /* Clear PLS[7:5] bits */ tmpreg &= ~ (uint32_t)PWR_CR_PLS; /* Set PLS[7:5] bits according to PVDLevel value */ tmpreg |= sConfigPVD->PVDLevel; /* Store the new value */ PWR->CR = tmpreg; /* Configure the EXTI 16 interrupt */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_RISING)) { __HAL_PVD_EXTI_ENABLE_IT(PWR_EXTI_LINE_PVD); } /* Clear the edge trigger for the EXTI Line 16 (PVD) */ EXTI->RTSR &= ~EXTI_RTSR_TR16; EXTI->FTSR &= ~EXTI_FTSR_TR16; /* Configure the rising edge */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_RISING)) { EXTI->RTSR |= PWR_EXTI_LINE_PVD; } /* Configure the falling edge */ if((sConfigPVD->Mode == PWR_MODE_IT_RISING_FALLING) ||\ (sConfigPVD->Mode == PWR_MODE_IT_FALLING)) { EXTI->FTSR |= PWR_EXTI_LINE_PVD; } }
/** * @brief Configure the voltage threshold detected by the Power Voltage Detector (PVD). * @param sConfigPVD: pointer to a PWR_PVDTypeDef structure that contains the PVD * configuration information. * @note Refer to the electrical characteristics of your device datasheet for * more details about the voltage thresholds corresponding to each * detection level. * @retval None */ HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD) { /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); /* Set PLS bits according to PVDLevel value */ MODIFY_REG(PWR->CR2, PWR_CR2_PLS, sConfigPVD->PVDLevel); /* Clear any previous config. Keep it clear if no event or IT mode is selected */ __HAL_PWR_PVD_EXTI_DISABLE_EVENT(); __HAL_PWR_PVD_EXTI_DISABLE_IT(); __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE(); /* Configure interrupt mode */ if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT) { __HAL_PWR_PVD_EXTI_ENABLE_IT(); } /* Configure event mode */ if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT) { __HAL_PWR_PVD_EXTI_ENABLE_EVENT(); } /* Configure the edge */ if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE) { __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); } if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE) { __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); } return HAL_OK; }
/** * @brief Configure the voltage threshold detected by the Power Voltage Detector(PVD). * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration * information for the PVD. * @note Refer to the electrical characteristics of your device datasheet for * more details about the voltage threshold corresponding to each * detection level. * @retval None */ void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD) { /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel)); assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode)); /* Set PLS[7:5] bits according to PVDLevel value */ MODIFY_REG(PWR->CR1, PWR_CR1_PLS, sConfigPVD->PVDLevel); /* Clear any previous config */ __HAL_PWR_PVD_EXTI_DISABLE_EVENT(); __HAL_PWR_PVD_EXTI_DISABLE_IT(); __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE(); __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); /* Configure interrupt mode */ if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT) { __HAL_PWR_PVD_EXTI_ENABLE_IT(); } /* Configure event mode */ if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT) { __HAL_PWR_PVD_EXTI_ENABLE_EVENT(); } /* Configure the edge */ if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE) { __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); } if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE) { __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); } }