Merge branch 'doc/add_types_api_ref_v4.1' into 'release/v4.1'

doc: add peripheral_types.h as API reference for peripheral docs (v4.1)

See merge request espressif/esp-idf!8895
This commit is contained in:
Krzysztof Budzynski 2020-05-27 17:44:30 +08:00
commit a02a782ee9
15 changed files with 36 additions and 15 deletions

View file

@ -26,6 +26,8 @@ typedef enum {
GPIO_PORT_MAX,
} gpio_port_t;
/** @cond */ //Doxy command to hide preprocessor definitions from docs */
#define GPIO_SEL_0 (BIT(0)) /*!< Pin 0 selected */
#define GPIO_SEL_1 (BIT(1)) /*!< Pin 1 selected */
#define GPIO_SEL_2 (BIT(2)) /*!< Pin 2 selected */
@ -130,6 +132,8 @@ typedef enum {
#define GPIO_PIN_REG_46 IO_MUX_GPIO46_REG
#endif
/** @endcond */
typedef enum {
GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */
GPIO_NUM_0 = 0, /*!< GPIO0, input and output */

View file

@ -29,6 +29,8 @@ typedef enum {
#endif
} spi_host_device_t;
/** @cond */ //Doxy command to hide preprocessor definitions from docs */
//alias for different chips
#ifdef CONFIG_IDF_TARGET_ESP32
#define SPI_HOST SPI1_HOST
@ -40,3 +42,5 @@ typedef enum {
#define HSPI_HOST SPI3_HOST
#define VSPI_HOST SPI4_HOST
#endif
/** @endcond */

View file

@ -19,9 +19,9 @@ Configuration and Reading ADC
The ADC should be configured before reading is taken.
- For ADC1, configure desired precision and attenuation by calling functions :cpp:func:`adc1_config_width` and :cpp:func:`adc1_config_channel_atten`.
- For ADC1, configure desired precision and attenuation by calling functions :cpp:func:`adc1_config_width` and :cpp:func:`adc1_config_channel_atten`.
- For ADC2, configure the attenuation by :cpp:func:`adc2_config_channel_atten`. The reading width of ADC2 is configured every time you take the reading.
Attenuation configuration is done per channel, see :cpp:type:`adc1_channel_t` and :cpp:type:`adc2_channel_t`, set as a parameter of above functions.
Then it is possible to read ADC conversion result with :cpp:func:`adc1_get_raw` and :cpp:func:`adc2_get_raw`. Reading width of ADC2 should be set as a parameter of :cpp:func:`adc2_get_raw` instead of in the configuration functions.
@ -55,7 +55,7 @@ Reading voltage on ADC2 channel 7 (GPIO 27)::
#include <driver/adc.h>
...
int read_raw;
adc2_config_channel_atten( ADC2_CHANNEL_7, ADC_ATTEN_0db );
@ -92,7 +92,7 @@ The ESP32 ADC can be sensitive to noise leading to large discrepancies in ADC re
.. figure:: ../../../_static/adc-noise-graph.jpg
:align: center
:alt: ADC noise mitigation
Graph illustrating noise mitigation using capacitor and multisampling of 64 samples.
ADC Calibration
@ -103,7 +103,7 @@ The :component_file:`esp_adc_cal/include/esp_adc_cal.h` API provides functions t
.. figure:: ../../../_static/adc-vref-graph.jpg
:align: center
:alt: ADC reference voltage comparison
Graph illustrating effect of differing reference voltages on the ADC voltage curve.
Correcting ADC readings using this API involves characterizing one of the ADCs at a given attenuation to obtain a characteristics curve (ADC-Voltage curve) that takes into account the difference in ADC reference voltage. The characteristics curve is in the form of ``y = coeff_a * x + coeff_b`` and is used to convert ADC readings to voltages in mV. Calculation of the characteristics curve is based on calibration values which can be stored in eFuse or provided by the user.
@ -115,7 +115,7 @@ Calibration values are used to generate characteristic curves that account for t
* **Two Point** values represent each of the ADCs readings at 150mV and 850mV. To obtain more accurate calibration results these values should be measured by user and burned into eFuse ``BLOCK3``.
* **eFuse Vref** represents the true ADC reference voltage. This value is measured and burned into eFuse ``BLOCK0`` during factory calibration.
* **eFuse Vref** represents the true ADC reference voltage. This value is measured and burned into eFuse ``BLOCK0`` during factory calibration.
* **Default Vref** is an estimate of the ADC reference voltage provided by the user as a parameter during characterization. If Two Point or eFuse Vref values are unavailable, **Default Vref** will be used.
@ -124,7 +124,7 @@ Individual measurement and burning of the **eFuse Vref** has been applied to ESP
.. figure:: ../../../_static/chip_surface_marking.png
:align: center
:alt: ESP32 Chip Surface Marking
ESP32 Chip Surface Marking
If you would like to purchase chips or modules with calibration, double check with distributor or Espressif directly.
@ -135,7 +135,7 @@ If you are unable to check the date code (i.e. the chip may be enclosed inside a
$IDF_PATH/components/esptool_py/esptool/espefuse.py --port /dev/ttyUSB0 adc_info
Replace ``/dev/ttyUSB0`` with ESP32 board's port name.
Replace ``/dev/ttyUSB0`` with ESP32 board's port name.
A chip that has specific **eFuse Vref** value programmed (in this case 1093mV) will be reported as follows::
@ -163,9 +163,9 @@ Characterizing an ADC at a particular attenuation::
#include "driver/adc.h"
#include "esp_adc_cal.h"
...
//Characterize ADC at particular atten
esp_adc_cal_characteristics_t *adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF, adc_chars);
@ -182,15 +182,15 @@ Reading an ADC then converting the reading to a voltage::
#include "driver/adc.h"
#include "esp_adc_cal.h"
...
uint32_t reading = adc1_get_raw(ADC1_CHANNEL_5);
uint32_t voltage = esp_adc_cal_raw_to_voltage(reading, adc_chars);
Routing ADC reference voltage to GPIO, so it can be manually measured (for **Default Vref**)::
#include "driver/adc.h"
...
esp_err_t status = adc2_vref_to_gpio(GPIO_NUM_25);
@ -226,6 +226,8 @@ ADC driver
.. include:: /_build/inc/adc.inc
.. include:: /_build/inc/adc_types.inc
.. _adc-api-reference-adc-calibration:
ADC Calibration

View file

@ -39,3 +39,4 @@ e.g.
2. ``DAC_GPIO26_CHANNEL`` is the channel number of GPIO 26 (channel 2).
.. include:: /_build/inc/dac_channel.inc
.. include:: /_build/inc/dac_types.inc

View file

@ -20,9 +20,10 @@ API Reference - Normal GPIO
---------------------------
.. include:: /_build/inc/gpio.inc
.. include:: /_build/inc/gpio_types.inc
API Reference - RTC GPIO
------------------------
.. include:: /_build/inc/rtc_io.inc
.. include:: /_build/inc/rtc_io_types.inc

View file

@ -250,3 +250,4 @@ API Reference
-------------
.. include:: /_build/inc/i2c.inc
.. include:: /_build/inc/i2c_types.inc

View file

@ -209,4 +209,5 @@ API Reference
-------------
.. include:: /_build/inc/i2s.inc
.. include:: /_build/inc/i2s_types.inc

View file

@ -174,4 +174,5 @@ API Reference
-------------
.. include:: /_build/inc/ledc.inc
.. include:: /_build/inc/ledc_types.inc

View file

@ -93,4 +93,5 @@ API Reference
-------------
.. include:: /_build/inc/pcnt.inc
.. include:: /_build/inc/pcnt_types.inc

View file

@ -265,4 +265,5 @@ API Reference
-------------
.. include:: /_build/inc/rmt.inc
.. include:: /_build/inc/rmt_types.inc

View file

@ -30,3 +30,4 @@ API Reference
-------------
.. include:: /_build/inc/sigmadelta.inc
.. include:: /_build/inc/sigmadelta_types.inc

View file

@ -107,3 +107,4 @@ API Reference
-------------
.. include:: /_build/inc/timer.inc
.. include:: /_build/inc/timer_types.inc

View file

@ -380,6 +380,7 @@ API Reference
-------------
.. include:: /_build/inc/uart.inc
.. include:: /_build/inc/uart_types.inc
GPIO Lookup Macros

View file

@ -1 +1 @@
.. include:: ../../../en/api-reference/peripherals/ledc.rst
.. include:: ../../../en/api-reference/peripherals/ledc.rst

View file

@ -105,3 +105,4 @@ API 参考
-------------
.. include:: /_build/inc/timer.inc
.. include:: /_build/inc/timer_types.inc