---revised VBAT-DETECT LINE ADC IN14 instead IN11

This commit is contained in:
Yunhorn 2024-07-08 16:10:33 +08:00
parent 0d05a65822
commit 390abd9943
4 changed files with 24816 additions and 24814 deletions

View File

@ -181,7 +181,9 @@ uint16_t STS_GetBatteryLevel(void)
uint16_t batteryLevelmV = 0;
uint32_t measuredLevel = 0;
measuredLevel = ADC_ReadChannels(LL_ADC_CHANNEL_11); //VBAT_DETECT PA15 ADC VIN11
//measuredLevel = ADC_ReadChannels(LL_ADC_CHANNEL_11); //VBAT_DETECT PA15 ADC VIN11
measuredLevel = ADC_ReadChannels(LL_ADC_CHANNEL_14); //LL_ADC_CHANNEL_14
//measuredLevel = ADC_ReadChannels(LL_ADC_CHANNEL_VBAT); fixed value of 3.6V
if (measuredLevel == 0)
{
batteryLevelmV = 0;
@ -199,11 +201,11 @@ uint16_t STS_GetBatteryLevel(void)
{
/* Device with Reference voltage not calibrated in production:
use generic parameters */
batteryLevelmV = (VREFINT_CAL_VREF * 1510) / measuredLevel;
batteryLevelmV = (uint16_t)(3*VREFINT_CAL_VREF * 1510) / measuredLevel;
}
}
return batteryLevelmV;
return (uint16_t)batteryLevelmV;
/* USER CODE BEGIN SYS_GetBatteryLevel_2 */
/* USER CODE END SYS_GetBatteryLevel_2 */

View File

@ -101,7 +101,7 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pin = GPIO_PIN_15; //VBAT_DETECT_PIN
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* EXTI interrupt init*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff