Skip to content

Commit

Permalink
docs(adc): added adc calibration doc on h2
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoxu committed Nov 13, 2023
1 parent c5e107c commit df46426
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion components/efuse/esp32c6/include/esp_efuse_rtc_calib.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {
#define ESP_EFUSE_ADC_CALIB_VER2 2
#define ESP_EFUSE_ADC_CALIB_VER_MIN ESP_EFUSE_ADC_CALIB_VER1
#define ESP_EFUSE_ADC_CALIB_VER_MAX ESP_EFUSE_ADC_CALIB_VER2
#define VER2IDX(ver) (ver - 1) // Version number to index number of the array
#define VER2IDX(ver) ((ver) - 1) // Version number to index number of the array
/**
* @brief Get the RTC calibration efuse version
*
Expand Down
7 changes: 3 additions & 4 deletions components/efuse/esp32h2/include/esp_efuse_rtc_calib.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
#define ESP_EFUSE_ADC_CALIB_VER1 1
#define ESP_EFUSE_ADC_CALIB_VER_MIN ESP_EFUSE_ADC_CALIB_VER1
#define ESP_EFUSE_ADC_CALIB_VER_MAX ESP_EFUSE_ADC_CALIB_VER1
#define VER2IDX(ver) (ver - 1) // Version number to index number of the array
#define VER2IDX(ver) ((ver) - 1) // Version number to index number of the array

/**
* @brief Get the RTC calibration efuse version
Expand All @@ -38,10 +38,9 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
* @brief Get the channel specific calibration compensation
*
* @param version Version of the stored efuse
* @param adc_unit ADC unit. Not used, for compatibility. On ESP32H2, for calibration v1, both ADC units use the same init code (calibrated by ADC1)
* @param adc_channel ADC channel number
* @param adc_unit ADC unit. Not used, for compatibility. ESP32H2 only supports one ADC unit
* @param atten Attenuation of the init code
* @return The channel calibration compensation value
* @return The channel calibration compensation value
*/
int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_t adc_channel, int atten);

Expand Down
1 change: 0 additions & 1 deletion docs/docs_not_updated/esp32h2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ api-guides/index
api-reference/peripherals/i2s
api-reference/peripherals/spi_features
api-reference/peripherals/sdio_slave
api-reference/peripherals/adc_calibration
api-reference/peripherals/dedic_gpio
api-reference/peripherals/sd_pullup_requirements
api-reference/peripherals/index
Expand Down
16 changes: 6 additions & 10 deletions docs/en/api-reference/peripherals/adc_calibration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ If you use your custom ADC calibration schemes, you could either modify this fun

.. only:: esp32

There is also a configuration :cpp:member:`adc_cali_line_fitting_config_t::default_vref`. Normally this can be simply set to 0. Line Fitting scheme does not rely on this value. However, if the Line Fitting scheme required eFuse bits are not burnt on your board, the driver will rely on this value to do the calibration.
There is also a configuration :cpp:member:`adc_cali_line_fitting_config_t::default_vref`. Normally this can be simply set to 0. Line Fitting scheme does not rely on this value. However, if the Line Fitting scheme required eFuse bits are not burned on your board, the driver will rely on this value to do the calibration.

You can use :cpp:func:`adc_cali_scheme_line_fitting_check_efuse` to check the eFuse bits. Normally the Line Fitting scheme eFuse value is :c:macro:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_TP` or :c:macro:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_VREF`. This means the Line Fitting scheme uses calibration parameters burnt in the eFuse to do the calibration.
You can use :cpp:func:`adc_cali_scheme_line_fitting_check_efuse` to check the eFuse bits. Normally the Line Fitting scheme eFuse value is :c:macro:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_TP` or :c:macro:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_VREF`. This means the Line Fitting scheme uses calibration parameters burned in the eFuse to do the calibration.

When the Line Fitting scheme eFuse value is :c:macro:`ADC_CALI_LINE_FITTING_EFUSE_VAL_DEFAULT_VREF`, you need to set the :cpp:member:`esp_adc_cali_line_fitting_init::default_vref`. Default vref is an estimate of the ADC reference voltage provided as a parameter during calibration.

After setting up the configuration structure, call :cpp:func:`adc_cali_create_scheme_line_fitting` to create a Line Fitting calibration scheme handle.

.. only:: esp32s2

This function may fail due to reasons such as :c:macro:`ESP_ERR_INVALID_ARG` or :c:macro:`ESP_ERR_NO_MEM`. Especially, when the function returns :c:macro:`ESP_ERR_NOT_SUPPORTED`, this means the calibration scheme required eFuse bits are not burnt on your board.
This function may fail due to reasons such as :c:macro:`ESP_ERR_INVALID_ARG` or :c:macro:`ESP_ERR_NO_MEM`. Especially, when the function returns :c:macro:`ESP_ERR_NOT_SUPPORTED`, this means the calibration scheme required eFuse bits are not burned on your board.

