/** * @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) { /* 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 PWR_PVDLevel: specifies the PVD detection level * This parameter can be one of the following values: * @arg PWR_PVDLevel_2V2: PVD detection level set to 2.2V * @arg PWR_PVDLevel_2V3: PVD detection level set to 2.3V * @arg PWR_PVDLevel_2V4: PVD detection level set to 2.4V * @arg PWR_PVDLevel_2V5: PVD detection level set to 2.5V * @arg PWR_PVDLevel_2V6: PVD detection level set to 2.6V * @arg PWR_PVDLevel_2V7: PVD detection level set to 2.7V * @arg PWR_PVDLevel_2V8: PVD detection level set to 2.8V * @arg PWR_PVDLevel_2V9: PVD detection level set to 2.9V * @retval None */ void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) { #ifdef OS_UCOS OS_CPU_SR cpu_sr; #endif uint32_t tmpreg = 0; #ifdef OS_UCOS OS_ENTER_CRITICAL(); #endif /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); tmpreg = PWR->CR; /* Clear PLS[7:5] bits */ tmpreg &= CR_PLS_MASK; /* Set PLS[7:5] bits according to PWR_PVDLevel value */ tmpreg |= PWR_PVDLevel; /* Store the new value */ PWR->CR = tmpreg; #ifdef OS_UCOS OS_EXIT_CRITICAL(); #endif }
/** * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). * @param PWR_PVDLevel: specifies the PVD detection level * This parameter can be one of the following values: * @arg PWR_PVDLevel_1V85: PVD detection level set to 1.85V * @arg PWR_PVDLevel_2V05: PVD detection level set to 2.05V * @arg PWR_PVDLevel_2V26: PVD detection level set to 2.26V * @arg PWR_PVDLevel_2V45: PVD detection level set to 2.45V * @arg PWR_PVDLevel_2V65: PVD detection level set to 2.65V * @arg PWR_PVDLevel_2V85: PVD detection level set to 2.85V * @arg PWR_PVDLevel_3V05: PVD detection level set to 3.05V * @arg PWR_PVDLevel_PVDIn: External input analog voltage (Compare internally to VREFINT) * @retval None */ void PWR_PVDLevelConfig(PWR_PVDLevel_TypeDef PWR_PVDLevel) { /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); /* Clear the PVD level */ PWR->CSR1 &= (uint8_t)(~PWR_CSR1_PLS); /* Configure the PVD level */ PWR->CSR1 |= PWR_PVDLevel; }
/** * @brief Configures the voltage threshold detected by the Power Voltage * Detector(PVD). * @param PWR_PVDLevel: specifies the PVD detection level * This parameter can be one of the following values: * @arg PWR_PVDLevel_2V2: PVD detection level set to 2.2V * @arg PWR_PVDLevel_2V3: PVD detection level set to 2.3V * @arg PWR_PVDLevel_2V4: PVD detection level set to 2.4V * @arg PWR_PVDLevel_2V5: PVD detection level set to 2.5V * @arg PWR_PVDLevel_2V6: PVD detection level set to 2.6V * @arg PWR_PVDLevel_2V7: PVD detection level set to 2.7V * @arg PWR_PVDLevel_2V8: PVD detection level set to 2.8V * @arg PWR_PVDLevel_2V9: PVD detection level set to 2.9V * @retval : None */ void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); tmpreg = PWR->CR; /* Clear PLS[7:5] bits */ tmpreg &= CR_PLS_Mask; /* Set PLS[7:5] bits according to PWR_PVDLevel value */ tmpreg |= PWR_PVDLevel; /* Store the new value */ PWR->CR = tmpreg; }
/******************************************************************************* * 函数名称: PWR_PVDLevelConfig * 功能描述: 配置由电源电压探测器探测的电压门限值(PVD). * 输入参数: PWR_PVDLevel:PVD探测电平。 * 这个参数可以取下面的值之一: * - PWR_PVDLevel_2V2: PVD探测电平设置为 2.2V * - PWR_PVDLevel_2V3: PVD探测电平设置为 2.3V * - PWR_PVDLevel_2V4: PVD探测电平设置为 2.4V * - PWR_PVDLevel_2V5: PVD探测电平设置为 2.5V * - PWR_PVDLevel_2V6: PVD探测电平设置为 2.6V * - PWR_PVDLevel_2V7: PVD探测电平设置为 2.7V * - PWR_PVDLevel_2V8: PVD探测电平设置为 2.8V * - PWR_PVDLevel_2V9: PVD探测电平设置为 2.9V * 输出参数: 无 * 返回参数: 无 *******************************************************************************/ void PWR_PVDLevelConfig(u32 PWR_PVDLevel) { u32 tmpreg = 0; /* Check the parameters [检查参数]*/ assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); tmpreg = PWR->CR; /* Clear PLS[7:5] bits [清零PLS[7:5]位]*/ tmpreg &= CR_PLS_Mask; /* Set PLS[7:5] bits according to PWR_PVDLevel value [依照PWR_PVDLevel的值置位PLS[7:5]]*/ tmpreg |= PWR_PVDLevel; /* Store the new value [保存新的值]*/ PWR->CR = tmpreg; }
/** * @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)); 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(); } }