From b4f699021cc37c397d8603992243ab3d828888a0 Mon Sep 17 00:00:00 2001 From: yuhang-ingchips <102842796+yuhang-ingchips@users.noreply.github.com> Date: Thu, 4 May 2023 17:44:24 +0800 Subject: [PATCH 1/2] updata ADC FtInit updata ADC FtInit with V12Data - 14 when ver=1 --- src/FWlib/peripheral_adc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/FWlib/peripheral_adc.c b/src/FWlib/peripheral_adc.c index 36dbc3644..aaa3fd14e 100644 --- a/src/FWlib/peripheral_adc.c +++ b/src/FWlib/peripheral_adc.c @@ -456,7 +456,6 @@ void ADC_ftInit(void) { if (ftCali) return; uint8_t readFlg = 0; - uint8_t addrType = 0; uint8_t ret = flash_prepare_factory_data(); const factory_calib_data_t *p_factoryCali = flash_get_factory_calib_data(); const uint16_t *p_adcCali = (const uint16_t *)flash_get_adc_calib_data(); @@ -465,12 +464,13 @@ void ADC_ftInit(void) ftCali = malloc(sizeof(SADC_ftCali_t)); memset(ftCali, 0, sizeof(SADC_ftCali_t)); + uint8_t ver; uint32_t flg; if (readFlg) flg = read_flash_security(0x1170); else flg = p_factoryCali->adc_calib_ver; - addrType = flg & ADC_MK_MASK(16); + ver = flg & ADC_MK_MASK(16); flg = (flg >> 16) & ADC_MK_MASK(16); uint32_t V1, V2; uint32_t V1_diff, V2_diff; @@ -513,7 +513,7 @@ void ADC_ftInit(void) Cin1 = V1 * 16384 / ftCali->Vp; Cin2 = V2 / 10 * 16384 / (ftCali->Vp / 10); for (i = 0; i < 8; ++i) { - if (addrType) { + if (ver) { if (readFlg) { Cout1 = read_flash_security(0x2000 + 4 * i) & ADC_MK_MASK(16); Cout2 = (read_flash_security(0x2000 + 4 * i) >> 16) & ADC_MK_MASK(16); @@ -536,7 +536,7 @@ void ADC_ftInit(void) Cin2 = (V2_diff - V1_diff) / 10 * 16384 / (ftCali->Vp / 10) + 8192; Cin1 = 16384 - Cin2; for (i = 0; i < 4; ++i) { - if (addrType) { + if (ver) { if (readFlg) { Cout1 = read_flash_security(0x2020 + 4 * i) & ADC_MK_MASK(16); Cout2 = (read_flash_security(0x2020 + 4 * i) >> 16) & ADC_MK_MASK(16); @@ -560,6 +560,8 @@ void ADC_ftInit(void) ftCali->V12Data = read_flash_security(0x1144) & ADC_MK_MASK(16); else ftCali->V12Data = p_factoryCali->v12_adc[0]; + if (ver == 1) + ftCali->V12Data -= 14; ftCali->f = ADC_FtCal; ADC_VrefRegister(ftCali->Vp * 0.00001f, 0.f); } From b082712edd1778593ee13fb3b310d6d1548564d6 Mon Sep 17 00:00:00 2001 From: yuhang-ingchips <102842796+yuhang-ingchips@users.noreply.github.com> Date: Sat, 6 May 2023 11:51:11 +0800 Subject: [PATCH 2/2] bugfix that fifo not empty after calibration bugfix that fifo not empty after calibration --- src/FWlib/peripheral_adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FWlib/peripheral_adc.c b/src/FWlib/peripheral_adc.c index aaa3fd14e..bed98b62d 100644 --- a/src/FWlib/peripheral_adc.c +++ b/src/FWlib/peripheral_adc.c @@ -617,6 +617,7 @@ void ADC_Calibration(SADC_adcIputMode mode) ADC_SetAdcMode(CONVERSION_MODE); ADC_EnableChannel(ADC_CH_0, 0); ADC_RegClr(SADC_CFG_0, 17, 1); + ADC_ClrFifo(); } void ADC_ConvCfg(SADC_adcCtrlMode ctrlMode,