mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
adc: update adc calibration efuse version
ADC calibration scheme and algorithm are not changed. Only the eFuse bit BLOCK1_VERSION is changed. This MR updated the logic to recognize the adc efuse version
This commit is contained in:
@ -19,20 +19,15 @@
|
|||||||
|
|
||||||
int esp_efuse_rtc_calib_get_ver(void)
|
int esp_efuse_rtc_calib_get_ver(void)
|
||||||
{
|
{
|
||||||
uint32_t blk1_version = 0;
|
uint32_t blk_ver_major = 0;
|
||||||
uint32_t blk2_version = 0;
|
ESP_ERROR_CHECK(esp_efuse_read_field_blob(ESP_EFUSE_BLK_VER_MAJOR, &blk_ver_major, ESP_EFUSE_BLK_VER_MAJOR[0]->bit_count));
|
||||||
ESP_ERROR_CHECK(esp_efuse_read_field_blob(ESP_EFUSE_BLOCK1_VERSION, &blk1_version, ESP_EFUSE_BLOCK1_VERSION[0]->bit_count));
|
|
||||||
ESP_ERROR_CHECK(esp_efuse_read_field_blob(ESP_EFUSE_BLOCK2_VERSION, &blk2_version, ESP_EFUSE_BLOCK2_VERSION[0]->bit_count));
|
|
||||||
|
|
||||||
if (blk1_version == blk2_version) {
|
uint32_t cali_version_v1 = (blk_ver_major == 1) ? 1 : 0;
|
||||||
return blk1_version;
|
if (!cali_version_v1) {
|
||||||
} else {
|
|
||||||
blk1_version = 0;
|
|
||||||
blk2_version = 0;
|
|
||||||
ESP_LOGW("eFuse", "calibration efuse version does not match, set default version: %d", 0);
|
ESP_LOGW("eFuse", "calibration efuse version does not match, set default version: %d", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return blk2_version;
|
return cali_version_v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int atten)
|
uint16_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int atten)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "esp_efuse_table.h"
|
#include "esp_efuse_table.h"
|
||||||
|
|
||||||
// md5_digest_table ee5142bc489eee22230a49b5c7cafe00
|
// md5_digest_table 9444b887379d924049af42806ca71d45
|
||||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||||
@ -412,8 +412,8 @@ static const esp_efuse_desc_t PKG_VERSION[] = {
|
|||||||
{EFUSE_BLK1, 117, 3}, // Package version,
|
{EFUSE_BLK1, 117, 3}, // Package version,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const esp_efuse_desc_t BLOCK1_VERSION[] = {
|
static const esp_efuse_desc_t BLK_VER_MINOR[] = {
|
||||||
{EFUSE_BLK1, 120, 3}, // BLOCK1 efuse version 0:No calibration 1:With calibration,
|
{EFUSE_BLK1, 120, 3}, // BLK_VERSION_MINOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const esp_efuse_desc_t ADC2_CAL_VOL_ATTEN3[] = {
|
static const esp_efuse_desc_t ADC2_CAL_VOL_ATTEN3[] = {
|
||||||
@ -424,8 +424,8 @@ static const esp_efuse_desc_t OPTIONAL_UNIQUE_ID[] = {
|
|||||||
{EFUSE_BLK2, 0, 128}, // Optional unique 128-bit ID,
|
{EFUSE_BLK2, 0, 128}, // Optional unique 128-bit ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const esp_efuse_desc_t BLOCK2_VERSION[] = {
|
static const esp_efuse_desc_t BLK_VER_MAJOR[] = {
|
||||||
{EFUSE_BLK2, 128, 4}, // Version of BLOCK2,
|
{EFUSE_BLK2, 128, 2}, // BLK_VERSION_MAJOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const esp_efuse_desc_t TEMP_CALIB[] = {
|
static const esp_efuse_desc_t TEMP_CALIB[] = {
|
||||||
@ -1031,8 +1031,8 @@ const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const esp_efuse_desc_t* ESP_EFUSE_BLOCK1_VERSION[] = {
|
const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MINOR[] = {
|
||||||
&BLOCK1_VERSION[0], // BLOCK1 efuse version 0:No calibration 1:With calibration
|
&BLK_VER_MINOR[0], // BLK_VERSION_MINOR
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1046,8 +1046,8 @@ const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const esp_efuse_desc_t* ESP_EFUSE_BLOCK2_VERSION[] = {
|
const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MAJOR[] = {
|
||||||
&BLOCK2_VERSION[0], // Version of BLOCK2
|
&BLK_VER_MAJOR[0], // BLK_VERSION_MAJOR
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@
|
|||||||
SPI_PAD_CONFIG_D7, EFUSE_BLK1, 108, 6, SPI_PAD_configure D7
|
SPI_PAD_CONFIG_D7, EFUSE_BLK1, 108, 6, SPI_PAD_configure D7
|
||||||
WAFER_VERSION, EFUSE_BLK1, 114, 3, WAFER version 0:A
|
WAFER_VERSION, EFUSE_BLK1, 114, 3, WAFER version 0:A
|
||||||
PKG_VERSION, EFUSE_BLK1, 117, 3, Package version
|
PKG_VERSION, EFUSE_BLK1, 117, 3, Package version
|
||||||
BLOCK1_VERSION, EFUSE_BLK1, 120, 3, BLOCK1 efuse version 0:No calibration 1:With calibration
|
BLK_VER_MINOR, EFUSE_BLK1, 120, 3, BLK_VERSION_MINOR, won't influence users
|
||||||
ADC2_CAL_VOL_ATTEN3, EFUSE_BLK1, 186, 6, ADC2 calibration voltage at atten3
|
ADC2_CAL_VOL_ATTEN3, EFUSE_BLK1, 186, 6, ADC2 calibration voltage at atten3
|
||||||
|
|
||||||
# SYS_DATA_PART1 BLOCK# - System configuration
|
# SYS_DATA_PART1 BLOCK# - System configuration
|
||||||
#######################
|
#######################
|
||||||
OPTIONAL_UNIQUE_ID, EFUSE_BLK2, 0, 128, Optional unique 128-bit ID
|
OPTIONAL_UNIQUE_ID, EFUSE_BLK2, 0, 128, Optional unique 128-bit ID
|
||||||
BLOCK2_VERSION, EFUSE_BLK2, 128, 4, Version of BLOCK2
|
BLK_VER_MAJOR, EFUSE_BLK2, 128, 2, BLK_VERSION_MAJOR, change of this bit means users need to update firmware
|
||||||
TEMP_CALIB, EFUSE_BLK2, 132, 9, Temperature calibration data
|
TEMP_CALIB, EFUSE_BLK2, 132, 9, Temperature calibration data
|
||||||
OCODE, EFUSE_BLK2, 141, 8, ADC OCode
|
OCODE, EFUSE_BLK2, 141, 8, ADC OCode
|
||||||
ADC1_INIT_CODE_ATTEN0, EFUSE_BLK2, 149, 8, ADC1 init code at atten0
|
ADC1_INIT_CODE_ATTEN0, EFUSE_BLK2, 149, 8, ADC1 init code at atten0
|
||||||
|
Can't render this file because it contains an unexpected character in line 8 and column 53.
|
@ -9,7 +9,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// md5_digest_table ee5142bc489eee22230a49b5c7cafe00
|
// md5_digest_table 9444b887379d924049af42806ca71d45
|
||||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||||
@ -114,10 +114,10 @@ extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D6[];
|
|||||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D7[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D7[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_WAFER_VERSION[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_WAFER_VERSION[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_BLOCK1_VERSION[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MINOR[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN3[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN3[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_BLOCK2_VERSION[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MAJOR[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_TEMP_CALIB[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_TEMP_CALIB[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_OCODE[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_OCODE[];
|
||||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN0[];
|
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN0[];
|
||||||
|
@ -69,25 +69,17 @@ void rtc_init(rtc_config_t cfg)
|
|||||||
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_RTC_DREG, RTC_CNTL_DBIAS_1V10);
|
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_RTC_DREG, RTC_CNTL_DBIAS_1V10);
|
||||||
|
|
||||||
if (cfg.cali_ocode) {
|
if (cfg.cali_ocode) {
|
||||||
uint32_t blk1_version = 0;
|
uint32_t blk_ver_major = 0;
|
||||||
uint32_t blk2_version = 0;
|
esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_BLK_VER_MAJOR, &blk_ver_major, ESP_EFUSE_BLK_VER_MAJOR[0]->bit_count);
|
||||||
esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_BLOCK1_VERSION, &blk1_version, 3);
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
blk1_version = 0;
|
blk_ver_major = 0;
|
||||||
SOC_LOGW(TAG, "efuse read fail, set default blk1_version: %d\n", blk1_version);
|
SOC_LOGW(TAG, "efuse read fail, set default blk_ver_major: %d\n", blk_ver_major);
|
||||||
}
|
}
|
||||||
err = esp_efuse_read_field_blob(ESP_EFUSE_BLOCK2_VERSION, &blk2_version, 4);
|
|
||||||
if (err != ESP_OK) {
|
//default blk_ver_major will fallback to using the self-calibration way for OCode
|
||||||
blk2_version = 0;
|
bool ocode_efuse_cali = (blk_ver_major == 1);
|
||||||
SOC_LOGW(TAG, "efuse read fail, set default blk2_version: %d\n", blk2_version);
|
if (ocode_efuse_cali) {
|
||||||
}
|
set_ocode_by_efuse(blk_ver_major);
|
||||||
if (blk1_version != blk2_version) {
|
|
||||||
blk1_version = 0;
|
|
||||||
blk2_version = 0;
|
|
||||||
SOC_LOGW(TAG, "calibration efuse version does not match, set default version: %d\n", 0);
|
|
||||||
}
|
|
||||||
if (blk2_version == 1) {
|
|
||||||
set_ocode_by_efuse(blk2_version);
|
|
||||||
} else {
|
} else {
|
||||||
calibrate_ocode();
|
calibrate_ocode();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user