forked from espressif/arduino-esp32
Update IDF Libs
This commit is contained in:
@ -17,13 +17,12 @@ void adc_hal_init(void);
|
||||
void adc_hal_deinit(void);
|
||||
|
||||
/**
|
||||
* Set adc sample cycle for digital controller.
|
||||
* Set adc sample cycle.
|
||||
*
|
||||
* @note Normally, please use default value.
|
||||
* @param sample_cycle Cycles between DIG ADC controller start ADC sensor and beginning to receive data from sensor.
|
||||
* Range: 2 ~ 0xFF.
|
||||
* @param sample_cycle The number of ADC sampling cycles. Range: 1 ~ 7.
|
||||
*/
|
||||
#define adc_hal_digi_set_sample_cycle(sample_cycle) adc_ll_digi_set_sample_cycle(sample_cycle)
|
||||
#define adc_hal_set_sample_cycle(sample_cycle) adc_ll_set_sample_cycle(sample_cycle)
|
||||
|
||||
/**
|
||||
* Set ADC module power management.
|
||||
|
@ -13,7 +13,7 @@ typedef enum {
|
||||
ADC_UNIT_1 = 1, /*!< SAR ADC 1. */
|
||||
ADC_UNIT_2 = 2, /*!< SAR ADC 2. */
|
||||
ADC_UNIT_BOTH = 3, /*!< SAR ADC 1 and 2. */
|
||||
ADC_UNIT_ALTER = 7, /*!< SAR ADC 1 and 2 alternative mode, not supported yet */
|
||||
ADC_UNIT_ALTER = 7, /*!< SAR ADC 1 and 2 alternative mode. */
|
||||
ADC_UNIT_MAX,
|
||||
} adc_unit_t;
|
||||
|
||||
@ -75,29 +75,58 @@ typedef enum {
|
||||
ADC_WIDTH_MAX,
|
||||
} adc_bits_width_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) output data format option.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_FORMAT_12BIT, /*!<ADC to DMA data format, [15:12]-channel, [11: 0]-12 bits ADC data (`adc_digi_output_data_t`).
|
||||
Note: In single convert mode. */
|
||||
ADC_DIGI_FORMAT_11BIT, /*!<ADC to DMA data format, [15]-adc unit, [14:11]-channel, [10: 0]-11 bits ADC data (`adc_digi_output_data_t`).
|
||||
Note: In multi or alter convert mode. */
|
||||
ADC_DIGI_FORMAT_MAX,
|
||||
} adc_digi_output_format_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) output data format.
|
||||
* Used to analyze the acquired ADC (DMA) data.
|
||||
*
|
||||
* @note ESP32S2:
|
||||
* Member `channel` can be used to judge the validity of the ADC data, because the role of the arbiter may get invalid ADC data.
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
uint16_t data: 12; /*!<ADC real output data info. Resolution: 12 bit. */
|
||||
uint16_t channel: 4; /*!<ADC channel index info. For ESP32S2:
|
||||
If (channel < ADC_CHANNEL_MAX), The data is valid.
|
||||
If (channel > ADC_CHANNEL_MAX), The data is invalid. */
|
||||
} type1; /*!<When the configured output format is 12bit. `ADC_DIGI_FORMAT_12BIT` */
|
||||
struct {
|
||||
uint16_t data: 11; /*!<ADC real output data info. Resolution: 11 bit. */
|
||||
uint16_t channel: 4; /*!<ADC channel index info. For ESP32S2:
|
||||
If (channel < ADC_CHANNEL_MAX), The data is valid.
|
||||
If (channel > ADC_CHANNEL_MAX), The data is invalid. */
|
||||
uint16_t unit: 1; /*!<ADC unit index info. 0: ADC1; 1: ADC2. */
|
||||
} type2; /*!<When the configured output format is 11bit. `ADC_DIGI_FORMAT_11BIT` */
|
||||
uint16_t val;
|
||||
};
|
||||
} adc_digi_output_data_t;
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) clock system setting.
|
||||
* Expression: controller_clk = (`APLL` or `APB`) * (div_num + div_b / div_a).
|
||||
* Expression: controller_clk = (`APLL` or `APB`) / (div_num + div_a / div_b + 1).
|
||||
*/
|
||||
typedef struct {
|
||||
bool use_apll; /*!<true: use APLL clock; false: use APB clock. */
|
||||
uint32_t div_num; /*!<Division factor. Range: 1 ~ 255. */
|
||||
uint32_t div_num; /*!<Division factor. Range: 0 ~ 255.
|
||||
Note: When a higher frequency clock is used (the division factor is less than 9),
|
||||
the ADC reading value will be slightly offset. */
|
||||
uint32_t div_b; /*!<Division factor. Range: 1 ~ 63. */
|
||||
uint32_t div_a; /*!<Division factor. Range: 1 ~ 63. */
|
||||
uint32_t div_a; /*!<Division factor. Range: 0 ~ 63. */
|
||||
} adc_digi_clk_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) clock system default setting.
|
||||
*/
|
||||
#define ADC_DIGITAL_CLK_DEFAULT() { \
|
||||
.use_apll = 0, \
|
||||
.div_num = 40, \
|
||||
.div_b = 1, \
|
||||
.div_a = 1, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ADC arbiter work mode option.
|
||||
*
|
||||
@ -116,7 +145,7 @@ typedef enum {
|
||||
* @note ESP32S2: Only ADC2 support arbiter.
|
||||
*/
|
||||
typedef struct {
|
||||
adc_arbiter_mode_t mode; /*!<Refer to `adc_arbiter_mode_t`. Note: only support ADC2. */
|
||||
adc_arbiter_mode_t mode; /*!<Refer to ``adc_arbiter_mode_t``. Note: only support ADC2. */
|
||||
uint8_t rtc_pri; /*!<RTC controller priority. Range: 0 ~ 2. */
|
||||
uint8_t dig_pri; /*!<Digital controller priority. Range: 0 ~ 2. */
|
||||
uint8_t pwdet_pri; /*!<Wi-Fi controller priority. Range: 0 ~ 2. */
|
||||
@ -137,7 +166,11 @@ typedef struct {
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) work mode.
|
||||
*
|
||||
* @note Member `channel` can be used to judge the validity of the ADC data, because the role of the arbiter may get invalid ADC data.
|
||||
* @note The conversion mode affects the sampling frequency:
|
||||
* SINGLE_UNIT_1: When the measurement is triggered, only ADC1 is sampled once.
|
||||
* SINGLE_UNIT_2: When the measurement is triggered, only ADC2 is sampled once.
|
||||
* BOTH_UNIT : When the measurement is triggered, ADC1 and ADC2 are sampled at the same time.
|
||||
* ALTER_UNIT : When the measurement is triggered, ADC1 or ADC2 samples alternately.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_CONV_SINGLE_UNIT_1 = 1, /*!< SAR ADC 1. */
|
||||
@ -147,42 +180,6 @@ typedef enum {
|
||||
ADC_CONV_UNIT_MAX,
|
||||
} adc_digi_convert_mode_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) output data format option.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_FORMAT_12BIT, /*!<ADC to DMA data format, [15:12]-channel, [11: 0]-12 bits ADC data (`adc_digi_output_data_t`).
|
||||
Note: In single convert mode. */
|
||||
ADC_DIGI_FORMAT_11BIT, /*!<ADC to DMA data format, [15]-adc unit, [14:11]-channel, [10: 0]-11 bits ADC data (`adc_digi_output_data_t`).
|
||||
Note: In multi or alter convert mode. */
|
||||
ADC_DIGI_FORMAT_MAX,
|
||||
} adc_digi_output_format_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) output data format.
|
||||
* Used to analyze the acquired ADC (DMA) data.
|
||||
*
|
||||
* @note Member `channel` can be used to judge the validity of the ADC data, because the role of the arbiter may get invalid ADC data.
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
uint16_t data: 12; /*!<ADC real output data info. Resolution: 12 bit. */
|
||||
uint16_t channel: 4; /*!<ADC channel index info.
|
||||
If (channel < ADC_CHANNEL_MAX), The data is valid.
|
||||
If (channel > ADC_CHANNEL_MAX), The data is invalid. */
|
||||
} type1; /*!<When the configured output format is 12bit. `ADC_DIGI_FORMAT_12BIT` */
|
||||
struct {
|
||||
uint16_t data: 11; /*!<ADC real output data info. Resolution: 11 bit. */
|
||||
uint16_t channel: 4; /*!<ADC channel index info.
|
||||
If (channel < ADC_CHANNEL_MAX), The data is valid.
|
||||
If (channel > ADC_CHANNEL_MAX), The data is invalid. */
|
||||
uint16_t unit: 1; /*!<ADC unit index info. 0: ADC1; 1: ADC2. */
|
||||
} type2; /*!<When the configured output format is 11bit. `ADC_DIGI_FORMAT_11BIT` */
|
||||
uint16_t val;
|
||||
};
|
||||
} adc_digi_output_data_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) conversion rules setting.
|
||||
*/
|
||||
@ -212,26 +209,54 @@ typedef enum {
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) configuration parameters.
|
||||
*
|
||||
* Example setting: Use ADC1 channel0 to measure voltage, the sampling rate is required to be 1KHz:
|
||||
* +---------------------+--------+--------+--------+
|
||||
* | sample rate | 1KHz | 1KHz | 1KHz |
|
||||
* +---------------------+--------+--------+--------+
|
||||
* | conv_mode | single | both | alter |
|
||||
* | adc1_pattern_len | 1 | 1 | 1 |
|
||||
* | dig_clk.use_apll | 0 | 0 | 0 |
|
||||
* | dig_clk.div_num | 99 | 99 | 99 |
|
||||
* | dig_clk.div_b | 0 | 0 | 0 |
|
||||
* | dig_clk.div_a | 0 | 0 | 0 |
|
||||
* | interval | 400 | 400 | 200 |
|
||||
* +---------------------+--------+--------+--------+
|
||||
* | `trigger_meas_freq` | 1KHz | 1KHz | 2KHz |
|
||||
* +---------------------+--------+--------+--------+
|
||||
*
|
||||
* Explain the relationship between `conv_limit_num`, `dma_eof_num` and the number of DMA output:
|
||||
* +---------------------+--------+--------+--------+
|
||||
* | conv_mode | single | both | alter |
|
||||
* +---------------------+--------+--------+--------+
|
||||
* | trigger meas times | 1 | 1 | 1 |
|
||||
* +---------------------+--------+--------+--------+
|
||||
* | conv_limit_num | +1 | +1 | +1 |
|
||||
* | dma_eof_num | +1 | +2 | +1 |
|
||||
* | dma output (byte) | +2 | +4 | +2 |
|
||||
* +---------------------+--------+--------+--------+
|
||||
*/
|
||||
typedef struct {
|
||||
bool conv_limit_en; /*!<Enable max conversion number detection for digital controller.
|
||||
If the number of ADC conversion is equal to the `limit_num`, the conversion is stopped. */
|
||||
uint32_t conv_limit_num; /*!<ADC max conversion number for digital controller. */
|
||||
uint32_t adc1_pattern_len; /*!<Pattern table length for digital controller. Range: 0 ~ 16.
|
||||
bool conv_limit_en; /*!<Enable the function of limiting ADC conversion times.
|
||||
If the number of ADC conversion trigger count is equal to the `limit_num`, the conversion is stopped. */
|
||||
uint32_t conv_limit_num; /*!<Set the upper limit of the number of ADC conversion triggers. Range: 1 ~ 255. */
|
||||
uint32_t adc1_pattern_len; /*!<Pattern table length for digital controller. Range: 0 ~ 16 (0: Don't change the pattern table setting).
|
||||
The pattern table that defines the conversion rules for each SAR ADC. Each table has 16 items, in which channel selection,
|
||||
resolution and attenuation are stored. When the conversion is started, the controller reads conversion rules from the
|
||||
pattern table one by one. For each controller the scan sequence has at most 16 different rules before repeating itself. */
|
||||
uint32_t adc2_pattern_len; /*!<Refer to `adc1_pattern_len` */
|
||||
uint32_t adc2_pattern_len; /*!<Refer to ``adc1_pattern_len`` */
|
||||
adc_digi_pattern_table_t *adc1_pattern; /*!<Pointer to pattern table for digital controller. The table size defined by `adc1_pattern_len`. */
|
||||
adc_digi_pattern_table_t *adc2_pattern; /*!<Refer to `adc1_pattern` */
|
||||
adc_digi_convert_mode_t conv_mode; /*!<ADC conversion mode for digital controller. */
|
||||
adc_digi_output_format_t format; /*!<ADC output data format for digital controller. */
|
||||
adc_digi_pattern_table_t *adc2_pattern; /*!<Refer to ``adc1_pattern`` */
|
||||
adc_digi_convert_mode_t conv_mode; /*!<ADC conversion mode for digital controller. See ``adc_digi_convert_mode_t``. */
|
||||
adc_digi_output_format_t format; /*!<ADC output data format for digital controller. See ``adc_digi_output_format_t``. */
|
||||
uint32_t interval; /*!<The number of interval clock cycles for the digital controller to trigger the measurement.
|
||||
The unit is the divided clock. Range: 40 ~ 4095. */
|
||||
adc_digi_clk_t dig_clk; /*!<Refer to `adc_digi_clk_t` */
|
||||
The unit is the divided clock. Range: 40 ~ 4095.
|
||||
Expression: `trigger_meas_freq` = `controller_clk` / 2 / interval. Refer to ``adc_digi_clk_t``.
|
||||
Note: The sampling rate of each channel is also related to the conversion mode (See ``adc_digi_convert_mode_t``) and pattern table settings. */
|
||||
adc_digi_clk_t dig_clk; /*!<ADC digital controller clock divider settings. Refer to ``adc_digi_clk_t`` */
|
||||
uint32_t dma_eof_num; /*!<DMA eof num of adc digital controller.
|
||||
If the number of measurements reaches `dma_eof_num`,
|
||||
then `dma_in_suc_eof` signal is generated. */
|
||||
If the number of measurements reaches `dma_eof_num`, then `dma_in_suc_eof` signal is generated in DMA.
|
||||
Note: The converted data in the DMA in link buffer will be multiple of two bytes. */
|
||||
} adc_digi_config_t;
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,15 @@
|
||||
*/
|
||||
#define dac_hal_power_down(channel) dac_ll_power_down(channel)
|
||||
|
||||
/**
|
||||
* Enable/disable the synchronization operation function of ADC1 and DAC.
|
||||
*
|
||||
* @note If enabled(default), ADC RTC controller sampling will cause the DAC channel output voltage.
|
||||
*
|
||||
* @param enable Enable or disable adc and dac synchronization function.
|
||||
*/
|
||||
#define dac_hal_rtc_sync_by_adc(enable) dac_ll_rtc_sync_by_adc(enable)
|
||||
|
||||
/**
|
||||
* Output voltage with value (8 bit).
|
||||
*
|
||||
|
@ -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 */
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -34,9 +34,6 @@ typedef enum {
|
||||
I2S_NUM_MAX, /*!< I2S port max */
|
||||
} i2s_port_t;
|
||||
|
||||
|
||||
#define I2S_PIN_NO_CHANGE (-1) /*!< Use in i2s_pin_config_t for pins which should not be changed */
|
||||
|
||||
/**
|
||||
* @brief I2S bit width per sample.
|
||||
*
|
||||
@ -62,14 +59,21 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_COMM_FORMAT_I2S = 0x01, /*!< I2S communication format I2S*/
|
||||
I2S_COMM_FORMAT_I2S_MSB = 0x02, /*!< I2S format MSB*/
|
||||
I2S_COMM_FORMAT_I2S_LSB = 0x04, /*!< I2S format LSB*/
|
||||
I2S_COMM_FORMAT_PCM = 0x08, /*!< I2S communication format PCM*/
|
||||
I2S_COMM_FORMAT_PCM_SHORT = 0x10, /*!< PCM Short*/
|
||||
I2S_COMM_FORMAT_PCM_LONG = 0x20, /*!< PCM Long*/
|
||||
} i2s_comm_format_t;
|
||||
// In order to keep compatibility, remain the old definitions and introduce new definitions,
|
||||
I2S_COMM_FORMAT_STAND_I2S = 0X01, /*!< I2S communication I2S Philips standard, data launch at second BCK*/
|
||||
I2S_COMM_FORMAT_STAND_MSB = 0X03, /*!< I2S communication MSB alignment standard, data launch at first BCK*/
|
||||
I2S_COMM_FORMAT_STAND_PCM_SHORT = 0x04, /*!< PCM Short standard*/
|
||||
I2S_COMM_FORMAT_STAND_PCM_LONG = 0x0C, /*!< PCM Long standard*/
|
||||
I2S_COMM_FORMAT_STAND_MAX, /*!< standard max*/
|
||||
|
||||
//old definition will be removed in the future.
|
||||
I2S_COMM_FORMAT_I2S __attribute__((deprecated)) = 0x01, /*!< I2S communication format I2S, correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
|
||||
I2S_COMM_FORMAT_I2S_MSB __attribute__((deprecated)) = 0x01, /*!< I2S format MSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_MSB) correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
|
||||
I2S_COMM_FORMAT_I2S_LSB __attribute__((deprecated)) = 0x02, /*!< I2S format LSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_LSB) correspond to `I2S_COMM_FORMAT_STAND_MSB`*/
|
||||
I2S_COMM_FORMAT_PCM __attribute__((deprecated)) = 0x04, /*!< I2S communication format PCM, correspond to `I2S_COMM_FORMAT_STAND_PCM_SHORT`*/
|
||||
I2S_COMM_FORMAT_PCM_SHORT __attribute__((deprecated)) = 0x04, /*!< PCM Short, (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT) correspond to `I2S_COMM_FORMAT_STAND_PCM_SHORT`*/
|
||||
I2S_COMM_FORMAT_PCM_LONG __attribute__((deprecated)) = 0x08, /*!< PCM Long, (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG) correspond to `I2S_COMM_FORMAT_STAND_PCM_LONG`*/
|
||||
} i2s_comm_format_t;
|
||||
|
||||
/**
|
||||
* @brief I2S channel format type
|
||||
@ -82,26 +86,6 @@ typedef enum {
|
||||
I2S_CHANNEL_FMT_ONLY_LEFT,
|
||||
} i2s_channel_fmt_t;
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
/**
|
||||
* @brief PDM sample rate ratio, measured in Hz.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
PDM_SAMPLE_RATE_RATIO_64,
|
||||
PDM_SAMPLE_RATE_RATIO_128,
|
||||
} pdm_sample_rate_ratio_t;
|
||||
|
||||
/**
|
||||
* @brief PDM PCM convter enable/disable.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
PDM_PCM_CONV_ENABLE,
|
||||
PDM_PCM_CONV_DISABLE,
|
||||
} pdm_pcm_conv_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I2S Mode, defaut is I2S_MODE_MASTER | I2S_MODE_TX
|
||||
*
|
||||
@ -109,19 +93,29 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_MODE_MASTER = 1,
|
||||
I2S_MODE_SLAVE = 2,
|
||||
I2S_MODE_TX = 4,
|
||||
I2S_MODE_RX = 8,
|
||||
I2S_MODE_MASTER = 1, /*!< Master mode*/
|
||||
I2S_MODE_SLAVE = 2, /*!< Slave mode*/
|
||||
I2S_MODE_TX = 4, /*!< TX mode*/
|
||||
I2S_MODE_RX = 8, /*!< RX mode*/
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
I2S_MODE_DAC_BUILT_IN = 16, /*!< Output I2S data to built-in DAC, no matter the data format is 16bit or 32 bit, the DAC module will only take the 8bits from MSB*/
|
||||
I2S_MODE_ADC_BUILT_IN = 32, /*!< Input I2S data from built-in ADC, each data can be 12-bit width at most*/
|
||||
#endif
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
I2S_MODE_PDM = 64,
|
||||
I2S_MODE_PDM = 64, /*!< PDM mode*/
|
||||
#endif
|
||||
} i2s_mode_t;
|
||||
|
||||
/**
|
||||
* @brief I2S source clock
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CLK_D2CLK = 0, /*!< Clock from PLL_D2_CLK(160M)*/
|
||||
I2S_CLK_APLL, /*!< Clock from APLL*/
|
||||
} i2s_clock_src_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief I2S configuration parameters for i2s_param_config function
|
||||
*
|
||||
@ -193,12 +187,16 @@ typedef enum {
|
||||
I2S_PDM_DSR_16S, /*!< downsampling number is 16 for PDM RX mode*/
|
||||
I2S_PDM_DSR_MAX,
|
||||
} i2s_pdm_dsr_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PDM PCM convter enable/disable.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CLK_D2CLK = 0,
|
||||
I2S_CLK_APLL,
|
||||
} i2s_clock_src_t;
|
||||
PDM_PCM_CONV_ENABLE, /*!< Enable PDM PCM convert*/
|
||||
PDM_PCM_CONV_DISABLE, /*!< Disable PDM PCM convert*/
|
||||
} pdm_pcm_conv_t;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -39,13 +39,6 @@ typedef struct {
|
||||
*/
|
||||
void rmt_hal_init(rmt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Reset RMT HAL driver
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
*/
|
||||
void rmt_hal_reset(rmt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Reset RMT Channel specific HAL driver
|
||||
*
|
||||
@ -133,7 +126,8 @@ uint32_t rmt_hal_receive(rmt_hal_context_t *hal, uint32_t channel, rmt_item32_t
|
||||
* @param channel: RMT channel number
|
||||
* @param src: RMT items to transmit
|
||||
* @param length: length of RMT items to transmit
|
||||
* @param offset: offset of RMT internal memory to store the items
|
||||
* @param offset: offset of RMT internal memory to store the items.
|
||||
* Note: the caller should ensure that (length + offset) <= (memory block * SOC_RMT_CHANNEL_MEM_WORDS).
|
||||
*/
|
||||
void rmt_hal_transmit(rmt_hal_context_t *hal, uint32_t channel, const rmt_item32_t *src, uint32_t length, uint32_t offset);
|
||||
|
||||
|
@ -27,6 +27,8 @@ typedef enum {
|
||||
SPI3_HOST=2, ///< SPI3
|
||||
} 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
|
||||
@ -38,3 +40,5 @@ typedef enum {
|
||||
#define FSPI_HOST SPI2_HOST
|
||||
#define HSPI_HOST SPI3_HOST
|
||||
#endif
|
||||
|
||||
/** @endcond */
|
||||
|
@ -265,7 +265,7 @@ typedef struct touch_filter_config {
|
||||
uint32_t hysteresis_thr; /*!<Hysteresis threshold coefficient. hysteresis = hysteresis coefficient * touch threshold.
|
||||
If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
|
||||
If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
|
||||
Range: 0 ~ 3. The coefficient is 0: 4/32; 1: 3/32; 2: 2/32; 3: OFF */
|
||||
Range: 0 ~ 3. The coefficient is 0: 4/32; 1: 3/32; 2: 1/32; 3: OFF */
|
||||
uint32_t noise_thr; /*!<Noise threshold coefficient. noise = noise coefficient * touch threshold.
|
||||
If (raw data - baseline) > (noise), the baseline stop updating.
|
||||
If (raw data - baseline) < (noise), the baseline start updating.
|
||||
|
@ -150,6 +150,7 @@ void uart_hal_write_txfifo(uart_hal_context_t *hal, const uint8_t *buf, uint32_t
|
||||
|
||||
/**
|
||||
* @brief Reset the UART txfifo
|
||||
* @note On ESP32, this function is reserved for UART1 and UART2.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
|
@ -176,6 +176,12 @@ inline static bool IRAM_ATTR esp_ptr_byte_accessible(const void *p)
|
||||
intptr_t ip = (intptr_t) p;
|
||||
bool r;
|
||||
r = (ip >= SOC_BYTE_ACCESSIBLE_LOW && ip < SOC_BYTE_ACCESSIBLE_HIGH);
|
||||
#if CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP
|
||||
/* For ESP32 case, RTC fast memory is accessible to PRO cpu only and hence
|
||||
* for single core configuration (where it gets added to system heap) following
|
||||
* additional check is required */
|
||||
r |= (ip >= SOC_RTC_DRAM_LOW && ip < SOC_RTC_DRAM_HIGH);
|
||||
#endif
|
||||
#if CONFIG_SPIRAM
|
||||
#if CONFIG_SPIRAM_SIZE != -1 // Fixed size, can be more accurate
|
||||
r |= (ip >= SOC_EXTRAM_DATA_LOW && ip < (SOC_EXTRAM_DATA_LOW + CONFIG_SPIRAM_SIZE));
|
||||
@ -190,6 +196,12 @@ inline static bool IRAM_ATTR esp_ptr_internal(const void *p) {
|
||||
bool r;
|
||||
r = ((intptr_t)p >= SOC_MEM_INTERNAL_LOW && (intptr_t)p < SOC_MEM_INTERNAL_HIGH);
|
||||
r |= ((intptr_t)p >= SOC_RTC_DATA_LOW && (intptr_t)p < SOC_RTC_DATA_HIGH);
|
||||
#if CONFIG_ESP32_ALLOW_RTC_FAST_MEM_AS_HEAP
|
||||
/* For ESP32 case, RTC fast memory is accessible to PRO cpu only and hence
|
||||
* for single core configuration (where it gets added to system heap) following
|
||||
* additional check is required */
|
||||
r |= ((intptr_t)p >= SOC_RTC_DRAM_LOW && (intptr_t)p < SOC_RTC_DRAM_HIGH);
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ typedef struct {
|
||||
adc_hal_digi_pattern_table_t *adc1_pattern; /*!<Pointer to pattern table for digital controller. The table size defined by `adc1_pattern_len`. */
|
||||
adc_hal_digi_pattern_table_t *adc2_pattern; /*!<Refer to `adc1_pattern` */
|
||||
adc_hal_digi_convert_mode_t conv_mode; /*!<ADC conversion mode for digital controller. ESP32 only support ADC1 single mode. */
|
||||
adc_hal_digi_output_format_t format; /*!<ADC output data format for digital controller. */
|
||||
adc_digi_output_format_t format; /*!<ADC output data format for digital controller. */
|
||||
uint32_t clk_div; /*!< ADC module clock division factor. ADC clock divided from APB clock.*/
|
||||
} adc_hal_digi_config_t;
|
||||
|
||||
|
@ -8,14 +8,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ADC_DIGI_FORMAT_12BIT, /*!< ADC to I2S data format, [15:12]-channel [11:0]-12 bits ADC data.
|
||||
Note: In single convert mode. */
|
||||
ADC_DIGI_FORMAT_11BIT, /*!< ADC to I2S data format, [15]-adc unit [14:11]-channel [10:0]-11 bits ADC data.
|
||||
Note: In multi convert mode. */
|
||||
ADC_DIGI_FORMAT_MAX,
|
||||
} adc_hal_digi_output_format_t;
|
||||
|
||||
typedef enum {
|
||||
ADC_CONV_SINGLE_UNIT_1 = 1, /*!< SAR ADC 1*/
|
||||
ADC_CONV_SINGLE_UNIT_2 = 2, /*!< SAR ADC 2, not supported yet*/
|
||||
@ -94,13 +86,12 @@ static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wa
|
||||
}
|
||||
|
||||
/**
|
||||
* Set adc sample cycle for digital controller.
|
||||
* Set adc sample cycle.
|
||||
*
|
||||
* @note Normally, please use default value.
|
||||
* @param sample_cycle Cycles between DIG ADC controller start ADC sensor and beginning to receive data from sensor.
|
||||
* Range: 2 ~ 0xFF.
|
||||
* @param sample_cycle The number of ADC sampling cycles. Range: 1 ~ 7.
|
||||
*/
|
||||
static inline void adc_ll_digi_set_sample_cycle(uint32_t sample_cycle)
|
||||
static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle)
|
||||
{
|
||||
SYSCON.saradc_fsm.sample_cycle = sample_cycle;
|
||||
}
|
||||
@ -119,9 +110,9 @@ static inline void adc_ll_digi_set_clk_div(uint32_t div)
|
||||
/**
|
||||
* Set adc output data format for digital controller.
|
||||
*
|
||||
* @param format Output data format, see ``adc_hal_digi_output_format_t``.
|
||||
* @param format Output data format, see ``adc_digi_output_format_t``.
|
||||
*/
|
||||
static inline void adc_ll_digi_set_output_format(adc_hal_digi_output_format_t format)
|
||||
static inline void adc_ll_digi_set_output_format(adc_digi_output_format_t format)
|
||||
{
|
||||
SYSCON.saradc_ctrl.data_sar_sel = format;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ static inline void cpu_ll_set_watchpoint(int id,
|
||||
|
||||
//We support watching 2^n byte values, from 1 to 64. Calculate the mask for that.
|
||||
for (int x = 0; x < 7; x++) {
|
||||
if (size == (1 << x)) {
|
||||
if (size == (size_t)(1 << x)) {
|
||||
break;
|
||||
}
|
||||
dbreakc <<= 1;
|
||||
|
@ -69,6 +69,18 @@ static inline void dac_ll_update_output_value(dac_channel_t channel, uint8_t val
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable the synchronization operation function of ADC1 and DAC.
|
||||
*
|
||||
* @note If enabled(default), ADC RTC controller sampling will cause the DAC channel output voltage.
|
||||
*
|
||||
* @param enable Enable or disable adc and dac synchronization function.
|
||||
*/
|
||||
static inline void dac_ll_rtc_sync_by_adc(bool enable)
|
||||
{
|
||||
SENS.sar_meas_ctrl2.sar1_dac_xpd_fsm = enable;
|
||||
}
|
||||
|
||||
/************************************/
|
||||
/* DAC cosine wave generator API's */
|
||||
/************************************/
|
||||
|
@ -621,50 +621,6 @@ static inline void i2s_ll_set_tx_pdm_en(i2s_dev_t *hw, bool val)
|
||||
hw->pdm_conf.tx_pdm_en = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx msb shift
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
* @param val value to set tx msb shift
|
||||
*/
|
||||
static inline void i2s_ll_set_tx_msb_shift(i2s_dev_t *hw, uint32_t val)
|
||||
{
|
||||
hw->conf.tx_msb_shift = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx msb shift
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
* @param val value to set rx msb shift
|
||||
*/
|
||||
static inline void i2s_ll_set_rx_msb_shift(i2s_dev_t *hw, uint32_t val)
|
||||
{
|
||||
hw->conf.rx_msb_shift = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx short sync
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
* @param val value to set tx short sync
|
||||
*/
|
||||
static inline void i2s_ll_set_tx_short_sync(i2s_dev_t *hw, uint32_t val)
|
||||
{
|
||||
hw->conf.tx_short_sync = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx short sync
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
* @param val value to set rx short sync
|
||||
*/
|
||||
static inline void i2s_ll_set_rx_short_sync(i2s_dev_t *hw, uint32_t val)
|
||||
{
|
||||
hw->conf.rx_short_sync = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx fifo mod force en
|
||||
*
|
||||
@ -819,6 +775,150 @@ static inline void i2s_ll_set_sig_loopback(i2s_dev_t *hw, uint32_t val)
|
||||
hw->conf.sig_loopback = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S TX to philip standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_tx_format_philip(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.tx_short_sync = 0;
|
||||
hw->conf.tx_msb_shift = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S RX to philip standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_rx_format_philip(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.rx_short_sync = 0;
|
||||
hw->conf.rx_msb_shift = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S TX to MSB Alignment Standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_tx_format_msb_align(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.tx_short_sync = 0;
|
||||
hw->conf.tx_msb_shift = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S RX to MSB Alignment Standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_rx_format_msb_align(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.rx_short_sync = 0;
|
||||
hw->conf.rx_msb_shift = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S TX to PCM short standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_tx_pcm_short(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.tx_short_sync = 1;
|
||||
hw->conf.tx_msb_shift = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S RX to PCM short standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_rx_pcm_short(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.rx_short_sync = 1;
|
||||
hw->conf.rx_msb_shift = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S TX to PCM long standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_tx_pcm_long(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.tx_short_sync = 0;
|
||||
hw->conf.tx_msb_shift = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2S RX to PCM long standard
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_set_rx_pcm_long(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf.rx_short_sync = 0;
|
||||
hw->conf.rx_msb_shift = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure I2S TX pdm
|
||||
*
|
||||
* @param sample_rate The sample rate to be set.
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_tx_pdm_cfg(i2s_dev_t *hw, uint32_t sample_rate)
|
||||
{
|
||||
uint32_t fp = 96;
|
||||
uint32_t fs = sample_rate / 1000 * 10;
|
||||
hw->pdm_freq_conf.tx_pdm_fp = fp;
|
||||
hw->pdm_freq_conf.tx_pdm_fs = fs;
|
||||
hw->pdm_conf.tx_sinc_osr2 = fp/fs;
|
||||
hw->pdm_conf.pcm2pdm_conv_en = 1;
|
||||
hw->pdm_conf.tx_pdm_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure I2S TX pdm
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_rx_pdm_cfg(i2s_dev_t *hw)
|
||||
{
|
||||
hw->pdm_conf.rx_sinc_dsr_16_en = 0;
|
||||
hw->pdm_conf.pdm2pcm_conv_en = 1;
|
||||
hw->pdm_conf.rx_pdm_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable I2S build in ADC mode
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_build_in_adc_ena(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf2.lcd_en = 1;
|
||||
hw->conf2.camera_en = 0;
|
||||
hw->conf.rx_msb_shift = 0;
|
||||
hw->conf.rx_short_sync = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable I2S build in DAC mode
|
||||
*
|
||||
* @param hw Peripheral I2S hardware instance address.
|
||||
*/
|
||||
static inline void i2s_ll_build_in_dac_ena(i2s_dev_t *hw)
|
||||
{
|
||||
hw->conf2.lcd_en = 1;
|
||||
hw->conf2.camera_en = 0;
|
||||
hw->conf.tx_right_first = 1;
|
||||
hw->conf.tx_msb_shift = 0;
|
||||
hw->conf.tx_short_sync = 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,9 @@ extern "C" {
|
||||
#include "soc/rmt_struct.h"
|
||||
#include "soc/rmt_caps.h"
|
||||
|
||||
#define RMT_LL_HW_BASE (&RMT)
|
||||
#define RMT_LL_MEM_BASE (&RMTMEM)
|
||||
|
||||
static inline void rmt_ll_enable_drive_clock(rmt_dev_t *dev, bool enable)
|
||||
{
|
||||
dev->conf_ch[0].conf0.clk_en = enable;
|
||||
@ -276,9 +279,10 @@ static inline void rmt_ll_set_carrier_on_level(rmt_dev_t *dev, uint32_t channel,
|
||||
dev->conf_ch[channel].conf0.carrier_out_lv = level;
|
||||
}
|
||||
|
||||
//Writes items to the specified TX channel memory with the given offset and writen length.
|
||||
//the caller should ensure that (length + off) <= (memory block * SOC_RMT_CHANNEL_MEM_WORDS)
|
||||
static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const rmt_item32_t *data, uint32_t length, uint32_t off)
|
||||
{
|
||||
length = (off + length) > SOC_RMT_CHANNEL_MEM_WORDS ? (SOC_RMT_CHANNEL_MEM_WORDS - off) : length;
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
mem->chan[channel].data32[i + off].val = data[i].val;
|
||||
}
|
||||
|
@ -219,14 +219,20 @@ static inline void uart_ll_rxfifo_rst(uart_dev_t *hw)
|
||||
/**
|
||||
* @brief Reset the UART hw txfifo.
|
||||
*
|
||||
* Note: Due to hardware issue, reset UART1's txfifo will also reset UART2's txfifo.
|
||||
* So reserve this function for UART1 and UART2. Please do DPORT reset for UART and its memory at chip startup
|
||||
* to ensure the TX FIFO is reset correctly at the beginning.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void uart_ll_txfifo_rst(uart_dev_t *hw)
|
||||
{
|
||||
hw->conf0.txfifo_rst = 1;
|
||||
hw->conf0.txfifo_rst = 0;
|
||||
if (hw == &UART0) {
|
||||
hw->conf0.txfifo_rst = 1;
|
||||
hw->conf0.txfifo_rst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -238,7 +244,21 @@ static inline void uart_ll_txfifo_rst(uart_dev_t *hw)
|
||||
*/
|
||||
static inline uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw)
|
||||
{
|
||||
return hw->status.rxfifo_cnt;
|
||||
uint32_t fifo_cnt = hw->status.rxfifo_cnt;
|
||||
typeof(hw->mem_rx_status) rx_status = hw->mem_rx_status;
|
||||
uint32_t len = 0;
|
||||
|
||||
// When using DPort to read fifo, fifo_cnt is not credible, we need to calculate the real cnt based on the fifo read and write pointer.
|
||||
// When using AHB to read FIFO, we can use fifo_cnt to indicate the data length in fifo.
|
||||
if (rx_status.wr_addr > rx_status.rd_addr) {
|
||||
len = rx_status.wr_addr - rx_status.rd_addr;
|
||||
} else if (rx_status.wr_addr < rx_status.rd_addr) {
|
||||
len = (rx_status.wr_addr + 128) - rx_status.rd_addr;
|
||||
} else {
|
||||
len = fifo_cnt > 0 ? 128 : 0;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user