.. code:: c
Expand All @@ -82,22 +82,22 @@ If you use your custom ADC calibration schemes, you could either modify this fun
ESP_ERROR_CHECK(adc_cali_delete_scheme_line_fitting(handle));
.. only:: esp32c3 or esp32s3 or esp32c6
.. only:: esp32c3 or esp32s3 or esp32c6 or esp32h2

ADC Calibration Curve Fitting Scheme
````````````````````````````````````

{IDF_TARGET_NAME} supports :c:macro:`ADC_CALI_SCHEME_VER_CURVE_FITTING` scheme. To create this scheme, set up :cpp:type:`adc_cali_curve_fitting_config_t` first.


.. only:: not esp32c6
.. only:: esp32c3 or esp32s3

- :cpp:member:`adc_cali_curve_fitting_config_t::unit_id`, the ADC that your ADC raw results are from.
- :cpp:member:`adc_cali_curve_fitting_config_t::chan`, this member is kept here for extensibility. The calibration scheme only differs by attenuation, there is no difference among different channels.
- :cpp:member:`adc_cali_curve_fitting_config_t::atten`, ADC attenuation that your ADC raw results use.
- :cpp:member:`adc_cali_curve_fitting_config_t::bitwidth`, bit width of ADC raw result.

.. only:: esp32c6
.. only:: esp32c6 or esp32h2

- :cpp:member:`adc_cali_curve_fitting_config_t::unit_id`, the ADC that your ADC raw results are from.
- :cpp:member:`adc_cali_curve_fitting_config_t::chan`, the ADC channel that your ADC raw results are from. The calibration scheme not only differs by attenuation but is also related to the channels.
Expand Down Expand Up @@ -132,10 +132,6 @@ If you use your custom ADC calibration schemes, you could either modify this fun
ESP_ERROR_CHECK(adc_cali_delete_scheme_curve_fitting(handle));
.. only:: esp32h2

There is no supported calibration scheme yet.

.. note::

If you want to use your custom calibration schemes, you could provide a creation function to create your calibration scheme handle. Check the function table ``adc_cali_scheme_t`` in ``components/esp_adc/interface/adc_cali_interface.h`` to know the ESP ADC calibration interface.
Expand Down
10 changes: 3 additions & 7 deletions docs/zh_CN/api-reference/peripherals/adc_calibration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ ADC 校准驱动程序会提供 ADC 校准方案。对于驱动程序来说,
ESP_ERROR_CHECK(adc_cali_delete_scheme_line_fitting(handle));
.. only:: esp32c3 or esp32s3 or esp32c6
.. only:: esp32c3 or esp32s3 or esp32c6 or esp32h2

ADC 校准曲线拟合方案
````````````````````````````````````

{IDF_TARGET_NAME} 支持 :c:macro:`ADC_CALI_SCHEME_VER_CURVE_FITTING` 方案。要创建此方案,请先根据以下配置选项,设置 :cpp:type:`adc_cali_curve_fitting_config_t`。


.. only:: not esp32c6
.. only:: esp32c3 or esp32s3

- :cpp:member:`adc_cali_curve_fitting_config_t::unit_id`,表示 ADC 原始结果来自哪个 ADC 单元。
- :cpp:member:`adc_cali_curve_fitting_config_t::chan`,此选项保留以供扩展。校准方案仅因衰减程度而异,与通道选择无关。
- :cpp:member:`adc_cali_curve_fitting_config_t::atten`,表示 ADC 原始结果的衰减程度。
- :cpp:member:`adc_cali_curve_fitting_config_t::bitwidth`,表示 ADC 原始结果的位宽。

.. only:: esp32c6
.. only:: esp32c6 or esp32h2

- :cpp:member:`adc_cali_curve_fitting_config_t::unit_id`,表示 ADC 原始结果来自哪个 ADC 单元。
- :cpp:member:`adc_cali_curve_fitting_config_t::chan`,表示获取 ADC 原始结果的 ADC 通道。校准方案不仅因衰减程度而异,还与通道选择有关。
Expand Down Expand Up @@ -132,10 +132,6 @@ ADC 校准驱动程序会提供 ADC 校准方案。对于驱动程序来说,
ESP_ERROR_CHECK(adc_cali_delete_scheme_curve_fitting(handle));
.. only:: esp32h2

目前尚不支持任何校准方案。

.. note::

要使用自定义校准方案,可以通过提供创建函数,创建自己的校准方案句柄。请参阅 ``components/esp_adc/interface/adc_cali_interface.h`` 中的函数表 ``adc_cali_scheme_t``,了解 ESP ADC 校准接口。
Expand Down

0 comments on commit df46426

Please sign in to comment.