mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-10-26 11:41:42 +01:00
Initial Commit
This commit is contained in:
181
tools/sdk/esp32/include/soc/include/hal/adc_hal.h
Normal file
181
tools/sdk/esp32/include/soc/include/hal/adc_hal.h
Normal file
@@ -0,0 +1,181 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/adc_types.h"
|
||||
#include "hal/adc_ll.h"
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Common setting
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* ADC module initialization.
|
||||
*/
|
||||
void adc_hal_init(void);
|
||||
|
||||
/**
|
||||
* ADC module deinitialization.
|
||||
*/
|
||||
void adc_hal_deinit(void);
|
||||
|
||||
/**
|
||||
* Set adc sample cycle for digital controller.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
#define adc_hal_digi_set_sample_cycle(sample_cycle) adc_ll_digi_set_sample_cycle(sample_cycle)
|
||||
|
||||
/**
|
||||
* Set ADC module power management.
|
||||
*
|
||||
* @prarm manage Set ADC power status.
|
||||
*/
|
||||
#define adc_hal_set_power_manage(manage) adc_ll_set_power_manage(manage)
|
||||
|
||||
/**
|
||||
* Get ADC module power management.
|
||||
*
|
||||
* @return
|
||||
* - ADC power status.
|
||||
*/
|
||||
#define adc_hal_get_power_manage() adc_ll_get_power_manage()
|
||||
|
||||
/**
|
||||
* ADC module clock division factor setting. ADC clock devided from APB clock.
|
||||
*
|
||||
* @prarm div Division factor.
|
||||
*/
|
||||
#define adc_hal_digi_set_clk_div(div) adc_ll_digi_set_clk_div(div)
|
||||
|
||||
/**
|
||||
* ADC SAR clock division factor setting. ADC SAR clock devided from `RTC_FAST_CLK`.
|
||||
*
|
||||
* @prarm div Division factor.
|
||||
*/
|
||||
#define adc_hal_set_sar_clk_div(adc_n, div) adc_ll_set_sar_clk_div(adc_n, div)
|
||||
|
||||
/**
|
||||
* Set ADC module controller.
|
||||
* There are five SAR ADC controllers:
|
||||
* Two digital controller: Continuous conversion mode (DMA). High performance with multiple channel scan modes;
|
||||
* Two RTC controller: Single conversion modes (Polling). For low power purpose working during deep sleep;
|
||||
* the other is dedicated for Power detect (PWDET / PKDET), Only support ADC2.
|
||||
*
|
||||
* @prarm adc_n ADC unit.
|
||||
* @prarm ctrl ADC controller.
|
||||
*/
|
||||
#define adc_hal_set_controller(adc_n, ctrl) adc_ll_set_controller(adc_n, ctrl)
|
||||
|
||||
/**
|
||||
* Set the attenuation of a particular channel on ADCn.
|
||||
*
|
||||
* @note For any given channel, this function must be called before the first time conversion.
|
||||
*
|
||||
* The default ADC full-scale voltage is 1.1V. To read higher voltages (up to the pin maximum voltage,
|
||||
* usually 3.3V) requires setting >0dB signal attenuation for that ADC channel.
|
||||
*
|
||||
* When VDD_A is 3.3V:
|
||||
*
|
||||
* - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
|
||||
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
|
||||
* - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
|
||||
* - 11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V (see note below)
|
||||
*
|
||||
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
|
||||
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
|
||||
*
|
||||
* @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
|
||||
*
|
||||
* Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges:
|
||||
*
|
||||
* - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV
|
||||
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV
|
||||
* - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV
|
||||
* - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV
|
||||
*
|
||||
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
|
||||
*
|
||||
* @prarm adc_n ADC unit.
|
||||
* @prarm channel ADCn channel number.
|
||||
* @prarm atten The attenuation option.
|
||||
*/
|
||||
#define adc_hal_set_atten(adc_n, channel, atten) adc_ll_set_atten(adc_n, channel, atten)
|
||||
|
||||
/**
|
||||
* Get the attenuation of a particular channel on ADCn.
|
||||
*
|
||||
* @param adc_n ADC unit.
|
||||
* @param channel ADCn channel number.
|
||||
* @return atten The attenuation option.
|
||||
*/
|
||||
#define adc_hal_get_atten(adc_n, channel) adc_ll_get_atten(adc_n, channel)
|
||||
|
||||
/**
|
||||
* Close ADC AMP module if don't use it for power save.
|
||||
*/
|
||||
#define adc_hal_amp_disable() adc_ll_amp_disable()
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
PWDET(Power detect) controller setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Set adc cct for PWDET controller.
|
||||
*
|
||||
* @note Capacitor tuning of the PA power monitor. cct set to the same value with PHY.
|
||||
* @prarm cct Range: 0 ~ 7.
|
||||
*/
|
||||
#define adc_hal_pwdet_set_cct(cct) adc_ll_pwdet_set_cct(cct)
|
||||
|
||||
/**
|
||||
* Get adc cct for PWDET controller.
|
||||
*
|
||||
* @note Capacitor tuning of the PA power monitor. cct set to the same value with PHY.
|
||||
* @return cct Range: 0 ~ 7.
|
||||
*/
|
||||
#define adc_hal_pwdet_get_cct() adc_ll_pwdet_get_cct()
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
RTC controller setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Get the converted value for each ADCn for RTC controller.
|
||||
*
|
||||
* @note It may be block to wait conversion finish.
|
||||
*
|
||||
* @prarm adc_n ADC unit.
|
||||
* @param channel adc channel number.
|
||||
* @param value Pointer for touch value.
|
||||
*
|
||||
* @return
|
||||
* - 0: The value is valid.
|
||||
* - ~0: The value is invalid.
|
||||
*/
|
||||
int adc_hal_convert(adc_ll_num_t adc_n, int channel, int *value);
|
||||
|
||||
/**
|
||||
* Set adc output data format for RTC controller.
|
||||
*
|
||||
* @prarm adc_n ADC unit.
|
||||
* @prarm bits Output data bits width option.
|
||||
*/
|
||||
#define adc_hal_rtc_set_output_format(adc_n, bits) adc_ll_rtc_set_output_format(adc_n, bits)
|
||||
|
||||
/**
|
||||
* ADC module output data invert or not.
|
||||
*
|
||||
* @prarm adc_n ADC unit.
|
||||
*/
|
||||
#define adc_hal_rtc_output_invert(adc_n, inv_en) adc_ll_rtc_output_invert(adc_n, inv_en)
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Digital controller setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Reset the pattern table pointer, then take the measurement rule from table header in next measurement.
|
||||
*
|
||||
* @param adc_n ADC unit.
|
||||
*/
|
||||
#define adc_hal_digi_clear_pattern_table(adc_n) adc_ll_digi_clear_pattern_table(adc_n)
|
||||
316
tools/sdk/esp32/include/soc/include/hal/adc_types.h
Normal file
316
tools/sdk/esp32/include/soc/include/hal/adc_types.h
Normal file
@@ -0,0 +1,316 @@
|
||||
#pragma once
|
||||
|
||||
#include "soc/adc_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief ADC units selected handle.
|
||||
*
|
||||
* @note For ADC digital controller(DMA mode), ESP32 don't support `ADC_UNIT_2`, `ADC_UNIT_BOTH`, `ADC_UNIT_ALTER`.
|
||||
*/
|
||||
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_MAX,
|
||||
} adc_unit_t;
|
||||
|
||||
/**
|
||||
* @brief ADC channels handle. See ``adc1_channel_t``, ``adc2_channel_t``.
|
||||
*
|
||||
* @note For ESP32 ADC1, don't support `ADC_CHANNEL_8`, `ADC_CHANNEL_9`. See ``adc1_channel_t``.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_CHANNEL_0 = 0, /*!< ADC channel */
|
||||
ADC_CHANNEL_1, /*!< ADC channel */
|
||||
ADC_CHANNEL_2, /*!< ADC channel */
|
||||
ADC_CHANNEL_3, /*!< ADC channel */
|
||||
ADC_CHANNEL_4, /*!< ADC channel */
|
||||
ADC_CHANNEL_5, /*!< ADC channel */
|
||||
ADC_CHANNEL_6, /*!< ADC channel */
|
||||
ADC_CHANNEL_7, /*!< ADC channel */
|
||||
ADC_CHANNEL_8, /*!< ADC channel */
|
||||
ADC_CHANNEL_9, /*!< ADC channel */
|
||||
ADC_CHANNEL_MAX,
|
||||
} adc_channel_t;
|
||||
|
||||
/**
|
||||
* @brief ADC attenuation parameter. Different parameters determine the range of the ADC. See ``adc1_config_channel_atten``.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_ATTEN_DB_0 = 0, /*!<The input voltage of ADC will be reduced to about 1/1 */
|
||||
ADC_ATTEN_DB_2_5 = 1, /*!<The input voltage of ADC will be reduced to about 1/1.34 */
|
||||
ADC_ATTEN_DB_6 = 2, /*!<The input voltage of ADC will be reduced to about 1/2 */
|
||||
ADC_ATTEN_DB_11 = 3, /*!<The input voltage of ADC will be reduced to about 1/3.6*/
|
||||
ADC_ATTEN_MAX,
|
||||
} adc_atten_t;
|
||||
|
||||
/**
|
||||
* @brief ESP32 ADC DMA source selection.
|
||||
*
|
||||
* @note It's be deprecated in ESP32S2. Beacause ESP32S2 don't use I2S DMA.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_I2S_DATA_SRC_IO_SIG = 0, /*!< I2S data from GPIO matrix signal */
|
||||
ADC_I2S_DATA_SRC_ADC = 1, /*!< I2S data from ADC */
|
||||
ADC_I2S_DATA_SRC_MAX,
|
||||
} adc_i2s_source_t;
|
||||
|
||||
/**
|
||||
* @brief ADC resolution setting option.
|
||||
*
|
||||
* @note For ESP32S2. Only support 13 bit resolution.
|
||||
* For ESP32. Don't support 13 bit resolution.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_WIDTH_BIT_9 = 0, /*!< ADC capture width is 9Bit. Only ESP32 is supported. */
|
||||
ADC_WIDTH_BIT_10 = 1, /*!< ADC capture width is 10Bit. Only ESP32 is supported. */
|
||||
ADC_WIDTH_BIT_11 = 2, /*!< ADC capture width is 11Bit. Only ESP32 is supported. */
|
||||
ADC_WIDTH_BIT_12 = 3, /*!< ADC capture width is 12Bit. Only ESP32 is supported. */
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||
ADC_WIDTH_BIT_13 = 4, /*!< ADC capture width is 13Bit. Only ESP32S2 is supported. */
|
||||
#endif
|
||||
ADC_WIDTH_MAX,
|
||||
} adc_bits_width_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).
|
||||
*/
|
||||
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_b; /*!<Division factor. Range: 1 ~ 63. */
|
||||
uint32_t div_a; /*!<Division factor. Range: 1 ~ 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.
|
||||
*
|
||||
* @note ESP32S2: Only ADC2 support arbiter.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_ARB_MODE_SHIELD,/*!<Force shield arbiter, Select the highest priority controller to work. */
|
||||
ADC_ARB_MODE_FIX, /*!<Fixed priority switch controller mode. */
|
||||
ADC_ARB_MODE_LOOP, /*!<Loop priority switch controller mode. Each controller has the same priority,
|
||||
and the arbiter will switch to the next controller after the measurement is completed. */
|
||||
} adc_arbiter_mode_t;
|
||||
|
||||
/**
|
||||
* @brief ADC arbiter work mode and priority setting.
|
||||
*
|
||||
* @note ESP32S2: Only ADC2 support arbiter.
|
||||
*/
|
||||
typedef struct {
|
||||
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. */
|
||||
} adc_arbiter_t;
|
||||
|
||||
/**
|
||||
* @brief ADC arbiter default configuration.
|
||||
*
|
||||
* @note ESP32S2: Only ADC2 support arbiter.
|
||||
*/
|
||||
#define ADC_ARBITER_CONFIG_DEFAULT() { \
|
||||
.mode = ADC_ARB_MODE_FIX, \
|
||||
.rtc_pri = 1, \
|
||||
.dig_pri = 0, \
|
||||
.pwdet_pri = 2, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_CONV_SINGLE_UNIT_1 = 1, /*!< SAR ADC 1. */
|
||||
ADC_CONV_SINGLE_UNIT_2 = 2, /*!< SAR ADC 2. */
|
||||
ADC_CONV_BOTH_UNIT = 3, /*!< SAR ADC 1 and 2. */
|
||||
ADC_CONV_ALTER_UNIT = 7, /*!< SAR ADC 1 and 2 alternative mode. */
|
||||
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.
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
uint8_t atten: 2; /*!< ADC sampling voltage attenuation configuration.
|
||||
0: input voltage * 1;
|
||||
1: input voltage * 1/1.34;
|
||||
2: input voltage * 1/2;
|
||||
3: input voltage * 1/3.6. */
|
||||
uint8_t reserved: 2; /*!< reserved0 */
|
||||
uint8_t channel: 4; /*!< ADC channel index. */
|
||||
};
|
||||
uint8_t val;
|
||||
};
|
||||
} adc_digi_pattern_table_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) interrupt type options.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_INTR_MASK_MONITOR = 0x1,
|
||||
ADC_DIGI_INTR_MASK_MEAS_DONE = 0x2,
|
||||
ADC_DIGI_INTR_MASK_ALL = 0x3,
|
||||
} adc_digi_intr_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) configuration parameters.
|
||||
*/
|
||||
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.
|
||||
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` */
|
||||
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. */
|
||||
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` */
|
||||
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. */
|
||||
} adc_digi_config_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) filter index options.
|
||||
*
|
||||
* @note For ESP32S2, The filter object of the ADC is fixed.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_FILTER_IDX0 = 0, /*!<The filter index 0.
|
||||
For ESP32S2, It can only be used to filter all enabled channels of ADC1 unit at the same time. */
|
||||
ADC_DIGI_FILTER_IDX1, /*!<The filter index 1.
|
||||
For ESP32S2, It can only be used to filter all enabled channels of ADC2 unit at the same time. */
|
||||
ADC_DIGI_FILTER_IDX_MAX
|
||||
} adc_digi_filter_idx_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) filter type options.
|
||||
* Expression: filter_data = (k-1)/k * last_data + new_data / k.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_FILTER_IIR_2 = 0, /*!<The filter mode is first-order IIR filter. The coefficient is 2. */
|
||||
ADC_DIGI_FILTER_IIR_4, /*!<The filter mode is first-order IIR filter. The coefficient is 4. */
|
||||
ADC_DIGI_FILTER_IIR_8, /*!<The filter mode is first-order IIR filter. The coefficient is 8. */
|
||||
ADC_DIGI_FILTER_IIR_16, /*!<The filter mode is first-order IIR filter. The coefficient is 16. */
|
||||
ADC_DIGI_FILTER_IIR_64, /*!<The filter mode is first-order IIR filter. The coefficient is 64. */
|
||||
ADC_DIGI_FILTER_IIR_MAX
|
||||
} adc_digi_filter_mode_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) filter configuration.
|
||||
*
|
||||
* @note For ESP32S2, The filter object of the ADC is fixed.
|
||||
* @note For ESP32S2, The filter object is always all enabled channels.
|
||||
*/
|
||||
typedef struct {
|
||||
adc_unit_t adc_unit; /*!<Set adc unit number for filter.
|
||||
For ESP32S2, Filter IDX0/IDX1 can only be used to filter all enabled channels of ADC1/ADC2 unit at the same time. */
|
||||
adc_channel_t channel; /*!<Set adc channel number for filter.
|
||||
For ESP32S2, it's always `ADC_CHANNEL_MAX` */
|
||||
adc_digi_filter_mode_t mode;/*!<Set adc filter mode for filter. See ``adc_digi_filter_mode_t``. */
|
||||
} adc_digi_filter_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) monitor index options.
|
||||
*
|
||||
* @note For ESP32S2, The monitor object of the ADC is fixed.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_MONITOR_IDX0 = 0, /*!<The monitor index 0.
|
||||
For ESP32S2, It can only be used to monitor all enabled channels of ADC1 unit at the same time. */
|
||||
ADC_DIGI_MONITOR_IDX1, /*!<The monitor index 1.
|
||||
For ESP32S2, It can only be used to monitor all enabled channels of ADC2 unit at the same time. */
|
||||
ADC_DIGI_MONITOR_IDX_MAX
|
||||
} adc_digi_monitor_idx_t;
|
||||
|
||||
/**
|
||||
* @brief Set monitor mode of adc digital controller.
|
||||
* MONITOR_HIGH:If ADC_OUT > threshold, Generates monitor interrupt.
|
||||
* MONITOR_LOW: If ADC_OUT < threshold, Generates monitor interrupt.
|
||||
*/
|
||||
typedef enum {
|
||||
ADC_DIGI_MONITOR_HIGH = 0, /*!<If ADC_OUT > threshold, Generates monitor interrupt. */
|
||||
ADC_DIGI_MONITOR_LOW, /*!<If ADC_OUT < threshold, Generates monitor interrupt. */
|
||||
ADC_DIGI_MONITOR_MAX
|
||||
} adc_digi_monitor_mode_t;
|
||||
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) monitor configuration.
|
||||
*
|
||||
* @note For ESP32S2, The monitor object of the ADC is fixed.
|
||||
* @note For ESP32S2, The monitor object is always all enabled channels.
|
||||
*/
|
||||
typedef struct {
|
||||
adc_unit_t adc_unit; /*!<Set adc unit number for monitor.
|
||||
For ESP32S2, monitor IDX0/IDX1 can only be used to monitor all enabled channels of ADC1/ADC2 unit at the same time. */
|
||||
adc_channel_t channel; /*!<Set adc channel number for monitor.
|
||||
For ESP32S2, it's always `ADC_CHANNEL_MAX` */
|
||||
adc_digi_monitor_mode_t mode; /*!<Set adc monitor mode. See ``adc_digi_monitor_mode_t``. */
|
||||
uint32_t threshold; /*!<Set monitor threshold of adc digital controller. */
|
||||
} adc_digi_monitor_t;
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32S2
|
||||
48
tools/sdk/esp32/include/soc/include/hal/brownout_hal.h
Normal file
48
tools/sdk/esp32/include/soc/include/hal/brownout_hal.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "soc/brownout_caps.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t threshold;
|
||||
bool enabled;
|
||||
bool reset_enabled;
|
||||
bool flash_power_down;
|
||||
bool rf_power_down;
|
||||
} brownout_hal_config_t;
|
||||
|
||||
void brownout_hal_config(const brownout_hal_config_t *cfg);
|
||||
|
||||
void brownout_hal_intr_enable(bool enable);
|
||||
|
||||
void brownout_hal_intr_clear(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
305
tools/sdk/esp32/include/soc/include/hal/can_hal.h
Normal file
305
tools/sdk/esp32/include/soc/include/hal/can_hal.h
Normal file
@@ -0,0 +1,305 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "hal/can_types.h"
|
||||
#include "hal/can_ll.h"
|
||||
|
||||
/* ------------------------- Defines and Typedefs --------------------------- */
|
||||
|
||||
//Error active interrupt related
|
||||
#define CAN_HAL_EVENT_BUS_OFF (1 << 0)
|
||||
#define CAN_HAL_EVENT_BUS_RECOV_CPLT (1 << 1)
|
||||
#define CAN_HAL_EVENT_BUS_RECOV_PROGRESS (1 << 2)
|
||||
#define CAN_HAL_EVENT_ABOVE_EWL (1 << 3)
|
||||
#define CAN_HAL_EVENT_BELOW_EWL (1 << 4)
|
||||
#define CAN_HAL_EVENT_ERROR_PASSIVE (1 << 5)
|
||||
#define CAN_HAL_EVENT_ERROR_ACTIVE (1 << 6)
|
||||
#define CAN_HAL_EVENT_BUS_ERR (1 << 7)
|
||||
#define CAN_HAL_EVENT_ARB_LOST (1 << 8)
|
||||
#define CAN_HAL_EVENT_RX_BUFF_FRAME (1 << 9)
|
||||
#define CAN_HAL_EVENT_TX_BUFF_FREE (1 << 10)
|
||||
|
||||
typedef struct {
|
||||
can_dev_t *dev;
|
||||
} can_hal_context_t;
|
||||
|
||||
typedef can_ll_frame_buffer_t can_hal_frame_t;
|
||||
|
||||
/* ---------------------------- Init and Config ----------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Initialize CAN peripheral and HAL context
|
||||
*
|
||||
* Sets HAL context, puts CAN peripheral into reset mode, then sets some
|
||||
* registers with default values.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return True if successfully initialized, false otherwise.
|
||||
*/
|
||||
bool can_hal_init(can_hal_context_t *hal_ctx);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the CAN peripheral and HAL context
|
||||
*
|
||||
* Clears any unhandled interrupts and unsets HAL context
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
*/
|
||||
void can_hal_deinit(can_hal_context_t *hal_ctx);
|
||||
|
||||
/**
|
||||
* @brief Configure the CAN peripheral
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @param t_config Pointer to timing configuration structure
|
||||
* @param f_config Pointer to filter configuration structure
|
||||
* @param intr_mask Mask of interrupts to enable
|
||||
* @param clkout_divider Clock divider value for CLKOUT. Set to -1 to disable CLKOUT
|
||||
*/
|
||||
void can_hal_configure(can_hal_context_t *hal_ctx, const can_timing_config_t *t_config, const can_filter_config_t *f_config, uint32_t intr_mask, uint32_t clkout_divider);
|
||||
|
||||
/* -------------------------------- Actions --------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Start the CAN peripheral
|
||||
*
|
||||
* Start the CAN peripheral by configuring its operating mode, then exiting
|
||||
* reset mode so that the CAN peripheral can participate in bus activities.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @param mode Operating mode
|
||||
* @return True if successfully started, false otherwise.
|
||||
*/
|
||||
bool can_hal_start(can_hal_context_t *hal_ctx, can_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Stop the CAN peripheral
|
||||
*
|
||||
* Stop the CAN peripheral by entering reset mode to stop any bus activity, then
|
||||
* setting the operating mode to Listen Only so that REC is frozen.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return True if successfully stopped, false otherwise.
|
||||
*/
|
||||
bool can_hal_stop(can_hal_context_t *hal_ctx);
|
||||
|
||||
/**
|
||||
* @brief Start bus recovery
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return True if successfully started bus recovery, false otherwise.
|
||||
*/
|
||||
static inline bool can_hal_start_bus_recovery(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
return can_ll_exit_reset_mode(hal_ctx->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value of the TX Error Counter
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return TX Error Counter Value
|
||||
*/
|
||||
static inline uint32_t can_hal_get_tec(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
return can_ll_get_tec((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value of the RX Error Counter
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return RX Error Counter Value
|
||||
*/
|
||||
static inline uint32_t can_hal_get_rec(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
return can_ll_get_rec((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the RX message count register
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return RX message count
|
||||
*/
|
||||
static inline uint32_t can_hal_get_rx_msg_count(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
return can_ll_get_rx_msg_count((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the last transmitted frame was successful
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return True if successful
|
||||
*/
|
||||
static inline bool can_hal_check_last_tx_successful(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
return can_ll_is_last_tx_successful((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/* ----------------------------- Event Handling ----------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Decode current events that triggered an interrupt
|
||||
*
|
||||
* This function should be called on every CAN interrupt. It will read (and
|
||||
* thereby clear) the interrupt register, then determine what events have
|
||||
* occurred to trigger the interrupt.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @param bus_recovering Whether the CAN peripheral was previous undergoing bus recovery
|
||||
* @return Bit mask of events that have occurred
|
||||
*/
|
||||
uint32_t can_hal_decode_interrupt_events(can_hal_context_t *hal_ctx, bool bus_recovering);
|
||||
|
||||
/**
|
||||
* @brief Handle bus recovery complete
|
||||
*
|
||||
* This function should be called on an bus recovery complete event. It simply
|
||||
* enters reset mode to stop bus activity.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @return True if successfully handled bus recovery completion, false otherwise.
|
||||
*/
|
||||
static inline bool can_hal_handle_bus_recov_cplt(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
return can_ll_enter_reset_mode((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handle arbitration lost
|
||||
*
|
||||
* This function should be called on an arbitration lost event. It simply clears
|
||||
* the clears the ALC register.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
*/
|
||||
static inline void can_hal_handle_arb_lost(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
can_ll_clear_arb_lost_cap((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handle bus error
|
||||
*
|
||||
* This function should be called on an bus error event. It simply clears
|
||||
* the clears the ECC register.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
*/
|
||||
static inline void can_hal_handle_bus_error(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
can_ll_clear_err_code_cap((hal_ctx)->dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handle BUS OFF
|
||||
*
|
||||
* This function should be called on a BUS OFF event. It simply changes the
|
||||
* mode to LOM to freeze REC
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
*/
|
||||
static inline void can_hal_handle_bus_off(can_hal_context_t *hal_ctx)
|
||||
{
|
||||
can_ll_set_mode((hal_ctx)->dev, CAN_MODE_LISTEN_ONLY);
|
||||
}
|
||||
|
||||
/* ------------------------------- TX and RX -------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Format a CAN Frame
|
||||
*
|
||||
* This function takes a CAN message structure (containing ID, DLC, data, and
|
||||
* flags) and formats it to match the layout of the TX frame buffer.
|
||||
*
|
||||
* @param message Pointer to CAN message
|
||||
* @param frame Pointer to empty frame structure
|
||||
*/
|
||||
static inline void can_hal_format_frame(const can_message_t *message, can_hal_frame_t *frame)
|
||||
{
|
||||
//Direct call to ll function
|
||||
can_ll_format_frame_buffer(message->identifier, message->data_length_code, message->data,
|
||||
message->flags, frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse a CAN Frame
|
||||
*
|
||||
* This function takes a CAN frame (in the format of the RX frame buffer) and
|
||||
* parses it to a CAN message (containing ID, DLC, data and flags).
|
||||
*
|
||||
* @param frame Pointer to frame structure
|
||||
* @param message Pointer to empty message structure
|
||||
*/
|
||||
static inline void can_hal_parse_frame(can_hal_frame_t *frame, can_message_t *message)
|
||||
{
|
||||
//Direct call to ll function
|
||||
can_ll_prase_frame_buffer(frame, &message->identifier, &message->data_length_code,
|
||||
message->data, &message->flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy a frame into the TX buffer and transmit
|
||||
*
|
||||
* This function copies a formatted TX frame into the TX buffer, and the
|
||||
* transmit by setting the correct transmit command (e.g. normal, single shot,
|
||||
* self RX) in the command register.
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @param tx_frame Pointer to structure containing formatted TX frame
|
||||
*/
|
||||
void can_hal_set_tx_buffer_and_transmit(can_hal_context_t *hal_ctx, can_hal_frame_t *tx_frame);
|
||||
|
||||
/**
|
||||
* @brief Copy a frame from the RX buffer and release
|
||||
*
|
||||
* This function copies a frame from the RX buffer, then release the buffer (so
|
||||
* that it loads the next frame in the RX FIFO).
|
||||
*
|
||||
* @param hal_ctx Context of the HAL layer
|
||||
* @param rx_frame Pointer to structure to store RX frame
|
||||
*/
|
||||
static inline void can_hal_read_rx_buffer_and_clear(can_hal_context_t *hal_ctx, can_hal_frame_t *rx_frame)
|
||||
{
|
||||
can_ll_get_rx_buffer(hal_ctx->dev, rx_frame);
|
||||
can_ll_set_cmd_release_rx_buffer(hal_ctx->dev);
|
||||
/*
|
||||
* Todo: Support overrun handling by:
|
||||
* - Check overrun status bit. Return false if overrun
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//Todo: Decode ALC register
|
||||
//Todo: Decode error code capture
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
137
tools/sdk/esp32/include/soc/include/hal/can_types.h
Normal file
137
tools/sdk/esp32/include/soc/include/hal/can_types.h
Normal file
@@ -0,0 +1,137 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief CAN2.0B Constants
|
||||
*/
|
||||
#define CAN_EXTD_ID_MASK 0x1FFFFFFF /**< Bit mask for 29 bit Extended Frame Format ID */
|
||||
#define CAN_STD_ID_MASK 0x7FF /**< Bit mask for 11 bit Standard Frame Format ID */
|
||||
#define CAN_FRAME_MAX_DLC 8 /**< Max data bytes allowed in CAN2.0 */
|
||||
#define CAN_FRAME_EXTD_ID_LEN_BYTES 4 /**< EFF ID requires 4 bytes (29bit) */
|
||||
#define CAN_FRAME_STD_ID_LEN_BYTES 2 /**< SFF ID requires 2 bytes (11bit) */
|
||||
#define CAN_ERR_PASS_THRESH 128 /**< Error counter threshold for error passive */
|
||||
|
||||
/** @cond */ //Doxy command to hide preprocessor definitions from docs
|
||||
/**
|
||||
* @brief CAN Message flags
|
||||
*
|
||||
* The message flags are used to indicate the type of message transmitted/received.
|
||||
* Some flags also specify the type of transmission.
|
||||
*/
|
||||
#define CAN_MSG_FLAG_NONE 0x00 /**< No message flags (Standard Frame Format) */
|
||||
#define CAN_MSG_FLAG_EXTD 0x01 /**< Extended Frame Format (29bit ID) */
|
||||
#define CAN_MSG_FLAG_RTR 0x02 /**< Message is a Remote Transmit Request */
|
||||
#define CAN_MSG_FLAG_SS 0x04 /**< Transmit as a Single Shot Transmission. Unused for received. */
|
||||
#define CAN_MSG_FLAG_SELF 0x08 /**< Transmit as a Self Reception Request. Unused for received. */
|
||||
#define CAN_MSG_FLAG_DLC_NON_COMP 0x10 /**< Message's Data length code is larger than 8. This will break compliance with CAN2.0B */
|
||||
|
||||
/**
|
||||
* @brief Initializer macros for timing configuration structure
|
||||
*
|
||||
* The following initializer macros offer commonly found bit rates.
|
||||
*
|
||||
* @note These timing values are based on the assumption APB clock is at 80MHz
|
||||
* @note The 20K, 16K and 12.5K bit rates are only available from ESP32 Revision 2 onwards
|
||||
*/
|
||||
#ifdef CAN_BRP_DIV_SUPPORTED
|
||||
#define CAN_TIMING_CONFIG_12_5KBITS() {.brp = 256, .tseg_1 = 16, .tseg_2 = 8, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_16KBITS() {.brp = 200, .tseg_1 = 16, .tseg_2 = 8, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_20KBITS() {.brp = 200, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
#endif
|
||||
#define CAN_TIMING_CONFIG_25KBITS() {.brp = 128, .tseg_1 = 16, .tseg_2 = 8, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_50KBITS() {.brp = 80, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_100KBITS() {.brp = 40, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_125KBITS() {.brp = 32, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_250KBITS() {.brp = 16, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_500KBITS() {.brp = 8, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_800KBITS() {.brp = 4, .tseg_1 = 16, .tseg_2 = 8, .sjw = 3, .triple_sampling = false}
|
||||
#define CAN_TIMING_CONFIG_1MBITS() {.brp = 4, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false}
|
||||
|
||||
/**
|
||||
* @brief Initializer macro for filter configuration to accept all IDs
|
||||
*/
|
||||
#define CAN_FILTER_CONFIG_ACCEPT_ALL() {.acceptance_code = 0, .acceptance_mask = 0xFFFFFFFF, .single_filter = true}
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief CAN Controller operating modes
|
||||
*/
|
||||
typedef enum {
|
||||
CAN_MODE_NORMAL, /**< Normal operating mode where CAN controller can send/receive/acknowledge messages */
|
||||
CAN_MODE_NO_ACK, /**< Transmission does not require acknowledgment. Use this mode for self testing */
|
||||
CAN_MODE_LISTEN_ONLY, /**< The CAN controller will not influence the bus (No transmissions or acknowledgments) but can receive messages */
|
||||
} can_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Structure to store a CAN message
|
||||
*
|
||||
* @note
|
||||
* @note The flags member is deprecated
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
//The order of these bits must match deprecated message flags for compatibility reasons
|
||||
uint32_t extd: 1; /**< Extended Frame Format (29bit ID) */
|
||||
uint32_t rtr: 1; /**< Message is a Remote Transmit Request */
|
||||
uint32_t ss: 1; /**< Transmit as a Single Shot Transmission. Unused for received. */
|
||||
uint32_t self: 1; /**< Transmit as a Self Reception Request. Unused for received. */
|
||||
uint32_t dlc_non_comp: 1; /**< Message's Data length code is larger than 8. This will break compliance with CAN2.0B. */
|
||||
uint32_t reserved: 27; /**< Reserved bits */
|
||||
};
|
||||
//Todo: Deprecate flags
|
||||
uint32_t flags; /**< Alternate way to set message flags using message flag macros (see documentation) */
|
||||
};
|
||||
uint32_t identifier; /**< 11 or 29 bit identifier */
|
||||
uint8_t data_length_code; /**< Data length code */
|
||||
uint8_t data[CAN_FRAME_MAX_DLC]; /**< Data bytes (not relevant in RTR frame) */
|
||||
} can_message_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for bit timing configuration of the CAN driver
|
||||
*
|
||||
* @note Macro initializers are available for this structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t brp; /**< Baudrate prescaler (i.e., APB clock divider) can be any even number from 2 to 128.
|
||||
For ESP32 Rev 2 or later, multiples of 4 from 132 to 256 are also supported */
|
||||
uint8_t tseg_1; /**< Timing segment 1 (Number of time quanta, between 1 to 16) */
|
||||
uint8_t tseg_2; /**< Timing segment 2 (Number of time quanta, 1 to 8) */
|
||||
uint8_t sjw; /**< Synchronization Jump Width (Max time quanta jump for synchronize from 1 to 4) */
|
||||
bool triple_sampling; /**< Enables triple sampling when the CAN controller samples a bit */
|
||||
} can_timing_config_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for acceptance filter configuration of the CAN driver (see documentation)
|
||||
*
|
||||
* @note Macro initializers are available for this structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t acceptance_code; /**< 32-bit acceptance code */
|
||||
uint32_t acceptance_mask; /**< 32-bit acceptance mask */
|
||||
bool single_filter; /**< Use Single Filter Mode (see documentation) */
|
||||
} can_filter_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
121
tools/sdk/esp32/include/soc/include/hal/cpu_hal.h
Normal file
121
tools/sdk/esp32/include/soc/include/hal/cpu_hal.h
Normal file
@@ -0,0 +1,121 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "hal/cpu_types.h"
|
||||
#include "hal/cpu_ll.h"
|
||||
#include "soc/cpu_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the ID of the core currently executing this code.
|
||||
*
|
||||
* @return core id [0..SOC_CPU_CORES_NUM - 1]
|
||||
*/
|
||||
#define cpu_hal_get_core_id() cpu_ll_get_core_id()
|
||||
|
||||
/**
|
||||
* Get the current value of the stack pointer.
|
||||
*
|
||||
* @return the current stack pointer
|
||||
*/
|
||||
#define cpu_hal_get_sp() cpu_ll_get_sp()
|
||||
|
||||
/**
|
||||
* Get the current value of the internal counter that increments
|
||||
* every processor-clock cycle.
|
||||
*
|
||||
* @return cycle count; returns 0 if not supported
|
||||
*/
|
||||
#define cpu_hal_get_cycle_count() cpu_ll_get_cycle_count()
|
||||
|
||||
/**
|
||||
* Check if some form of debugger is attached to CPU.
|
||||
*
|
||||
* @return true debugger is attached
|
||||
* @return false no debugger is attached/ no support for debuggers
|
||||
*/
|
||||
#define cpu_hal_is_debugger_attached() cpu_ll_is_debugger_attached()
|
||||
|
||||
/**
|
||||
* Init HW loop status.
|
||||
*/
|
||||
#define cpu_hal_init_hwloop() cpu_ll_init_hwloop()
|
||||
|
||||
/**
|
||||
* Trigger a call to debugger.
|
||||
*/
|
||||
#define cpu_hal_break() cpu_ll_break()
|
||||
|
||||
#if SOC_CPU_BREAKPOINTS_NUM > 0
|
||||
|
||||
/**
|
||||
* Set and enable breakpoint at an instruction address.
|
||||
*
|
||||
* @note Overwrites previously set breakpoint with same breakpoint ID.
|
||||
*
|
||||
* @param id breakpoint to set [0..SOC_CPU_BREAKPOINTS_NUM - 1]
|
||||
* @param addr address to set a breakpoint on
|
||||
*/
|
||||
void cpu_hal_set_breakpoint(int id, const void* addr);
|
||||
|
||||
/**
|
||||
* Clear and disable breakpoint.
|
||||
*
|
||||
* @param id breakpoint to clear [0..SOC_CPU_BREAKPOINTS_NUM - 1]
|
||||
*/
|
||||
void cpu_hal_clear_breakpoint(int id);
|
||||
|
||||
#endif // SOC_CPU_BREAKPOINTS_NUM > 0
|
||||
|
||||
#if SOC_CPU_WATCHPOINTS_NUM > 0
|
||||
|
||||
/**
|
||||
* Set and enable a watchpoint, specifying the memory range and trigger operation.
|
||||
*
|
||||
* @param id watchpoint to set [0..SOC_CPU_WATCHPOINTS_NUM - 1]
|
||||
* @param addr starting address
|
||||
* @param size number of bytes from starting address to watch
|
||||
* @param trigger operation on specified memory range that triggers the watchpoint (read, write, read/write)
|
||||
*/
|
||||
void cpu_hal_set_watchpoint(int id, const void* addr, size_t size, watchpoint_trigger_t trigger);
|
||||
|
||||
/**
|
||||
* Clear and disable watchpoint.
|
||||
*
|
||||
* @param id watchpoint to clear [0..SOC_CPU_WATCHPOINTS_NUM - 1]
|
||||
*/
|
||||
void cpu_hal_clear_watchpoint(int id);
|
||||
|
||||
#endif // SOC_CPU_WATCHPOINTS_NUM > 0
|
||||
|
||||
/**
|
||||
* Set exception vector table base address.
|
||||
*
|
||||
* @param base address to move the exception vector table to
|
||||
*/
|
||||
void cpu_hal_set_vecbase(const void* base);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
21
tools/sdk/esp32/include/soc/include/hal/cpu_types.h
Normal file
21
tools/sdk/esp32/include/soc/include/hal/cpu_types.h
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
WATCHPOINT_TRIGGER_ON_RO, // on read
|
||||
WATCHPOINT_TRIGGER_ON_WO, // on write
|
||||
WATCHPOINT_TRIGGER_ON_RW // on either read or write
|
||||
} watchpoint_trigger_t;
|
||||
76
tools/sdk/esp32/include/soc/include/hal/dac_hal.h
Normal file
76
tools/sdk/esp32/include/soc/include/hal/dac_hal.h
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/dac_ll.h"
|
||||
#include "hal/hal_defs.h"
|
||||
#include <esp_err.h>
|
||||
|
||||
/**
|
||||
* Power on dac module and start output voltage.
|
||||
*
|
||||
* @note Before powering up, make sure the DAC PAD is set to RTC PAD and floating status.
|
||||
* @param channel DAC channel num.
|
||||
*/
|
||||
#define dac_hal_power_on(channel) dac_ll_power_on(channel)
|
||||
|
||||
/**
|
||||
* Power done dac module and stop output voltage.
|
||||
*
|
||||
* @param channel DAC channel num.
|
||||
*/
|
||||
#define dac_hal_power_down(channel) dac_ll_power_down(channel)
|
||||
|
||||
/**
|
||||
* Output voltage with value (8 bit).
|
||||
*
|
||||
* @param channel DAC channel num.
|
||||
* @param value Output value. Value range: 0 ~ 255.
|
||||
* The corresponding range of voltage is 0v ~ VDD3P3_RTC.
|
||||
*/
|
||||
#define dac_hal_update_output_value(channel, value) dac_ll_update_output_value(channel, value)
|
||||
|
||||
/**
|
||||
* Enable cosine wave generator output.
|
||||
*/
|
||||
#define dac_hal_cw_generator_enable() dac_ll_cw_generator_enable()
|
||||
|
||||
/**
|
||||
* Disable cosine wave generator output.
|
||||
*/
|
||||
#define dac_hal_cw_generator_disable() dac_ll_cw_generator_disable()
|
||||
|
||||
/**
|
||||
* Config the cosine wave generator function in DAC module.
|
||||
*
|
||||
* @param cw Configuration.
|
||||
*/
|
||||
void dac_hal_cw_generator_config(dac_cw_config_t *cw);
|
||||
|
||||
/**
|
||||
* Enable DAC output data from DMA.
|
||||
*/
|
||||
#define dac_hal_dma_enable() dac_ll_dma_enable()
|
||||
|
||||
/**
|
||||
* Disable DAC output data from DMA.
|
||||
*/
|
||||
#define dac_hal_dma_disable() dac_ll_dma_disable()
|
||||
40
tools/sdk/esp32/include/soc/include/hal/dac_types.h
Normal file
40
tools/sdk/esp32/include/soc/include/hal/dac_types.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "soc/dac_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
typedef enum {
|
||||
DAC_CHANNEL_1 = 0, /*!< DAC channel 1 is GPIO25(ESP32) / GPIO17(ESP32S2) */
|
||||
DAC_CHANNEL_2 = 1, /*!< DAC channel 2 is GPIO26(ESP32) / GPIO18(ESP32S2) */
|
||||
DAC_CHANNEL_MAX,
|
||||
} dac_channel_t;
|
||||
|
||||
/**
|
||||
* @brief The multiple of the amplitude of the cosine wave generator. The max amplitude is VDD3P3_RTC.
|
||||
*/
|
||||
typedef enum {
|
||||
DAC_CW_SCALE_1 = 0x0, /*!< 1/1. Default. */
|
||||
DAC_CW_SCALE_2 = 0x1, /*!< 1/2. */
|
||||
DAC_CW_SCALE_4 = 0x2, /*!< 1/4. */
|
||||
DAC_CW_SCALE_8 = 0x3, /*!< 1/8. */
|
||||
} dac_cw_scale_t;
|
||||
|
||||
/**
|
||||
* @brief Set the phase of the cosine wave generator output.
|
||||
*/
|
||||
typedef enum {
|
||||
DAC_CW_PHASE_0 = 0x2, /*!< Phase shift +0° */
|
||||
DAC_CW_PHASE_180 = 0x3, /*!< Phase shift +180° */
|
||||
} dac_cw_phase_t;
|
||||
|
||||
/**
|
||||
* @brief Config the cosine wave generator function in DAC module.
|
||||
*/
|
||||
typedef struct {
|
||||
dac_channel_t en_ch; /*!< Enable the cosine wave generator of DAC channel. */
|
||||
dac_cw_scale_t scale; /*!< Set the amplitude of the cosine wave generator output. */
|
||||
dac_cw_phase_t phase; /*!< Set the phase of the cosine wave generator output. */
|
||||
uint32_t freq; /*!< Set frequency of cosine wave generator output. Range: 130(130Hz) ~ 55000(100KHz). */
|
||||
int8_t offset; /*!< Set the voltage value of the DC component of the cosine wave generator output.
|
||||
Note: Unreasonable settings can cause waveform to be oversaturated. Range: -128 ~ 127. */
|
||||
} dac_cw_config_t;
|
||||
48
tools/sdk/esp32/include/soc/include/hal/esp_flash_err.h
Normal file
48
tools/sdk/esp32/include/soc/include/hal/esp_flash_err.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Possible errors returned from esp flash internal functions, these error codes
|
||||
* should be consistent with esp_err_t codes. But in order to make the source
|
||||
* files less dependent to esp_err_t, they use the error codes defined in this
|
||||
* replacable header. This header should ensure the consistency to esp_err_t.
|
||||
*/
|
||||
|
||||
enum {
|
||||
/* These codes should be consistent with esp_err_t errors. However, error codes with the same values are not
|
||||
* allowed in ESP-IDF. This is a workaround in order to not introduce a dependency between the "soc" and
|
||||
* "esp_common" components. The disadvantage is that the output of esp_err_to_name(ESP_ERR_FLASH_SIZE_NOT_MATCH)
|
||||
* will be ESP_ERR_INVALID_SIZE. */
|
||||
ESP_ERR_FLASH_SIZE_NOT_MATCH = ESP_ERR_INVALID_SIZE, ///< The chip doesn't have enough space for the current partition table
|
||||
ESP_ERR_FLASH_NO_RESPONSE = ESP_ERR_INVALID_RESPONSE, ///< Chip did not respond to the command, or timed out.
|
||||
};
|
||||
|
||||
//The ROM code has already taken 1 and 2, to avoid possible conflicts, start from 3.
|
||||
#define ESP_ERR_FLASH_NOT_INITIALISED (ESP_ERR_FLASH_BASE+3) ///< esp_flash_chip_t structure not correctly initialised by esp_flash_init().
|
||||
#define ESP_ERR_FLASH_UNSUPPORTED_HOST (ESP_ERR_FLASH_BASE+4) ///< Requested operation isn't supported via this host SPI bus (chip->spi field).
|
||||
#define ESP_ERR_FLASH_UNSUPPORTED_CHIP (ESP_ERR_FLASH_BASE+5) ///< Requested operation isn't supported by this model of SPI flash chip.
|
||||
#define ESP_ERR_FLASH_PROTECTED (ESP_ERR_FLASH_BASE+6) ///< Write operation failed due to chip's write protection being enabled.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
342
tools/sdk/esp32/include/soc/include/hal/gpio_hal.h
Normal file
342
tools/sdk/esp32/include/soc/include/hal/gpio_hal.h
Normal file
@@ -0,0 +1,342 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for GPIO
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "hal/gpio_ll.h"
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
#ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS
|
||||
#include "soc/rtc_io_reg.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get GPIO hardware instance with giving gpio num
|
||||
#define GPIO_HAL_GET_HW(num) GPIO_LL_GET_HW(num)
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
gpio_dev_t *dev;
|
||||
uint32_t version;
|
||||
} gpio_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Enable pull-up on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_pullup_en(hal, gpio_num) gpio_ll_pullup_en((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Disable pull-up on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_pullup_dis(hal, gpio_num) gpio_ll_pullup_dis((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Enable pull-down on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_pulldown_en(hal, gpio_num) gpio_ll_pulldown_en((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Disable pull-down on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_pulldown_dis(hal, gpio_num) gpio_ll_pulldown_dis((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief GPIO set interrupt trigger type
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number. If you want to set the trigger type of e.g. of GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param intr_type Interrupt type, select from gpio_int_type_t
|
||||
*/
|
||||
#define gpio_hal_set_intr_type(hal, gpio_num, intr_type) gpio_ll_set_intr_type((hal)->dev, gpio_num, intr_type)
|
||||
|
||||
/**
|
||||
* @brief Get GPIO interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param core_id interrupt core id
|
||||
* @param status interrupt status
|
||||
*/
|
||||
#define gpio_hal_get_intr_status(hal, core_id, status) gpio_ll_get_intr_status((hal)->dev, core_id, status)
|
||||
|
||||
/**
|
||||
* @brief Get GPIO interrupt status high
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param core_id interrupt core id
|
||||
* @param status interrupt status high
|
||||
*/
|
||||
#define gpio_hal_get_intr_status_high(hal, core_id, status) gpio_ll_get_intr_status_high((hal)->dev, core_id, status)
|
||||
|
||||
/**
|
||||
* @brief Clear GPIO interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask interrupt status clear mask
|
||||
*/
|
||||
#define gpio_hal_clear_intr_status(hal, mask) gpio_ll_clear_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Clear GPIO interrupt status high
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask interrupt status high clear mask
|
||||
*/
|
||||
#define gpio_hal_clear_intr_status_high(hal, mask) gpio_ll_clear_intr_status_high((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Enable GPIO module interrupt signal
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number. If you want to enable the interrupt of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param core_id Interrupt enabled CPU to corresponding ID
|
||||
*/
|
||||
void gpio_hal_intr_enable_on_core(gpio_hal_context_t *hal, gpio_num_t gpio_num, uint32_t core_id);
|
||||
|
||||
/**
|
||||
* @brief Disable GPIO module interrupt signal
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number. If you want to disable the interrupt of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*/
|
||||
void gpio_hal_intr_disable(gpio_hal_context_t *hal, gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Disable input mode on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_input_disable(hal, gpio_num) gpio_ll_input_disable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Enable input mode on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_input_enable(hal, gpio_num) gpio_ll_input_enable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Disable output mode on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_output_disable(hal, gpio_num) gpio_ll_output_disable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Enable output mode on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_output_enable(hal, gpio_num) gpio_ll_output_enable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Disable open-drain mode on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_od_disable(hal, gpio_num) gpio_ll_od_disable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Enable open-drain mode on GPIO.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_od_enable(hal, gpio_num) gpio_ll_od_enable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief GPIO set output level
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number. If you want to set the output level of e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
* @param level Output level. 0: low ; 1: high
|
||||
*/
|
||||
#define gpio_hal_set_level(hal, gpio_num, level) gpio_ll_set_level((hal)->dev, gpio_num, level)
|
||||
|
||||
/**
|
||||
* @brief GPIO get input level
|
||||
*
|
||||
* @warning If the pad is not configured for input (or input and output) the returned value is always 0.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number. If you want to get the logic level of e.g. pin GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*
|
||||
* @return
|
||||
* - 0 the GPIO input level is 0
|
||||
* - 1 the GPIO input level is 1
|
||||
*/
|
||||
#define gpio_hal_get_level(hal, gpio_num) gpio_ll_get_level((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Enable GPIO wake-up function.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number.
|
||||
* @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used.
|
||||
*/
|
||||
#define gpio_hal_wakeup_enable(hal, gpio_num, intr_type) gpio_ll_wakeup_enable((hal)->dev, gpio_num, intr_type)
|
||||
|
||||
/**
|
||||
* @brief Disable GPIO wake-up function.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
*/
|
||||
#define gpio_hal_wakeup_disable(hal, gpio_num) gpio_ll_wakeup_disable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Set GPIO pad drive capability
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Drive capability of the pad
|
||||
*/
|
||||
#define gpio_hal_set_drive_capability(hal, gpio_num, strength) gpio_ll_set_drive_capability((hal)->dev, gpio_num, strength)
|
||||
|
||||
/**
|
||||
* @brief Get GPIO pad drive capability
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Pointer to accept drive capability of the pad
|
||||
*/
|
||||
#define gpio_hal_get_drive_capability(hal, gpio_num, strength) gpio_ll_get_drive_capability((hal)->dev, gpio_num, strength)
|
||||
|
||||
/**
|
||||
* @brief Enable gpio pad hold function.
|
||||
*
|
||||
* The gpio pad hold function works in both input and output modes, but must be output-capable gpios.
|
||||
* If pad hold enabled:
|
||||
* in output mode: the output level of the pad will be force locked and can not be changed.
|
||||
* in input mode: the input value read will not change, regardless the changes of input signal.
|
||||
*
|
||||
* The state of digital gpio cannot be held during Deep-sleep, and it will resume the hold function
|
||||
* when the chip wakes up from Deep-sleep. If the digital gpio also needs to be held during Deep-sleep,
|
||||
* `gpio_deep_sleep_hold_en` should also be called.
|
||||
*
|
||||
* Power down or call gpio_hold_dis will disable this function.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
*/
|
||||
#define gpio_hal_hold_en(hal, gpio_num) gpio_ll_hold_en((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Disable gpio pad hold function.
|
||||
*
|
||||
* When the chip is woken up from Deep-sleep, the gpio will be set to the default mode, so, the gpio will output
|
||||
* the default level if this function is called. If you don't want the level changes, the gpio should be configured to
|
||||
* a known state before this function is called.
|
||||
* e.g.
|
||||
* If you hold gpio18 high during Deep-sleep, after the chip is woken up and `gpio_hold_dis` is called,
|
||||
* gpio18 will output low level(because gpio18 is input mode by default). If you don't want this behavior,
|
||||
* you should configure gpio18 as output mode and set it to hight level before calling `gpio_hold_dis`.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
*/
|
||||
#define gpio_hal_hold_dis(hal, gpio_num) gpio_ll_hold_dis((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Enable all digital gpio pad hold function during Deep-sleep.
|
||||
*
|
||||
* When the chip is in Deep-sleep mode, all digital gpio will hold the state before sleep, and when the chip is woken up,
|
||||
* the status of digital gpio will not be held. Note that the pad hold feature only works when the chip is in Deep-sleep mode,
|
||||
* when not in sleep mode, the digital gpio state can be changed even you have called this function.
|
||||
*
|
||||
* Power down or call gpio_hold_dis will disable this function, otherwise, the digital gpio hold feature works as long as the chip enter Deep-sleep.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define gpio_hal_deep_sleep_hold_en(hal) gpio_ll_deep_sleep_hold_en((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define gpio_hal_deep_sleep_hold_dis(hal) gpio_ll_deep_sleep_hold_dis((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Set pad input to a peripheral signal through the IOMUX.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
* @param signal_idx Peripheral signal id to input. One of the ``*_IN_IDX`` signals in ``soc/gpio_sig_map.h``.
|
||||
*/
|
||||
#define gpio_hal_iomux_in(hal, gpio_num, signal_idx) gpio_ll_iomux_in((hal)->dev, gpio_num, signal_idx)
|
||||
|
||||
/**
|
||||
* @brief Set peripheral output to an GPIO pad through the IOMUX.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num gpio_num GPIO number of the pad.
|
||||
* @param func The function number of the peripheral pin to output pin.
|
||||
* One of the ``FUNC_X_*`` of specified pin (X) in ``soc/io_mux_reg.h``.
|
||||
* @param oen_inv True if the output enable needs to be inverted, otherwise False.
|
||||
*/
|
||||
#define gpio_hal_iomux_out(hal, gpio_num, func, oen_inv) gpio_ll_iomux_out((hal)->dev, gpio_num, func, oen_inv)
|
||||
|
||||
#if GPIO_SUPPORTS_FORCE_HOLD
|
||||
/**
|
||||
* @brief Force hold digital and rtc gpio pad.
|
||||
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* */
|
||||
#define gpio_hal_force_hold_all(hal) gpio_ll_force_hold_all((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Force unhold digital and rtc gpio pad.
|
||||
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* */
|
||||
#define gpio_hal_force_unhold_all(hal) gpio_ll_force_unhold_all((hal)->dev)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
251
tools/sdk/esp32/include/soc/include/hal/gpio_types.h
Normal file
251
tools/sdk/esp32/include/soc/include/hal/gpio_types.h
Normal file
@@ -0,0 +1,251 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/gpio_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
GPIO_PORT_0 = 0,
|
||||
GPIO_PORT_MAX,
|
||||
} gpio_port_t;
|
||||
|
||||
#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 */
|
||||
#define GPIO_SEL_3 (BIT(3)) /*!< Pin 3 selected */
|
||||
#define GPIO_SEL_4 (BIT(4)) /*!< Pin 4 selected */
|
||||
#define GPIO_SEL_5 (BIT(5)) /*!< Pin 5 selected */
|
||||
#define GPIO_SEL_6 (BIT(6)) /*!< Pin 6 selected */
|
||||
#define GPIO_SEL_7 (BIT(7)) /*!< Pin 7 selected */
|
||||
#define GPIO_SEL_8 (BIT(8)) /*!< Pin 8 selected */
|
||||
#define GPIO_SEL_9 (BIT(9)) /*!< Pin 9 selected */
|
||||
#define GPIO_SEL_10 (BIT(10)) /*!< Pin 10 selected */
|
||||
#define GPIO_SEL_11 (BIT(11)) /*!< Pin 11 selected */
|
||||
#define GPIO_SEL_12 (BIT(12)) /*!< Pin 12 selected */
|
||||
#define GPIO_SEL_13 (BIT(13)) /*!< Pin 13 selected */
|
||||
#define GPIO_SEL_14 (BIT(14)) /*!< Pin 14 selected */
|
||||
#define GPIO_SEL_15 (BIT(15)) /*!< Pin 15 selected */
|
||||
#define GPIO_SEL_16 (BIT(16)) /*!< Pin 16 selected */
|
||||
#define GPIO_SEL_17 (BIT(17)) /*!< Pin 17 selected */
|
||||
#define GPIO_SEL_18 (BIT(18)) /*!< Pin 18 selected */
|
||||
#define GPIO_SEL_19 (BIT(19)) /*!< Pin 19 selected */
|
||||
#define GPIO_SEL_20 (BIT(20)) /*!< Pin 20 selected */
|
||||
#define GPIO_SEL_21 (BIT(21)) /*!< Pin 21 selected */
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define GPIO_SEL_22 (BIT(22)) /*!< Pin 22 selected */
|
||||
#define GPIO_SEL_23 (BIT(23)) /*!< Pin 23 selected */
|
||||
|
||||
#define GPIO_SEL_25 (BIT(25)) /*!< Pin 25 selected */
|
||||
#endif
|
||||
#define GPIO_SEL_26 (BIT(26)) /*!< Pin 26 selected */
|
||||
#define GPIO_SEL_27 (BIT(27)) /*!< Pin 27 selected */
|
||||
#define GPIO_SEL_28 (BIT(28)) /*!< Pin 28 selected */
|
||||
#define GPIO_SEL_29 (BIT(29)) /*!< Pin 29 selected */
|
||||
#define GPIO_SEL_30 (BIT(30)) /*!< Pin 30 selected */
|
||||
#define GPIO_SEL_31 (BIT(31)) /*!< Pin 31 selected */
|
||||
#define GPIO_SEL_32 ((uint64_t)(((uint64_t)1)<<32)) /*!< Pin 32 selected */
|
||||
#define GPIO_SEL_33 ((uint64_t)(((uint64_t)1)<<33)) /*!< Pin 33 selected */
|
||||
#define GPIO_SEL_34 ((uint64_t)(((uint64_t)1)<<34)) /*!< Pin 34 selected */
|
||||
#define GPIO_SEL_35 ((uint64_t)(((uint64_t)1)<<35)) /*!< Pin 35 selected */
|
||||
#define GPIO_SEL_36 ((uint64_t)(((uint64_t)1)<<36)) /*!< Pin 36 selected */
|
||||
#define GPIO_SEL_37 ((uint64_t)(((uint64_t)1)<<37)) /*!< Pin 37 selected */
|
||||
#define GPIO_SEL_38 ((uint64_t)(((uint64_t)1)<<38)) /*!< Pin 38 selected */
|
||||
#define GPIO_SEL_39 ((uint64_t)(((uint64_t)1)<<39)) /*!< Pin 39 selected */
|
||||
#if GPIO_PIN_COUNT > 40
|
||||
#define GPIO_SEL_40 ((uint64_t)(((uint64_t)1)<<40)) /*!< Pin 40 selected */
|
||||
#define GPIO_SEL_41 ((uint64_t)(((uint64_t)1)<<41)) /*!< Pin 41 selected */
|
||||
#define GPIO_SEL_42 ((uint64_t)(((uint64_t)1)<<42)) /*!< Pin 42 selected */
|
||||
#define GPIO_SEL_43 ((uint64_t)(((uint64_t)1)<<43)) /*!< Pin 43 selected */
|
||||
#define GPIO_SEL_44 ((uint64_t)(((uint64_t)1)<<44)) /*!< Pin 44 selected */
|
||||
#define GPIO_SEL_45 ((uint64_t)(((uint64_t)1)<<45)) /*!< Pin 45 selected */
|
||||
#define GPIO_SEL_46 ((uint64_t)(((uint64_t)1)<<46)) /*!< Pin 46 selected */
|
||||
#endif
|
||||
|
||||
#define GPIO_PIN_REG_0 IO_MUX_GPIO0_REG
|
||||
#define GPIO_PIN_REG_1 IO_MUX_GPIO1_REG
|
||||
#define GPIO_PIN_REG_2 IO_MUX_GPIO2_REG
|
||||
#define GPIO_PIN_REG_3 IO_MUX_GPIO3_REG
|
||||
#define GPIO_PIN_REG_4 IO_MUX_GPIO4_REG
|
||||
#define GPIO_PIN_REG_5 IO_MUX_GPIO5_REG
|
||||
#define GPIO_PIN_REG_6 IO_MUX_GPIO6_REG
|
||||
#define GPIO_PIN_REG_7 IO_MUX_GPIO7_REG
|
||||
#define GPIO_PIN_REG_8 IO_MUX_GPIO8_REG
|
||||
#define GPIO_PIN_REG_9 IO_MUX_GPIO9_REG
|
||||
#define GPIO_PIN_REG_10 IO_MUX_GPIO10_REG
|
||||
#define GPIO_PIN_REG_11 IO_MUX_GPIO11_REG
|
||||
#define GPIO_PIN_REG_12 IO_MUX_GPIO12_REG
|
||||
#define GPIO_PIN_REG_13 IO_MUX_GPIO13_REG
|
||||
#define GPIO_PIN_REG_14 IO_MUX_GPIO14_REG
|
||||
#define GPIO_PIN_REG_15 IO_MUX_GPIO15_REG
|
||||
#define GPIO_PIN_REG_16 IO_MUX_GPIO16_REG
|
||||
#define GPIO_PIN_REG_17 IO_MUX_GPIO17_REG
|
||||
#define GPIO_PIN_REG_18 IO_MUX_GPIO18_REG
|
||||
#define GPIO_PIN_REG_19 IO_MUX_GPIO19_REG
|
||||
#define GPIO_PIN_REG_20 IO_MUX_GPIO20_REG
|
||||
#define GPIO_PIN_REG_21 IO_MUX_GPIO21_REG
|
||||
#define GPIO_PIN_REG_22 IO_MUX_GPIO22_REG
|
||||
#define GPIO_PIN_REG_23 IO_MUX_GPIO23_REG
|
||||
#define GPIO_PIN_REG_24 IO_MUX_GPIO24_REG
|
||||
#define GPIO_PIN_REG_25 IO_MUX_GPIO25_REG
|
||||
#define GPIO_PIN_REG_26 IO_MUX_GPIO26_REG
|
||||
#define GPIO_PIN_REG_27 IO_MUX_GPIO27_REG
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#define GPIO_PIN_REG_28 IO_MUX_GPIO28_REG
|
||||
#define GPIO_PIN_REG_29 IO_MUX_GPIO29_REG
|
||||
#define GPIO_PIN_REG_30 IO_MUX_GPIO30_REG
|
||||
#define GPIO_PIN_REG_31 IO_MUX_GPIO31_REG
|
||||
#endif
|
||||
#define GPIO_PIN_REG_32 IO_MUX_GPIO32_REG
|
||||
#define GPIO_PIN_REG_33 IO_MUX_GPIO33_REG
|
||||
#define GPIO_PIN_REG_34 IO_MUX_GPIO34_REG
|
||||
#define GPIO_PIN_REG_35 IO_MUX_GPIO35_REG
|
||||
#define GPIO_PIN_REG_36 IO_MUX_GPIO36_REG
|
||||
#define GPIO_PIN_REG_37 IO_MUX_GPIO37_REG
|
||||
#define GPIO_PIN_REG_38 IO_MUX_GPIO38_REG
|
||||
#define GPIO_PIN_REG_39 IO_MUX_GPIO39_REG
|
||||
#if GPIO_PIN_COUNT > 40
|
||||
#define GPIO_PIN_REG_40 IO_MUX_GPIO40_REG
|
||||
#define GPIO_PIN_REG_41 IO_MUX_GPIO41_REG
|
||||
#define GPIO_PIN_REG_42 IO_MUX_GPIO42_REG
|
||||
#define GPIO_PIN_REG_43 IO_MUX_GPIO43_REG
|
||||
#define GPIO_PIN_REG_44 IO_MUX_GPIO44_REG
|
||||
#define GPIO_PIN_REG_45 IO_MUX_GPIO45_REG
|
||||
#define GPIO_PIN_REG_46 IO_MUX_GPIO46_REG
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */
|
||||
GPIO_NUM_0 = 0, /*!< GPIO0, input and output */
|
||||
GPIO_NUM_1 = 1, /*!< GPIO1, input and output */
|
||||
GPIO_NUM_2 = 2, /*!< GPIO2, input and output */
|
||||
GPIO_NUM_3 = 3, /*!< GPIO3, input and output */
|
||||
GPIO_NUM_4 = 4, /*!< GPIO4, input and output */
|
||||
GPIO_NUM_5 = 5, /*!< GPIO5, input and output */
|
||||
GPIO_NUM_6 = 6, /*!< GPIO6, input and output */
|
||||
GPIO_NUM_7 = 7, /*!< GPIO7, input and output */
|
||||
GPIO_NUM_8 = 8, /*!< GPIO8, input and output */
|
||||
GPIO_NUM_9 = 9, /*!< GPIO9, input and output */
|
||||
GPIO_NUM_10 = 10, /*!< GPIO10, input and output */
|
||||
GPIO_NUM_11 = 11, /*!< GPIO11, input and output */
|
||||
GPIO_NUM_12 = 12, /*!< GPIO12, input and output */
|
||||
GPIO_NUM_13 = 13, /*!< GPIO13, input and output */
|
||||
GPIO_NUM_14 = 14, /*!< GPIO14, input and output */
|
||||
GPIO_NUM_15 = 15, /*!< GPIO15, input and output */
|
||||
GPIO_NUM_16 = 16, /*!< GPIO16, input and output */
|
||||
GPIO_NUM_17 = 17, /*!< GPIO17, input and output */
|
||||
GPIO_NUM_18 = 18, /*!< GPIO18, input and output */
|
||||
GPIO_NUM_19 = 19, /*!< GPIO19, input and output */
|
||||
GPIO_NUM_20 = 20, /*!< GPIO20, input and output */
|
||||
GPIO_NUM_21 = 21, /*!< GPIO21, input and output */
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
GPIO_NUM_22 = 22, /*!< GPIO22, input and output */
|
||||
GPIO_NUM_23 = 23, /*!< GPIO23, input and output */
|
||||
|
||||
GPIO_NUM_25 = 25, /*!< GPIO25, input and output */
|
||||
#endif
|
||||
/* Note: The missing IO is because it is used inside the chip. */
|
||||
GPIO_NUM_26 = 26, /*!< GPIO26, input and output */
|
||||
GPIO_NUM_27 = 27, /*!< GPIO27, input and output */
|
||||
GPIO_NUM_28 = 28, /*!< GPIO28, input and output */
|
||||
GPIO_NUM_29 = 29, /*!< GPIO29, input and output */
|
||||
GPIO_NUM_30 = 30, /*!< GPIO30, input and output */
|
||||
GPIO_NUM_31 = 31, /*!< GPIO31, input and output */
|
||||
GPIO_NUM_32 = 32, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO33, input and output */
|
||||
GPIO_NUM_34 = 34, /*!< GPIO34, input mode only(ESP32) / input and output(ESP32-S2) */
|
||||
GPIO_NUM_35 = 35, /*!< GPIO35, input mode only(ESP32) / input and output(ESP32-S2) */
|
||||
GPIO_NUM_36 = 36, /*!< GPIO36, input mode only(ESP32) / input and output(ESP32-S2) */
|
||||
GPIO_NUM_37 = 37, /*!< GPIO37, input mode only(ESP32) / input and output(ESP32-S2) */
|
||||
GPIO_NUM_38 = 38, /*!< GPIO38, input mode only(ESP32) / input and output(ESP32-S2) */
|
||||
GPIO_NUM_39 = 39, /*!< GPIO39, input mode only(ESP32) / input and output(ESP32-S2) */
|
||||
#if GPIO_PIN_COUNT > 40
|
||||
GPIO_NUM_40 = 40, /*!< GPIO40, input and output */
|
||||
GPIO_NUM_41 = 41, /*!< GPIO41, input and output */
|
||||
GPIO_NUM_42 = 42, /*!< GPIO42, input and output */
|
||||
GPIO_NUM_43 = 43, /*!< GPIO43, input and output */
|
||||
GPIO_NUM_44 = 44, /*!< GPIO44, input and output */
|
||||
GPIO_NUM_45 = 45, /*!< GPIO45, input and output */
|
||||
GPIO_NUM_46 = 46, /*!< GPIO46, input mode only */
|
||||
#endif
|
||||
GPIO_NUM_MAX,
|
||||
/** @endcond */
|
||||
} gpio_num_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */
|
||||
GPIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */
|
||||
GPIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */
|
||||
GPIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */
|
||||
GPIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */
|
||||
GPIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */
|
||||
GPIO_INTR_MAX,
|
||||
} gpio_int_type_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_DISABLE = GPIO_MODE_DEF_DISABLE, /*!< GPIO mode : disable input and output */
|
||||
GPIO_MODE_INPUT = GPIO_MODE_DEF_INPUT, /*!< GPIO mode : input only */
|
||||
GPIO_MODE_OUTPUT = GPIO_MODE_DEF_OUTPUT, /*!< GPIO mode : output only mode */
|
||||
GPIO_MODE_OUTPUT_OD = ((GPIO_MODE_DEF_OUTPUT) | (GPIO_MODE_DEF_OD)), /*!< GPIO mode : output only with open-drain mode */
|
||||
GPIO_MODE_INPUT_OUTPUT_OD = ((GPIO_MODE_DEF_INPUT) | (GPIO_MODE_DEF_OUTPUT) | (GPIO_MODE_DEF_OD)), /*!< GPIO mode : output and input with open-drain mode*/
|
||||
GPIO_MODE_INPUT_OUTPUT = ((GPIO_MODE_DEF_INPUT) | (GPIO_MODE_DEF_OUTPUT)), /*!< GPIO mode : output and input mode */
|
||||
} gpio_mode_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULLUP_DISABLE = 0x0, /*!< Disable GPIO pull-up resistor */
|
||||
GPIO_PULLUP_ENABLE = 0x1, /*!< Enable GPIO pull-up resistor */
|
||||
} gpio_pullup_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULLDOWN_DISABLE = 0x0, /*!< Disable GPIO pull-down resistor */
|
||||
GPIO_PULLDOWN_ENABLE = 0x1, /*!< Enable GPIO pull-down resistor */
|
||||
} gpio_pulldown_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration parameters of GPIO pad for gpio_config function
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t pin_bit_mask; /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */
|
||||
gpio_mode_t mode; /*!< GPIO mode: set input/output mode */
|
||||
gpio_pullup_t pull_up_en; /*!< GPIO pull-up */
|
||||
gpio_pulldown_t pull_down_en; /*!< GPIO pull-down */
|
||||
gpio_int_type_t intr_type; /*!< GPIO interrupt type */
|
||||
} gpio_config_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_PULLUP_ONLY, /*!< Pad pull up */
|
||||
GPIO_PULLDOWN_ONLY, /*!< Pad pull down */
|
||||
GPIO_PULLUP_PULLDOWN, /*!< Pad pull up + pull down*/
|
||||
GPIO_FLOATING, /*!< Pad floating */
|
||||
} gpio_pull_mode_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_DRIVE_CAP_0 = 0, /*!< Pad drive capability: weak */
|
||||
GPIO_DRIVE_CAP_1 = 1, /*!< Pad drive capability: stronger */
|
||||
GPIO_DRIVE_CAP_2 = 2, /*!< Pad drive capability: medium */
|
||||
GPIO_DRIVE_CAP_DEFAULT = 2, /*!< Pad drive capability: medium */
|
||||
GPIO_DRIVE_CAP_3 = 3, /*!< Pad drive capability: strongest */
|
||||
GPIO_DRIVE_CAP_MAX,
|
||||
} gpio_drive_cap_t;
|
||||
|
||||
typedef void (*gpio_isr_t)(void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
30
tools/sdk/esp32/include/soc/include/hal/hal_defs.h
Normal file
30
tools/sdk/esp32/include/soc/include/hal/hal_defs.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright 2010-2018 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
// platform related stuff
|
||||
|
||||
#define HAL_SWAP32(word) __builtin_bswap32(word)
|
||||
#define HAL_SWAP64(word) __builtin_bswap64(word)
|
||||
|
||||
#define HAL_LOGE(...) ESP_LOGE(__VA_ARGS__)
|
||||
#define HAL_LOGW(...) ESP_LOGW(__VA_ARGS__)
|
||||
#define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__)
|
||||
#define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__)
|
||||
#define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__)
|
||||
|
||||
#define STATIC_HAL_REG_CHECK(TAG, ENUM, VAL) _Static_assert((ENUM) == (VAL), #TAG" "#ENUM" definition no longer matches register value")
|
||||
524
tools/sdk/esp32/include/soc/include/hal/i2c_hal.h
Normal file
524
tools/sdk/esp32/include/soc/include/hal/i2c_hal.h
Normal file
@@ -0,0 +1,524 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for I2C
|
||||
|
||||
#pragma once
|
||||
#include "hal/i2c_ll.h"
|
||||
#include "hal/i2c_types.h"
|
||||
|
||||
/**
|
||||
* @brief I2C hal Context definition
|
||||
*/
|
||||
typedef struct {
|
||||
i2c_dev_t *dev;
|
||||
uint32_t version;
|
||||
} i2c_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Write the I2C rxfifo with the given length
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param wr_data Pointer to data buffer
|
||||
* @param wr_size Amount of data needs write
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_write_txfifo(hal,wr_data,wr_size) i2c_ll_write_txfifo((hal)->dev,wr_data,wr_size)
|
||||
|
||||
/**
|
||||
* @brief Read the I2C rxfifo with the given length
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param buf Pointer to data buffer
|
||||
* @param rd_size Amount of data needs read
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_read_rxfifo(hal,buf,rd_size) i2c_ll_read_rxfifo((hal)->dev,buf,rd_size)
|
||||
|
||||
/**
|
||||
* @brief Write I2C cmd register
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param cmd I2C hardware command
|
||||
* @param cmd_idx The index of the command register, should be less than 16
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_write_cmd_reg(hal,cmd, cmd_idx) i2c_ll_write_cmd_reg((hal)->dev,cmd,cmd_idx)
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C to triger a trasaction
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_trans_start(hal) i2c_ll_trans_start((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Enable I2C master RX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_enable_master_rx_it(hal) i2c_ll_master_enable_rx_it((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Enable I2C master TX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_enable_master_tx_it(hal) i2c_ll_master_enable_tx_it((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Clear I2C slave TX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_slave_clr_tx_it(hal) i2c_ll_slave_clr_tx_it((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Clear I2C slave RX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define i2c_hal_slave_clr_rx_it(hal) i2c_ll_slave_clr_rx_it((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Init the I2C master.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param i2c_num I2C port number
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_master_init(i2c_hal_context_t *hal, i2c_port_t i2c_num);
|
||||
|
||||
/**
|
||||
* @brief Init the I2C slave.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param i2c_num I2C port number
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_slave_init(i2c_hal_context_t *hal, i2c_port_t i2c_num);
|
||||
|
||||
/**
|
||||
* @brief Reset the I2C hw txfifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_txfifo_rst(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Reset the I2C hw rxfifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_rxfifo_rst(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C data MSB bit shifted first or LSB bit shifted first.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param tx_mode Data format of TX
|
||||
* @param rx_mode Data format of RX
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_data_mode(i2c_hal_context_t *hal, i2c_trans_mode_t tx_mode, i2c_trans_mode_t rx_mode);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C hardware filter function.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param filter_num If the glitch period on the line is less than this value(in APB cycle), it will be filtered out
|
||||
* If `filter_num == 0`, the filter will be disabled
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_filter(i2c_hal_context_t *hal, uint8_t filter_num);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C hardware filter configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param filter_num Pointer to accept the hardware filter configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_filter(i2c_hal_context_t *hal, uint8_t *filter_num);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C SCL timing
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param hight_period SCL high period
|
||||
* @param low_period SCL low period
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_scl_timing(i2c_hal_context_t *hal, int hight_period, int low_period);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C master SCL frequency
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param src_clk The I2C Source clock frequency
|
||||
* @param scl_freq The SCL frequency to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_scl_freq(i2c_hal_context_t *hal, uint32_t src_clk, uint32_t scl_freq);
|
||||
|
||||
/**
|
||||
* @brief Clear the I2C interrupt status with the given mask
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt bitmap needs to be clearned
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_clr_intsts_mask(i2c_hal_context_t *hal, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Enable the I2C interrupt with the given mask
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt bitmap needs to be enabled
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_enable_intr_mask(i2c_hal_context_t *hal, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Disable the I2C interrupt with the given mask
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt bitmap needs to be disabled
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_disable_intr_mask(i2c_hal_context_t *hal, uint32_t mask);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C memory access mode, FIFO mode or none FIFO mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param fifo_mode_en Set true to enable FIFO access mode, else set it false
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_fifo_mode(i2c_hal_context_t *hal, bool fifo_mode_en);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C timeout value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param tout_val the timeout value to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_tout(i2c_hal_context_t *hal, int tout_val);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C time out configuration
|
||||
*
|
||||
* @param tout_val Pointer to accept the timeout configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_tout(i2c_hal_context_t *hal, int *tout_val);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C slave address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param slave_addr Slave address
|
||||
* @param addr_10bit_en Set true to enable 10-bit slave address mode, Set false to enable 7-bit address mode
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_slave_addr(i2c_hal_context_t *hal, uint16_t slave_addr, bool addr_10bit_en);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C stop timing
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param stop_setup The stop condition setup period (in APB cycle)
|
||||
* @param stop_hold The stop condition hold period (in APB cycle)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_stop_timing(i2c_hal_context_t *hal, int stop_setup, int stop_hold);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C start timing
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param start_setup The start condition setup period (in APB cycle)
|
||||
* @param start_hold The start condition hold period (in APB cycle)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_start_timing(i2c_hal_context_t *hal, int start_setup, int start_hold);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C sda sample timing
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sda_sample The SDA sample time (in APB cycle)
|
||||
* @param sda_hold The SDA hold time (in APB cycle)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_sda_timing(i2c_hal_context_t *hal, int sda_sample, int sda_hold);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C txfifo empty threshold value
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param empty_thr TxFIFO empty threshold value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_txfifo_empty_thr(i2c_hal_context_t *hal, uint8_t empty_thr);
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C rxfifo full threshold value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param full_thr RxFIFO full threshold value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_rxfifo_full_thr(i2c_hal_context_t *hal, uint8_t full_thr);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask Pointer to accept the interrupt status
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_intsts_mask(i2c_hal_context_t *hal, uint32_t *mask);
|
||||
|
||||
/**
|
||||
* @brief Check if the I2C bus is busy
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return True if the bus is busy, otherwise, fale will be returned
|
||||
*/
|
||||
bool i2c_hal_is_bus_busy(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C sda sample timing configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sample_time Pointer to accept the SDA sample time
|
||||
* @param hold_time Pointer to accept the SDA hold time
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_sda_timing(i2c_hal_context_t *hal, int *sample_time, int *hold_time);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C stop timing configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param setup_time Pointer to accept the stop condition setup period
|
||||
* @param hold_time Pointer to accept the stop condition hold period
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_stop_timing(i2c_hal_context_t *hal, int *setup_time, int *hold_time);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C scl timing configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param high_period Pointer to accept the scl high period
|
||||
* @param low_period Pointer to accept the scl low period
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_scl_timing(i2c_hal_context_t *hal, int *high_period, int *low_period);
|
||||
|
||||
/**
|
||||
* @brief Get the I2C start timing configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param setup_time Pointer to accept the start condition setup period
|
||||
* @param hold_time Pointer to accept the start condition hold period
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_start_timing(i2c_hal_context_t *hal, int *setup_time, int *hold_time);
|
||||
|
||||
/**
|
||||
* @brief Check if the I2C is master mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return True if in master mode, otherwise, false will be returned
|
||||
*/
|
||||
bool i2c_hal_is_master_mode(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Get the rxFIFO readable length
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param len Pointer to accept the rxFIFO readable length
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_rxfifo_cnt(i2c_hal_context_t *hal, uint32_t *len);
|
||||
|
||||
/**
|
||||
* @brief Set I2C bus timing with the given frequency
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param scl_freq The scl frequency to be set
|
||||
* @param src_clk Source clock of I2C
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_set_bus_timing(i2c_hal_context_t *hal, uint32_t scl_freq, i2c_sclk_t src_clk);
|
||||
|
||||
/**
|
||||
* @brief Get I2C txFIFO writeable length
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param len Pointer to accept the txFIFO writeable length
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_txfifo_cnt(i2c_hal_context_t *hal, uint32_t *len);
|
||||
|
||||
/**
|
||||
* @brief Check if the I2C is master mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param tx_mode Pointer to accept the TX data mode
|
||||
* @param rx_mode Pointer to accept the RX data mode
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_get_data_mode(i2c_hal_context_t *hal, i2c_trans_mode_t *tx_mode, i2c_trans_mode_t *rx_mode);
|
||||
|
||||
/**
|
||||
* @brief I2C hardware FSM reset
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_master_fsm_rst(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief @brief Clear I2C bus
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_master_clr_bus(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable I2C slave TX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_enable_slave_tx_it(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Disable I2C slave TX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_disable_slave_tx_it(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable I2C slave RX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_enable_slave_rx_it(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Disable I2C slave RX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_disable_slave_rx_it(i2c_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief I2C master handle tx interrupt event
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param event Pointer to accept the interrupt event
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_master_handle_tx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event);
|
||||
|
||||
/**
|
||||
* @brief I2C master handle rx interrupt event
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param event Pointer to accept the interrupt event
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_master_handle_rx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event);
|
||||
|
||||
/**
|
||||
* @brief I2C slave handle interrupt event
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param event Pointer to accept the interrupt event
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void i2c_hal_slave_handle_event(i2c_hal_context_t *hal, i2c_intr_event_t *event);
|
||||
96
tools/sdk/esp32/include/soc/include/hal/i2c_types.h
Normal file
96
tools/sdk/esp32/include/soc/include/hal/i2c_types.h
Normal file
@@ -0,0 +1,96 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/i2c_caps.h"
|
||||
|
||||
/**
|
||||
* @brief I2C port number, can be I2C_NUM_0 ~ (I2C_NUM_MAX-1).
|
||||
*/
|
||||
typedef int i2c_port_t;
|
||||
|
||||
typedef enum{
|
||||
I2C_MODE_SLAVE = 0, /*!< I2C slave mode */
|
||||
I2C_MODE_MASTER, /*!< I2C master mode */
|
||||
I2C_MODE_MAX,
|
||||
} i2c_mode_t;
|
||||
|
||||
typedef enum {
|
||||
I2C_MASTER_WRITE = 0, /*!< I2C write data */
|
||||
I2C_MASTER_READ, /*!< I2C read data */
|
||||
} i2c_rw_t;
|
||||
|
||||
typedef enum{
|
||||
I2C_CMD_RESTART = 0, /*!<I2C restart command */
|
||||
I2C_CMD_WRITE, /*!<I2C write command */
|
||||
I2C_CMD_READ, /*!<I2C read command */
|
||||
I2C_CMD_STOP, /*!<I2C stop command */
|
||||
I2C_CMD_END /*!<I2C end command */
|
||||
} i2c_opmode_t;
|
||||
|
||||
typedef enum {
|
||||
I2C_DATA_MODE_MSB_FIRST = 0, /*!< I2C data msb first */
|
||||
I2C_DATA_MODE_LSB_FIRST = 1, /*!< I2C data lsb first */
|
||||
I2C_DATA_MODE_MAX
|
||||
} i2c_trans_mode_t;
|
||||
|
||||
typedef enum {
|
||||
I2C_ADDR_BIT_7 = 0, /*!< I2C 7bit address for slave mode */
|
||||
I2C_ADDR_BIT_10, /*!< I2C 10bit address for slave mode */
|
||||
I2C_ADDR_BIT_MAX,
|
||||
} i2c_addr_mode_t;
|
||||
|
||||
typedef enum {
|
||||
I2C_MASTER_ACK = 0x0, /*!< I2C ack for each byte read */
|
||||
I2C_MASTER_NACK = 0x1, /*!< I2C nack for each byte read */
|
||||
I2C_MASTER_LAST_NACK = 0x2, /*!< I2C nack for the last byte*/
|
||||
I2C_MASTER_ACK_MAX,
|
||||
} i2c_ack_type_t;
|
||||
|
||||
typedef enum {
|
||||
I2C_SCLK_REF_TICK, /*!< I2C source clock from REF_TICK */
|
||||
I2C_SCLK_APB, /*!< I2C source clock from APB */
|
||||
} i2c_sclk_t;
|
||||
|
||||
/**
|
||||
* @brief I2C initialization parameters
|
||||
*/
|
||||
typedef struct{
|
||||
i2c_mode_t mode; /*!< I2C mode */
|
||||
int sda_io_num; /*!< GPIO number for I2C sda signal */
|
||||
int scl_io_num; /*!< GPIO number for I2C scl signal */
|
||||
bool sda_pullup_en; /*!< Internal GPIO pull mode for I2C sda signal*/
|
||||
bool scl_pullup_en; /*!< Internal GPIO pull mode for I2C scl signal*/
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t clk_speed; /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
|
||||
} master; /*!< I2C master config */
|
||||
struct {
|
||||
uint8_t addr_10bit_en; /*!< I2C 10bit address mode enable for slave mode */
|
||||
uint16_t slave_addr; /*!< I2C address for slave mode */
|
||||
} slave; /*!< I2C slave config */
|
||||
};
|
||||
} i2c_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
300
tools/sdk/esp32/include/soc/include/hal/i2s_hal.h
Normal file
300
tools/sdk/esp32/include/soc/include/hal/i2s_hal.h
Normal file
@@ -0,0 +1,300 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for I2S.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/i2s_periph.h"
|
||||
#include "soc/i2s_caps.h"
|
||||
#include "hal/i2s_ll.h"
|
||||
#include "hal/i2s_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
i2s_dev_t *dev;
|
||||
uint32_t version;
|
||||
} i2s_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Reset I2S fifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_reset_fifo(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Get I2S interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param status interrupt status
|
||||
*/
|
||||
#define i2s_hal_get_intr_status(hal, status) i2s_ll_get_intr_status((hal)->dev, status)
|
||||
|
||||
/**
|
||||
* @brief Clear I2S interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask interrupt status mask
|
||||
*/
|
||||
#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Get I2S out eof des address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out eof des address
|
||||
*/
|
||||
#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_get_out_eof_des_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Get I2S in eof des address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr in eof des address
|
||||
*/
|
||||
#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_get_in_eof_des_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S rx interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_rx_intr(hal) i2s_ll_enable_rx_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Disable I2S rx interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_rx_intr(hal) i2s_ll_disable_rx_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Disable I2S tx interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_tx_intr(hal) i2s_ll_disable_tx_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S tx interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_tx_intr(hal) i2s_ll_enable_tx_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param ch i2s channel
|
||||
* @param bits bits per sample
|
||||
*/
|
||||
void i2s_hal_set_tx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param ch i2s channel
|
||||
* @param bits bits per sample
|
||||
*/
|
||||
void i2s_hal_set_rx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Set I2S out link address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out link address
|
||||
*/
|
||||
#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S out link address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out link address
|
||||
*/
|
||||
#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S out link address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out link address
|
||||
*/
|
||||
#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S in link
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param rx_eof_num in link eof num
|
||||
* @param addr in link address
|
||||
*/
|
||||
void i2s_hal_set_in_link(i2s_hal_context_t *hal, uint32_t rx_eof_num, uint32_t addr);
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
/**
|
||||
* @brief Get I2S tx pdm
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param fp tx pdm fp
|
||||
* @param fs tx pdm fs
|
||||
*/
|
||||
void i2s_hal_get_tx_pdm(i2s_hal_context_t *hal, int *fp, int *fs);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get I2S rx sinc dsr 16 en
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param en 0: disable, 1: enable
|
||||
*/
|
||||
#define i2s_hal_get_rx_sinc_dsr_16_en(hal, en) i2s_ll_get_rx_sinc_dsr_16_en((hal)->dev, en)
|
||||
|
||||
/**
|
||||
* @brief Set I2S clk div
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param div_num i2s clkm div num
|
||||
* @param div_a i2s clkm div a
|
||||
* @param div_b i2s clkm div b
|
||||
* @param tx_bck_div tx bck div num
|
||||
* @param rx_bck_div rx bck div num
|
||||
*/
|
||||
void i2s_hal_set_clk_div(i2s_hal_context_t *hal, int div_num, int div_a, int div_b, int tx_bck_div, int rx_bck_div);
|
||||
|
||||
/**
|
||||
* @brief Set I2S clock sel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sel clock sel
|
||||
*/
|
||||
#define i2s_hal_set_clock_sel(hal, sel) i2s_ll_set_clk_sel((hal)->dev, sel)
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx bits mod
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param bits bit width per sample.
|
||||
*/
|
||||
void i2s_hal_set_tx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx bits mod
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param bits bit width per sample.
|
||||
*/
|
||||
void i2s_hal_set_rx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Reset I2S tx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_reset(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Start I2S tx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_start_tx(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Start I2S rx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_start_rx(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Stop I2S tx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_stop_tx(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Stop I2S rx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_stop_rx(i2s_hal_context_t *hal);
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
/**
|
||||
* @brief Set I2S pdm rx down sample
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param dsr 0:disable, 1: enable
|
||||
*/
|
||||
#define i2s_hal_set_pdm_rx_down_sample(hal, dsr) i2s_ll_set_rx_sinc_dsr_16_en((hal)->dev, dsr)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Config I2S param
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param i2s_config I2S configurations - see i2s_config_t struct
|
||||
*/
|
||||
void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_config_t *i2s_config);
|
||||
|
||||
/**
|
||||
* @brief Enable I2S sig loopback
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_sig_loopback(hal) i2s_ll_set_sig_loopback((hal)->dev, 1)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S master mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_enable_master_mode(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable I2S slave mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_enable_slave_mode(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Init the I2S hal and set the I2S to the default configuration. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1)
|
||||
*/
|
||||
void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
206
tools/sdk/esp32/include/soc/include/hal/i2s_types.h
Normal file
206
tools/sdk/esp32/include/soc/include/hal/i2s_types.h
Normal file
@@ -0,0 +1,206 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include "soc/i2s_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I2S port number, the max port number is (I2S_NUM_MAX -1).
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_NUM_0 = 0, /*!< I2S port 0 */
|
||||
#if SOC_I2S_NUM > 1
|
||||
I2S_NUM_1 = 1, /*!< I2S port 1 */
|
||||
#endif
|
||||
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.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< I2S bits per sample: 8-bits*/
|
||||
I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< I2S bits per sample: 16-bits*/
|
||||
I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< I2S bits per sample: 24-bits*/
|
||||
I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< I2S bits per sample: 32-bits*/
|
||||
} i2s_bits_per_sample_t;
|
||||
|
||||
/**
|
||||
* @brief I2S channel.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/
|
||||
I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/
|
||||
} i2s_channel_t;
|
||||
|
||||
/**
|
||||
* @brief I2S communication standard format
|
||||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* @brief I2S channel format type
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CHANNEL_FMT_RIGHT_LEFT = 0x00,
|
||||
I2S_CHANNEL_FMT_ALL_RIGHT,
|
||||
I2S_CHANNEL_FMT_ALL_LEFT,
|
||||
I2S_CHANNEL_FMT_ONLY_RIGHT,
|
||||
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
|
||||
*
|
||||
* @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_MODE_MASTER = 1,
|
||||
I2S_MODE_SLAVE = 2,
|
||||
I2S_MODE_TX = 4,
|
||||
I2S_MODE_RX = 8,
|
||||
#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,
|
||||
#endif
|
||||
} i2s_mode_t;
|
||||
|
||||
/**
|
||||
* @brief I2S configuration parameters for i2s_param_config function
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
i2s_mode_t mode; /*!< I2S work mode*/
|
||||
int sample_rate; /*!< I2S sample rate*/
|
||||
i2s_bits_per_sample_t bits_per_sample; /*!< I2S bits per sample*/
|
||||
i2s_channel_fmt_t channel_format; /*!< I2S channel format */
|
||||
i2s_comm_format_t communication_format; /*!< I2S communication format */
|
||||
int intr_alloc_flags; /*!< Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info */
|
||||
int dma_buf_count; /*!< I2S DMA Buffer Count */
|
||||
int dma_buf_len; /*!< I2S DMA Buffer Length */
|
||||
bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */
|
||||
bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */
|
||||
int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value.*/
|
||||
} i2s_config_t;
|
||||
|
||||
/**
|
||||
* @brief I2S event types
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_EVENT_DMA_ERROR,
|
||||
I2S_EVENT_TX_DONE, /*!< I2S DMA finish sent 1 buffer*/
|
||||
I2S_EVENT_RX_DONE, /*!< I2S DMA finish received 1 buffer*/
|
||||
I2S_EVENT_MAX, /*!< I2S event max index*/
|
||||
} i2s_event_type_t;
|
||||
|
||||
/**
|
||||
* @brief I2S DAC mode for i2s_set_dac_mode.
|
||||
*
|
||||
* @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_DAC_CHANNEL_DISABLE = 0, /*!< Disable I2S built-in DAC signals*/
|
||||
I2S_DAC_CHANNEL_RIGHT_EN = 1, /*!< Enable I2S built-in DAC right channel, maps to DAC channel 1 on GPIO25*/
|
||||
I2S_DAC_CHANNEL_LEFT_EN = 2, /*!< Enable I2S built-in DAC left channel, maps to DAC channel 2 on GPIO26*/
|
||||
I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/
|
||||
I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/
|
||||
} i2s_dac_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Event structure used in I2S event queue
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
i2s_event_type_t type; /*!< I2S event type */
|
||||
size_t size; /*!< I2S data size for I2S_DATA event*/
|
||||
} i2s_event_t;
|
||||
|
||||
/**
|
||||
* @brief I2S pin number for i2s_set_pin
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int bck_io_num; /*!< BCK in out pin*/
|
||||
int ws_io_num; /*!< WS in out pin*/
|
||||
int data_out_num; /*!< DATA out pin*/
|
||||
int data_in_num; /*!< DATA in pin*/
|
||||
} i2s_pin_config_t;
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
/**
|
||||
* @brief I2S PDM RX downsample mode
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_PDM_DSR_8S = 0, /*!< downsampling number is 8 for PDM RX mode*/
|
||||
I2S_PDM_DSR_16S, /*!< downsampling number is 16 for PDM RX mode*/
|
||||
I2S_PDM_DSR_MAX,
|
||||
} i2s_pdm_dsr_t;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
I2S_CLK_D2CLK = 0,
|
||||
I2S_CLK_APLL,
|
||||
} i2s_clock_src_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
388
tools/sdk/esp32/include/soc/include/hal/ledc_hal.h
Normal file
388
tools/sdk/esp32/include/soc/include/hal/ledc_hal.h
Normal file
@@ -0,0 +1,388 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for LEDC.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/ledc_ll.h"
|
||||
#include "hal/ledc_types.h"
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
ledc_dev_t *dev;
|
||||
ledc_mode_t speed_mode;
|
||||
} ledc_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Set LEDC low speed timer clock
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param slow_clk_sel LEDC low speed timer clock source
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_slow_clk_sel(hal, slow_clk_sel) ledc_ll_set_slow_clk_sel((hal)->dev, slow_clk_sel)
|
||||
|
||||
/**
|
||||
* @brief Get LEDC low speed timer clock
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param slow_clk_sel LEDC low speed timer clock source
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_slow_clk_sel(hal, slow_clk_sel) ledc_ll_get_slow_clk_sel((hal)->dev, slow_clk_sel)
|
||||
|
||||
/**
|
||||
* @brief Update LEDC low speed timer
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_ls_timer_update(hal, timer_sel) ledc_ll_ls_timer_update((hal)->dev, (hal)->speed_mode, timer_sel)
|
||||
|
||||
/**
|
||||
* @brief Reset LEDC timer
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_timer_rst(hal, timer_sel) ledc_ll_timer_rst((hal)->dev, (hal)->speed_mode, timer_sel)
|
||||
|
||||
/**
|
||||
* @brief Pause LEDC timer
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_timer_pause(hal, timer_sel) ledc_ll_timer_pause((hal)->dev, (hal)->speed_mode, timer_sel)
|
||||
|
||||
/**
|
||||
* @brief Resume LEDC timer
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_timer_resume(hal, timer_sel) ledc_ll_timer_resume((hal)->dev, (hal)->speed_mode, timer_sel)
|
||||
|
||||
/**
|
||||
* @brief Set LEDC timer clock divider
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_clock_divider(hal, timer_sel, clock_divider) ledc_ll_set_clock_divider((hal)->dev, (hal)->speed_mode, timer_sel, clock_divider)
|
||||
|
||||
/**
|
||||
* @brief Get LEDC timer clock divider
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_clock_divider(hal, timer_sel, clock_divider) ledc_ll_get_clock_divider((hal)->dev, (hal)->speed_mode, timer_sel, clock_divider)
|
||||
|
||||
/**
|
||||
* @brief Set LEDC timer clock source
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param clk_src Timer clock source
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_clock_source(hal, timer_sel, clk_src) ledc_ll_set_clock_source((hal)->dev, (hal)->speed_mode, timer_sel, clk_src)
|
||||
|
||||
/**
|
||||
* @brief Get LEDC timer clock source
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param clk_src Pointer to accept the timer clock source
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_clock_source(hal, timer_sel, clk_src) ledc_ll_get_clock_source((hal)->dev, (hal)->speed_mode, timer_sel, clk_src)
|
||||
|
||||
/**
|
||||
* @brief Set LEDC duty resolution
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param duty_resolution Resolution of duty setting in number of bits. The range of duty values is [0, (2**duty_resolution)]
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_duty_resolution(hal, timer_sel, duty_resolution) ledc_ll_set_duty_resolution((hal)->dev, (hal)->speed_mode, timer_sel, duty_resolution)
|
||||
|
||||
/**
|
||||
* @brief Get LEDC duty resolution
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param duty_resolution Pointer to accept the resolution of duty setting in number of bits.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_duty_resolution(hal, timer_sel, duty_resolution) ledc_ll_get_duty_resolution((hal)->dev, (hal)->speed_mode, timer_sel, duty_resolution)
|
||||
|
||||
/**
|
||||
* @brief Get LEDC max duty
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param max_duty Pointer to accept the max duty
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_max_duty(hal, channel_num, max_duty) ledc_ll_get_max_duty((hal)->dev, (hal)->speed_mode, channel_num, max_duty)
|
||||
|
||||
/**
|
||||
* @brief Get LEDC hpoint value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param hpoint_val Pointer to accept the LEDC hpoint value(max: 0xfffff)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_hpoint(hal, channel_num, hpoint_val) ledc_ll_get_hpoint((hal)->dev, (hal)->speed_mode, channel_num, hpoint_val)
|
||||
|
||||
/**
|
||||
* @brief Set LEDC the integer part of duty value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_val LEDC duty value, the range of duty setting is [0, (2**duty_resolution)]
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_duty_int_part(hal, channel_num, duty_val) ledc_ll_set_duty_int_part((hal)->dev, (hal)->speed_mode, channel_num, duty_val)
|
||||
|
||||
/**
|
||||
* @brief Set the output enable
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param sig_out_en The output enable status
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_sig_out_en(hal, channel_num, sig_out_en) ledc_ll_set_sig_out_en((hal)->dev, (hal)->speed_mode, channel_num, sig_out_en)
|
||||
|
||||
/**
|
||||
* @brief Set the duty start
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_start The duty start
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_duty_start(hal, channel_num, duty_start) ledc_ll_set_duty_start((hal)->dev, (hal)->speed_mode, channel_num, duty_start)
|
||||
|
||||
/**
|
||||
* @brief Set output idle level
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param idle_level The output idle level
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_idle_level(hal, channel_num, idle_level) ledc_ll_set_idle_level((hal)->dev, (hal)->speed_mode, channel_num, idle_level)
|
||||
|
||||
/**
|
||||
* @brief Set fade end interrupt enable
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param fade_end_intr_en The fade end interrupt enable status
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_set_fade_end_intr(hal, channel_num, fade_end_intr_en) ledc_ll_set_fade_end_intr((hal)->dev, (hal)->speed_mode, channel_num, fade_end_intr_en)
|
||||
|
||||
/**
|
||||
* @brief Set timer index of the specified channel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_bind_channel_timer(hal, channel_num, timer_sel) ledc_ll_bind_channel_timer((hal)->dev, (hal)->speed_mode, channel_num, timer_sel)
|
||||
|
||||
/**
|
||||
* @brief Get timer index of the specified channel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param timer_sel Pointer to accept the LEDC timer index
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define ledc_hal_get_channel_timer(hal, channel_num, timer_sel) ledc_ll_get_channel_timer((hal)->dev, (hal)->speed_mode, channel_num, timer_sel)
|
||||
|
||||
/**
|
||||
* @brief Init the LEDC hal. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param speed_mode speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mod
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_init(ledc_hal_context_t *hal, ledc_mode_t speed_mode);
|
||||
|
||||
/**
|
||||
* @brief Update channel configure when select low speed mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_ls_channel_update(ledc_hal_context_t *hal, ledc_channel_t channel_num);
|
||||
|
||||
/**
|
||||
* @brief Set LEDC hpoint value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param hpoint_val LEDC hpoint value(max: 0xfffff)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_set_hpoint(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t hpoint_val);
|
||||
|
||||
/**
|
||||
* @brief Get LEDC duty value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_val Pointer to accept the LEDC duty value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_get_duty(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t *duty_val);
|
||||
|
||||
/**
|
||||
* @brief Set LEDC duty change direction
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_direction LEDC duty change direction, increase or decrease
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_set_duty_direction(ledc_hal_context_t *hal, ledc_channel_t channel_num, ledc_duty_direction_t duty_direction);
|
||||
|
||||
/**
|
||||
* @brief Set the number of increased or decreased times
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_num The number of increased or decreased times
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_set_duty_num(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_num);
|
||||
|
||||
/**
|
||||
* @brief Set the duty cycles of increase or decrease
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_cycle The duty cycles
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_set_duty_cycle(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_cycle);
|
||||
|
||||
/**
|
||||
* @brief Set the step scale of increase or decrease
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param duty_scale The step scale
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_set_duty_scale(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_scale);
|
||||
|
||||
/**
|
||||
* @brief Get interrupt status of the specified channel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param intr_status Pointer to accept the interrupt status
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_get_fade_end_intr_status(ledc_hal_context_t *hal, uint32_t *intr_status);
|
||||
|
||||
/**
|
||||
* @brief Clear interrupt status of the specified channel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel_num LEDC channel index (0-7), select from ledc_channel_t
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_clear_fade_end_intr_status(ledc_hal_context_t *hal, ledc_channel_t channel_num);
|
||||
|
||||
/**
|
||||
* @brief Get clock config of LEDC timer
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
|
||||
* @param clk_cfg Pointer to accept clock config
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_get_clk_cfg(ledc_hal_context_t *hal, ledc_timer_t timer_sel, ledc_clk_cfg_t *clk_cfg);
|
||||
|
||||
/**
|
||||
* @brief Config low speed timer clock source with clock config
|
||||
*s
|
||||
* @param hal Context of the HAL layer
|
||||
* @param clk_cfg clock config
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void ledc_hal_set_slow_clk(ledc_hal_context_t *hal, ledc_clk_cfg_t clk_cfg);
|
||||
153
tools/sdk/esp32/include/soc/include/hal/ledc_types.h
Normal file
153
tools/sdk/esp32/include/soc/include/hal/ledc_types.h
Normal file
@@ -0,0 +1,153 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/ledc_caps.h"
|
||||
|
||||
typedef enum {
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */
|
||||
#endif
|
||||
LEDC_LOW_SPEED_MODE, /*!< LEDC low speed speed_mode */
|
||||
LEDC_SPEED_MODE_MAX, /*!< LEDC speed limit */
|
||||
} ledc_mode_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_INTR_DISABLE = 0, /*!< Disable LEDC interrupt */
|
||||
LEDC_INTR_FADE_END, /*!< Enable LEDC interrupt */
|
||||
LEDC_INTR_MAX,
|
||||
} ledc_intr_type_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_DUTY_DIR_DECREASE = 0, /*!< LEDC duty decrease direction */
|
||||
LEDC_DUTY_DIR_INCREASE = 1, /*!< LEDC duty increase direction */
|
||||
LEDC_DUTY_DIR_MAX,
|
||||
} ledc_duty_direction_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_SLOW_CLK_RTC8M = 0, /*!< LEDC low speed timer clock source is 8MHz RTC clock*/
|
||||
LEDC_SLOW_CLK_APB, /*!< LEDC low speed timer clock source is 80MHz APB clock*/
|
||||
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
|
||||
LEDC_SLOW_CLK_XTAL, /*!< LEDC low speed timer clock source XTAL clock*/
|
||||
#endif
|
||||
} ledc_slow_clk_sel_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_AUTO_CLK = 0, /*!< The driver will automatically select the source clock(REF_TICK or APB) based on the giving resolution and duty parameter when init the timer*/
|
||||
LEDC_USE_REF_TICK, /*!< LEDC timer select REF_TICK clock as source clock*/
|
||||
LEDC_USE_APB_CLK, /*!< LEDC timer select APB clock as source clock*/
|
||||
LEDC_USE_RTC8M_CLK, /*!< LEDC timer select RTC8M_CLK as source clock. Only for low speed channels and this parameter must be the same for all low speed channels*/
|
||||
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
|
||||
LEDC_USE_XTAL_CLK, /*!< LEDC timer select XTAL clock as source clock*/
|
||||
#endif
|
||||
} ledc_clk_cfg_t;
|
||||
|
||||
/* Note: Setting numeric values to match ledc_clk_cfg_t values are a hack to avoid collision with
|
||||
LEDC_AUTO_CLK in the driver, as these enums have very similar names and user may pass
|
||||
one of these by mistake. */
|
||||
typedef enum {
|
||||
LEDC_REF_TICK = LEDC_USE_REF_TICK, /*!< LEDC timer clock divided from reference tick (1Mhz) */
|
||||
LEDC_APB_CLK = LEDC_USE_APB_CLK, /*!< LEDC timer clock divided from APB clock (80Mhz) */
|
||||
} ledc_clk_src_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_0 = 0, /*!< LEDC timer 0 */
|
||||
LEDC_TIMER_1, /*!< LEDC timer 1 */
|
||||
LEDC_TIMER_2, /*!< LEDC timer 2 */
|
||||
LEDC_TIMER_3, /*!< LEDC timer 3 */
|
||||
LEDC_TIMER_MAX,
|
||||
} ledc_timer_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_CHANNEL_0 = 0, /*!< LEDC channel 0 */
|
||||
LEDC_CHANNEL_1, /*!< LEDC channel 1 */
|
||||
LEDC_CHANNEL_2, /*!< LEDC channel 2 */
|
||||
LEDC_CHANNEL_3, /*!< LEDC channel 3 */
|
||||
LEDC_CHANNEL_4, /*!< LEDC channel 4 */
|
||||
LEDC_CHANNEL_5, /*!< LEDC channel 5 */
|
||||
LEDC_CHANNEL_6, /*!< LEDC channel 6 */
|
||||
LEDC_CHANNEL_7, /*!< LEDC channel 7 */
|
||||
LEDC_CHANNEL_MAX,
|
||||
} ledc_channel_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_1_BIT = 1, /*!< LEDC PWM duty resolution of 1 bits */
|
||||
LEDC_TIMER_2_BIT, /*!< LEDC PWM duty resolution of 2 bits */
|
||||
LEDC_TIMER_3_BIT, /*!< LEDC PWM duty resolution of 3 bits */
|
||||
LEDC_TIMER_4_BIT, /*!< LEDC PWM duty resolution of 4 bits */
|
||||
LEDC_TIMER_5_BIT, /*!< LEDC PWM duty resolution of 5 bits */
|
||||
LEDC_TIMER_6_BIT, /*!< LEDC PWM duty resolution of 6 bits */
|
||||
LEDC_TIMER_7_BIT, /*!< LEDC PWM duty resolution of 7 bits */
|
||||
LEDC_TIMER_8_BIT, /*!< LEDC PWM duty resolution of 8 bits */
|
||||
LEDC_TIMER_9_BIT, /*!< LEDC PWM duty resolution of 9 bits */
|
||||
LEDC_TIMER_10_BIT, /*!< LEDC PWM duty resolution of 10 bits */
|
||||
LEDC_TIMER_11_BIT, /*!< LEDC PWM duty resolution of 11 bits */
|
||||
LEDC_TIMER_12_BIT, /*!< LEDC PWM duty resolution of 12 bits */
|
||||
LEDC_TIMER_13_BIT, /*!< LEDC PWM duty resolution of 13 bits */
|
||||
LEDC_TIMER_14_BIT, /*!< LEDC PWM duty resolution of 14 bits */
|
||||
LEDC_TIMER_15_BIT, /*!< LEDC PWM duty resolution of 15 bits */
|
||||
LEDC_TIMER_16_BIT, /*!< LEDC PWM duty resolution of 16 bits */
|
||||
LEDC_TIMER_17_BIT, /*!< LEDC PWM duty resolution of 17 bits */
|
||||
LEDC_TIMER_18_BIT, /*!< LEDC PWM duty resolution of 18 bits */
|
||||
LEDC_TIMER_19_BIT, /*!< LEDC PWM duty resolution of 19 bits */
|
||||
LEDC_TIMER_20_BIT, /*!< LEDC PWM duty resolution of 20 bits */
|
||||
LEDC_TIMER_BIT_MAX,
|
||||
} ledc_timer_bit_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_FADE_NO_WAIT = 0, /*!< LEDC fade function will return immediately */
|
||||
LEDC_FADE_WAIT_DONE, /*!< LEDC fade function will block until fading to the target duty */
|
||||
LEDC_FADE_MAX,
|
||||
} ledc_fade_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration parameters of LEDC channel for ledc_channel_config function
|
||||
*/
|
||||
typedef struct {
|
||||
int gpio_num; /*!< the LEDC output gpio_num, if you want to use gpio16, gpio_num = 16 */
|
||||
ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode */
|
||||
ledc_channel_t channel; /*!< LEDC channel (0 - 7) */
|
||||
ledc_intr_type_t intr_type; /*!< configure interrupt, Fade interrupt enable or Fade interrupt disable */
|
||||
ledc_timer_t timer_sel; /*!< Select the timer source of channel (0 - 3) */
|
||||
uint32_t duty; /*!< LEDC channel duty, the range of duty setting is [0, (2**duty_resolution)] */
|
||||
int hpoint; /*!< LEDC channel hpoint value, the max value is 0xfffff */
|
||||
} ledc_channel_config_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration parameters of LEDC Timer timer for ledc_timer_config function
|
||||
*/
|
||||
typedef struct {
|
||||
ledc_mode_t speed_mode; /*!< LEDC speed speed_mode, high-speed mode or low-speed mode */
|
||||
union {
|
||||
ledc_timer_bit_t duty_resolution; /*!< LEDC channel duty resolution */
|
||||
ledc_timer_bit_t bit_num __attribute__((deprecated)); /*!< Deprecated in ESP-IDF 3.0. This is an alias to 'duty_resolution' for backward compatibility with ESP-IDF 2.1 */
|
||||
};
|
||||
ledc_timer_t timer_num; /*!< The timer source of channel (0 - 3) */
|
||||
uint32_t freq_hz; /*!< LEDC timer frequency (Hz) */
|
||||
ledc_clk_cfg_t clk_cfg; /*!< Configure LEDC source clock.
|
||||
For low speed channels and high speed channels, you can specify the source clock using LEDC_USE_REF_TICK, LEDC_USE_APB_CLK or LEDC_AUTO_CLK.
|
||||
For low speed channels, you can also specify the source clock using LEDC_USE_RTC8M_CLK, in this case, all low speed channel's source clock must be RTC8M_CLK*/
|
||||
} ledc_timer_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
328
tools/sdk/esp32/include/soc/include/hal/mcpwm_hal.h
Normal file
328
tools/sdk/esp32/include/soc/include/hal/mcpwm_hal.h
Normal file
@@ -0,0 +1,328 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for MCPWM (common part)
|
||||
|
||||
/*
|
||||
* MCPWM HAL usages:
|
||||
*
|
||||
* Initialization:
|
||||
* 1. Fill the parameters in `mcpwm_hal_context_t`.
|
||||
* 2. Call `mcpwm_hal_init` to initialize the context.
|
||||
* 3. Call `mcpwm_hal_hw_init` to initialize the hardware.
|
||||
*
|
||||
* Basic PWM:
|
||||
* 1. Update parameters for the timers, comparators and generators.
|
||||
* 2. Call `mcpwm_hal_timer_update_basic` to update the timer used.
|
||||
* 3. Call `mcpwm_hal_operator_update_basic` to update all the parameters of a operator.
|
||||
*
|
||||
* Alternatively, if only the comparator is updated (duty rate), call
|
||||
* `mcpwm_hal_operator_update_comparator` to update the comparator parameters; if only the
|
||||
* generator is updated (output style), call `mcpwm_hal_operator_update_generator` to update the
|
||||
* generator parameters.
|
||||
*
|
||||
* 4. At any time, call `mcpwm_hal_timer_start` to start the timer (so that PWM output will toggle
|
||||
* according to settings), or call `mcpwm_hal_timer_stop` to stop the timer (so that the PWM output
|
||||
* will be kept as called).
|
||||
*
|
||||
* Timer settings:
|
||||
* - Sync: Call `mcpwm_hal_timer_enable_sync` to enable the sync for the timer, and call
|
||||
* `mcpwm_hal_timer_disable_sync` to disable it.
|
||||
*
|
||||
* Operator settings:
|
||||
* - Carrier: Call `mcpwm_hal_operator_enable_carrier` to enable carrier for an operator, and call
|
||||
* `mcpwm_hal_operator_disable_carrier` to disable it.
|
||||
*
|
||||
* - Deadzone: Call `mcpwm_hal_operator_update_deadzone` to update settings of deadzone for an operator.
|
||||
*
|
||||
* Fault handling settings:
|
||||
* 1. Call `mcpwm_hal_fault_init` to initialize an fault signal to be detected.
|
||||
* 2. Call `mcpwm_hal_operator_update_fault` to update the behavior of an operator when fault is
|
||||
* detected.
|
||||
* 3. If the operator selects oneshot mode to handle the fault event, call
|
||||
* `mcpwm_hal_fault_oneshot_clear` to clear that fault event after the fault is handled properly.
|
||||
* 4. Call `mcpwm_hal_fault_disable` to deinitialize the fault signal when it's no longer used.
|
||||
*
|
||||
* Capture:
|
||||
* 1. Call `mcpwm_hal_capture_enable` to enable the capture for one capture signal.
|
||||
* 2. Call `mcpwm_hal_capture_get_result` to get the last captured result.
|
||||
* 3. Call `mcpwm_hal_capture_disable` to disable the capture for a signal.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <esp_err.h>
|
||||
#include "hal/mcpwm_ll.h"
|
||||
|
||||
#define MCPWM_BASE_CLK (2 * APB_CLK_FREQ) //2*APB_CLK_FREQ 160Mhz
|
||||
|
||||
/// Configuration of HAL that used only once.
|
||||
typedef struct {
|
||||
int host_id; ///< Which MCPWM peripheral to use, 0-1.
|
||||
} mcpwm_hal_init_config_t;
|
||||
|
||||
/// Configuration of each generator (output of operator)
|
||||
typedef struct {
|
||||
mcpwm_duty_type_t duty_type; ///< How the generator output
|
||||
int comparator; ///< for mode `MCPWM_DUTY_MODE_*`, which comparator it refers to.
|
||||
} mcpwm_hal_generator_config_t;
|
||||
|
||||
/// Configuration of each operator
|
||||
typedef struct {
|
||||
mcpwm_hal_generator_config_t gen[SOC_MCPWM_GENERATOR_NUM]; ///< Configuration of the generators
|
||||
float duty[SOC_MCPWM_COMPARATOR_NUM]; ///< Duty rate for each comparator, 10 means 10%.
|
||||
int timer; ///< The timer this operator is using
|
||||
} mcpwm_hal_operator_config_t;
|
||||
|
||||
/// Configuration of each timer
|
||||
typedef struct {
|
||||
uint32_t timer_prescale; ///< The prescale from the MCPWM main clock to the timer clock, TIMER_FREQ=(MCPWM_FREQ/(timer_prescale+1))
|
||||
uint32_t freq; ///< Frequency desired, will be updated to actual value after the `mcpwm_hal_timer_update_freq` is called.
|
||||
mcpwm_counter_type_t count_mode; ///< Counting mode
|
||||
} mcpwm_hal_timer_config_t;
|
||||
|
||||
typedef struct {
|
||||
mcpwm_dev_t *dev; ///< Beginning address of the MCPWM peripheral registers. Call `mcpwm_hal_init` to initialize it.
|
||||
uint32_t prescale; ///< Prescale from the 160M clock to MCPWM main clock.
|
||||
mcpwm_hal_timer_config_t timer[SOC_MCPWM_TIMER_NUM]; ///< Configuration of the timers
|
||||
mcpwm_hal_operator_config_t op[SOC_MCPWM_OP_NUM]; ///< Configuration of the operators
|
||||
} mcpwm_hal_context_t;
|
||||
|
||||
/// Configuration of the carrier
|
||||
typedef struct {
|
||||
bool inverted; ///< Whether to invert the output
|
||||
uint8_t duty; ///< Duty of the carrier, 0-7. Duty rate = duty/8.
|
||||
uint8_t oneshot_pulse_width; ///< oneshot pulse width, in carrier periods. 0 to disable. 0-15.
|
||||
uint32_t period; ///< Prescale from the MCPWM main clock to the carrier clock. CARRIER_FREQ=(MCPWM_FREQ/(period+1)/8.)
|
||||
} mcpwm_hal_carrier_conf_t;
|
||||
|
||||
/// Configuration of the deadzone
|
||||
typedef struct {
|
||||
mcpwm_deadtime_type_t mode; ///< Deadzone mode, `MCPWM_DEADTIME_BYPASS` to disable.
|
||||
uint32_t fed; ///< Delay on falling edge. By MCPWM main clock.
|
||||
uint32_t red; ///< Delay on rising edge. By MCPWM main clock.
|
||||
} mcpwm_hal_deadzone_conf_t;
|
||||
|
||||
/// Configuration of the fault handling for each operator
|
||||
typedef struct {
|
||||
uint32_t cbc_enabled_mask; ///< Whether the cycle-by-cycle fault handling is enabled on each fault signal. BIT(n) stands for signal n.
|
||||
uint32_t ost_enabled_mask; ///< Whether the oneshot fault handling is enabled on each on each fault signal. BIT(n) stands for signal n.
|
||||
mcpwm_output_action_t action_on_fault[SOC_MCPWM_GENERATOR_NUM]; ///< Action to perform on each generator when any one of the fault signal triggers.
|
||||
} mcpwm_hal_fault_conf_t;
|
||||
|
||||
/// Configuration of the synchronization of each clock
|
||||
typedef struct {
|
||||
mcpwm_sync_signal_t sync_sig; ///< Sync signal to use
|
||||
uint32_t reload_permillage; ///< Reload permillage when the sync is triggered. 100 means the timer will be reload to (period * 100)/1000=10% period value.
|
||||
} mcpwm_hal_sync_config_t;
|
||||
|
||||
/// Configuration of the capture feature on each capture signal
|
||||
typedef struct {
|
||||
mcpwm_capture_on_edge_t cap_edge; ///< Whether the edges is captured, bitwise.
|
||||
uint32_t prescale; ///< Prescale of the input signal.
|
||||
} mcpwm_hal_capture_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the internal state of the HAL. Call after settings are set and before other functions are called.
|
||||
*
|
||||
* @note Since There are several individual parts (timers + operators, captures), this funciton is
|
||||
* allowed to called several times.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param init_config Configuration for the HAL to be used only once.
|
||||
*/
|
||||
void mcpwm_hal_init(mcpwm_hal_context_t *hal, const mcpwm_hal_init_config_t *init_config);
|
||||
|
||||
/**
|
||||
* @brief Initialize the hardware, call after `mcpwm_hal_init` and before other functions.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void mcpwm_hal_hw_init(mcpwm_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Start a timer
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to start, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_start(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Stop a timer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to stop, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_stop(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Update the basic parameters of a timer.
|
||||
*
|
||||
* @note This will influence the duty rate and count mode of each operator relies on this timer.
|
||||
* Call `mcpwm_hal_operator_update_basic` for each of the operator that relies on this timer after
|
||||
* to update the duty rate and generator output.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to update, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_update_basic(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Start the synchronization for a timer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to enable, 0-2.
|
||||
* @param sync_conf Configuration of the sync operation.
|
||||
*/
|
||||
void mcpwm_hal_timer_enable_sync(mcpwm_hal_context_t *hal, int timer, const mcpwm_hal_sync_config_t *sync_conf);
|
||||
|
||||
/**
|
||||
* @brief Stop the synchronization for a timer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to disable sync, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_disable_sync(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Update the basic settings (duty, output mode) for an operator.
|
||||
*
|
||||
* Will call `mcpwm_hal_operator_update_comparator` and `mcpwm_hal_operator_update_generator`
|
||||
* recursively to update each of their duty and output mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_basic(mcpwm_hal_context_t *hal, int op);
|
||||
|
||||
/**
|
||||
* @brief Update a comparator (duty) for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update, 0-2.
|
||||
* @param cmp Comparator to update, 0-1.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_comparator(mcpwm_hal_context_t *hal, int op, int cmp);
|
||||
|
||||
/**
|
||||
* @brief Update a generator (output mode) for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update, 0-2.
|
||||
* @param cmp Comparator to update, 0-1.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_generator(mcpwm_hal_context_t *hal, int op, int gen_num);
|
||||
|
||||
/**
|
||||
* @brief Enable the carrier for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to enable carrier, 0-2.
|
||||
* @param carrier_conf Configuration of the carrier.
|
||||
*/
|
||||
void mcpwm_hal_operator_enable_carrier(mcpwm_hal_context_t *hal, int op, const mcpwm_hal_carrier_conf_t *carrier_conf);
|
||||
|
||||
/**
|
||||
* @brief Disable the carrier for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to disable carrier, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_operator_disable_carrier(mcpwm_hal_context_t *hal, int op);
|
||||
|
||||
/**
|
||||
* @brief Update the deadzone for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update the deadzone, 0-2.
|
||||
* @param deadzone Configuration of the deadzone. Set member `mode` to `MCPWM_DEADTIME_BYPASS` will bypass the deadzone.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_deadzone(mcpwm_hal_context_t *hal, int op, const mcpwm_hal_deadzone_conf_t *deadzone);
|
||||
|
||||
/**
|
||||
* @brief Enable one of the fault signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param fault_sig The signal to enable, 0-2.
|
||||
* @param level The active level for the fault signal, true for high and false for low.
|
||||
*/
|
||||
void mcpwm_hal_fault_init(mcpwm_hal_context_t *hal, int fault_sig, bool level);
|
||||
|
||||
/**
|
||||
* @brief Configure how the operator behave to the fault signals.
|
||||
*
|
||||
* Call after the fault signal is enabled by `mcpwm_hal_fault_init`.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to configure, 0-2.
|
||||
* @param fault_conf Configuration of the behavior of the operator when fault. Clear member `cbc_enabled_mask` and `ost_enabled_mask` will disable the fault detection of this operator.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_fault(mcpwm_hal_context_t *hal, int op, const mcpwm_hal_fault_conf_t *fault_conf);
|
||||
|
||||
/**
|
||||
* @brief Clear the oneshot fault status for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op The operator to clear oneshot fault status, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_fault_oneshot_clear(mcpwm_hal_context_t *hal, int op);
|
||||
|
||||
/**
|
||||
* @brief Disable one of the fault signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param fault_sig The fault signal to disable, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_fault_disable(mcpwm_hal_context_t *hal, int fault_sig);
|
||||
|
||||
/**
|
||||
* @brief Enable one of the capture signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param cap_sig Capture signal to enable, 0-2.
|
||||
* @param conf Configuration on how to capture the signal.
|
||||
*/
|
||||
void mcpwm_hal_capture_enable(mcpwm_hal_context_t *hal, int cap_sig, const mcpwm_hal_capture_config_t *conf);
|
||||
|
||||
/**
|
||||
* @brief Get the capture result.
|
||||
*
|
||||
* @note The output value will always be updated with the register value, no matter event triggered or not.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param cap_sig Signal to get capture result, 0-2.
|
||||
* @param out_count Output of the captured counter.
|
||||
* @param out_edge Output of the captured edge.
|
||||
* @return
|
||||
* - ESP_OK: if a signal is captured
|
||||
* - ESP_ERR_NOT_FOUND: if no capture event happened.
|
||||
*/
|
||||
esp_err_t mcpwm_hal_capture_get_result(mcpwm_hal_context_t *hal, int cap_sig, uint32_t *out_count,
|
||||
mcpwm_capture_on_edge_t *out_edge);
|
||||
|
||||
/**
|
||||
* @brief Disable one of the capture signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param cap_sig The signal to capture, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_capture_disable(mcpwm_hal_context_t *hal, int cap_sig);
|
||||
86
tools/sdk/esp32/include/soc/include/hal/mcpwm_types.h
Normal file
86
tools/sdk/esp32/include/soc/include/hal/mcpwm_types.h
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Interrupts for MCPWM
|
||||
typedef enum {
|
||||
MCPWM_LL_INTR_CAP0 = BIT(27), ///< Capture 0 happened
|
||||
MCPWM_LL_INTR_CAP1 = BIT(28), ///< Capture 1 happened
|
||||
MCPWM_LL_INTR_CAP2 = BIT(29), ///< Capture 2 happened
|
||||
} mcpwm_intr_t;
|
||||
|
||||
/**
|
||||
* @brief Select type of MCPWM counter
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_UP_COUNTER = 1, /*!<For asymmetric MCPWM*/
|
||||
MCPWM_DOWN_COUNTER, /*!<For asymmetric MCPWM*/
|
||||
MCPWM_UP_DOWN_COUNTER, /*!<For symmetric MCPWM, frequency is half of MCPWM frequency set*/
|
||||
MCPWM_COUNTER_MAX, /*!<Maximum counter mode*/
|
||||
} mcpwm_counter_type_t;
|
||||
|
||||
/**
|
||||
* @brief Select type of MCPWM duty cycle mode
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_DUTY_MODE_0 = 0, /*!<Active high duty, i.e. duty cycle proportional to high time for asymmetric MCPWM*/
|
||||
MCPWM_DUTY_MODE_1, /*!<Active low duty, i.e. duty cycle proportional to low time for asymmetric MCPWM, out of phase(inverted) MCPWM*/
|
||||
MCPWM_HAL_GENERATOR_MODE_FORCE_LOW,
|
||||
MCPWM_HAL_GENERATOR_MODE_FORCE_HIGH,
|
||||
MCPWM_DUTY_MODE_MAX, /*!<Num of duty cycle modes*/
|
||||
} mcpwm_duty_type_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select action to be taken on the output when event happens
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_ACTION_NO_CHANGE = 0, /*!<No change in the output*/
|
||||
MCPWM_ACTION_FORCE_LOW, /*!<Make output low*/
|
||||
MCPWM_ACTION_FORCE_HIGH, /*!<Make output high*/
|
||||
MCPWM_ACTION_TOGGLE, /*!<Make output toggle*/
|
||||
} mcpwm_output_action_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM deadtime types, used to generate deadtime, RED refers to rising edge delay and FED refers to falling edge delay
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_DEADTIME_BYPASS = 0, /*!<Bypass the deadtime*/
|
||||
MCPWM_BYPASS_RED, /*!<MCPWMXA = no change, MCPWMXB = falling edge delay*/
|
||||
MCPWM_BYPASS_FED, /*!<MCPWMXA = rising edge delay, MCPWMXB = no change*/
|
||||
MCPWM_ACTIVE_HIGH_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = falling edge delay*/
|
||||
MCPWM_ACTIVE_LOW_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = compliment of falling edge delay*/
|
||||
MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = compliment of falling edge delay*/
|
||||
MCPWM_ACTIVE_LOW_COMPLIMENT_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = falling edge delay*/
|
||||
MCPWM_ACTIVE_RED_FED_FROM_PWMXA, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXA*/
|
||||
MCPWM_ACTIVE_RED_FED_FROM_PWMXB, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXB*/
|
||||
MCPWM_DEADTIME_TYPE_MAX,
|
||||
} mcpwm_deadtime_type_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select sync signal input
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_SELECT_SYNC0 = 4, /*!<Select SYNC0 as input*/
|
||||
MCPWM_SELECT_SYNC1, /*!<Select SYNC1 as input*/
|
||||
MCPWM_SELECT_SYNC2, /*!<Select SYNC2 as input*/
|
||||
} mcpwm_sync_signal_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select capture starts from which edge
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_NEG_EDGE = BIT(0), /*!<Capture the negative edge*/
|
||||
MCPWM_POS_EDGE = BIT(1), /*!<Capture the positive edge*/
|
||||
} mcpwm_capture_on_edge_t;
|
||||
36
tools/sdk/esp32/include/soc/include/hal/mpu_hal.h
Normal file
36
tools/sdk/esp32/include/soc/include/hal/mpu_hal.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "hal/mpu_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Specify the type of access allowed on a memory region.
|
||||
*
|
||||
* @param id index to the region table; on targets not SOC_MPU_CONFIGURABLE_REGIONS_SUPPORTED,
|
||||
* the region divisions is predefined in hardware which is likely reflected in LL implementation.
|
||||
* @param access type of access allowed
|
||||
*/
|
||||
void mpu_hal_set_region_access(int id, mpu_access_t access);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
33
tools/sdk/esp32/include/soc/include/hal/mpu_types.h
Normal file
33
tools/sdk/esp32/include/soc/include/hal/mpu_types.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if SOC_MPU_CONFIGURABLE_REGIONS_SUPPORTED
|
||||
typedef void** mpu_region_table_t;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
MPU_REGION_ILLEGAL,
|
||||
#if SOC_MPU_REGION_RO_SUPPORTED
|
||||
MPU_REGION_RO, // read-only
|
||||
#endif
|
||||
#if SOC_MPU_REGION_WO_SUPPORTED
|
||||
MPU_REGION_WO, // write-only
|
||||
#endif
|
||||
MPU_REGION_RW, // read-write
|
||||
MPU_REGION_X, // executable
|
||||
MPU_REGION_RWX // read-write-executable
|
||||
} mpu_access_t;
|
||||
214
tools/sdk/esp32/include/soc/include/hal/pcnt_hal.h
Normal file
214
tools/sdk/esp32/include/soc/include/hal/pcnt_hal.h
Normal file
@@ -0,0 +1,214 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for PCNT.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_types.h"
|
||||
#include "hal/pcnt_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
pcnt_dev_t *dev;
|
||||
} pcnt_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Set PCNT counter mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param channel PCNT channel number
|
||||
* @param pos_mode Counter mode when detecting positive edge
|
||||
* @param neg_mode Counter mode when detecting negative edge
|
||||
* @param hctrl_mode Counter mode when control signal is high level
|
||||
* @param lctrl_mode Counter mode when control signal is low level
|
||||
*/
|
||||
#define pcnt_hal_set_mode(hal, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) pcnt_ll_set_mode((hal)->dev, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode)
|
||||
|
||||
/**
|
||||
* @brief Get pulse counter value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit Pulse Counter unit number
|
||||
* @param count Pointer to accept counter value
|
||||
*/
|
||||
#define pcnt_hal_get_counter_value(hal, unit, count) pcnt_ll_get_counter_value((hal)->dev, unit, count)
|
||||
|
||||
/**
|
||||
* @brief Pause PCNT counter of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_counter_pause(hal, unit) pcnt_ll_counter_pause((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Resume counting for PCNT counter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number, select from unit_t
|
||||
*/
|
||||
#define pcnt_hal_counter_resume(hal, unit) pcnt_ll_counter_resume((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Clear and reset PCNT counter value to zero
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number, select from unit_t
|
||||
*/
|
||||
#define pcnt_hal_counter_clear(hal, unit) pcnt_ll_counter_clear((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT interrupt for PCNT unit
|
||||
* @note
|
||||
* Each Pulse counter unit has five watch point events that share the same interrupt.
|
||||
* Configure events with pcnt_event_enable() and pcnt_event_disable()
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_intr_enable(hal, unit) pcnt_ll_intr_enable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT interrupt for PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_intr_disable(hal, unit) pcnt_ll_intr_disable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt status mask to be cleared. Pointer to accept value interrupt status mask.
|
||||
*/
|
||||
#define pcnt_hal_get_intr_status(hal, mask) pcnt_ll_get_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Clear PCNT interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt status mask to be cleared.
|
||||
*/
|
||||
#define pcnt_hal_clear_intr_status(hal, mask) pcnt_ll_clear_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT event of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*/
|
||||
#define pcnt_hal_event_enable(hal, unit, evt_type) pcnt_ll_event_enable((hal)->dev, unit, evt_type)
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT event of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*/
|
||||
#define pcnt_hal_event_disable(hal, unit, evt_type) pcnt_ll_event_disable((hal)->dev, unit, evt_type)
|
||||
|
||||
/**
|
||||
* @brief Set PCNT event value of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*
|
||||
* @param value Counter value for PCNT event
|
||||
*/
|
||||
#define pcnt_hal_set_event_value(hal, unit, evt_type, value) pcnt_ll_set_event_value((hal)->dev, unit, evt_type, value)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT event value of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
* @param value Pointer to accept counter value for PCNT event
|
||||
*/
|
||||
#define pcnt_hal_get_event_value(hal, unit, evt_type, value) pcnt_ll_get_event_value((hal)->dev, unit, evt_type, value)
|
||||
|
||||
/**
|
||||
* @brief Set PCNT filter value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param filter_val PCNT signal filter value, counter in APB_CLK cycles.
|
||||
* Any pulses lasting shorter than this will be ignored when the filter is enabled.
|
||||
* @note
|
||||
* filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023.
|
||||
*/
|
||||
#define pcnt_hal_set_filter_value(hal, unit, filter_val) pcnt_ll_set_filter_value((hal)->dev, unit, filter_val)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT filter value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param filter_val Pointer to accept PCNT filter value.
|
||||
*/
|
||||
#define pcnt_hal_get_filter_value(hal, unit, filter_val) pcnt_ll_get_filter_value((hal)->dev, unit, filter_val)
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT input filter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_filter_enable(hal, unit) pcnt_ll_filter_enable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT input filter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_filter_disable(hal, unit) pcnt_ll_filter_disable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Init the PCNT hal and set the PCNT to the default configuration. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param pcnt_num The uart port number, the max port number is (PCNT_NUM_MAX -1)
|
||||
*/
|
||||
void pcnt_hal_init(pcnt_hal_context_t *hal, int pcnt_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
109
tools/sdk/esp32/include/soc/include/hal/pcnt_types.h
Normal file
109
tools/sdk/esp32/include/soc/include/hal/pcnt_types.h
Normal file
@@ -0,0 +1,109 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PCNT_PIN_NOT_USED (-1) /*!< When selected for a pin, this pin will not be used */
|
||||
|
||||
/**
|
||||
* @brief PCNT port number, the max port number is (PCNT_PORT_MAX - 1).
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_PORT_0 = 0, /*!< PCNT port 0 */
|
||||
PCNT_PORT_MAX, /*!< PCNT port max */
|
||||
} pcnt_port_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of all available PCNT units
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_UNIT_0 = 0, /*!< PCNT unit 0 */
|
||||
PCNT_UNIT_1 = 1, /*!< PCNT unit 1 */
|
||||
PCNT_UNIT_2 = 2, /*!< PCNT unit 2 */
|
||||
PCNT_UNIT_3 = 3, /*!< PCNT unit 3 */
|
||||
#if SOC_PCNT_UNIT_NUM > 4
|
||||
PCNT_UNIT_4 = 4, /*!< PCNT unit 4 */
|
||||
PCNT_UNIT_5 = 5, /*!< PCNT unit 5 */
|
||||
PCNT_UNIT_6 = 6, /*!< PCNT unit 6 */
|
||||
PCNT_UNIT_7 = 7, /*!< PCNT unit 7 */
|
||||
#endif
|
||||
PCNT_UNIT_MAX,
|
||||
} pcnt_unit_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO
|
||||
* @note Configuration covers two actions, one for high, and one for low level on the control input
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_MODE_KEEP = 0, /*!< Control mode: won't change counter mode*/
|
||||
PCNT_MODE_REVERSE = 1, /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */
|
||||
PCNT_MODE_DISABLE = 2, /*!< Control mode: Inhibit counter(counter value will not change in this condition) */
|
||||
PCNT_MODE_MAX
|
||||
} pcnt_ctrl_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO
|
||||
* @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_COUNT_DIS = 0, /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */
|
||||
PCNT_COUNT_INC = 1, /*!< Counter mode: Increase counter value */
|
||||
PCNT_COUNT_DEC = 2, /*!< Counter mode: Decrease counter value */
|
||||
PCNT_COUNT_MAX
|
||||
} pcnt_count_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of channels available for a single PCNT unit
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_CHANNEL_0 = 0x00, /*!< PCNT channel 0 */
|
||||
PCNT_CHANNEL_1 = 0x01, /*!< PCNT channel 1 */
|
||||
PCNT_CHANNEL_MAX,
|
||||
} pcnt_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of counter's events the may trigger an interrupt
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_EVT_THRES_1 = BIT(2), /*!< PCNT watch point event: threshold1 value event */
|
||||
PCNT_EVT_THRES_0 = BIT(3), /*!< PCNT watch point event: threshold0 value event */
|
||||
PCNT_EVT_L_LIM = BIT(4), /*!< PCNT watch point event: Minimum counter value */
|
||||
PCNT_EVT_H_LIM = BIT(5), /*!< PCNT watch point event: Maximum counter value */
|
||||
PCNT_EVT_ZERO = BIT(6), /*!< PCNT watch point event: counter value zero event */
|
||||
PCNT_EVT_MAX
|
||||
} pcnt_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Pulse Counter configuration for a single channel
|
||||
*/
|
||||
typedef struct {
|
||||
int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */
|
||||
int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */
|
||||
pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */
|
||||
pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */
|
||||
pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */
|
||||
pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */
|
||||
int16_t counter_h_lim; /*!< Maximum counter value */
|
||||
int16_t counter_l_lim; /*!< Minimum counter value */
|
||||
pcnt_unit_t unit; /*!< PCNT unit number */
|
||||
pcnt_channel_t channel; /*!< the PCNT channel */
|
||||
} pcnt_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
142
tools/sdk/esp32/include/soc/include/hal/rmt_hal.h
Normal file
142
tools/sdk/esp32/include/soc/include/hal/rmt_hal.h
Normal file
@@ -0,0 +1,142 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "soc/rmt_struct.h"
|
||||
#include "soc/rmt_caps.h"
|
||||
|
||||
/**
|
||||
* @brief HAL context type of RMT driver
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
rmt_dev_t *regs; /*!< RMT Register base address */
|
||||
rmt_mem_t *mem; /*!< RMT Memory base address */
|
||||
} rmt_hal_context_t;
|
||||
|
||||
#define RMT_MEM_OWNER_SW (0) /*!< RMT Memory ownership belongs to software side */
|
||||
#define RMT_MEM_OWNER_HW (1) /*!< RMT Memory ownership belongs to hardware side */
|
||||
|
||||
/**
|
||||
* @brief Initialize the RMT HAL driver
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
*/
|
||||
void rmt_hal_channel_reset(rmt_hal_context_t *hal, uint32_t channel);
|
||||
|
||||
/**
|
||||
* @brief Set counter clock for RMT channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param base_clk_hz: base clock for RMT internal channel (counter clock will divide from it)
|
||||
* @param counter_clk_hz: target counter clock
|
||||
*/
|
||||
void rmt_hal_set_counter_clock(rmt_hal_context_t *hal, uint32_t channel, uint32_t base_clk_hz, uint32_t counter_clk_hz);
|
||||
|
||||
/**
|
||||
* @brief Get counter clock for RMT channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param base_clk_hz: base clock for RMT internal channel (counter clock will divide from it)
|
||||
* @return counter clock in Hz
|
||||
*/
|
||||
uint32_t rmt_hal_get_counter_clock(rmt_hal_context_t *hal, uint32_t channel, uint32_t base_clk_hz);
|
||||
|
||||
/**
|
||||
* @brief Set carrier clock for RMT channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param base_clk_hz: base clock for RMT carrier generation (carrier clock will divide from it)
|
||||
* @param carrier_clk_hz: target carrier clock
|
||||
* @param carrier_clk_duty: duty ratio of carrier clock
|
||||
*/
|
||||
void rmt_hal_set_carrier_clock(rmt_hal_context_t *hal, uint32_t channel, uint32_t base_clk_hz, uint32_t carrier_clk_hz, float carrier_clk_duty);
|
||||
|
||||
/**
|
||||
* @brief Get carrier clock for RMT channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param base_clk_hz: base clock for RMT carrier generation
|
||||
* @param carrier_clk_hz: target carrier clock
|
||||
* @param carrier_clk_duty: duty ratio of carrier clock
|
||||
*/
|
||||
void rmt_hal_get_carrier_clock(rmt_hal_context_t *hal, uint32_t channel, uint32_t base_clk_hz, uint32_t *carrier_clk_hz, float *carrier_clk_duty);
|
||||
|
||||
/**
|
||||
* @brief Set filter threshold for RMT Receive channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param base_clk_hz: base clock for RMT receive filter
|
||||
* @param thres_us: threshold of RMT receive filter, in us
|
||||
*/
|
||||
void rmt_hal_set_rx_filter_thres(rmt_hal_context_t *hal, uint32_t channel, uint32_t base_clk_hz, uint32_t thres_us);
|
||||
|
||||
/**
|
||||
* @brief Set idle threshold for RMT Receive channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param base_clk_hz: base clock for RMT receive channel
|
||||
* @param thres_us: IDLE threshold for RMT receive channel
|
||||
*/
|
||||
void rmt_hal_set_rx_idle_thres(rmt_hal_context_t *hal, uint32_t channel, uint32_t base_clk_hz, uint32_t thres_us);
|
||||
|
||||
/**
|
||||
* @brief Receive a frame from RMT channel
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @param channel: RMT channel number
|
||||
* @param buf: buffer to store received RMT frame
|
||||
* @return number of items that get received
|
||||
*/
|
||||
uint32_t rmt_hal_receive(rmt_hal_context_t *hal, uint32_t channel, rmt_item32_t *buf);
|
||||
|
||||
/**
|
||||
* @brief Transmit a from by RMT
|
||||
*
|
||||
* @param hal: RMT HAL context
|
||||
* @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
|
||||
*/
|
||||
void rmt_hal_transmit(rmt_hal_context_t *hal, uint32_t channel, const rmt_item32_t *src, uint32_t length, uint32_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
122
tools/sdk/esp32/include/soc/include/hal/rmt_types.h
Normal file
122
tools/sdk/esp32/include/soc/include/hal/rmt_types.h
Normal file
@@ -0,0 +1,122 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "soc/rmt_caps.h"
|
||||
|
||||
/**
|
||||
* @brief RMT channel ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_CHANNEL_0, /*!< RMT channel number 0 */
|
||||
RMT_CHANNEL_1, /*!< RMT channel number 1 */
|
||||
RMT_CHANNEL_2, /*!< RMT channel number 2 */
|
||||
RMT_CHANNEL_3, /*!< RMT channel number 3 */
|
||||
#if SOC_RMT_CHANNELS_NUM > 4
|
||||
RMT_CHANNEL_4, /*!< RMT channel number 4 */
|
||||
RMT_CHANNEL_5, /*!< RMT channel number 5 */
|
||||
RMT_CHANNEL_6, /*!< RMT channel number 6 */
|
||||
RMT_CHANNEL_7, /*!< RMT channel number 7 */
|
||||
#endif
|
||||
RMT_CHANNEL_MAX /*!< Number of RMT channels */
|
||||
} rmt_channel_t;
|
||||
|
||||
/**
|
||||
* @brief RMT Internal Memory Owner
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_MEM_OWNER_TX, /*!< RMT RX mode, RMT transmitter owns the memory block*/
|
||||
RMT_MEM_OWNER_RX, /*!< RMT RX mode, RMT receiver owns the memory block*/
|
||||
RMT_MEM_OWNER_MAX,
|
||||
} rmt_mem_owner_t;
|
||||
|
||||
/**
|
||||
* @brief Clock Source of RMT Channel
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_BASECLK_REF, /*!< RMT source clock is REF_TICK, 1MHz by default */
|
||||
RMT_BASECLK_APB, /*!< RMT source clock is APB CLK, 80Mhz by default */
|
||||
RMT_BASECLK_MAX,
|
||||
} rmt_source_clk_t;
|
||||
|
||||
/**
|
||||
* @brief RMT Data Mode
|
||||
*
|
||||
* @note We highly recommended to use MEM mode not FIFO mode since there will be some gotcha in FIFO mode.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_DATA_MODE_FIFO, /*<! RMT memory access in FIFO mode */
|
||||
RMT_DATA_MODE_MEM, /*<! RMT memory access in memory mode */
|
||||
RMT_DATA_MODE_MAX,
|
||||
} rmt_data_mode_t;
|
||||
|
||||
/**
|
||||
* @brief RMT Channel Working Mode (TX or RX)
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_MODE_TX, /*!< RMT TX mode */
|
||||
RMT_MODE_RX, /*!< RMT RX mode */
|
||||
RMT_MODE_MAX
|
||||
} rmt_mode_t;
|
||||
|
||||
/**
|
||||
* @brief RMT Idle Level
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_IDLE_LEVEL_LOW, /*!< RMT TX idle level: low Level */
|
||||
RMT_IDLE_LEVEL_HIGH, /*!< RMT TX idle level: high Level */
|
||||
RMT_IDLE_LEVEL_MAX,
|
||||
} rmt_idle_level_t;
|
||||
|
||||
/**
|
||||
* @brief RMT Carrier Level
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_CARRIER_LEVEL_LOW, /*!< RMT carrier wave is modulated for low Level output */
|
||||
RMT_CARRIER_LEVEL_HIGH, /*!< RMT carrier wave is modulated for high Level output */
|
||||
RMT_CARRIER_LEVEL_MAX
|
||||
} rmt_carrier_level_t;
|
||||
|
||||
/**
|
||||
* @brief RMT Channel Status
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_CHANNEL_UNINIT, /*!< RMT channel uninitialized */
|
||||
RMT_CHANNEL_IDLE, /*!< RMT channel status idle */
|
||||
RMT_CHANNEL_BUSY, /*!< RMT channel status busy */
|
||||
} rmt_channel_status_t;
|
||||
|
||||
/**
|
||||
* @brief Data struct of RMT channel status
|
||||
*/
|
||||
typedef struct {
|
||||
rmt_channel_status_t status[RMT_CHANNEL_MAX]; /*!< Store the current status of each channel */
|
||||
} rmt_channel_status_result_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
239
tools/sdk/esp32/include/soc/include/hal/rtc_io_hal.h
Normal file
239
tools/sdk/esp32/include/soc/include/hal/rtc_io_hal.h
Normal file
@@ -0,0 +1,239 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for RTC IO master (common part)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/rtc_io_ll.h"
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Select the rtcio function.
|
||||
*
|
||||
* @note The RTC function must be selected before the pad analog function is enabled.
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param func Select pin function.
|
||||
*/
|
||||
#define rtcio_hal_function_select(rtcio_num, func) rtcio_ll_function_select(rtcio_num, func)
|
||||
|
||||
/**
|
||||
* Enable rtcio output.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_output_enable(rtcio_num) rtcio_ll_output_enable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Disable rtcio output.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_output_disable(rtcio_num) rtcio_ll_output_disable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Set RTCIO output level.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param level 0: output low; ~0: output high.
|
||||
*/
|
||||
#define rtcio_hal_set_level(rtcio_num, level) rtcio_ll_set_level(rtcio_num, level)
|
||||
|
||||
/**
|
||||
* Enable rtcio input.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_input_enable(rtcio_num) rtcio_ll_input_enable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Disable rtcio input.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_input_disable(rtcio_num) rtcio_ll_input_disable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Get RTCIO input level.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @return 0: input low; ~0: input high.
|
||||
*/
|
||||
#define rtcio_hal_get_level(rtcio_num) rtcio_ll_get_level(rtcio_num)
|
||||
|
||||
/**
|
||||
* @brief Set RTC GPIO pad drive capability.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param strength Drive capability of the pad. Range: 0 ~ 3.
|
||||
*/
|
||||
#define rtcio_hal_set_drive_capability(rtcio_num, strength) rtcio_ll_set_drive_capability(rtcio_num, strength)
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad drive capability.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @return Drive capability of the pad. Range: 0 ~ 3.
|
||||
*/
|
||||
#define rtcio_hal_get_drive_capability(rtcio_num) rtcio_ll_get_drive_capability(rtcio_num)
|
||||
|
||||
/**
|
||||
* Set RTCIO output level.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param level 0: output low; ~0: output high.
|
||||
*/
|
||||
#define rtcio_hal_set_level(rtcio_num, level) rtcio_ll_set_level(rtcio_num, level)
|
||||
|
||||
/**
|
||||
* Get RTCIO input level.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @return 0: input low; ~0: input high.
|
||||
*/
|
||||
#define rtcio_hal_get_level(rtcio_num) rtcio_ll_get_level(rtcio_num)
|
||||
|
||||
/**
|
||||
* Set RTC IO direction.
|
||||
*
|
||||
* Configure RTC IO direction, such as output only, input only,
|
||||
* output and input.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param mode IO direction.
|
||||
*/
|
||||
void rtcio_hal_set_direction(int rtcio_num, rtc_gpio_mode_t mode);
|
||||
|
||||
/**
|
||||
* Set RTC IO direction in deep sleep or disable sleep status.
|
||||
*
|
||||
* NOTE: ESP32 support INPUT_ONLY mode.
|
||||
* ESP32S2 support INPUT_ONLY, OUTPUT_ONLY, INPUT_OUTPUT mode.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param mode IO direction.
|
||||
*/
|
||||
void rtcio_hal_set_direction_in_sleep(int rtcio_num, rtc_gpio_mode_t mode);
|
||||
|
||||
/**
|
||||
* RTC GPIO pullup enable.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_pullup_enable(rtcio_num) rtcio_ll_pullup_enable(rtcio_num)
|
||||
|
||||
/**
|
||||
* RTC GPIO pullup disable.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_pullup_disable(rtcio_num) rtcio_ll_pullup_disable(rtcio_num)
|
||||
|
||||
/**
|
||||
* RTC GPIO pulldown enable.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_pulldown_enable(rtcio_num) rtcio_ll_pulldown_enable(rtcio_num)
|
||||
|
||||
/**
|
||||
* RTC GPIO pulldown disable.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_pulldown_disable(rtcio_num) rtcio_ll_pulldown_disable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Enable force hold function for RTC IO pad.
|
||||
*
|
||||
* Enabling HOLD function will cause the pad to lock current status, such as,
|
||||
* input/output enable, input/output value, function, drive strength values.
|
||||
* This function is useful when going into light or deep sleep mode to prevent
|
||||
* the pin configuration from changing.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_hold_enable(rtcio_num) rtcio_ll_force_hold_enable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Disable hold function on an RTC IO pad
|
||||
*
|
||||
* @note If disable the pad hold, the status of pad maybe changed in sleep mode.
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_hold_disable(rtcio_num) rtcio_ll_force_hold_disable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Enable force hold function for RTC IO pads.
|
||||
*
|
||||
* Enabling HOLD function will cause the pad to lock current status, such as,
|
||||
* input/output enable, input/output value, function, drive strength values.
|
||||
* This function is useful when going into light or deep sleep mode to prevent
|
||||
* the pin configuration from changing.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_hold_all() rtcio_ll_force_hold_all()
|
||||
|
||||
/**
|
||||
* Disable hold function on an RTC IO pads.
|
||||
*
|
||||
* @note If disable the pad hold, the status of pad maybe changed in sleep mode.
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_unhold_all() rtcio_ll_force_unhold_all()
|
||||
|
||||
/**
|
||||
* Enable wakeup function and set wakeup type from light sleep status for rtcio.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
* @param type Wakeup on high level or low level.
|
||||
*/
|
||||
#define rtcio_hal_wakeup_enable(rtcio_num, type) rtcio_ll_wakeup_enable(rtcio_num, type)
|
||||
|
||||
/**
|
||||
* Disable wakeup function from light sleep status for rtcio.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
#define rtcio_hal_wakeup_disable(rtcio_num) rtcio_ll_wakeup_disable(rtcio_num)
|
||||
|
||||
/**
|
||||
* Helper function to disconnect internal circuits from an RTC IO
|
||||
* This function disables input, output, pullup, pulldown, and enables
|
||||
* hold feature for an RTC IO.
|
||||
* Use this function if an RTC IO needs to be disconnected from internal
|
||||
* circuits in deep sleep, to minimize leakage current.
|
||||
*
|
||||
* In particular, for ESP32-WROVER module, call
|
||||
* rtc_gpio_isolate(GPIO_NUM_12) before entering deep sleep, to reduce
|
||||
* deep sleep current.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ SOC_RTC_IO_PIN_COUNT.
|
||||
*/
|
||||
void rtcio_hal_isolate(int rtc_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
25
tools/sdk/esp32/include/soc/include/hal/rtc_io_types.h
Normal file
25
tools/sdk/esp32/include/soc/include/hal/rtc_io_types.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/** RTCIO output/input mode type. */
|
||||
typedef enum {
|
||||
RTC_GPIO_MODE_INPUT_ONLY , /*!< Pad input */
|
||||
RTC_GPIO_MODE_OUTPUT_ONLY, /*!< Pad output */
|
||||
RTC_GPIO_MODE_INPUT_OUTPUT, /*!< Pad input + output */
|
||||
RTC_GPIO_MODE_DISABLED, /*!< Pad (output + input) disable */
|
||||
RTC_GPIO_MODE_OUTPUT_OD, /*!< Pad open-drain output */
|
||||
RTC_GPIO_MODE_INPUT_OUTPUT_OD, /*!< Pad input + open-drain output */
|
||||
} rtc_gpio_mode_t;
|
||||
529
tools/sdk/esp32/include/soc/include/hal/sdio_slave_hal.h
Normal file
529
tools/sdk/esp32/include/soc/include/hal/sdio_slave_hal.h
Normal file
@@ -0,0 +1,529 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SDIO slave (common part)
|
||||
|
||||
// SDIO slave HAL usages:
|
||||
|
||||
/*
|
||||
Architecture:
|
||||
|
||||
The whole SDIO slave peripheral consists of three parts: the registers (including the interrupt
|
||||
control and shared registers), a send FIFO, and a receive FIFO. The document
|
||||
``esp_slave_protocol.rst`` describes the functionality of the peripheral in detail. An SDIO host
|
||||
will only ever access one of the three parts at any one time, thus the hardware functionality of
|
||||
the SDIO slave peripheral are completely independent. Likewise, this HAL is organized in such a
|
||||
fashion as to correspond to the three independent parts.
|
||||
|
||||
The shared registers are quite simple: the slave can directly access them from the internal data
|
||||
bus, while the host can access them by CMD52/53 with the correct address. As for the interrupts:
|
||||
when an SDIO host interrupts the SDIO slave peripheral (by writing a command), the corresponding
|
||||
bit in the interrupt register will be set; when the SDIO slave peripheral needs to interrupt the
|
||||
host, it write some register to cause the host interrupt bit being set, and the slave hardware
|
||||
will output the interrupt signal on the DAT1 line.
|
||||
|
||||
For the FIFOs, the peripheral provides counters as registers so that the host can always know whether the slave
|
||||
is ready to send/receive data. The HAL resets the counters during initialization, and the host should somehow
|
||||
inform the slave to reset the counters again if it should reboot (or lose the counter value for some reasons).
|
||||
Then the host can read/write the FIFOs by CMD53 commands according to the counters.
|
||||
|
||||
In order to avoid copying data to/from the FIFOs or memory buffers each time, the HAL layer
|
||||
contains a descriptor queue (implemented as linked-list) that allows descriptors of memory
|
||||
buffers to be queued for transmission/reception. Once a buffer is queued, the HAL takes ownership
|
||||
of the buffer until some "finish" functions successfully return, indicating the
|
||||
transmission/reception of that buffer is complete. The ISR is invoked multiple times to iterate
|
||||
through the queued descriptors, and also to signal to the upper layer if a buffer has been
|
||||
freed.
|
||||
|
||||
The HAL is used as below:
|
||||
|
||||
- Receiving part:
|
||||
|
||||
1. Call `sdio_slave_hal_recv_start` to start the receiving DMA.
|
||||
|
||||
If there are already buffers loaded, the receiving will start from those buffers first.
|
||||
|
||||
2. Call `sdio_slave_hal_recv_init_desc` with a `sdio_slave_hal_recv_desc_t` and the buffer address to
|
||||
associate the descriptor with the buffer.
|
||||
|
||||
The HAL initialize this descriptors with the determined length and maybe some extra data.
|
||||
|
||||
3. Call `sdio_slave_hal_load_buf` with the initialized descriptor of the buffer to load a
|
||||
receiving buffer to the HAL.
|
||||
|
||||
When the DMA is started, the descriptors is loaded onto the DMA linked-list, and the
|
||||
counter of receiving buffers is increased so that the host will know this by the
|
||||
receiving interrupt. The hardware will automatically go through the linked list and write
|
||||
data into the buffers loaded on the list.
|
||||
|
||||
4. (Optional, mandatory only when interrupt enabled) Call `sdio_slave_hal_recv_done` to check
|
||||
and clear the receiving interrupt bits.
|
||||
|
||||
5. Call `sdio_slave_hal_recv_has_next_item` to check whether there are finished buffers.
|
||||
|
||||
6. Call `sdio_slave_hal_recv_unload_desc` for the same times as
|
||||
`sdio_slave_hal_recv_has_next_item` successfully returns.
|
||||
|
||||
7. (Optional) Call `sdio_slave_hal_recv_reset_counter` to reset the counter to current loaded
|
||||
but not used buffers if you want to reset the counter only. This is available only when
|
||||
the DMA is stopped.
|
||||
|
||||
8. (Optional) Call `sdio_slave_hal_recv_flush_one_buffer` (recursively) if you want to
|
||||
discard data of one (or more) buffers and load them again. This is available only when
|
||||
the DMA is stopped.
|
||||
|
||||
9. (Optional when deinitialization) Call `sdio_slave_hal_recv_unload_desc` recursively to get
|
||||
all the buffers loaded to the HAL, no matter they are used or not. Don't do this when the
|
||||
DMA is not stopped.
|
||||
|
||||
- Sending part:
|
||||
|
||||
The sending driver is slightly different, since we are not using the re-start feature.
|
||||
(TODO: re-write this part if the stitch mode is released)
|
||||
|
||||
1. Call `sdio_slave_hal_send_start` to start the sending DMA.
|
||||
|
||||
If there is already any data queued, it will ne ready to be sent to host now.
|
||||
|
||||
2. Call `sdio_slave_hal_send_queue` to queue the data to send.
|
||||
|
||||
If the interrupt is enabled, the ISR will be invoked.
|
||||
|
||||
3. (Required if interrupt enabled) Call `` to clear the interrupt bits used by the SW
|
||||
invoking logic.
|
||||
|
||||
4. Call `sdio_slave_hal_send_new_packet_if_exist` to check and send new packet (if there is
|
||||
data queued).
|
||||
|
||||
5. Call `sdio_slave_hal_send_eof_happened` to check whether the previous packet is done.
|
||||
|
||||
It will also clear the interrupt status bit for this event.
|
||||
|
||||
6. Call `sdio_slave_hal_send_get_next_finished_arg` recursively to get the arguments for the
|
||||
finished buffers.
|
||||
|
||||
7. (Optional when deinitialization) Call `sdio_slave_hal_send_flush_next_buffer` recursively
|
||||
to get all buffers queued, regardless sent or not. Don't do this when the DMA is not stopped.
|
||||
|
||||
8. (Optional) Call `sdio_slave_hal_send_reset_counter` to reset the counter to current loaded
|
||||
but not sent buffers if you want to reset the counter only. Don't do this when the DMA is not
|
||||
stopped.
|
||||
|
||||
Note a counter should be used when performing step 2 and 6, to make sure that the queue size
|
||||
is enough.
|
||||
|
||||
- Host part:
|
||||
|
||||
1. Call `sdio_slave_hal_hostint_set_ena` and `sdio_slave_hal_hostint_get_ena` to
|
||||
enable/disable the interrupt sent to master. Note that the host can also modify the same
|
||||
registers at the same time. Try to avoid using them outside the initialization process.
|
||||
|
||||
2. Call `sdio_slave_hal_hostint_send` and `sdio_slave_hal_hostint_clear` to trigger general
|
||||
purpose interrupts or cancel all kinds of interrupts send to the host. These interrupts are
|
||||
set/cleared in a concurrent-safe way, so the slave can call these functions safely.
|
||||
|
||||
3. Call `sdio_slave_hal_slvint_fetch_clear` to fetch the general purpose interrupts sent by
|
||||
the host to the slave. These interrupts will also be cleared after the calls.
|
||||
|
||||
4. Call `sdio_slave_hal_host_get_reg` and `sdio_slave_hal_host_set_reg` to read/write the
|
||||
general purpose shared between the host and slave. Note that these registers are also not
|
||||
concurrent-safe. Try not to write to the same register from two directions at the same time.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <esp_err.h>
|
||||
#include "soc/lldesc.h"
|
||||
#include "hal/sdio_slave_types.h"
|
||||
#include "hal/sdio_slave_ll.h"
|
||||
|
||||
/// Space used for each sending descriptor. Should initialize the sendbuf accoring to this size.
|
||||
#define SDIO_SLAVE_SEND_DESC_SIZE sizeof(sdio_slave_hal_send_desc_t)
|
||||
|
||||
|
||||
/// Status of the sending part
|
||||
typedef enum {
|
||||
STATE_IDLE = 1,
|
||||
STATE_WAIT_FOR_START = 2,
|
||||
STATE_SENDING = 3,
|
||||
STATE_GETTING_RESULT = 4,
|
||||
STATE_GETTING_UNSENT_DESC = 5,
|
||||
} send_state_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t* data; ///< Address of the buffer
|
||||
size_t size; ///< Size of the buffer, but can only queue (size/SDIO_SLAVE_SEND_DESC_SIZE)-1 descriptors
|
||||
uint8_t* write_ptr;
|
||||
uint8_t* read_ptr;
|
||||
uint8_t* free_ptr;
|
||||
} sdio_ringbuf_t;
|
||||
|
||||
// Append two extra words to be used by the HAL.
|
||||
// Should Initialize the member `data` of `send_desc_queue` of the HAL context
|
||||
// with size of this desc * N.
|
||||
|
||||
/// DMA descriptor with extra fields
|
||||
typedef struct sdio_slave_hal_send_desc_s {
|
||||
lldesc_t dma_desc; ///< Used by Hardware, has pointer linking to next desc
|
||||
uint32_t pkt_len; ///< Accumulated length till this descriptor
|
||||
void* arg; ///< Holding arguments indicating this buffer */
|
||||
} sdio_slave_hal_send_desc_t;
|
||||
|
||||
/// Descriptor used by the receiving part, call `sdio_slave_hal_recv_init_desc`
|
||||
/// to initialize it before use.
|
||||
typedef lldesc_t sdio_slave_hal_recv_desc_t;
|
||||
#define sdio_slave_hal_recv_desc_s lldesc_s
|
||||
typedef STAILQ_HEAD(recv_stailq_head_s, sdio_slave_hal_recv_desc_s) sdio_slave_hal_recv_stailq_t;
|
||||
|
||||
|
||||
/** HAL context structure. Call `sdio_slave_hal_init` to initialize it and
|
||||
* configure required members before actually use the HAL.
|
||||
*/
|
||||
typedef struct {
|
||||
/// Hardware registers for this SDIO slave peripheral, configured by
|
||||
/// `sdio_slave_hal_init`
|
||||
struct {
|
||||
slc_dev_t* slc;
|
||||
host_dev_t* host;
|
||||
hinf_dev_t* hinf;
|
||||
};
|
||||
sdio_slave_sending_mode_t sending_mode; /**< Sending mode, should be manually configured before using the HAL.
|
||||
* see `sdio_slave_sending_mode_t`.
|
||||
*/
|
||||
sdio_slave_timing_t timing; /**< Timing mode (launch edge and latch edge settings). Should be manually
|
||||
* configured before using the HAL. `SDIO_SLAVE_TIMING_PSEND_PSAMPLE` is
|
||||
* recommended by default.
|
||||
*/
|
||||
int send_queue_size; /**< Max buffers that can be queued before sending. Should be manually
|
||||
* configured before using the HAL.
|
||||
*/
|
||||
size_t recv_buffer_size; /**< The size of each buffer. The host and slave should share a
|
||||
* pre-negotiated value. Should be manually configured before using
|
||||
* the HAL.
|
||||
*/
|
||||
sdio_ringbuf_t send_desc_queue; /**< The ring buffer used to hold queued descriptors. Should be manually
|
||||
* initialized before using the HAL.
|
||||
*/
|
||||
//Internal status, no need to touch.
|
||||
send_state_t send_state; // Current state of sending part.
|
||||
uint32_t tail_pkt_len; // The accumulated send length of the tail packet.
|
||||
sdio_slave_hal_send_desc_t* in_flight_head; // The head of linked list in-flight.
|
||||
sdio_slave_hal_send_desc_t* in_flight_end; // The end of linked list in-flight.
|
||||
sdio_slave_hal_send_desc_t* in_flight_next; // The header of linked list to be sent next time.
|
||||
sdio_slave_hal_send_desc_t* returned_desc; // The last returned descriptor
|
||||
|
||||
sdio_slave_hal_recv_stailq_t recv_link_list; // Linked list of buffers ready to hold data and the buffers already hold data.
|
||||
volatile sdio_slave_hal_recv_desc_t* recv_cur_ret; // Next desc to return, NULL if all loaded descriptors are returned.
|
||||
} sdio_slave_context_t ;
|
||||
|
||||
/**
|
||||
* Initialize the HAL, should provide buffers to the context and configure the
|
||||
* members before this funciton is called.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_init(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Initialize the SDIO slave peripheral hardware.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_hw_init(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Set the IO ready for host to read.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param ready true to tell the host the slave is ready, otherwise false.
|
||||
*/
|
||||
void sdio_slave_hal_set_ioready(sdio_slave_context_t *hal, bool ready);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Send
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The hardware sending DMA starts. If there is existing data, send them.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
esp_err_t sdio_slave_hal_send_start(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Stops hardware sending DMA.
|
||||
*
|
||||
* @note The data in the queue, as well as the counter are not touched.
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_send_stop(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Put some data into the sending queue.
|
||||
*
|
||||
* @note The caller should keeps the buffer, until the `arg` is returned by
|
||||
* `sdio_slave_hal_send_get_next_finished_arg`.
|
||||
* @note The caller should count to ensure there is enough space in the queue.
|
||||
* The initial queue size is sizeof(sendbuf.data)/sizeof(sdio_slave_hal_send_desc_t)-1,
|
||||
* Will decrease by one when this function successfully returns.
|
||||
* Released only by `sdio_slave_hal_send_get_next_finished_arg` or
|
||||
* `sdio_slave_hal_send_flush_next_buffer`.
|
||||
*
|
||||
* @note The HAL is not thread-safe. The caller should use a spinlock to ensure
|
||||
* the `sdio_slave_hal_send_queue` and ... are not called at the same time.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param addr Address of data in the memory to send.
|
||||
* @param len Length of data to send.
|
||||
* @param arg Argument indicating this sending.
|
||||
* @return Always ESP_OK.
|
||||
*/
|
||||
esp_err_t sdio_slave_hal_send_queue(sdio_slave_context_t *hal, uint8_t *addr, size_t len, void *arg);
|
||||
|
||||
/**
|
||||
* The ISR should call this, to handle the SW invoking event.
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_send_handle_isr_invoke(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Check whether there is no in-flight transactions, and send new packet if there
|
||||
* is new packets queued.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @return
|
||||
* - ESP_OK: The DMA starts to send a new packet.
|
||||
* - ESP_ERR_NOT_FOUND: No packet waiting to be sent.
|
||||
* - ESP_ERR_INVALID_STATE: There is packet in-flight.
|
||||
*/
|
||||
esp_err_t sdio_slave_hal_send_new_packet_if_exist(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Check whether the sending EOF has happened and clear the interrupt.
|
||||
*
|
||||
* Call `sdio_slave_hal_send_get_next_finished_arg` recursively to retrieve arguments of finished
|
||||
* buffers.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @return true if happened, otherwise false.
|
||||
*/
|
||||
bool sdio_slave_hal_send_eof_happened(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Get the arguments of finished packets. Call recursively until all finished
|
||||
* arguments are all retrieved.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param out_arg Output argument of the finished buffer.
|
||||
* @param out_returned_cnt Released queue size to be queued again.
|
||||
* @return
|
||||
* - ESP_OK: if one argument retrieved.
|
||||
* - ESP_ERR_NOT_FOUND: All the arguments of the finished buffers are retrieved.
|
||||
*/
|
||||
esp_err_t sdio_slave_hal_send_get_next_finished_arg(sdio_slave_context_t *hal, void **out_arg, uint32_t* out_returned_cnt);
|
||||
|
||||
/**
|
||||
* Flush one buffer in the queue, no matter sent, canceled or not sent yet.
|
||||
*
|
||||
* Call recursively to clear the whole queue before deinitialization.
|
||||
*
|
||||
* @note Only call when the DMA is stopped!
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param out_arg Argument indiciating the buffer to send
|
||||
* @param out_return_cnt Space in the queue released after this descriptor is flushed.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE: This function call be called only when the DMA is stopped.
|
||||
* - ESP_ERR_NOT_FOUND: if no buffer in the queue
|
||||
* - ESP_OK: if a buffer is successfully flushed and returned.
|
||||
*/
|
||||
esp_err_t sdio_slave_hal_send_flush_next_buffer(sdio_slave_context_t *hal, void **out_arg, uint32_t *out_return_cnt);
|
||||
|
||||
/**
|
||||
* Walk through all the unsent buffers and reset the counter to the accumulated length of them. The data will be kept.
|
||||
*
|
||||
* @note Only call when the DMA is stopped!
|
||||
* @param hal Context of the HAL layer.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE: this function call be called only when the DMA is stopped
|
||||
* - ESP_OK: if success
|
||||
*/
|
||||
esp_err_t sdio_slave_hal_send_reset_counter(sdio_slave_context_t *hal);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Receive
|
||||
*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Start the receiving DMA.
|
||||
*
|
||||
* @note If there are already some buffers loaded, will receive from them first.
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_recv_start(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Stop the receiving DMA.
|
||||
*
|
||||
* @note Data and the counter will not be touched. You can still call
|
||||
* `sdio_slave_hal_recv_has_next_item` to get the received buffer.
|
||||
* And unused buffers loaded to the HAL will still be in the `loaded`
|
||||
* state in the HAL, until returned by `sdio_slave_hal_recv_unload_desc`.
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_recv_stop(sdio_slave_context_t* hal);
|
||||
|
||||
/**
|
||||
* Associate the buffer to the descriptor given. The descriptor may also be initialized with some
|
||||
* other data.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param desc Descriptor to associate with the buffer
|
||||
* @param start Start address of the buffer
|
||||
*/
|
||||
void sdio_slave_hal_recv_init_desc(sdio_slave_context_t *hal, sdio_slave_hal_recv_desc_t *desc, uint8_t *start);
|
||||
|
||||
/**
|
||||
* Load the buffer to the HAL to be used to receive data.
|
||||
*
|
||||
* @note Loaded buffers will be returned to the upper layer only when:
|
||||
* 1. Returned by `sdio_slave_hal_recv_has_next_item` when receiving to that buffer successfully
|
||||
* done.
|
||||
* 2. Returned by `sdio_slave_hal_recv_unload_desc` unconditionally.
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param desc Descriptor to load to the HAL to receive.
|
||||
*/
|
||||
void sdio_slave_hal_load_buf(sdio_slave_context_t *hal, sdio_slave_hal_recv_desc_t *desc);
|
||||
|
||||
/**
|
||||
* Check and clear the interrupt indicating a buffer has finished receiving.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @return true if interrupt triggered, otherwise false.
|
||||
*/
|
||||
bool sdio_slave_hal_recv_done(sdio_slave_context_t* hal);
|
||||
|
||||
/**
|
||||
* Call this function recursively to check whether there is any buffer that has
|
||||
* finished receiving.
|
||||
*
|
||||
* Will walk through the linked list to find a newer finished buffer. For each successful return,
|
||||
* it means there is one finished buffer. You can one by `sdio_slave_hal_recv_unload_desc`. You can
|
||||
* also call `sdio_slave_hal_recv_has_next_item` several times continuously before you call the
|
||||
* `sdio_slave_hal_recv_unload_desc` for the same times.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @return true if there is
|
||||
*/
|
||||
bool sdio_slave_hal_recv_has_next_item(sdio_slave_context_t* hal);
|
||||
|
||||
/**
|
||||
* Unconditionally remove and return the first descriptor loaded to the HAL.
|
||||
*
|
||||
* Unless during de-initialization, `sdio_slave_hal_recv_has_next_item` should have succeed for the
|
||||
* same times as this function is called, to ensure the returned descriptor has finished its
|
||||
* receiving job.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @return The removed descriptor, NULL means the linked-list is empty.
|
||||
*/
|
||||
sdio_slave_hal_recv_desc_t *sdio_slave_hal_recv_unload_desc(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Walk through all the unused buffers and reset the counter to the number of
|
||||
* them.
|
||||
*
|
||||
* @note Only call when the DMA is stopped!
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_recv_reset_counter(sdio_slave_context_t *hal);
|
||||
|
||||
/**
|
||||
* Walk through all the used buffers, clear the finished flag and appended them
|
||||
* back to the end of the unused list, waiting to receive then.
|
||||
*
|
||||
* @note You will lose all the received data in the buffer.
|
||||
* @note Only call when the DMA is stopped!
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void sdio_slave_hal_recv_flush_one_buffer(sdio_slave_context_t *hal);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Host
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Enable some of the interrupts for the host.
|
||||
*
|
||||
* @note May have concurrency issue wit the host or other tasks, suggest only use it during
|
||||
* initialization.
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param mask Bitwise mask for the interrupts to enable.
|
||||
*/
|
||||
void sdio_slave_hal_hostint_set_ena(sdio_slave_context_t *hal, const sdio_slave_hostint_t *mask);
|
||||
|
||||
/**
|
||||
* Get the enabled interrupts.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param out_int_mask Output of the enabled interrupts
|
||||
*/
|
||||
void sdio_slave_hal_hostint_get_ena(sdio_slave_context_t *hal, sdio_slave_hostint_t *out_int_mask);
|
||||
|
||||
/**
|
||||
* Send general purpose interrupt (slave send to host).
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param mask Interrupts to send, only `SDIO_SLAVE_HOSTINT_BIT*` are allowed.
|
||||
*/
|
||||
void sdio_slave_hal_hostint_send(sdio_slave_context_t *hal, const sdio_slave_hostint_t *mask);
|
||||
|
||||
/**
|
||||
* Cleared the specified interrupts for the host.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param mask Interrupts to clear.
|
||||
*/
|
||||
void sdio_slave_hal_hostint_clear(sdio_slave_context_t *hal, const sdio_slave_hostint_t *mask);
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the interrupt (host send to slave) status bits and clear all of them.
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param out_int_mask Output interrupt status
|
||||
*/
|
||||
void sdio_slave_hal_slvint_fetch_clear(sdio_slave_context_t *hal, sdio_slave_ll_slvint_t *out_int_mask);
|
||||
|
||||
/**
|
||||
* Get the value of a shared general purpose register.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param pos Position of the register, 4 bytes share a word. 0-63 except 24-27.
|
||||
* @return The register value.
|
||||
*/
|
||||
uint8_t sdio_slave_hal_host_get_reg(sdio_slave_context_t *hal, int pos);
|
||||
|
||||
/**
|
||||
* Set the value of shared general purpose register.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param pos Position of the register, 4 bytes share a word. 0-63 except 24-27.
|
||||
* @param reg Value to set.
|
||||
*/
|
||||
void sdio_slave_hal_host_set_reg(sdio_slave_context_t *hal, int pos, uint8_t reg);
|
||||
|
||||
482
tools/sdk/esp32/include/soc/include/hal/sdio_slave_ll.h
Normal file
482
tools/sdk/esp32/include/soc/include/hal/sdio_slave_ll.h
Normal file
@@ -0,0 +1,482 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The LL layer for ESP32 SDIO slave register operations
|
||||
// It's strange but `tx_*` regs for host->slave transfers while `rx_*` regs for slave->host transfers
|
||||
// To reduce ambiguity, we call (host->slave, tx) transfers receiving and (slave->host, rx) transfers receiving
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/sdio_slave_hal.h"
|
||||
#include "soc/slc_struct.h"
|
||||
#include "soc/slc_reg.h"
|
||||
#include "soc/host_struct.h"
|
||||
#include "soc/host_reg.h"
|
||||
#include "soc/hinf_struct.h"
|
||||
#include "soc/lldesc.h"
|
||||
|
||||
/// Get address of the only SLC registers for ESP32
|
||||
#define sdio_slave_ll_get_slc(ID) (&SLC)
|
||||
/// Get address of the only HOST registers for ESP32
|
||||
#define sdio_slave_ll_get_host(ID) (&HOST)
|
||||
/// Get address of the only HINF registers for ESP32
|
||||
#define sdio_slave_ll_get_hinf(ID) (&HINF)
|
||||
|
||||
|
||||
/// Mask of general purpose interrupts sending from the host.
|
||||
typedef enum {
|
||||
SDIO_SLAVE_LL_SLVINT_0 = BIT(0), ///< General purpose interrupt bit 0.
|
||||
SDIO_SLAVE_LL_SLVINT_1 = BIT(1),
|
||||
SDIO_SLAVE_LL_SLVINT_2 = BIT(2),
|
||||
SDIO_SLAVE_LL_SLVINT_3 = BIT(3),
|
||||
SDIO_SLAVE_LL_SLVINT_4 = BIT(4),
|
||||
SDIO_SLAVE_LL_SLVINT_5 = BIT(5),
|
||||
SDIO_SLAVE_LL_SLVINT_6 = BIT(6),
|
||||
SDIO_SLAVE_LL_SLVINT_7 = BIT(7),
|
||||
} sdio_slave_ll_slvint_t;
|
||||
|
||||
/**
|
||||
* Initialize the hardware.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_init(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_int_ena.val = 0;
|
||||
|
||||
slc->conf0.slc0_rx_auto_wrback = 1;
|
||||
slc->conf0.slc0_token_auto_clr = 0;
|
||||
slc->conf0.slc0_rx_loop_test = 0;
|
||||
slc->conf0.slc0_tx_loop_test = 0;
|
||||
|
||||
slc->conf1.slc0_rx_stitch_en = 0;
|
||||
slc->conf1.slc0_tx_stitch_en = 0;
|
||||
slc->conf1.slc0_len_auto_clr = 0;
|
||||
|
||||
slc->rx_dscr_conf.slc0_token_no_replace = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timing for the communication
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @param timing Timing configuration to set
|
||||
*/
|
||||
static inline void sdio_slave_ll_set_timing(host_dev_t *host, sdio_slave_timing_t timing)
|
||||
{
|
||||
switch(timing) {
|
||||
case SDIO_SLAVE_TIMING_PSEND_PSAMPLE:
|
||||
host->conf.frc_sdio20 = 0x1f;
|
||||
host->conf.frc_sdio11 = 0;
|
||||
host->conf.frc_pos_samp = 0x1f;
|
||||
host->conf.frc_neg_samp = 0;
|
||||
break;
|
||||
case SDIO_SLAVE_TIMING_PSEND_NSAMPLE:
|
||||
host->conf.frc_sdio20 = 0x1f;
|
||||
host->conf.frc_sdio11 = 0;
|
||||
host->conf.frc_pos_samp = 0;
|
||||
host->conf.frc_neg_samp = 0x1f;
|
||||
break;
|
||||
case SDIO_SLAVE_TIMING_NSEND_PSAMPLE:
|
||||
host->conf.frc_sdio20 = 0;
|
||||
host->conf.frc_sdio11 = 0x1f;
|
||||
host->conf.frc_pos_samp = 0x1f;
|
||||
host->conf.frc_neg_samp = 0;
|
||||
break;
|
||||
case SDIO_SLAVE_TIMING_NSEND_NSAMPLE:
|
||||
host->conf.frc_sdio20 = 0;
|
||||
host->conf.frc_sdio11 = 0x1f;
|
||||
host->conf.frc_pos_samp = 0;
|
||||
host->conf.frc_neg_samp = 0x1f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HS supported bit to be read by the host.
|
||||
*
|
||||
* @param hinf Address of the hinf registers
|
||||
* @param hs true if supported, otherwise false.
|
||||
*/
|
||||
static inline void sdio_slave_ll_enable_hs(hinf_dev_t *hinf, bool hs)
|
||||
{
|
||||
if (hs) {
|
||||
hinf->cfg_data1.sdio_ver = 0x232;
|
||||
hinf->cfg_data1.highspeed_enable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IO Ready bit to be read by the host.
|
||||
*
|
||||
* @param hinf Address of the hinf registers
|
||||
* @param ready true if ready, otherwise false.
|
||||
*/
|
||||
static inline void sdio_slave_ll_set_ioready(hinf_dev_t *hinf, bool ready)
|
||||
{
|
||||
hinf->cfg_data1.sdio_ioready1 = (ready ? 1 : 0); //set IO ready to 1 to stop host from using
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Send
|
||||
*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Reset the sending DMA.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_reset(slc_dev_t *slc)
|
||||
{
|
||||
//reset to flush previous packets
|
||||
slc->conf0.slc0_rx_rst = 1;
|
||||
slc->conf0.slc0_rx_rst = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the sending DMA with the given descriptor.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param desc Descriptor to send
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_start(slc_dev_t *slc, const lldesc_t *desc)
|
||||
{
|
||||
slc->slc0_rx_link.addr = (uint32_t)desc;
|
||||
slc->slc0_rx_link.start = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the PKT_LEN register to be written by the host to a certain value.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param len Length to write
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_write_len(slc_dev_t *slc, uint32_t len)
|
||||
{
|
||||
slc->slc0_len_conf.val = FIELD_TO_VALUE2(SLC_SLC0_LEN_WDATA, len) | FIELD_TO_VALUE2(SLC_SLC0_LEN_WR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the value of PKT_LEN register. The register may keep the same until read
|
||||
* by the host.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @return The value of PKT_LEN register.
|
||||
*/
|
||||
static inline uint32_t sdio_slave_ll_send_read_len(host_dev_t *host)
|
||||
{
|
||||
return host->pkt_len.reg_slc0_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the rx_done interrupt. (sending)
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param ena true if enable, otherwise false.
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_part_done_intr_ena(slc_dev_t *slc, bool ena)
|
||||
{
|
||||
slc->slc0_int_ena.rx_done = (ena ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the rx_done interrupt. (sending)
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_part_done_clear(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_int_clr.rx_done = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the hardware is ready for the SW to use rx_done to invoke
|
||||
* the ISR.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @return true if ready, otherwise false.
|
||||
*/
|
||||
static inline bool sdio_slave_ll_send_invoker_ready(slc_dev_t *slc)
|
||||
{
|
||||
return slc->slc0_int_raw.rx_done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the sending DMA.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_stop(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_rx_link.stop = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the sending interrupt (rx_eof).
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param ena true to enable, false to disable
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_intr_ena(slc_dev_t *slc, bool ena)
|
||||
{
|
||||
slc->slc0_int_ena.rx_eof = (ena? 1: 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the sending interrupt (rx_eof).
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_intr_clr(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_int_clr.rx_eof = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the sending is done.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @return true if done, otherwise false
|
||||
*/
|
||||
static inline bool sdio_slave_ll_send_done(slc_dev_t *slc)
|
||||
{
|
||||
return slc->slc0_int_st.rx_eof != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the host interrupt indicating the slave having packet to be read.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_send_hostint_clr(host_dev_t *host)
|
||||
{
|
||||
host->slc0_int_clr.rx_new_packet = 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Receive
|
||||
*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Enable the receiving interrupt.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param ena
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_intr_ena(slc_dev_t *slc, bool ena)
|
||||
{
|
||||
slc->slc0_int_ena.tx_done = (ena ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start receiving DMA with the given descriptor.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param desc Descriptor of the receiving buffer.
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_start(slc_dev_t *slc, lldesc_t *desc)
|
||||
{
|
||||
slc->slc0_tx_link.addr = (uint32_t)desc;
|
||||
slc->slc0_tx_link.start = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the receiving buffer counter by 1.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_size_inc(slc_dev_t *slc)
|
||||
{
|
||||
// fields wdata and inc_more should be written by the same instruction.
|
||||
slc->slc0_token1.val = FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_WDATA, 1) | FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_INC_MORE, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the receiving buffer.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_size_reset(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_token1.val = FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_WDATA, 0) | FIELD_TO_VALUE2(SLC_SLC0_TOKEN1_WR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether there is a receiving finished event.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @return
|
||||
*/
|
||||
static inline bool sdio_slave_ll_recv_done(slc_dev_t *slc)
|
||||
{
|
||||
return slc->slc0_int_raw.tx_done != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the receiving finished interrupt.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_done_clear(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_int_clr.tx_done = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restart the DMA. Call after you modified the next pointer of the tail descriptor to the appended
|
||||
* descriptor.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_restart(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_tx_link.restart = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the receiving DMA.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_reset(slc_dev_t *slc)
|
||||
{
|
||||
slc->conf0.slc0_tx_rst = 1;
|
||||
slc->conf0.slc0_tx_rst = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the receiving DMA.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
*/
|
||||
static inline void sdio_slave_ll_recv_stop(slc_dev_t *slc)
|
||||
{
|
||||
slc->slc0_tx_link.stop = 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Host
|
||||
*--------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Get the address of the shared general purpose register. Internal.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @param pos Position of the register, 0-63 except 24-27.
|
||||
* @return address of the register.
|
||||
*/
|
||||
static inline intptr_t sdio_slave_ll_host_get_w_reg(host_dev_t* host, int pos)
|
||||
{
|
||||
return (intptr_t )&(host->conf_w0) + pos + (pos>23?4:0) + (pos>31?12:0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the shared general purpose register.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @param pos Position of the register, 0-63, except 24-27.
|
||||
* @return value of the register.
|
||||
*/
|
||||
static inline uint8_t sdio_slave_ll_host_get_reg(host_dev_t *host, int pos)
|
||||
{
|
||||
return *(uint8_t*)sdio_slave_ll_host_get_w_reg(host, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of the shared general purpose register.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @param pos Position of the register, 0-63, except 24-27.
|
||||
* @param reg Value to set.
|
||||
*/
|
||||
static inline void sdio_slave_ll_host_set_reg(host_dev_t* host, int pos, uint8_t reg)
|
||||
{
|
||||
uint32_t* addr = (uint32_t*)(sdio_slave_ll_host_get_w_reg(host, pos) & (~3));
|
||||
uint32_t shift = (pos % 4) * 8;
|
||||
*addr &= ~(0xff << shift);
|
||||
*addr |= ((uint32_t)reg << shift);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the interrupt enable bits for the host.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @return Enabled interrupts
|
||||
*/
|
||||
static inline sdio_slave_hostint_t sdio_slave_ll_host_get_intena(host_dev_t* host)
|
||||
{
|
||||
return host->slc0_func1_int_ena.val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the interrupt enable bits for the host.
|
||||
*
|
||||
* @param host Address of the host registers
|
||||
* @param mask Mask of interrupts to enable
|
||||
*/
|
||||
static inline void sdio_slave_ll_host_set_intena(host_dev_t *host, const sdio_slave_hostint_t *mask)
|
||||
{
|
||||
host->slc0_func1_int_ena.val = (*mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the interrupt bits for the host.
|
||||
* @param host Address of the host registers
|
||||
* @param mask Mask of interrupts to clear.
|
||||
*/
|
||||
static inline void sdio_slave_ll_host_intr_clear(host_dev_t* host, const sdio_slave_hostint_t *mask)
|
||||
{
|
||||
host->slc0_int_clr.val = (*mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send general purpose interrupts to the host.
|
||||
* @param slc Address of the SLC registers
|
||||
* @param mask Mask of interrupts to seend to host
|
||||
*/
|
||||
static inline void sdio_slave_ll_host_send_int(slc_dev_t *slc, const sdio_slave_hostint_t *mask)
|
||||
{
|
||||
//use registers in SLC to trigger, rather than write HOST registers directly
|
||||
//other interrupts than tohost interrupts are not supported yet
|
||||
slc->intvec_tohost.slc0_intvec = (*mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable some of the slave interrups (send from host)
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param mask Mask of interrupts to enable, all those set to 0 will be disabled.
|
||||
*/
|
||||
static inline void sdio_slave_ll_slvint_set_ena(slc_dev_t *slc, const sdio_slave_ll_slvint_t *mask)
|
||||
{
|
||||
//other interrupts are not enabled
|
||||
slc->slc0_int_ena.val = (slc->slc0_int_ena.val & (~0xff)) | ((*mask) & 0xff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the slave interrupts (send from host) and clear them.
|
||||
*
|
||||
* @param slc Address of the SLC registers
|
||||
* @param out_slv_int Output of the slave interrupts fetched and cleared.
|
||||
*/
|
||||
static inline void sdio_slave_ll_slvint_fetch_clear(slc_dev_t *slc, sdio_slave_ll_slvint_t *out_slv_int)
|
||||
{
|
||||
sdio_slave_ll_slvint_t slv_int = slc->slc0_int_st.val & 0xff;
|
||||
*out_slv_int = slv_int;
|
||||
slc->slc0_int_clr.val = slv_int;
|
||||
}
|
||||
|
||||
47
tools/sdk/esp32/include/soc/include/hal/sdio_slave_types.h
Normal file
47
tools/sdk/esp32/include/soc/include/hal/sdio_slave_types.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc.h"
|
||||
|
||||
/// Mask of interrupts sending to the host.
|
||||
typedef enum {
|
||||
SDIO_SLAVE_HOSTINT_BIT0 = BIT(0), ///< General purpose interrupt bit 0.
|
||||
SDIO_SLAVE_HOSTINT_BIT1 = BIT(1),
|
||||
SDIO_SLAVE_HOSTINT_BIT2 = BIT(2),
|
||||
SDIO_SLAVE_HOSTINT_BIT3 = BIT(3),
|
||||
SDIO_SLAVE_HOSTINT_BIT4 = BIT(4),
|
||||
SDIO_SLAVE_HOSTINT_BIT5 = BIT(5),
|
||||
SDIO_SLAVE_HOSTINT_BIT6 = BIT(6),
|
||||
SDIO_SLAVE_HOSTINT_BIT7 = BIT(7),
|
||||
SDIO_SLAVE_HOSTINT_SEND_NEW_PACKET = BIT(23), ///< New packet available
|
||||
} sdio_slave_hostint_t;
|
||||
|
||||
|
||||
/// Timing of SDIO slave
|
||||
typedef enum {
|
||||
SDIO_SLAVE_TIMING_PSEND_PSAMPLE = 0,/**< Send at posedge, and sample at posedge. Default value for HS mode.
|
||||
* Normally there's no problem using this to work in DS mode.
|
||||
*/
|
||||
SDIO_SLAVE_TIMING_NSEND_PSAMPLE ,///< Send at negedge, and sample at posedge. Default value for DS mode and below.
|
||||
SDIO_SLAVE_TIMING_PSEND_NSAMPLE, ///< Send at posedge, and sample at negedge
|
||||
SDIO_SLAVE_TIMING_NSEND_NSAMPLE, ///< Send at negedge, and sample at negedge
|
||||
} sdio_slave_timing_t;
|
||||
|
||||
/// Configuration of SDIO slave mode
|
||||
typedef enum {
|
||||
SDIO_SLAVE_SEND_STREAM = 0, ///< Stream mode, all packets to send will be combined as one if possible
|
||||
SDIO_SLAVE_SEND_PACKET = 1, ///< Packet mode, one packets will be sent one after another (only increase packet_len if last packet sent).
|
||||
} sdio_slave_sending_mode_t;
|
||||
71
tools/sdk/esp32/include/soc/include/hal/sigmadelta_hal.h
Normal file
71
tools/sdk/esp32/include/soc/include/hal/sigmadelta_hal.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SIGMADELTA.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/sigmadelta_periph.h"
|
||||
#include "hal/sigmadelta_types.h"
|
||||
#include "hal/sigmadelta_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
gpio_sd_dev_t *dev;
|
||||
} sigmadelta_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Set Sigma-delta channel duty.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel Sigma-delta channel number
|
||||
* @param duty Sigma-delta duty of one channel, the value ranges from -128 to 127, recommended range is -90 ~ 90.
|
||||
* The waveform is more like a random one in this range.
|
||||
*/
|
||||
#define sigmadelta_hal_set_duty(hal, channel, duty) sigmadelta_ll_set_duty((hal)->dev, channel, duty)
|
||||
|
||||
/**
|
||||
* @brief Set Sigma-delta channel's clock pre-scale value.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param channel Sigma-delta channel number
|
||||
* @param prescale The divider of source clock, ranges from 0 to 255
|
||||
*/
|
||||
#define sigmadelta_hal_set_prescale(hal, channel, prescale) sigmadelta_ll_set_prescale((hal)->dev, channel, prescale)
|
||||
|
||||
/**
|
||||
* @brief Init the SIGMADELTA hal and set the SIGMADELTA to the default configuration. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sigmadelta_num The uart port number, the max port number is (SIGMADELTA_NUM_MAX -1)
|
||||
*/
|
||||
void sigmadelta_hal_init(sigmadelta_hal_context_t *hal, int sigmadelta_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
45
tools/sdk/esp32/include/soc/include/hal/sigmadelta_types.h
Normal file
45
tools/sdk/esp32/include/soc/include/hal/sigmadelta_types.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/sigmadelta_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SIGMADELTA port number, the max port number is (SIGMADELTA_NUM_MAX -1).
|
||||
*/
|
||||
typedef int sigmadelta_port_t;
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta channel list
|
||||
*/
|
||||
typedef int sigmadelta_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Sigma-delta configure struct
|
||||
*/
|
||||
typedef struct {
|
||||
sigmadelta_channel_t channel; /*!< Sigma-delta channel number */
|
||||
int8_t sigmadelta_duty; /*!< Sigma-delta duty, duty ranges from -128 to 127. */
|
||||
uint8_t sigmadelta_prescale; /*!< Sigma-delta prescale, prescale ranges from 0 to 255. */
|
||||
uint8_t sigmadelta_gpio; /*!< Sigma-delta output io number, refer to gpio.h for more details. */
|
||||
} sigmadelta_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
75
tools/sdk/esp32/include/soc/include/hal/soc_hal.h
Normal file
75
tools/sdk/esp32/include/soc/include/hal/soc_hal.h
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/cpu_hal.h"
|
||||
#include "hal/soc_ll.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if SOC_CPU_CORES_NUM > 1
|
||||
// Utility functions for multicore targets
|
||||
#define __SOC_HAL_PERFORM_ON_OTHER_CORES(action) { \
|
||||
for (int i = 0, cur = cpu_hal_get_core_id(); i < SOC_CPU_CORES_NUM; i++) { \
|
||||
if (i != cur) { \
|
||||
action(i); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SOC_HAL_STALL_OTHER_CORES() __SOC_HAL_PERFORM_ON_OTHER_CORES(soc_hal_stall_core);
|
||||
#define SOC_HAL_UNSTALL_OTHER_CORES() __SOC_HAL_PERFORM_ON_OTHER_CORES(soc_hal_unstall_core);
|
||||
#define SOC_HAL_RESET_OTHER_CORES() __SOC_HAL_PERFORM_ON_OTHER_CORES(soc_hal_reset_core);
|
||||
|
||||
/**
|
||||
* Stall the specified CPU core.
|
||||
*
|
||||
* @note Has no effect if the core is already stalled - does not return an
|
||||
* ESP_ERR_INVALID_STATE.
|
||||
*
|
||||
* @param core core to stall [0..SOC_CPU_CORES_NUM - 1]
|
||||
*/
|
||||
void soc_hal_stall_core(int core);
|
||||
|
||||
/**
|
||||
* Unstall the specified CPU core.
|
||||
*
|
||||
* @note Has no effect if the core is already unstalled - does not return an
|
||||
* ESP_ERR_INVALID_STATE.
|
||||
*
|
||||
* @param core core to unstall [0..SOC_CPU_CORES_NUM - 1]
|
||||
*/
|
||||
void soc_hal_unstall_core(int core);
|
||||
|
||||
#endif // SOC_CPU_CORES_NUM > 1
|
||||
|
||||
/**
|
||||
* Reset the specified core.
|
||||
*
|
||||
* @param core core to reset [0..SOC_CPU_CORES_NUM - 1]
|
||||
*/
|
||||
#define soc_hal_reset_core(core) soc_ll_reset_core((core))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
218
tools/sdk/esp32/include/soc/include/hal/spi_flash_hal.h
Normal file
218
tools/sdk/esp32/include/soc/include/hal/spi_flash_hal.h
Normal file
@@ -0,0 +1,218 @@
|
||||
// Copyright 2010-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The HAL is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SPI Flash (common part)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/spi_flash_ll.h"
|
||||
#include "hal/spi_types.h"
|
||||
#include "hal/spi_flash_types.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
/* Hardware host-specific constants */
|
||||
#define SPI_FLASH_HAL_MAX_WRITE_BYTES 64
|
||||
#define SPI_FLASH_HAL_MAX_READ_BYTES 64
|
||||
|
||||
/**
|
||||
* Generic driver context structure for all chips using the SPI peripheral.
|
||||
* Include this into the HEAD of the driver data for other driver
|
||||
* implementations that also use the SPI peripheral.
|
||||
*/
|
||||
typedef struct {
|
||||
spi_dev_t *spi; ///< Pointer to SPI peripheral registers (SP1, SPI2 or SPI3). Set before initialisation.
|
||||
int cs_num; ///< Which cs pin is used, 0-2.
|
||||
int extra_dummy;
|
||||
spi_flash_ll_clock_reg_t clock_conf;
|
||||
} spi_flash_memspi_data_t;
|
||||
|
||||
/// Configuration structure for the SPI driver.
|
||||
typedef struct {
|
||||
spi_host_device_t host_id; ///< SPI peripheral ID.
|
||||
int cs_num; ///< Which cs pin is used, 0-2.
|
||||
bool iomux; ///< Whether the IOMUX is used, used for timing compensation.
|
||||
int input_delay_ns; ///< Input delay on the MISO pin after the launch clock, used for timing compensation.
|
||||
esp_flash_speed_t speed;///< SPI flash clock speed to work at.
|
||||
} spi_flash_memspi_config_t;
|
||||
|
||||
/**
|
||||
* Configure SPI flash hal settings.
|
||||
*
|
||||
* @param data Buffer to hold configured data, the buffer should be in DRAM to be available when cache disabled
|
||||
* @param cfg Configurations to set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_ERR_INVALID_ARG: the data buffer is not in the DRAM.
|
||||
*/
|
||||
esp_err_t spi_flash_hal_init(spi_flash_memspi_data_t *data_out, const spi_flash_memspi_config_t *cfg);
|
||||
|
||||
/**
|
||||
* Configure the device-related register before transactions.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t spi_flash_hal_device_config(spi_flash_host_driver_t *driver);
|
||||
|
||||
/**
|
||||
* Send an user-defined spi transaction to the device.
|
||||
*
|
||||
* @note This is usually used when the memspi interface doesn't support some
|
||||
* particular commands. Since this function supports timing compensation, it is
|
||||
* also used to receive some data when the frequency is high.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param trans The transaction to send, also holds the received data.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t spi_flash_hal_common_command(spi_flash_host_driver_t *driver, spi_flash_trans_t *trans);
|
||||
|
||||
/**
|
||||
* Erase whole flash chip by using the erase chip (C7h) command.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
*/
|
||||
void spi_flash_hal_erase_chip(spi_flash_host_driver_t *driver);
|
||||
|
||||
/**
|
||||
* Erase a specific sector by its start address through the sector erase (20h)
|
||||
* command.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param start_address Start address of the sector to erase.
|
||||
*/
|
||||
void spi_flash_hal_erase_sector(spi_flash_host_driver_t *driver, uint32_t start_address);
|
||||
|
||||
/**
|
||||
* Erase a specific 64KB block by its start address through the 64KB block
|
||||
* erase (D8h) command.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param start_address Start address of the block to erase.
|
||||
*/
|
||||
void spi_flash_hal_erase_block(spi_flash_host_driver_t *driver, uint32_t start_address);
|
||||
|
||||
/**
|
||||
* Program a page of the flash using the page program (02h) command.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param address Address of the page to program
|
||||
* @param buffer Data to program
|
||||
* @param length Size of the buffer in bytes, no larger than ``SPI_FLASH_HAL_MAX_WRITE_BYTES`` (64) bytes.
|
||||
*/
|
||||
void spi_flash_hal_program_page(spi_flash_host_driver_t *driver, const void *buffer, uint32_t address, uint32_t length);
|
||||
|
||||
/**
|
||||
* Read from the flash. Call ``spi_flash_hal_configure_host_read_mode`` to
|
||||
* configure the read command before calling this function.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param buffer Buffer to store the read data
|
||||
* @param address Address to read
|
||||
* @param length Length to read, no larger than ``SPI_FLASH_HAL_MAX_READ_BYTES`` (64) bytes.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t spi_flash_hal_read(spi_flash_host_driver_t *driver, void *buffer, uint32_t address, uint32_t read_len);
|
||||
|
||||
/**
|
||||
* @brief Send the write enable (06h) or write disable (04h) command to the flash chip.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
* @param wp true to enable the write protection, otherwise false.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t spi_flash_hal_set_write_protect(spi_flash_host_driver_t *chip_drv, bool wp);
|
||||
|
||||
/**
|
||||
* Check whether the SPI host is idle and can perform other operations.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
*
|
||||
* @return ture if idle, otherwise false.
|
||||
*/
|
||||
bool spi_flash_hal_host_idle(spi_flash_host_driver_t *driver);
|
||||
|
||||
/**
|
||||
* @brief Configure the SPI host hardware registers for the specified io mode.
|
||||
*
|
||||
* Note that calling this configures SPI host registers, so if running any
|
||||
* other commands as part of set_io_mode() then these must be run before
|
||||
* calling this function.
|
||||
*
|
||||
* The command value, address length and dummy cycles are configured according
|
||||
* to the format of read commands:
|
||||
*
|
||||
* - command: 8 bits, value set.
|
||||
* - address: 24 bits
|
||||
* - dummy: cycles to compensate the input delay
|
||||
* - out & in data: 0 bits.
|
||||
*
|
||||
* The following commands still need to:
|
||||
*
|
||||
* - Read data: set address value and data (length and contents), no need
|
||||
* to touch command and dummy phases.
|
||||
* - Common read: set command value, address value (or length to 0 if not used)
|
||||
* - Common write: set command value, address value (or length to 0 if not
|
||||
* used), disable dummy phase, and set output data.
|
||||
*
|
||||
* @param driver The driver context
|
||||
* @param io_mode The HW read mode to use
|
||||
* @param addr_bitlen Length of the address phase, in bits
|
||||
* @param dummy_cyclelen_base Base cycles of the dummy phase, some extra dummy cycles may be appended to compensate the timing.
|
||||
* @param command Actual reading command to send to flash chip on the bus.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t spi_flash_hal_configure_host_io_mode(spi_flash_host_driver_t *driver, uint32_t command, uint32_t addr_bitlen,
|
||||
int dummy_cyclelen_base, esp_flash_io_mode_t io_mode);
|
||||
|
||||
/**
|
||||
* Poll until the last operation is done.
|
||||
*
|
||||
* @param driver The driver context.
|
||||
*/
|
||||
void spi_flash_hal_poll_cmd_done(spi_flash_host_driver_t *driver);
|
||||
|
||||
/**
|
||||
* Check whether the given buffer can be used as the write buffer directly. If 'chip' is connected to the main SPI bus, we can only write directly from
|
||||
* regions that are accessible ith cache disabled. *
|
||||
*
|
||||
* @param driver The driver context
|
||||
* @param p The buffer holding data to send.
|
||||
*
|
||||
* @return True if the buffer can be used to send data, otherwise false.
|
||||
*/
|
||||
bool spi_flash_hal_supports_direct_write(spi_flash_host_driver_t *driver, const void *p);
|
||||
|
||||
/**
|
||||
* Check whether the given buffer can be used as the read buffer directly. If 'chip' is connected to the main SPI bus, we can only read directly from
|
||||
* regions that are accessible ith cache disabled. *
|
||||
*
|
||||
* @param driver The driver context
|
||||
* @param p The buffer to hold the received data.
|
||||
*
|
||||
* @return True if the buffer can be used to receive data, otherwise false.
|
||||
*/
|
||||
bool spi_flash_hal_supports_direct_read(spi_flash_host_driver_t *driver, const void *p);
|
||||
153
tools/sdk/esp32/include/soc/include/hal/spi_flash_types.h
Normal file
153
tools/sdk/esp32/include/soc/include/hal/spi_flash_types.h
Normal file
@@ -0,0 +1,153 @@
|
||||
// Copyright 2010-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <esp_types.h>
|
||||
#include "esp_flash_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Definition of a common transaction. Also holds the return value. */
|
||||
typedef struct {
|
||||
uint8_t command; ///< Command to send, always 8bits
|
||||
uint8_t mosi_len; ///< Output data length, in bytes
|
||||
uint8_t miso_len; ///< Input data length, in bytes
|
||||
uint8_t address_bitlen; ///< Length of address in bits, set to 0 if command does not need an address
|
||||
uint32_t address; ///< Address to perform operation on
|
||||
const uint8_t *mosi_data; ///< Output data to salve
|
||||
uint8_t *miso_data; ///< [out] Input data from slave, little endian
|
||||
} spi_flash_trans_t;
|
||||
|
||||
/**
|
||||
* @brief SPI flash clock speed values, always refer to them by the enum rather
|
||||
* than the actual value (more speed may be appended into the list).
|
||||
*
|
||||
* A strategy to select the maximum allowed speed is to enumerate from the
|
||||
* ``ESP_FLSH_SPEED_MAX-1`` or highest frequency supported by your flash, and
|
||||
* decrease the speed until the probing success.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_FLASH_5MHZ = 0, ///< The flash runs under 5MHz
|
||||
ESP_FLASH_10MHZ, ///< The flash runs under 10MHz
|
||||
ESP_FLASH_20MHZ, ///< The flash runs under 20MHz
|
||||
ESP_FLASH_26MHZ, ///< The flash runs under 26MHz
|
||||
ESP_FLASH_40MHZ, ///< The flash runs under 40MHz
|
||||
ESP_FLASH_80MHZ, ///< The flash runs under 80MHz
|
||||
ESP_FLASH_SPEED_MAX, ///< The maximum frequency supported by the host is ``ESP_FLASH_SPEED_MAX-1``.
|
||||
} esp_flash_speed_t;
|
||||
|
||||
///Lowest speed supported by the driver, currently 5 MHz
|
||||
#define ESP_FLASH_SPEED_MIN ESP_FLASH_5MHZ
|
||||
|
||||
/** @brief Mode used for reading from SPI flash */
|
||||
typedef enum {
|
||||
SPI_FLASH_SLOWRD = 0, ///< Data read using single I/O, some limits on speed
|
||||
SPI_FLASH_FASTRD, ///< Data read using single I/O, no limit on speed
|
||||
SPI_FLASH_DOUT, ///< Data read using dual I/O
|
||||
SPI_FLASH_DIO, ///< Both address & data transferred using dual I/O
|
||||
SPI_FLASH_QOUT, ///< Data read using quad I/O
|
||||
SPI_FLASH_QIO, ///< Both address & data transferred using quad I/O
|
||||
|
||||
SPI_FLASH_READ_MODE_MAX, ///< The fastest io mode supported by the host is ``ESP_FLASH_READ_MODE_MAX-1``.
|
||||
} esp_flash_io_mode_t;
|
||||
|
||||
///Slowest io mode supported by ESP32, currently SlowRd
|
||||
#define SPI_FLASH_READ_MODE_MIN SPI_FLASH_SLOWRD
|
||||
|
||||
struct spi_flash_host_driver_t;
|
||||
typedef struct spi_flash_host_driver_t spi_flash_host_driver_t;
|
||||
|
||||
/** Host driver configuration and context structure. */
|
||||
struct spi_flash_host_driver_t {
|
||||
/**
|
||||
* Configuration and static data used by the specific host driver. The type
|
||||
* is determined by the host driver.
|
||||
*/
|
||||
void *driver_data;
|
||||
/**
|
||||
* Configure the device-related register before transactions. This saves
|
||||
* some time to re-configure those registers when we send continuously
|
||||
*/
|
||||
esp_err_t (*dev_config)(spi_flash_host_driver_t *driver);
|
||||
/**
|
||||
* Send an user-defined spi transaction to the device.
|
||||
*/
|
||||
esp_err_t (*common_command)(spi_flash_host_driver_t *driver, spi_flash_trans_t *t);
|
||||
/**
|
||||
* Read flash ID.
|
||||
*/
|
||||
esp_err_t (*read_id)(spi_flash_host_driver_t *driver, uint32_t *id);
|
||||
/**
|
||||
* Erase whole flash chip.
|
||||
*/
|
||||
void (*erase_chip)(spi_flash_host_driver_t *driver);
|
||||
/**
|
||||
* Erase a specific sector by its start address.
|
||||
*/
|
||||
void (*erase_sector)(spi_flash_host_driver_t *driver, uint32_t start_address);
|
||||
/**
|
||||
* Erase a specific block by its start address.
|
||||
*/
|
||||
void (*erase_block)(spi_flash_host_driver_t *driver, uint32_t start_address);
|
||||
/**
|
||||
* Read the status of the flash chip.
|
||||
*/
|
||||
esp_err_t (*read_status)(spi_flash_host_driver_t *driver, uint8_t *out_sr);
|
||||
/**
|
||||
* Disable write protection.
|
||||
*/
|
||||
esp_err_t (*set_write_protect)(spi_flash_host_driver_t *driver, bool wp);
|
||||
/**
|
||||
* Program a page of the flash. Check ``max_write_bytes`` for the maximum allowed writing length.
|
||||
*/
|
||||
void (*program_page)(spi_flash_host_driver_t *driver, const void *buffer, uint32_t address, uint32_t length);
|
||||
/** Check whether need to allocate new buffer to write */
|
||||
bool (*supports_direct_write)(spi_flash_host_driver_t *driver, const void *p);
|
||||
/** Check whether need to allocate new buffer to read */
|
||||
bool (*supports_direct_read)(spi_flash_host_driver_t *driver, const void *p);
|
||||
/** maximum length of program_page */
|
||||
int max_write_bytes;
|
||||
/**
|
||||
* Read data from the flash. Check ``max_read_bytes`` for the maximum allowed reading length.
|
||||
*/
|
||||
esp_err_t (*read)(spi_flash_host_driver_t *driver, void *buffer, uint32_t address, uint32_t read_len);
|
||||
/** maximum length of read */
|
||||
int max_read_bytes;
|
||||
/**
|
||||
* Check whether the host is idle to perform new operations.
|
||||
*/
|
||||
bool (*host_idle)(spi_flash_host_driver_t *driver);
|
||||
/**
|
||||
* Configure the host to work at different read mode. Responsible to compensate the timing and set IO mode.
|
||||
*/
|
||||
esp_err_t (*configure_host_io_mode)(spi_flash_host_driver_t *driver, uint32_t command,
|
||||
uint32_t addr_bitlen, int dummy_bitlen_base,
|
||||
esp_flash_io_mode_t io_mode);
|
||||
/**
|
||||
* Internal use, poll the HW until the last operation is done.
|
||||
*/
|
||||
void (*poll_cmd_done)(spi_flash_host_driver_t *driver);
|
||||
/**
|
||||
* For some host (SPI1), they are shared with a cache. When the data is
|
||||
* modified, the cache needs to be flushed. Left NULL if not supported.
|
||||
*/
|
||||
esp_err_t (*flush_cache)(spi_flash_host_driver_t* driver, uint32_t addr, uint32_t size);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
222
tools/sdk/esp32/include/soc/include/hal/spi_hal.h
Normal file
222
tools/sdk/esp32/include/soc/include/hal/spi_hal.h
Normal file
@@ -0,0 +1,222 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SPI master (common part)
|
||||
|
||||
// SPI HAL usages:
|
||||
// 1. initialize the bus
|
||||
// 2. initialize the DMA descriptors if DMA used
|
||||
// 3. setup the clock speed (since this takes long time)
|
||||
// 4. call setup_device to update parameters for the specific device
|
||||
// 5. call setup_trans to update parameters for the specific transaction
|
||||
// 6. prepare data to send, and prepare the receiving buffer
|
||||
// 7. trigger user defined SPI transaction to start
|
||||
// 8. wait until the user transaction is done
|
||||
// 9. fetch the received data
|
||||
// Parameter to be updated only during ``setup_device`` will be highlighted in the
|
||||
// field comments.
|
||||
|
||||
#pragma once
|
||||
#include "hal/spi_ll.h"
|
||||
#include <esp_err.h>
|
||||
#include "soc/lldesc.h"
|
||||
|
||||
/**
|
||||
* Timing configuration structure that should be calculated by
|
||||
* ``spi_hal_setup_clock`` at initialization and hold. Filled into the
|
||||
* ``timing_conf`` member of the context of HAL before setup a device.
|
||||
*/
|
||||
typedef struct {
|
||||
spi_ll_clock_val_t clock_reg; ///< Register value used by the LL layer
|
||||
int timing_dummy; ///< Extra dummy needed to compensate the timing
|
||||
int timing_miso_delay; ///< Extra miso delay clocks to compensate the timing
|
||||
} spi_hal_timing_conf_t;
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL.
|
||||
*/
|
||||
typedef struct {
|
||||
/* configured by driver at initialization, don't touch */
|
||||
spi_dev_t *hw; ///< Beginning address of the peripheral registers.
|
||||
/* should be configured by driver at initialization */
|
||||
lldesc_t *dmadesc_tx; /**< Array of DMA descriptor used by the TX DMA.
|
||||
* The amount should be larger than dmadesc_n. The driver should ensure that
|
||||
* the data to be sent is shorter than the descriptors can hold.
|
||||
*/
|
||||
lldesc_t *dmadesc_rx; /**< Array of DMA descriptor used by the RX DMA.
|
||||
* The amount should be larger than dmadesc_n. The driver should ensure that
|
||||
* the data to be sent is shorter than the descriptors can hold.
|
||||
*/
|
||||
int dmadesc_n; ///< The amount of descriptors of both ``dmadesc_tx`` and ``dmadesc_rx`` that the HAL can use.
|
||||
/*
|
||||
* Device specific, all these parameters will be updated to the peripheral
|
||||
* only when ``spi_hal_setup_device``. They may not get updated when
|
||||
* ``spi_hal_setup_trans``.
|
||||
*/
|
||||
int mode; ///< SPI mode, device specific
|
||||
int cs_setup; ///< Setup time of CS active edge before the first SPI clock, device specific
|
||||
int cs_hold; ///< Hold time of CS inactive edge after the last SPI clock, device specific
|
||||
int cs_pin_id; ///< CS pin to use, 0-2, otherwise all the CS pins are not used. Device specific
|
||||
spi_hal_timing_conf_t *timing_conf; /**< Pointer to an structure holding
|
||||
* the pre-calculated timing configuration for the device at initialization,
|
||||
* device specific
|
||||
*/
|
||||
struct {
|
||||
uint32_t sio : 1; ///< Whether to use SIO mode, device specific
|
||||
uint32_t half_duplex : 1; ///< Whether half duplex mode is used, device specific
|
||||
uint32_t tx_lsbfirst : 1; ///< Whether LSB is sent first for TX data, device specific
|
||||
uint32_t rx_lsbfirst : 1; ///< Whether LSB is received first for RX data, device specific
|
||||
uint32_t dma_enabled : 1; ///< Whether the DMA is enabled, do not update after initialization
|
||||
uint32_t no_compensate : 1; ///< No need to add dummy to compensate the timing, device specific
|
||||
#ifdef SOC_SPI_SUPPORT_AS_CS
|
||||
uint32_t as_cs : 1; ///< Whether to toggle the CS while the clock toggles, device specific
|
||||
#endif
|
||||
uint32_t positive_cs : 1; ///< Whether the postive CS feature is abled, device specific
|
||||
};//boolean configurations
|
||||
|
||||
/*
|
||||
* Transaction specific (data), all these parameters will be updated to the
|
||||
* peripheral every transaction.
|
||||
*/
|
||||
uint16_t cmd; ///< Command value to be sent
|
||||
int cmd_bits; ///< Length (in bits) of the command phase
|
||||
int addr_bits; ///< Length (in bits) of the address phase
|
||||
int dummy_bits; ///< Base length (in bits) of the dummy phase. Note when the compensation is enabled, some extra dummy bits may be appended.
|
||||
int tx_bitlen; ///< TX length, in bits
|
||||
int rx_bitlen; ///< RX length, in bits
|
||||
uint64_t addr; ///< Address value to be sent
|
||||
uint8_t *send_buffer; ///< Data to be sent
|
||||
uint8_t *rcv_buffer; ///< Buffer to hold the receive data.
|
||||
spi_ll_io_mode_t io_mode; ///< IO mode of the master
|
||||
|
||||
} spi_hal_context_t;
|
||||
|
||||
/**
|
||||
* Init the peripheral and the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param host_id Index of the SPI peripheral. 0 for SPI1, 1 for HSPI (SPI2) and 2 for VSPI (SPI3).
|
||||
*/
|
||||
void spi_hal_init(spi_hal_context_t *hal, int host_id);
|
||||
|
||||
/**
|
||||
* Deinit the peripheral (and the context if needed).
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_hal_deinit(spi_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Setup device-related configurations according to the settings in the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_hal_setup_device(const spi_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Setup transaction related configurations according to the settings in the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_hal_setup_trans(const spi_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Prepare the data for the current transaction.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_hal_prepare_data(const spi_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Trigger start a user-defined transaction.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_hal_user_start(const spi_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Check whether the transaction is done (trans_done is set).
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
bool spi_hal_usr_is_done(const spi_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Post transaction operations, mainly fetch data from the buffer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_hal_fetch_result(const spi_hal_context_t *hal);
|
||||
|
||||
/*----------------------------------------------------------
|
||||
* Utils
|
||||
* ---------------------------------------------------------*/
|
||||
/**
|
||||
* Get the configuration of clock and timing. The configuration will be used when ``spi_hal_setup_device``.
|
||||
*
|
||||
* It is highly suggested to do this at initialization, since it takes long time.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param speed_hz Desired frequency.
|
||||
* @param duty_cycle Desired duty cycle of SPI clock
|
||||
* @param use_gpio true if the GPIO matrix is used, otherwise false
|
||||
* @param input_delay_ns Maximum delay between SPI launch clock and the data to
|
||||
* be valid. This is used to compensate/calculate the maximum frequency
|
||||
* allowed. Left 0 if not known.
|
||||
* @param out_freq Output of the actual frequency, left NULL if not required.
|
||||
* @param timing_conf Output of the timing configuration.
|
||||
*
|
||||
* @return ESP_OK if desired is available, otherwise fail.
|
||||
*/
|
||||
esp_err_t spi_hal_get_clock_conf(const spi_hal_context_t *hal, int speed_hz, int duty_cycle, bool use_gpio, int input_delay_ns, int *out_freq, spi_hal_timing_conf_t *timing_conf);
|
||||
|
||||
/**
|
||||
* Get the frequency actual used.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param fapb APB clock frequency.
|
||||
* @param hz Desired frequencyc.
|
||||
* @param duty_cycle Desired duty cycle.
|
||||
*/
|
||||
int spi_hal_master_cal_clock(int fapb, int hz, int duty_cycle);
|
||||
|
||||
/**
|
||||
* Get the timing configuration for given parameters.
|
||||
*
|
||||
* @param eff_clk Actual SPI clock frequency
|
||||
* @param gpio_is_used true if the GPIO matrix is used, otherwise false.
|
||||
* @param input_delay_ns Maximum delay between SPI launch clock and the data to
|
||||
* be valid. This is used to compensate/calculate the maximum frequency
|
||||
* allowed. Left 0 if not known.
|
||||
* @param dummy_n Dummy cycles required to correctly read the data.
|
||||
* @param miso_delay_n suggested delay on the MISO line, in APB clocks.
|
||||
*/
|
||||
void spi_hal_cal_timing(int eff_clk, bool gpio_is_used, int input_delay_ns, int *dummy_n, int *miso_delay_n);
|
||||
|
||||
/**
|
||||
* Get the maximum frequency allowed to read if no compensation is used.
|
||||
*
|
||||
* @param gpio_is_used true if the GPIO matrix is used, otherwise false.
|
||||
* @param input_delay_ns Maximum delay between SPI launch clock and the data to
|
||||
* be valid. This is used to compensate/calculate the maximum frequency
|
||||
* allowed. Left 0 if not known.
|
||||
*/
|
||||
int spi_hal_get_freq_limit(bool gpio_is_used, int input_delay_ns);
|
||||
|
||||
152
tools/sdk/esp32/include/soc/include/hal/spi_slave_hal.h
Normal file
152
tools/sdk/esp32/include/soc/include/hal/spi_slave_hal.h
Normal file
@@ -0,0 +1,152 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for SPI slave (common part)
|
||||
|
||||
// SPI slave HAL usages:
|
||||
// 1. initialize the bus
|
||||
// 2. initialize the DMA descriptors if DMA used
|
||||
// 3. call setup_device to update parameters for the device
|
||||
// 4. prepare data to send, and prepare the receiving buffer
|
||||
// 5. trigger user defined SPI transaction to start
|
||||
// 6. wait until the user transaction is done
|
||||
// 7. store the received data and get the length
|
||||
// 8. check and reset the DMA (if needed) before the next transaction
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/lldesc.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include <esp_types.h>
|
||||
#include "soc/spi_caps.h"
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL.
|
||||
*/
|
||||
typedef struct {
|
||||
/* configured by driver at initialization, don't touch */
|
||||
spi_dev_t *hw; ///< Beginning address of the peripheral registers.
|
||||
/* should be configured by driver at initialization */
|
||||
lldesc_t *dmadesc_rx; /**< Array of DMA descriptor used by the TX DMA.
|
||||
* The amount should be larger than dmadesc_n. The driver should ensure that
|
||||
* the data to be sent is shorter than the descriptors can hold.
|
||||
*/
|
||||
lldesc_t *dmadesc_tx; /**< Array of DMA descriptor used by the RX DMA.
|
||||
* The amount should be larger than dmadesc_n. The driver should ensure that
|
||||
* the data to be sent is shorter than the descriptors can hold.
|
||||
*/
|
||||
int dmadesc_n; ///< The amount of descriptors of both ``dmadesc_tx`` and ``dmadesc_rx`` that the HAL can use.
|
||||
|
||||
/*
|
||||
* configurations to be filled after ``spi_slave_hal_init``. Updated to
|
||||
* peripheral registers when ``spi_slave_hal_setup_device`` is called.
|
||||
*/
|
||||
struct {
|
||||
uint32_t rx_lsbfirst : 1;
|
||||
uint32_t tx_lsbfirst : 1;
|
||||
uint32_t use_dma : 1;
|
||||
};
|
||||
int mode;
|
||||
|
||||
/*
|
||||
* Transaction specific (data), all these parameters will be updated to the
|
||||
* peripheral every transaction.
|
||||
*/
|
||||
uint32_t bitlen; ///< Expected maximum length of the transaction, in bits.
|
||||
const void *tx_buffer; ///< Data to be sent
|
||||
void *rx_buffer; ///< Buffer to hold the received data.
|
||||
|
||||
/* Other transaction result after one transaction */
|
||||
uint32_t rcv_bitlen; ///< Length of the last transaction, in bits.
|
||||
} spi_slave_hal_context_t;
|
||||
|
||||
/**
|
||||
* Init the peripheral and the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param host_id Index of the SPI peripheral. 0 for SPI1, 1 for HSPI (SPI2) and 2 for VSPI (SPI3).
|
||||
*/
|
||||
void spi_slave_hal_init(spi_slave_hal_context_t *hal, int host_id);
|
||||
|
||||
/**
|
||||
* Deinit the peripheral (and the context if needed).
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_slave_hal_deinit(spi_slave_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Setup device-related configurations according to the settings in the context.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_slave_hal_setup_device(const spi_slave_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Prepare the data for the current transaction.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_slave_hal_prepare_data(const spi_slave_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Trigger start a user-defined transaction.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_slave_hal_user_start(const spi_slave_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Check whether the transaction is done (trans_done is set).
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
bool spi_slave_hal_usr_is_done(spi_slave_hal_context_t* hal);
|
||||
|
||||
/**
|
||||
* Post transaction operations, fetch data from the buffer and recored the length.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void spi_slave_hal_store_result(spi_slave_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Get the length of last transaction, in bits. Should be called after ``spi_slave_hal_store_result``.
|
||||
*
|
||||
* Note that if last transaction is longer than configured before, the return
|
||||
* value will be truncated to the configured length.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*
|
||||
* @return Length of the last transaction, in bits.
|
||||
*/
|
||||
uint32_t spi_slave_hal_get_rcv_bitlen(spi_slave_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* Check whether we need to reset the DMA according to the status of last transactions.
|
||||
*
|
||||
* In ESP32, sometimes we may need to reset the DMA for the slave before the
|
||||
* next transaction. Call this to check it.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*
|
||||
* @return true if reset is needed, else false.
|
||||
*/
|
||||
bool spi_slave_hal_dma_need_reset(const spi_slave_hal_context_t *hal);
|
||||
40
tools/sdk/esp32/include/soc/include/hal/spi_types.h
Normal file
40
tools/sdk/esp32/include/soc/include/hal/spi_types.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/spi_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/**
|
||||
* @brief Enum with the three SPI peripherals that are software-accessible in it
|
||||
*/
|
||||
typedef enum {
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2
|
||||
SPI1_HOST=0, ///< SPI1
|
||||
SPI2_HOST=1, ///< SPI2
|
||||
SPI3_HOST=2, ///< SPI3
|
||||
} spi_host_device_t;
|
||||
|
||||
//alias for different chips
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define SPI_HOST SPI1_HOST
|
||||
#define HSPI_HOST SPI2_HOST
|
||||
#define VSPI_HOST SPI3_HOST
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2
|
||||
#define SPI_HOST SPI1_HOST
|
||||
#define FSPI_HOST SPI2_HOST
|
||||
#define HSPI_HOST SPI3_HOST
|
||||
#endif
|
||||
76
tools/sdk/esp32/include/soc/include/hal/systimer_hal.h
Normal file
76
tools/sdk/esp32/include/soc/include/hal/systimer_hal.h
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "hal/systimer_types.h"
|
||||
|
||||
/**
|
||||
* @brief enable systimer counter
|
||||
*/
|
||||
void systimer_hal_enable_counter(systimer_counter_id_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief get current counter value
|
||||
*/
|
||||
uint64_t systimer_hal_get_counter_value(systimer_counter_id_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief get current time (in microseconds)
|
||||
*/
|
||||
uint64_t systimer_hal_get_time(systimer_counter_id_t counter_id);
|
||||
|
||||
/**
|
||||
* @brief set alarm time
|
||||
*/
|
||||
void systimer_hal_set_alarm_value(systimer_alarm_id_t alarm_id, uint64_t timestamp);
|
||||
|
||||
/**
|
||||
* @brief get alarm time
|
||||
*/
|
||||
uint64_t systimer_hal_get_alarm_value(systimer_alarm_id_t alarm_id);
|
||||
|
||||
/**
|
||||
* @brief enable alarm interrupt
|
||||
*/
|
||||
void systimer_hal_enable_alarm_int(systimer_alarm_id_t alarm_id);
|
||||
|
||||
/**
|
||||
* @brief select alarm mode
|
||||
*/
|
||||
void systimer_hal_select_alarm_mode(systimer_alarm_id_t alarm_id, systimer_alarm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief update systimer step when apb clock gets changed
|
||||
*/
|
||||
void systimer_hal_on_apb_freq_update(uint32_t apb_ticks_per_us);
|
||||
|
||||
/**
|
||||
* @brief move systimer counter value forward or backward
|
||||
*/
|
||||
void systimer_hal_counter_value_advance(systimer_counter_id_t counter_id, int64_t time_us);
|
||||
|
||||
/**
|
||||
* @brief initialize systimer in HAL layer
|
||||
*/
|
||||
void systimer_hal_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
74
tools/sdk/esp32/include/soc/include/hal/systimer_types.h
Normal file
74
tools/sdk/esp32/include/soc/include/hal/systimer_types.h
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/systimer_caps.h"
|
||||
|
||||
/*
|
||||
* @brief The structure of the counter value in systimer
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */
|
||||
uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */
|
||||
};
|
||||
uint64_t val; /*!< counter value */
|
||||
};
|
||||
} systimer_counter_value_t;
|
||||
|
||||
/** @cond */
|
||||
_Static_assert(sizeof(systimer_counter_value_t) == 8, "systimer_counter_value_t should occupy 8 bytes in memory");
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief systimer counter ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
SYSTIMER_COUNTER_0, /*!< systimer counter 0 */
|
||||
#if SOC_SYSTIMER_COUNTER_NUM > 1
|
||||
SYSTIEMR_COUNTER_1, /*!< systimer counter 1 */
|
||||
#endif
|
||||
} systimer_counter_id_t;
|
||||
|
||||
/**
|
||||
* @brief systimer alarm ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
SYSTIMER_ALARM_0, /*!< systimer alarm 0 */
|
||||
SYSTIMER_ALARM_1, /*!< systimer alarm 1 */
|
||||
SYSTIMER_ALARM_2, /*!< systimer alarm 2 */
|
||||
} systimer_alarm_id_t;
|
||||
|
||||
/**
|
||||
* @brief systimer alarm mode
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
SYSTIMER_ALARM_MODE_ONESHOT, /*!< systimer alarm oneshot mode */
|
||||
SYSTIMER_ALARM_MODE_PERIOD, /*!< systimer alarm period mode */
|
||||
} systimer_alarm_mode_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
330
tools/sdk/esp32/include/soc/include/hal/timer_hal.h
Normal file
330
tools/sdk/esp32/include/soc/include/hal/timer_hal.h
Normal file
@@ -0,0 +1,330 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for Timer Group.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "hal/timer_ll.h"
|
||||
#include "hal/timer_types.h"
|
||||
#include "soc/timer_group_caps.h"
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
timg_dev_t *dev;
|
||||
timer_idx_t idx;
|
||||
} timer_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Init the timer hal. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param group_num The timer group number
|
||||
* @param timer_num The timer number
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx_t timer_num);
|
||||
|
||||
/**
|
||||
* @brief Get interrupt status register address and corresponding control bits mask
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param status_reg[out] interrupt status register address
|
||||
* @param mask_bit[out] control bits mask
|
||||
*/
|
||||
void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit);
|
||||
|
||||
/**
|
||||
* @brief Set timer clock prescale value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param divider Prescale value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_divider(hal, divider) timer_ll_set_divider((hal)->dev, (hal)->idx, divider)
|
||||
|
||||
/**
|
||||
* @brief Get timer clock prescale value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param divider Pointer to accept the prescale value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_get_divider(hal, divider) timer_ll_get_divider((hal)->dev, (hal)->idx, divider)
|
||||
|
||||
/**
|
||||
* @brief Load counter value into time-base counter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param load_val Counter value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_counter_value(hal, load_val) timer_ll_set_counter_value((hal)->dev, (hal)->idx, load_val)
|
||||
|
||||
/**
|
||||
* @brief Get counter value from time-base counter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param timer_val Pointer to accept the counter value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_get_counter_value(hal, timer_val) timer_ll_get_counter_value((hal)->dev, (hal)->idx, timer_val)
|
||||
|
||||
/**
|
||||
* @brief Set counter mode, include increment mode and decrement mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param increase_en True to increment mode, fasle to decrement mode
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_counter_increase(hal, increase_en) timer_ll_set_counter_increase((hal)->dev, (hal)->idx, increase_en)
|
||||
|
||||
/**
|
||||
* @brief Get counter mode, include increment mode and decrement mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param counter_dir Pointer to accept the counter mode
|
||||
*
|
||||
* @return
|
||||
* - true Increment mode
|
||||
* - false Decrement mode
|
||||
*/
|
||||
#define timer_hal_get_counter_increase(hal) timer_ll_get_counter_increase((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Set counter status, enable or disable counter.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param counter_en True to enable counter, false to disable counter
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_counter_enable(hal, counter_en) timer_ll_set_counter_enable((hal)->dev, (hal)->idx, counter_en)
|
||||
|
||||
/**
|
||||
* @brief Get counter status.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return
|
||||
* - true Enable counter
|
||||
* - false Disable conuter
|
||||
*/
|
||||
#define timer_hal_get_counter_enable(hal) timer_ll_get_counter_enable((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Set auto reload mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param auto_reload_en True to enable auto reload mode, flase to disable auto reload mode
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_auto_reload(hal, auto_reload_en) timer_ll_set_auto_reload((hal)->dev, (hal)->idx, auto_reload_en)
|
||||
|
||||
/**
|
||||
* @brief Get auto reload mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return
|
||||
* - true Enable auto reload mode
|
||||
* - false Disable auto reload mode
|
||||
*/
|
||||
#define timer_hal_get_auto_reload(hal) timer_ll_get_auto_reload((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Set the counter value to trigger the alarm.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param alarm_value Counter value to trigger the alarm
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_alarm_value(hal, alarm_value) timer_ll_set_alarm_value((hal)->dev, (hal)->idx, alarm_value)
|
||||
|
||||
/**
|
||||
* @brief Get the counter value to trigger the alarm.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param alarm_value Pointer to accept the counter value to trigger the alarm
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_get_alarm_value(hal, alarm_value) timer_ll_get_alarm_value((hal)->dev, (hal)->idx, alarm_value)
|
||||
|
||||
/**
|
||||
* @brief Set the alarm status, enable or disable the alarm.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param alarm_en True to enable alarm, false to disable alarm
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_alarm_enable(hal, alarm_en) timer_ll_set_alarm_enable((hal)->dev, (hal)->idx, alarm_en)
|
||||
|
||||
/**
|
||||
* @brief Get the alarm status.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return
|
||||
* - true Enable alarm
|
||||
* - false Disable alarm
|
||||
*/
|
||||
#define timer_hal_get_alarm_enable(hal) timer_ll_get_alarm_enable((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Set the level interrupt status, enable or disable the level interrupt.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param level_int_en True to enable level interrupt, false to disable level interrupt
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_level_int_enable(hal, level_int_en) timer_ll_set_level_int_enable((hal)->dev, (hal)->idx, level_int_en)
|
||||
|
||||
/**
|
||||
* @brief Get the level interrupt status.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return
|
||||
* - true Enable level interrupt
|
||||
* - false Disable level interrupt
|
||||
*/
|
||||
#define timer_hal_get_level_int_enable(hal) timer_ll_get_level_int_enable((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Set the edge interrupt status, enable or disable the edge interrupt.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param edge_int_en True to enable edge interrupt, false to disable edge interrupt
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_edge_int_enable(hal, edge_int_en) timer_ll_set_edge_int_enable((hal)->dev, (hal)->idx, edge_int_en)
|
||||
|
||||
/**
|
||||
* @brief Get the edge interrupt status.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return
|
||||
* - true Enable edge interrupt
|
||||
* - false Disable edge interrupt
|
||||
*/
|
||||
#define timer_hal_get_edge_int_enable(hal) timer_ll_get_edge_int_enable((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Enable timer interrupt.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_intr_enable(hal) timer_ll_intr_enable((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Disable timer interrupt.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_intr_disable(hal) timer_ll_intr_disable((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Clear interrupt status.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_clear_intr_status(hal) timer_ll_clear_intr_status((hal)->dev, (hal)->idx)
|
||||
|
||||
/**
|
||||
* @brief Get interrupt status.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param intr_status Interrupt status
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_get_intr_status(hal, intr_status) timer_ll_get_intr_status((hal)->dev, intr_status)
|
||||
|
||||
/**
|
||||
* @brief Get interrupt raw status.
|
||||
*
|
||||
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
|
||||
* @param intr_raw_status Interrupt raw status
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_get_intr_raw_status(group_num, intr_raw_status) timer_ll_get_intr_raw_status(group_num, intr_raw_status)
|
||||
|
||||
/**
|
||||
* @brief Get interrupt status register address.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return Interrupt status register address
|
||||
*/
|
||||
#define timer_hal_get_intr_status_reg(hal) timer_ll_get_intr_status_reg((hal)->dev)
|
||||
|
||||
#ifdef SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
/**
|
||||
* @brief Set clock source.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param use_xtal_en True to use XTAL clock, flase to use APB clock
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define timer_hal_set_use_xtal(hal, use_xtal_en) timer_ll_set_use_xtal((hal)->dev, (hal)->idx, use_xtal_en)
|
||||
|
||||
/**
|
||||
* @brief Get clock source.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return
|
||||
* - true Use XTAL clock
|
||||
* - false Use APB clock
|
||||
*/
|
||||
#define timer_hal_get_use_xtal(hal) timer_ll_get_use_xtal((hal)->dev, (hal)->idx)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
128
tools/sdk/esp32/include/soc/include/hal/timer_types.h
Normal file
128
tools/sdk/esp32/include/soc/include/hal/timer_types.h
Normal file
@@ -0,0 +1,128 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <esp_bit_defs.h>
|
||||
#include "soc/timer_group_caps.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
/**
|
||||
* @brief Selects a Timer-Group out of 2 available groups
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_GROUP_0 = 0, /*!<Hw timer group 0*/
|
||||
TIMER_GROUP_1 = 1, /*!<Hw timer group 1*/
|
||||
TIMER_GROUP_MAX,
|
||||
} timer_group_t;
|
||||
|
||||
/**
|
||||
* @brief Select a hardware timer from timer groups
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_0 = 0, /*!<Select timer0 of GROUPx*/
|
||||
TIMER_1 = 1, /*!<Select timer1 of GROUPx*/
|
||||
TIMER_MAX,
|
||||
} timer_idx_t;
|
||||
|
||||
/**
|
||||
* @brief Decides the direction of counter
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_COUNT_DOWN = 0, /*!< Descending Count from cnt.high|cnt.low*/
|
||||
TIMER_COUNT_UP = 1, /*!< Ascending Count from Zero*/
|
||||
TIMER_COUNT_MAX
|
||||
} timer_count_dir_t;
|
||||
|
||||
/**
|
||||
* @brief Decides whether timer is on or paused
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_PAUSE = 0, /*!<Pause timer counter*/
|
||||
TIMER_START = 1, /*!<Start timer counter*/
|
||||
} timer_start_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt types of the timer.
|
||||
*/
|
||||
//this is compatible with the value of esp32.
|
||||
typedef enum {
|
||||
TIMER_INTR_T0 = BIT(0), /*!< interrupt of timer 0 */
|
||||
TIMER_INTR_T1 = BIT(1), /*!< interrupt of timer 1 */
|
||||
TIMER_INTR_WDT = BIT(2), /*!< interrupt of watchdog */
|
||||
TIMER_INTR_NONE = 0
|
||||
} timer_intr_t;
|
||||
FLAG_ATTR(timer_intr_t)
|
||||
|
||||
/**
|
||||
* @brief Decides whether to enable alarm mode
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_ALARM_DIS = 0, /*!< Disable timer alarm*/
|
||||
TIMER_ALARM_EN = 1, /*!< Enable timer alarm*/
|
||||
TIMER_ALARM_MAX
|
||||
} timer_alarm_t;
|
||||
|
||||
/**
|
||||
* @brief Select interrupt type if running in alarm mode.
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_INTR_LEVEL = 0, /*!< Interrupt mode: level mode*/
|
||||
//TIMER_INTR_EDGE = 1, /*!< Interrupt mode: edge mode, Not supported Now*/
|
||||
TIMER_INTR_MAX
|
||||
} timer_intr_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Select if Alarm needs to be loaded by software or automatically reload by hardware.
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_AUTORELOAD_DIS = 0, /*!< Disable auto-reload: hardware will not load counter value after an alarm event*/
|
||||
TIMER_AUTORELOAD_EN = 1, /*!< Enable auto-reload: hardware will load counter value after an alarm event*/
|
||||
TIMER_AUTORELOAD_MAX,
|
||||
} timer_autoreload_t;
|
||||
|
||||
#ifdef SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
/**
|
||||
* @brief Select timer source clock.
|
||||
*/
|
||||
typedef enum {
|
||||
TIMER_SRC_CLK_APB = 0, /*!< Select APB as the source clock*/
|
||||
TIMER_SRC_CLK_XTAL = 1, /*!< Select XTAL as the source clock*/
|
||||
} timer_src_clk_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Data structure with timer's configuration settings
|
||||
*/
|
||||
typedef struct {
|
||||
timer_alarm_t alarm_en; /*!< Timer alarm enable */
|
||||
timer_start_t counter_en; /*!< Counter enable */
|
||||
timer_intr_mode_t intr_type; /*!< Interrupt mode */
|
||||
timer_count_dir_t counter_dir; /*!< Counter direction */
|
||||
timer_autoreload_t auto_reload; /*!< Timer auto-reload */
|
||||
uint32_t divider; /*!< Counter clock divider. The divider's range is from from 2 to 65536. */
|
||||
#ifdef SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
timer_src_clk_t clk_src; /*!< Use XTAL as source clock. */
|
||||
#endif
|
||||
} timer_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
225
tools/sdk/esp32/include/soc/include/hal/touch_sensor_hal.h
Normal file
225
tools/sdk/esp32/include/soc/include/hal/touch_sensor_hal.h
Normal file
@@ -0,0 +1,225 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for touch sensor (common part)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/touch_sensor_ll.h"
|
||||
#include "hal/touch_sensor_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
touch_high_volt_t refh;
|
||||
touch_low_volt_t refl;
|
||||
touch_volt_atten_t atten;
|
||||
} touch_hal_volt_t;
|
||||
|
||||
typedef struct {
|
||||
touch_cnt_slope_t slope; /*!<Set touch sensor charge/discharge speed(currents) for each pad.*/
|
||||
touch_tie_opt_t tie_opt; /*!<Set initial voltage state of touch channel for each measurement.*/
|
||||
} touch_hal_meas_mode_t;
|
||||
|
||||
/**
|
||||
* Set touch sensor sleep time (interval of measurement).
|
||||
*
|
||||
* @param sleep_time The touch sensor will sleep after each measurement.
|
||||
* sleep_cycle decide the interval between each measurement.
|
||||
* t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
|
||||
* The approximate frequency value of RTC_SLOW_CLK can be obtained using `rtc_clk_slow_freq_get_hz` function.
|
||||
*/
|
||||
#define touch_hal_set_sleep_time(sleep_time) touch_ll_set_sleep_time(sleep_time)
|
||||
|
||||
/**
|
||||
* Get touch sensor sleep time.
|
||||
*
|
||||
* @param sleep_time Pointer to accept sleep cycle count.
|
||||
*/
|
||||
#define touch_hal_get_sleep_time(sleep_time) touch_ll_get_sleep_time(sleep_time)
|
||||
|
||||
/**
|
||||
* Set touch sensor high / low voltage threshold of chanrge.
|
||||
* The touch sensor measures the channel capacitance value by charging and discharging the channel.
|
||||
* So charge threshold should be less than the supply voltage.
|
||||
* The actual charge threshold is high voltage threshold minus attenuation value.
|
||||
*
|
||||
* @param refh The high voltage threshold of chanrge.
|
||||
*/
|
||||
void touch_hal_set_voltage(const touch_hal_volt_t *volt);
|
||||
|
||||
/**
|
||||
* Get touch sensor high / low voltage threshold of chanrge.
|
||||
* The touch sensor measures the channel capacitance value by charging and discharging the channel.
|
||||
* So charge threshold should be less than the supply voltage.
|
||||
* The actual charge threshold is high voltage threshold minus attenuation value.
|
||||
*
|
||||
* @param refh The voltage threshold of chanrge / discharge.
|
||||
*/
|
||||
void touch_hal_get_voltage(touch_hal_volt_t *volt);
|
||||
|
||||
/**
|
||||
* Set touch sensor charge/discharge speed(currents) and initial voltage state for each pad measurement.
|
||||
*
|
||||
* @param touch_num Touch pad index.
|
||||
* @param meas Touch pad measurement config.
|
||||
*/
|
||||
void touch_hal_set_meas_mode(touch_pad_t touch_num, const touch_hal_meas_mode_t *meas);
|
||||
|
||||
/**
|
||||
* Get touch sensor charge/discharge speed(currents) and initial voltage state for each pad measurement.
|
||||
*
|
||||
* @param touch_num Touch pad index.
|
||||
* @param meas Touch pad measurement config.
|
||||
*/
|
||||
void touch_hal_get_meas_mode(touch_pad_t touch_num, touch_hal_meas_mode_t *meas);
|
||||
|
||||
/**
|
||||
* Set touch sensor FSM mode.
|
||||
* The measurement action can be triggered by the hardware timer, as well as by the software instruction.
|
||||
*
|
||||
* @param mode FSM mode.
|
||||
*/
|
||||
#define touch_hal_set_fsm_mode(mode) touch_ll_set_fsm_mode(mode)
|
||||
|
||||
/**
|
||||
* Get touch sensor FSM mode.
|
||||
* The measurement action can be triggered by the hardware timer, as well as by the software instruction.
|
||||
*
|
||||
* @param mode FSM mode.
|
||||
*/
|
||||
#define touch_hal_get_fsm_mode(mode) touch_ll_get_fsm_mode(mode)
|
||||
|
||||
/**
|
||||
* Start touch sensor FSM timer.
|
||||
* The measurement action can be triggered by the hardware timer, as well as by the software instruction.
|
||||
*/
|
||||
#define touch_hal_start_fsm() touch_ll_start_fsm()
|
||||
|
||||
/**
|
||||
* Stop touch sensor FSM timer.
|
||||
* The measurement action can be triggered by the hardware timer, as well as by the software instruction.
|
||||
*/
|
||||
#define touch_hal_stop_fsm() touch_ll_stop_fsm()
|
||||
|
||||
/**
|
||||
* Trigger a touch sensor measurement, only support in SW mode of FSM.
|
||||
*/
|
||||
#define touch_hal_start_sw_meas() touch_ll_start_sw_meas()
|
||||
|
||||
/**
|
||||
* Set touch sensor interrupt threshold.
|
||||
*
|
||||
* @note Refer to `touch_pad_set_trigger_mode` to see how to set trigger mode.
|
||||
* @param touch_num touch pad index.
|
||||
* @param threshold threshold of touchpad count.
|
||||
*/
|
||||
#define touch_hal_set_threshold(touch_num, threshold) touch_ll_set_threshold(touch_num, threshold)
|
||||
|
||||
/**
|
||||
* Get touch sensor interrupt threshold.
|
||||
*
|
||||
* @param touch_num touch pad index.
|
||||
* @param threshold pointer to accept threshold.
|
||||
*/
|
||||
#define touch_hal_get_threshold(touch_num, threshold) touch_ll_get_threshold(touch_num, threshold)
|
||||
|
||||
/**
|
||||
* Enable touch sensor channel. Register touch channel into touch sensor measurement group.
|
||||
* The working mode of the touch sensor is simultaneous measurement.
|
||||
* This function will set the measure bits according to the given bitmask.
|
||||
*
|
||||
* @note If set this mask, the FSM timer should be stop firsty.
|
||||
* @note The touch sensor that in scan map, should be deinit GPIO function firstly.
|
||||
* @param enable_mask bitmask of touch sensor scan group.
|
||||
* e.g. TOUCH_PAD_NUM1 -> BIT(1)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
#define touch_hal_set_channel_mask(enable_mask) touch_ll_set_channel_mask(enable_mask)
|
||||
|
||||
/**
|
||||
* Get touch sensor channel mask.
|
||||
*
|
||||
* @param enable_mask bitmask of touch sensor scan group.
|
||||
* e.g. TOUCH_PAD_NUM1 -> BIT(1)
|
||||
*/
|
||||
#define touch_hal_get_channel_mask(enable_mask) touch_ll_get_channel_mask(enable_mask)
|
||||
|
||||
/**
|
||||
* Disable touch sensor channel by bitmask.
|
||||
*
|
||||
* @param enable_mask bitmask of touch sensor scan group.
|
||||
* e.g. TOUCH_PAD_NUM1 -> BIT(1)
|
||||
*/
|
||||
#define touch_hal_clear_channel_mask(disable_mask) touch_ll_clear_channel_mask(disable_mask)
|
||||
|
||||
/**
|
||||
* Get the touch sensor status, usually used in ISR to decide which pads are 'touched'.
|
||||
*
|
||||
* @param status_mask The touch sensor status. e.g. Touch1 trigger status is `status_mask & (BIT1)`.
|
||||
*/
|
||||
#define touch_hal_read_trigger_status_mask(status_mask) touch_ll_read_trigger_status_mask(status_mask)
|
||||
|
||||
/**
|
||||
* Clear all touch sensor status.
|
||||
*/
|
||||
#define touch_hal_clear_trigger_status_mask() touch_ll_clear_trigger_status_mask()
|
||||
|
||||
/**
|
||||
* Get touch sensor raw data (touch sensor counter value) from register. No block.
|
||||
*
|
||||
* @param touch_num touch pad index.
|
||||
* @return touch_value pointer to accept touch sensor value.
|
||||
*/
|
||||
#define touch_hal_read_raw_data(touch_num) touch_ll_read_raw_data(touch_num)
|
||||
|
||||
/**
|
||||
* Get touch sensor measure status. No block.
|
||||
*
|
||||
* @return
|
||||
* - If touch sensors measure done.
|
||||
*/
|
||||
#define touch_hal_meas_is_done() touch_ll_meas_is_done()
|
||||
|
||||
/**
|
||||
* Initialize touch module.
|
||||
*
|
||||
* @note If default parameter don't match the usage scenario, it can be changed after this function.
|
||||
*/
|
||||
void touch_hal_init(void);
|
||||
|
||||
/**
|
||||
* Un-install touch pad driver.
|
||||
*
|
||||
* @note After this function is called, other touch functions are prohibited from being called.
|
||||
*/
|
||||
void touch_hal_deinit(void);
|
||||
|
||||
/**
|
||||
* Configure touch sensor for each channel.
|
||||
*/
|
||||
void touch_hal_config(touch_pad_t touch_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
298
tools/sdk/esp32/include/soc/include/hal/touch_sensor_types.h
Normal file
298
tools/sdk/esp32/include/soc/include/hal/touch_sensor_types.h
Normal file
@@ -0,0 +1,298 @@
|
||||
// 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/touch_sensor_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
/** Touch pad channel */
|
||||
typedef enum {
|
||||
TOUCH_PAD_NUM0 = 0, /*!< Touch pad channel 0 is GPIO4(ESP32) */
|
||||
TOUCH_PAD_NUM1, /*!< Touch pad channel 1 is GPIO0(ESP32) / GPIO1(ESP32-S2) */
|
||||
TOUCH_PAD_NUM2, /*!< Touch pad channel 2 is GPIO2(ESP32) / GPIO2(ESP32-S2) */
|
||||
TOUCH_PAD_NUM3, /*!< Touch pad channel 3 is GPIO15(ESP32) / GPIO3(ESP32-S2) */
|
||||
TOUCH_PAD_NUM4, /*!< Touch pad channel 4 is GPIO13(ESP32) / GPIO4(ESP32-S2) */
|
||||
TOUCH_PAD_NUM5, /*!< Touch pad channel 5 is GPIO12(ESP32) / GPIO5(ESP32-S2) */
|
||||
TOUCH_PAD_NUM6, /*!< Touch pad channel 6 is GPIO14(ESP32) / GPIO6(ESP32-S2) */
|
||||
TOUCH_PAD_NUM7, /*!< Touch pad channel 7 is GPIO27(ESP32) / GPIO7(ESP32-S2) */
|
||||
TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO33(ESP32) / GPIO8(ESP32-S2) */
|
||||
TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO32(ESP32) / GPIO9(ESP32-S2) */
|
||||
#if SOC_TOUCH_SENSOR_NUM > 10
|
||||
TOUCH_PAD_NUM10, /*!< Touch channel 10 is GPIO10(ESP32-S2) */
|
||||
TOUCH_PAD_NUM11, /*!< Touch channel 11 is GPIO11(ESP32-S2) */
|
||||
TOUCH_PAD_NUM12, /*!< Touch channel 12 is GPIO12(ESP32-S2) */
|
||||
TOUCH_PAD_NUM13, /*!< Touch channel 13 is GPIO13(ESP32-S2) */
|
||||
TOUCH_PAD_NUM14, /*!< Touch channel 14 is GPIO14(ESP32-S2) */
|
||||
#endif
|
||||
TOUCH_PAD_MAX,
|
||||
} touch_pad_t;
|
||||
|
||||
/** Touch sensor high reference voltage */
|
||||
typedef enum {
|
||||
TOUCH_HVOLT_KEEP = -1, /*!<Touch sensor high reference voltage, no change */
|
||||
TOUCH_HVOLT_2V4 = 0, /*!<Touch sensor high reference voltage, 2.4V */
|
||||
TOUCH_HVOLT_2V5, /*!<Touch sensor high reference voltage, 2.5V */
|
||||
TOUCH_HVOLT_2V6, /*!<Touch sensor high reference voltage, 2.6V */
|
||||
TOUCH_HVOLT_2V7, /*!<Touch sensor high reference voltage, 2.7V */
|
||||
TOUCH_HVOLT_MAX,
|
||||
} touch_high_volt_t;
|
||||
|
||||
/** Touch sensor low reference voltage */
|
||||
typedef enum {
|
||||
TOUCH_LVOLT_KEEP = -1, /*!<Touch sensor low reference voltage, no change */
|
||||
TOUCH_LVOLT_0V5 = 0, /*!<Touch sensor low reference voltage, 0.5V */
|
||||
TOUCH_LVOLT_0V6, /*!<Touch sensor low reference voltage, 0.6V */
|
||||
TOUCH_LVOLT_0V7, /*!<Touch sensor low reference voltage, 0.7V */
|
||||
TOUCH_LVOLT_0V8, /*!<Touch sensor low reference voltage, 0.8V */
|
||||
TOUCH_LVOLT_MAX,
|
||||
} touch_low_volt_t;
|
||||
|
||||
/** Touch sensor high reference voltage attenuation */
|
||||
typedef enum {
|
||||
TOUCH_HVOLT_ATTEN_KEEP = -1, /*!<Touch sensor high reference voltage attenuation, no change */
|
||||
TOUCH_HVOLT_ATTEN_1V5 = 0, /*!<Touch sensor high reference voltage attenuation, 1.5V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_1V, /*!<Touch sensor high reference voltage attenuation, 1.0V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_0V5, /*!<Touch sensor high reference voltage attenuation, 0.5V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_0V, /*!<Touch sensor high reference voltage attenuation, 0V attenuation */
|
||||
TOUCH_HVOLT_ATTEN_MAX,
|
||||
} touch_volt_atten_t;
|
||||
|
||||
/** Touch sensor charge/discharge speed */
|
||||
typedef enum {
|
||||
TOUCH_PAD_SLOPE_0 = 0, /*!<Touch sensor charge / discharge speed, always zero */
|
||||
TOUCH_PAD_SLOPE_1 = 1, /*!<Touch sensor charge / discharge speed, slowest */
|
||||
TOUCH_PAD_SLOPE_2 = 2, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_3 = 3, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_4 = 4, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_5 = 5, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_6 = 6, /*!<Touch sensor charge / discharge speed */
|
||||
TOUCH_PAD_SLOPE_7 = 7, /*!<Touch sensor charge / discharge speed, fast */
|
||||
TOUCH_PAD_SLOPE_MAX,
|
||||
} touch_cnt_slope_t;
|
||||
|
||||
/** Touch sensor initial charge level */
|
||||
typedef enum {
|
||||
TOUCH_PAD_TIE_OPT_LOW = 0, /*!<Initial level of charging voltage, low level */
|
||||
TOUCH_PAD_TIE_OPT_HIGH = 1, /*!<Initial level of charging voltage, high level */
|
||||
TOUCH_PAD_TIE_OPT_MAX,
|
||||
} touch_tie_opt_t;
|
||||
|
||||
/** Touch sensor FSM mode */
|
||||
typedef enum {
|
||||
TOUCH_FSM_MODE_TIMER = 0, /*!<To start touch FSM by timer */
|
||||
TOUCH_FSM_MODE_SW, /*!<To start touch FSM by software trigger */
|
||||
TOUCH_FSM_MODE_MAX,
|
||||
} touch_fsm_mode_t;
|
||||
|
||||
/**** ESP32 Only *****/
|
||||
|
||||
typedef enum {
|
||||
TOUCH_TRIGGER_BELOW = 0, /*!<Touch interrupt will happen if counter value is less than threshold.*/
|
||||
TOUCH_TRIGGER_ABOVE = 1, /*!<Touch interrupt will happen if counter value is larger than threshold.*/
|
||||
TOUCH_TRIGGER_MAX,
|
||||
} touch_trigger_mode_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_TRIGGER_SOURCE_BOTH = 0, /*!< wakeup interrupt is generated if both SET1 and SET2 are "touched"*/
|
||||
TOUCH_TRIGGER_SOURCE_SET1 = 1, /*!< wakeup interrupt is generated if SET1 is "touched"*/
|
||||
TOUCH_TRIGGER_SOURCE_MAX,
|
||||
} touch_trigger_src_t;
|
||||
|
||||
/********************************/
|
||||
#define TOUCH_PAD_SLOPE_DEFAULT (TOUCH_PAD_SLOPE_7)
|
||||
#define TOUCH_PAD_TIE_OPT_DEFAULT (TOUCH_PAD_TIE_OPT_LOW)
|
||||
#define TOUCH_PAD_BIT_MASK_MAX (SOC_TOUCH_SENSOR_BIT_MASK_MAX)
|
||||
#define TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD (TOUCH_HVOLT_2V7)
|
||||
#define TOUCH_PAD_LOW_VOLTAGE_THRESHOLD (TOUCH_LVOLT_0V5)
|
||||
#define TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD (TOUCH_HVOLT_ATTEN_0V5)
|
||||
#define TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT (TOUCH_PAD_CONN_GND)
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (SOC_TOUCH_PAD_THRESHOLD_MAX) /*!<If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#define TOUCH_PAD_SLEEP_CYCLE_DEFAULT (0x1000) /*!<The timer frequency is RTC_SLOW_CLK (can be 150k or 32k depending on the options), max value is 0xffff */
|
||||
#define TOUCH_PAD_MEASURE_CYCLE_DEFAULT (0x7fff) /*!<The timer frequency is 8Mhz, the max value is 0x7fff */
|
||||
#define TOUCH_FSM_MODE_DEFAULT (TOUCH_FSM_MODE_SW) /*!<The touch FSM my be started by the software or timer */
|
||||
#define TOUCH_TRIGGER_MODE_DEFAULT (TOUCH_TRIGGER_BELOW) /*!<Interrupts can be triggered if sensor value gets below or above threshold */
|
||||
#define TOUCH_TRIGGER_SOURCE_DEFAULT (TOUCH_TRIGGER_SOURCE_SET1) /*!<The wakeup trigger source can be SET1 or both SET1 and SET2 */
|
||||
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
/**
|
||||
* Excessive total time will slow down the touch response.
|
||||
* Too small measurement time will not be sampled enough, resulting in inaccurate measurements.
|
||||
*
|
||||
* @note The greater the duty cycle of the measurement time, the more system power is consumed.
|
||||
*/
|
||||
#define TOUCH_PAD_SLEEP_CYCLE_DEFAULT (0xf) /*!<The number of sleep cycle in each measure process of touch channels.
|
||||
The timer frequency is RTC_SLOW_CLK (can be 150k or 32k depending on the options).
|
||||
Range: 0 ~ 0xffff */
|
||||
#define TOUCH_PAD_MEASURE_CYCLE_DEFAULT (500) /*!<The times of charge and discharge in each measure process of touch channels.
|
||||
The timer frequency is 8Mhz.
|
||||
Recommended typical value: Modify this value to make the measurement time around 1ms.
|
||||
Range: 0 ~ 0xffff */
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_INTR_MASK_DONE = BIT(0), /*!<Measurement done for one of the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_ACTIVE = BIT(1), /*!<Active for one of the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_INACTIVE = BIT(2), /*!<Inactive for one of the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_SCAN_DONE = BIT(3), /*!<Measurement done for all the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_TIMEOUT = BIT(4), /*!<Timeout for one of the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_MAX
|
||||
#define TOUCH_PAD_INTR_MASK_ALL (TOUCH_PAD_INTR_MASK_TIMEOUT \
|
||||
| TOUCH_PAD_INTR_MASK_SCAN_DONE \
|
||||
| TOUCH_PAD_INTR_MASK_INACTIVE \
|
||||
| TOUCH_PAD_INTR_MASK_ACTIVE \
|
||||
| TOUCH_PAD_INTR_MASK_DONE) /*!<All touch interrupt type enable. */
|
||||
} touch_pad_intr_mask_t;
|
||||
FLAG_ATTR(touch_pad_intr_mask_t)
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_DENOISE_BIT12 = 0, /*!<Denoise range is 12bit */
|
||||
TOUCH_PAD_DENOISE_BIT10 = 1, /*!<Denoise range is 10bit */
|
||||
TOUCH_PAD_DENOISE_BIT8 = 2, /*!<Denoise range is 8bit */
|
||||
TOUCH_PAD_DENOISE_BIT4 = 3, /*!<Denoise range is 4bit */
|
||||
TOUCH_PAD_DENOISE_MAX
|
||||
} touch_pad_denoise_grade_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_DENOISE_CAP_L0 = 0, /*!<Denoise channel internal reference capacitance is 5pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L1 = 1, /*!<Denoise channel internal reference capacitance is 6.4pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L2 = 2, /*!<Denoise channel internal reference capacitance is 7.8pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L3 = 3, /*!<Denoise channel internal reference capacitance is 9.2pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L4 = 4, /*!<Denoise channel internal reference capacitance is 10.6pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L5 = 5, /*!<Denoise channel internal reference capacitance is 12.0pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L6 = 6, /*!<Denoise channel internal reference capacitance is 13.4pf */
|
||||
TOUCH_PAD_DENOISE_CAP_L7 = 7, /*!<Denoise channel internal reference capacitance is 14.8pf */
|
||||
TOUCH_PAD_DENOISE_CAP_MAX = 8
|
||||
} touch_pad_denoise_cap_t;
|
||||
|
||||
/** Touch sensor denoise configuration */
|
||||
typedef struct touch_pad_denoise {
|
||||
touch_pad_denoise_grade_t grade; /*!<Select denoise range of denoise channel.
|
||||
Determined by measuring the noise amplitude of the denoise channel. */
|
||||
touch_pad_denoise_cap_t cap_level; /*!<Select internal reference capacitance of denoise channel.
|
||||
Ensure that the denoise readings are closest to the readings of the channel being measured.
|
||||
Use `touch_pad_denoise_read_data` to get the reading of denoise channel.
|
||||
The equivalent capacitance of the shielded channel can be calculated
|
||||
from the reading of denoise channel. */
|
||||
} touch_pad_denoise_t;
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_SHIELD_DRV_L0 = 0,/*!<The max equivalent capacitance in shield channel is 40pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L1, /*!<The max equivalent capacitance in shield channel is 80pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L2, /*!<The max equivalent capacitance in shield channel is 120pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L3, /*!<The max equivalent capacitance in shield channel is 160pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L4, /*!<The max equivalent capacitance in shield channel is 200pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L5, /*!<The max equivalent capacitance in shield channel is 240pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L6, /*!<The max equivalent capacitance in shield channel is 280pf */
|
||||
TOUCH_PAD_SHIELD_DRV_L7, /*!<The max equivalent capacitance in shield channel is 320pf */
|
||||
TOUCH_PAD_SHIELD_DRV_MAX
|
||||
} touch_pad_shield_driver_t;
|
||||
|
||||
/** Touch sensor waterproof configuration */
|
||||
typedef struct touch_pad_waterproof {
|
||||
touch_pad_t guard_ring_pad; /*!<Waterproof. Select touch channel use for guard pad */
|
||||
touch_pad_shield_driver_t shield_driver;/*!<Waterproof. Select max equivalent capacitance for shield pad
|
||||
Config the Touch14 to the touch sensor and compare the measured
|
||||
reading to the Touch0 reading to estimate the equivalent capacitance.*/
|
||||
} touch_pad_waterproof_t;
|
||||
|
||||
/** Touch sensor proximity detection configuration */
|
||||
#define TOUCH_PROXIMITY_MEAS_NUM_MAX (0xFF)
|
||||
|
||||
/** Touch channel idle state configuration */
|
||||
typedef enum {
|
||||
TOUCH_PAD_CONN_HIGHZ = 0, /*!<Idle status of touch channel is high resistance state */
|
||||
TOUCH_PAD_CONN_GND = 1, /*!<Idle status of touch channel is ground connection */
|
||||
TOUCH_PAD_CONN_MAX
|
||||
} touch_pad_conn_type_t;
|
||||
|
||||
/**
|
||||
* @brief Touch channel IIR filter coefficient configuration.
|
||||
* @note On ESP32S2. There is an error in the IIR calculation. The magnitude of the error is twice the filter coefficient.
|
||||
* So please select a smaller filter coefficient on the basis of meeting the filtering requirements.
|
||||
* Recommended filter coefficient selection `IIR_16`.
|
||||
*/
|
||||
typedef enum {
|
||||
TOUCH_PAD_FILTER_IIR_4 = 0, /*!<The filter mode is first-order IIR filter. The coefficient is 4. */
|
||||
TOUCH_PAD_FILTER_IIR_8, /*!<The filter mode is first-order IIR filter. The coefficient is 8. */
|
||||
TOUCH_PAD_FILTER_IIR_16, /*!<The filter mode is first-order IIR filter. The coefficient is 16 (Typical value). */
|
||||
TOUCH_PAD_FILTER_IIR_32, /*!<The filter mode is first-order IIR filter. The coefficient is 32. */
|
||||
TOUCH_PAD_FILTER_IIR_64, /*!<The filter mode is first-order IIR filter. The coefficient is 64. */
|
||||
TOUCH_PAD_FILTER_IIR_128, /*!<The filter mode is first-order IIR filter. The coefficient is 128. */
|
||||
TOUCH_PAD_FILTER_IIR_256, /*!<The filter mode is first-order IIR filter. The coefficient is 256. */
|
||||
TOUCH_PAD_FILTER_JITTER, /*!<The filter mode is jitter filter */
|
||||
TOUCH_PAD_FILTER_MAX
|
||||
} touch_filter_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Level of filter applied on the original data against large noise interference.
|
||||
* @note On ESP32S2. There is an error in the IIR calculation. The magnitude of the error is twice the filter coefficient.
|
||||
* So please select a smaller filter coefficient on the basis of meeting the filtering requirements.
|
||||
* Recommended filter coefficient selection `IIR_2`.
|
||||
*/
|
||||
typedef enum {
|
||||
TOUCH_PAD_SMOOTH_OFF = 0, /*!<No filtering of raw data. */
|
||||
TOUCH_PAD_SMOOTH_IIR_2 = 1, /*!<Filter the raw data. The coefficient is 2 (Typical value). */
|
||||
TOUCH_PAD_SMOOTH_IIR_4 = 2, /*!<Filter the raw data. The coefficient is 4. */
|
||||
TOUCH_PAD_SMOOTH_IIR_8 = 3, /*!<Filter the raw data. The coefficient is 8. */
|
||||
TOUCH_PAD_SMOOTH_MAX,
|
||||
} touch_smooth_mode_t;
|
||||
|
||||
/** Touch sensor filter configuration */
|
||||
typedef struct touch_filter_config {
|
||||
touch_filter_mode_t mode; /*!<Set filter mode. The input to the filter is raw data and the output is the baseline value.
|
||||
Larger filter coefficients increase the stability of the baseline. */
|
||||
uint32_t debounce_cnt; /*!<Set debounce count, such as `n`. If the measured values continue to exceed
|
||||
the threshold for `n+1` times, the touch sensor state changes.
|
||||
Range: 0 ~ 7 */
|
||||
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 */
|
||||
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.
|
||||
Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1; */
|
||||
uint32_t noise_neg_thr; /*!<Negative noise threshold coefficient. negative noise = noise coefficient * touch threshold.
|
||||
If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
|
||||
If (baseline - raw data) < (negative noise), the baseline stop reset process(refer to `baseline_reset`).
|
||||
Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1/8; */
|
||||
uint32_t neg_noise_limit; /*!<Set the cumulative number of baseline reset processes. such as `n`. If the measured values continue to exceed
|
||||
the negative noise threshold for `n+1` times, the baseline reset to raw data.
|
||||
Range: 0 ~ 15 */
|
||||
uint32_t jitter_step; /*!<Set jitter filter step size. Range: 0 ~ 15 */
|
||||
touch_smooth_mode_t smh_lvl;/*!<Level of filter applied on the original data against large noise interference. */
|
||||
#define TOUCH_DEBOUNCE_CNT_MAX (7)
|
||||
#define TOUCH_HYSTERESIS_THR_MAX (3)
|
||||
#define TOUCH_NOISE_THR_MAX (3)
|
||||
#define TOUCH_NOISE_NEG_THR_MAX (3)
|
||||
#define TOUCH_NEG_NOISE_CNT_LIMIT (15)
|
||||
#define TOUCH_JITTER_STEP_MAX (15)
|
||||
} touch_filter_config_t;
|
||||
|
||||
/** Touch sensor channel sleep configuration */
|
||||
typedef struct {
|
||||
touch_pad_t touch_num; /*!<Set touch channel number for sleep pad.
|
||||
Only one touch sensor channel is supported in deep sleep mode.
|
||||
If clear the sleep channel, point this pad to `TOUCH_PAD_NUM0` */
|
||||
bool en_proximity; /*!<enable proximity function for sleep pad */
|
||||
} touch_pad_sleep_channel_t;
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32S2
|
||||
472
tools/sdk/esp32/include/soc/include/hal/uart_hal.h
Normal file
472
tools/sdk/esp32/include/soc/include/hal/uart_hal.h
Normal file
@@ -0,0 +1,472 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The HAL layer for UART.
|
||||
// There is no parameter check in the hal layer, so the caller must ensure the correctness of the parameters.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "hal/uart_ll.h"
|
||||
#include "hal/uart_types.h"
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
uart_dev_t *dev;
|
||||
} uart_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Clear the UART interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt status mask to be cleared. Using the ORred mask of `UART_INTR_RXFIFO_FULL ... UART_INTR_CMD_CHAR_DET`
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define uart_hal_clr_intsts_mask(hal, mask) uart_ll_clr_intsts_mask((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Disable the UART interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt mask to be disabled. Using the ORred mask of `UART_INTR_RXFIFO_FULL ... UART_INTR_CMD_CHAR_DET`
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define uart_hal_disable_intr_mask(hal, mask) uart_ll_disable_intr_mask((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Enable the UART interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The UART interrupt mask to be enabled. Using the ORred mask of `UART_INTR_RXFIFO_FULL ... UART_INTR_CMD_CHAR_DET`
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define uart_hal_ena_intr_mask(hal, mask) uart_ll_ena_intr_mask((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Get the UART interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return UART interrupt status
|
||||
*/
|
||||
#define uart_hal_get_intsts_mask(hal) uart_ll_get_intsts_mask((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Get status of enabled interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return UART Interrupt enabled value
|
||||
*/
|
||||
#define uart_hal_get_intr_ena_status(hal) uart_ll_get_intr_ena_status((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Get the UART pattern char configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param cmd_char Pointer to accept UART AT cmd char
|
||||
* @param char_num Pointer to accept the `UART_CHAR_NUM` configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define uart_hal_get_at_cmd_char(hal, cmd_char, char_num) uart_ll_get_at_cmd_char((hal)->dev, cmd_char, char_num)
|
||||
|
||||
/**
|
||||
* @brief Set the UART rst signal active level
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param active_level The rts active level. The active level is low if set to 0. The active level is high if set to 1
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
#define uart_hal_set_rts(hal, active_level) uart_ll_set_rts_active_level((hal)->dev, active_level)
|
||||
|
||||
/**
|
||||
* @brief Get the txfifo writeable length(in byte)
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return UART txfifo writeable length
|
||||
*/
|
||||
#define uart_hal_get_txfifo_len(hal) uart_ll_get_txfifo_len((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Check if the UART sending state machine is in the IDLE state.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return True if the state machine is in the IDLE state, otherwise false will be returned.
|
||||
*/
|
||||
#define uart_hal_is_tx_idle(hal) uart_ll_is_tx_idle((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Read data from the UART rxfifo
|
||||
*
|
||||
* @param[in] hal Context of the HAL layer
|
||||
* @param[in] buf Pointer to the buffer used to store the read data. The buffer size should be large than 128 byte
|
||||
* @param[inout] inout_rd_len As input, the size of output buffer to read (set to 0 to read all available data).
|
||||
* As output, returns the actual size written into the output buffer.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_read_rxfifo(uart_hal_context_t *hal, uint8_t *buf, int *inout_rd_len);
|
||||
|
||||
/**
|
||||
* @brief Write data into the UART txfifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param buf Pointer of the data buffer need to be written to txfifo
|
||||
* @param data_size The data size(in byte) need to be written
|
||||
* @param write_size The size has been written
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_write_txfifo(uart_hal_context_t *hal, const uint8_t *buf, uint32_t data_size, uint32_t *write_size);
|
||||
|
||||
/**
|
||||
* @brief Reset the UART txfifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_txfifo_rst(uart_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Reset the UART rxfifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_rxfifo_rst(uart_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Init the UART hal and set the UART to the default configuration.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param uart_num The uart port number, the max port number is (UART_NUM_MAX -1)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_init(uart_hal_context_t *hal, uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART baud-rate and select the source clock
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param source_clk The UART source clock. Support `UART_SCLK_REF_TICK` and `UART_SCLK_APB`
|
||||
* @param baud_rate The baud-rate to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_baudrate(uart_hal_context_t *hal, uart_sclk_t source_clk, uint32_t baud_rate);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART stop bit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param stop_bit The stop bit to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_stop_bits(uart_hal_context_t *hal, uart_stop_bits_t stop_bit);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART data bit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param data_bit The data bit to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_data_bit_num(uart_hal_context_t *hal, uart_word_length_t data_bit);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART parity mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param parity_mode The UART parity mode to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_parity(uart_hal_context_t *hal, uart_parity_t parity_mode);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART hardware flow control
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param flow_ctrl The flow control mode to be set
|
||||
* @param rx_thresh The rts flow control signal will be active if the data length in rxfifo is large than this value
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_hw_flow_ctrl(uart_hal_context_t *hal, uart_hw_flowcontrol_t flow_ctrl, uint8_t rx_thresh);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART AT cmd char detect function. When the receiver receives a continuous AT cmd char, it will produce a interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param at_cmd The AT cmd char detect configuration
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void uart_hal_set_at_cmd_char(uart_hal_context_t *hal, uart_at_cmd_t *at_cmd);
|
||||
|
||||
/**
|
||||
* @brief Set the timeout value of the UART receiver
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param tout The timeout value for receiver to receive a data
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_rx_timeout(uart_hal_context_t *hal, const uint8_t tout);
|
||||
|
||||
/**
|
||||
* @brief Set the UART dtr signal active level
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param active_level The dtr active level. The active level is low if set to 0. The active level is high if set to 1
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_dtr(uart_hal_context_t *hal, int active_level);
|
||||
|
||||
/**
|
||||
* @brief Set the UART software flow control
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param flow_ctrl The software flow control configuration
|
||||
* @param sw_flow_ctrl_en Set true to enable the software flow control, otherwise set it false
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_sw_flow_ctrl(uart_hal_context_t *hal, uart_sw_flowctrl_t *flow_ctrl, bool sw_flow_ctrl_en);
|
||||
|
||||
/**
|
||||
* @brief Set the UART tx idle number
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param idle_num The cycle number betwin the two transmission
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_tx_idle_num(uart_hal_context_t *hal, uint16_t idle_num);
|
||||
|
||||
/**
|
||||
* @brief Set the UART rxfifo full threshold
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param full_thrhd The rxfifo full threshold. If the `UART_RXFIFO_FULL` interrupt is enabled and
|
||||
* the data length in rxfifo is more than this value, it will generate `UART_RXFIFO_FULL` interrupt
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_rxfifo_full_thr(uart_hal_context_t *hal, uint32_t full_thrhd);
|
||||
|
||||
/**
|
||||
* @brief Set the UART txfifo empty threshold
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param empty_thrhd The txfifo empty threshold to be set. If the `UART_TXFIFO_EMPTY` interrupt is enabled and
|
||||
* the data length in txfifo is less than this value, it will generate `UART_TXFIFO_EMPTY` interrupt
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_txfifo_empty_thr(uart_hal_context_t *hal, uint32_t empty_thrhd);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART to send a number of break(NULL) chars
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param break_num The number of the break char need to be send
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_tx_break(uart_hal_context_t *hal, uint32_t break_num);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART wake up function.
|
||||
* Note that RXD cannot be input through GPIO Matrix but only through IO_MUX when use this function
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param wakeup_thrd The wake up threshold to be set. The system will be woken up from light-sleep when the input RXD edge changes more times than `wakeup_thrd+2`
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_wakeup_thrd(uart_hal_context_t *hal, uint32_t wakeup_thrd);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mode The UART mode to be set
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_mode(uart_hal_context_t *hal, uart_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Configure the UART hardware to inverse the signals
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param inv_mask The sigal mask needs to be inversed. Use the ORred mask of type `uart_signal_inv_t`
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_inverse_signal(uart_hal_context_t *hal, uint32_t inv_mask);
|
||||
|
||||
/**
|
||||
* @brief Get the UART wakeup threshold configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param wakeup_thrd Pointer to accept the value of UART wakeup threshold configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_wakeup_thrd(uart_hal_context_t *hal, uint32_t *wakeup_thrd);
|
||||
|
||||
/**
|
||||
* @brief Get the UART data bit configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param data_bit Pointer to accept the value of UART data bit configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_data_bit_num(uart_hal_context_t *hal, uart_word_length_t *data_bit);
|
||||
|
||||
/**
|
||||
* @brief Get the UART stop bit configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param stop_bit Pointer to accept the value of UART stop bit configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_stop_bits(uart_hal_context_t *hal, uart_stop_bits_t *stop_bit);
|
||||
|
||||
/**
|
||||
* @brief Get the UART parity mode configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param parity_mode Pointer to accept the UART parity mode configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_parity(uart_hal_context_t *hal, uart_parity_t *parity_mode);
|
||||
|
||||
/**
|
||||
* @brief Get the UART baud-rate configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param baud_rate Pointer to accept the current baud-rate
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_baudrate(uart_hal_context_t *hal, uint32_t *baud_rate);
|
||||
|
||||
/**
|
||||
* @brief Get the hw flow control configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param flow_ctrl Pointer to accept the UART flow control configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_hw_flow_ctrl(uart_hal_context_t *hal, uart_hw_flowcontrol_t *flow_ctrl);
|
||||
|
||||
/**
|
||||
* @brief Check if the UART rts flow control is enabled
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return True if rts flow control is enabled, otherwise false will be returned
|
||||
*/
|
||||
bool uart_hal_is_hw_rts_en(uart_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Get the UART source clock configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sclk The poiter to accept the UART source clock configuration
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_get_sclk(uart_hal_context_t *hal, uart_sclk_t *sclk);
|
||||
|
||||
/**
|
||||
* @brief Configure TX signal loop back to RX module, just for the testing purposes
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param loop_back_en Set ture to enable the loop back function, else set it false.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void uart_hal_set_loop_back(uart_hal_context_t *hal, bool loop_back_en);
|
||||
|
||||
/**
|
||||
* @brief Calculate uart symbol bit length, as defined in configuration.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*
|
||||
* @return number of bits per UART symbol.
|
||||
*/
|
||||
uint8_t uart_hal_get_symb_len(uart_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Get UART maximum timeout threshold.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*
|
||||
* @return maximum timeout threshold value for target.
|
||||
*/
|
||||
uint16_t uart_hal_get_max_rx_timeout_thrd(uart_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Get the timeout threshold value set for receiver.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*
|
||||
* @return tout_thr The timeout value. If timeout is disabled then returns 0.
|
||||
*/
|
||||
#define uart_hal_get_rx_tout_thr(hal) uart_ll_get_rx_tout_thr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Get the length of readable data in UART rxfifo.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*
|
||||
* @return The readable data length in rxfifo.
|
||||
*/
|
||||
#define uart_hal_get_rxfifo_len(hal) uart_ll_get_rxfifo_len((hal)->dev)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
146
tools/sdk/esp32/include/soc/include/hal/uart_types.h
Normal file
146
tools/sdk/esp32/include/soc/include/hal/uart_types.h
Normal file
@@ -0,0 +1,146 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/uart_caps.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief UART port number, can be UART_NUM_0 ~ (UART_NUM_MAX -1).
|
||||
*/
|
||||
typedef int uart_port_t;
|
||||
|
||||
/**
|
||||
* @brief UART mode selection
|
||||
*/
|
||||
typedef enum {
|
||||
UART_MODE_UART = 0x00, /*!< mode: regular UART mode*/
|
||||
UART_MODE_RS485_HALF_DUPLEX = 0x01, /*!< mode: half duplex RS485 UART mode control by RTS pin */
|
||||
UART_MODE_IRDA = 0x02, /*!< mode: IRDA UART mode*/
|
||||
UART_MODE_RS485_COLLISION_DETECT = 0x03, /*!< mode: RS485 collision detection UART mode (used for test purposes)*/
|
||||
UART_MODE_RS485_APP_CTRL = 0x04, /*!< mode: application control RS485 UART mode (used for test purposes)*/
|
||||
} uart_mode_t;
|
||||
|
||||
/**
|
||||
* @brief UART word length constants
|
||||
*/
|
||||
typedef enum {
|
||||
UART_DATA_5_BITS = 0x0, /*!< word length: 5bits*/
|
||||
UART_DATA_6_BITS = 0x1, /*!< word length: 6bits*/
|
||||
UART_DATA_7_BITS = 0x2, /*!< word length: 7bits*/
|
||||
UART_DATA_8_BITS = 0x3, /*!< word length: 8bits*/
|
||||
UART_DATA_BITS_MAX = 0x4,
|
||||
} uart_word_length_t;
|
||||
|
||||
/**
|
||||
* @brief UART stop bits number
|
||||
*/
|
||||
typedef enum {
|
||||
UART_STOP_BITS_1 = 0x1, /*!< stop bit: 1bit*/
|
||||
UART_STOP_BITS_1_5 = 0x2, /*!< stop bit: 1.5bits*/
|
||||
UART_STOP_BITS_2 = 0x3, /*!< stop bit: 2bits*/
|
||||
UART_STOP_BITS_MAX = 0x4,
|
||||
} uart_stop_bits_t;
|
||||
|
||||
/**
|
||||
* @brief UART parity constants
|
||||
*/
|
||||
typedef enum {
|
||||
UART_PARITY_DISABLE = 0x0, /*!< Disable UART parity*/
|
||||
UART_PARITY_EVEN = 0x2, /*!< Enable UART even parity*/
|
||||
UART_PARITY_ODD = 0x3 /*!< Enable UART odd parity*/
|
||||
} uart_parity_t;
|
||||
|
||||
/**
|
||||
* @brief UART hardware flow control modes
|
||||
*/
|
||||
typedef enum {
|
||||
UART_HW_FLOWCTRL_DISABLE = 0x0, /*!< disable hardware flow control*/
|
||||
UART_HW_FLOWCTRL_RTS = 0x1, /*!< enable RX hardware flow control (rts)*/
|
||||
UART_HW_FLOWCTRL_CTS = 0x2, /*!< enable TX hardware flow control (cts)*/
|
||||
UART_HW_FLOWCTRL_CTS_RTS = 0x3, /*!< enable hardware flow control*/
|
||||
UART_HW_FLOWCTRL_MAX = 0x4,
|
||||
} uart_hw_flowcontrol_t;
|
||||
|
||||
/**
|
||||
* @brief UART signal bit map
|
||||
*/
|
||||
typedef enum {
|
||||
UART_SIGNAL_INV_DISABLE = 0, /*!< Disable UART signal inverse*/
|
||||
UART_SIGNAL_IRDA_TX_INV = (0x1 << 0), /*!< inverse the UART irda_tx signal*/
|
||||
UART_SIGNAL_IRDA_RX_INV = (0x1 << 1), /*!< inverse the UART irda_rx signal*/
|
||||
UART_SIGNAL_RXD_INV = (0x1 << 2), /*!< inverse the UART rxd signal*/
|
||||
UART_SIGNAL_CTS_INV = (0x1 << 3), /*!< inverse the UART cts signal*/
|
||||
UART_SIGNAL_DSR_INV = (0x1 << 4), /*!< inverse the UART dsr signal*/
|
||||
UART_SIGNAL_TXD_INV = (0x1 << 5), /*!< inverse the UART txd signal*/
|
||||
UART_SIGNAL_RTS_INV = (0x1 << 6), /*!< inverse the UART rts signal*/
|
||||
UART_SIGNAL_DTR_INV = (0x1 << 7), /*!< inverse the UART dtr signal*/
|
||||
} uart_signal_inv_t;
|
||||
|
||||
/**
|
||||
* @brief UART source clock
|
||||
*/
|
||||
typedef enum {
|
||||
UART_SCLK_APB = 0x0, /*!< UART source clock from APB*/
|
||||
UART_SCLK_REF_TICK = 0x01, /*!< UART source clock from REF_TICK*/
|
||||
} uart_sclk_t;
|
||||
|
||||
/**
|
||||
* @brief UART AT cmd char configuration parameters
|
||||
* Note that this function may different on different chip. Please refer to the TRM at confirguration.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t cmd_char; /*!< UART AT cmd char*/
|
||||
uint8_t char_num; /*!< AT cmd char repeat number*/
|
||||
uint32_t gap_tout; /*!< gap time(in baud-rate) between AT cmd char*/
|
||||
uint32_t pre_idle; /*!< the idle time(in baud-rate) between the non AT char and first AT char*/
|
||||
uint32_t post_idle; /*!< the idle time(in baud-rate) between the last AT char and the none AT char*/
|
||||
} uart_at_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief UART software flow control configuration parameters
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t xon_char; /*!< Xon flow control char*/
|
||||
uint8_t xoff_char; /*!< Xoff flow control char*/
|
||||
uint8_t xon_thrd; /*!< If the software flow control is enabled and the data amount in rxfifo is less than xon_thrd, an xon_char will be sent*/
|
||||
uint8_t xoff_thrd; /*!< If the software flow control is enabled and the data amount in rxfifo is more than xoff_thrd, an xoff_char will be sent*/
|
||||
} uart_sw_flowctrl_t;
|
||||
|
||||
/**
|
||||
* @brief UART configuration parameters for uart_param_config function
|
||||
*/
|
||||
typedef struct {
|
||||
int baud_rate; /*!< UART baud rate*/
|
||||
uart_word_length_t data_bits; /*!< UART byte size*/
|
||||
uart_parity_t parity; /*!< UART parity mode*/
|
||||
uart_stop_bits_t stop_bits; /*!< UART stop bits*/
|
||||
uart_hw_flowcontrol_t flow_ctrl; /*!< UART HW flow control mode (cts/rts)*/
|
||||
uint8_t rx_flow_ctrl_thresh; /*!< UART HW RTS threshold*/
|
||||
union {
|
||||
uart_sclk_t source_clk; /*!< UART source clock selection */
|
||||
bool use_ref_tick __attribute__((deprecated)); /*!< Deprecated method to select ref tick clock source, set source_clk field instead */
|
||||
};
|
||||
} uart_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
31
tools/sdk/esp32/include/soc/include/hal/usb_hal.h
Normal file
31
tools/sdk/esp32/include/soc/include/hal/usb_hal.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
bool use_external_phy;
|
||||
} usb_hal_context_t;
|
||||
|
||||
void usb_hal_init(usb_hal_context_t *usb);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
180
tools/sdk/esp32/include/soc/include/hal/wdt_hal.h
Normal file
180
tools/sdk/esp32/include/soc/include/hal/wdt_hal.h
Normal file
@@ -0,0 +1,180 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in soc/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "soc/timer_group_caps.h"
|
||||
#include "hal/wdt_types.h"
|
||||
#include "hal/mwdt_ll.h"
|
||||
#include "hal/rwdt_ll.h"
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
wdt_inst_t inst; /**< Which WDT instance this HAL context is using (i.e. MWDT0, MWDT1, RWDT)*/
|
||||
union {
|
||||
timg_dev_t *mwdt_dev; /**< Starting address of the MWDT */
|
||||
rtc_cntl_dev_t *rwdt_dev; /**< Starting address of the RWDT*/
|
||||
};
|
||||
} wdt_hal_context_t;
|
||||
|
||||
/* ---------------------------- Init and Config ----------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Initialize one of the WDTs associated HAL context
|
||||
*
|
||||
* This function initializes one of the WDTs (MWDT0, MWDT1, or RWDT) hardware by
|
||||
* doing the following:
|
||||
* - Disables the WDT and all of its stages
|
||||
* - Sets some registers with default values
|
||||
* - Sets the WDTs source clock prescaler (not applicable to RWDT)
|
||||
* - Optionally enables the level interrupt
|
||||
*
|
||||
* The HAL context is initialized by storing the type (i.e. MWDT or RWDT) of
|
||||
* this WDT instance, and a pointer to the associated registers.
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
* @param wdt_inst Which WDT instance to initialize (MWDT0, MWDT1, or RWDT)
|
||||
* @param prescaler MWDT source clock prescaler. Unused for RWDT
|
||||
* @param enable_intr True to enable level interrupt. False to disable
|
||||
*
|
||||
* @note Although the WDTs on the ESP32 have an edge interrupt, this HAL does
|
||||
* not utilize it and will always disables it.
|
||||
* @note RWDT does not have a prescaler. Its tick rate is equal to the
|
||||
* frequency of its source clock (RTC slow clock).
|
||||
*/
|
||||
void wdt_hal_init(wdt_hal_context_t *hal, wdt_inst_t wdt_inst, uint32_t prescaler, bool enable_intr);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize a WDT and its HAL context
|
||||
*
|
||||
* This function deinitializes a WDT by feeding then disabling it. The WDT's
|
||||
* interrupt is also cleared and disabled. The HAL context is cleared.
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*/
|
||||
void wdt_hal_deinit(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Configure a particular stage of a WDT
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
* @param stage Stage to configure (0 to 3)
|
||||
* @param timeout Number of WDT ticks for the stage to time out
|
||||
* @param behavior What action to take when the stage times out. Note that only
|
||||
* the RWDT supports the RTC reset action.
|
||||
*
|
||||
* @note This function can only be called when the WDT is unlocked. Call
|
||||
* wdt_hal_write_protect_disable() first.
|
||||
*/
|
||||
void wdt_hal_config_stage(wdt_hal_context_t *hal, wdt_stage_t stage, uint32_t timeout, wdt_stage_action_t behavior);
|
||||
|
||||
/* -------------------------------- Runtime --------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable write protection of the WDT registers
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*/
|
||||
void wdt_hal_write_protect_disable(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable write protection of the WDT registers
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*/
|
||||
void wdt_hal_write_protect_enable(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable the WDT
|
||||
*
|
||||
* The WDT will start counting when enabled. This function also feeds the WDT
|
||||
* before enabling it.
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*
|
||||
* @note This function can only be called when the WDT is unlocked. Call
|
||||
* wdt_hal_write_protect_disable() first.
|
||||
*/
|
||||
void wdt_hal_enable(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Disable the WDT
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*
|
||||
* @note This function can only be called when the WDT is unlocked. Call
|
||||
* wdt_hal_write_protect_disable() first.
|
||||
*/
|
||||
void wdt_hal_disable(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Handle WDT interrupt
|
||||
*
|
||||
* Clears the interrupt status bit and feeds the WDT
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*
|
||||
* @note This function can only be called when the WDT is unlocked. Call
|
||||
* wdt_hal_write_protect_disable() first.
|
||||
*/
|
||||
void wdt_hal_handle_intr(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Feed the WDT
|
||||
*
|
||||
* Feeding the WDT will reset the internal count and current stage.
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
*
|
||||
* @note This function can only be called when the WDT is unlocked. Call
|
||||
* wdt_hal_write_protect_disable() first.
|
||||
*/
|
||||
void wdt_hal_feed(wdt_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable the WDT flash boot mode
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
* @param enable True to enable flash boot mode, false to disable.
|
||||
*
|
||||
* @note Flash boot mode can trigger a time out even if the WDT is disabled.
|
||||
* @note This function can only be called when the WDT is unlocked. Call
|
||||
* wdt_hal_write_protect_disable() first.
|
||||
*/
|
||||
void wdt_hal_set_flashboot_en(wdt_hal_context_t *hal, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Check if the WDT is enabled
|
||||
*
|
||||
* @param hal Context of HAL layer
|
||||
* @return True if enabled, false otherwise
|
||||
*/
|
||||
bool wdt_hal_is_enabled(wdt_hal_context_t *hal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
71
tools/sdk/esp32/include/soc/include/hal/wdt_types.h
Normal file
71
tools/sdk/esp32/include/soc/include/hal/wdt_types.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
WDT_RWDT = 0, /*!< RTC Watchdog Timer (RWDT) */
|
||||
WDT_MWDT0, /*!< Main System Watchdog Timer (MWDT) of Timer Group 0 */
|
||||
WDT_MWDT1, /*!< Main System Watchdog Timer (MWDT) of Timer Group 1 */
|
||||
} wdt_inst_t;
|
||||
|
||||
/**
|
||||
* @brief Stages of a Watchdog Timer. A WDT has 4 stages.
|
||||
*/
|
||||
typedef enum {
|
||||
WDT_STAGE0 = 0, /*!< Stage 0 */
|
||||
WDT_STAGE1 = 1, /*!< Stage 1 */
|
||||
WDT_STAGE2 = 2, /*!< Stage 2 */
|
||||
WDT_STAGE3 = 3 /*!< Stage 3 */
|
||||
} wdt_stage_t;
|
||||
|
||||
/**
|
||||
* @brief Behavior of the WDT stage if it times out
|
||||
*
|
||||
* @note These enum values should be compatible with the corresponding register
|
||||
* field values.
|
||||
*/
|
||||
typedef enum {
|
||||
WDT_STAGE_ACTION_OFF = 0, /*!< Disabled. This stage will have no effects on the system. */
|
||||
WDT_STAGE_ACTION_INT = 1, /*!< Trigger an interrupt when the stage expires. */
|
||||
WDT_STAGE_ACTION_RESET_CPU = 2, /*!< Reset a CPU core when the stage expires. */
|
||||
WDT_STAGE_ACTION_RESET_SYSTEM = 3, /*!< Reset the main system when the stage expires. This includes the CPU and all peripherals. The RTC is an exception and will not be reset. */
|
||||
WDT_STAGE_ACTION_RESET_RTC = 4, /*!< Reset the main system and the RTC when the stage expires. ONLY AVAILABLE FOR RWDT */
|
||||
} wdt_stage_action_t;
|
||||
|
||||
/**
|
||||
* @brief Length of CPU or System Reset signals
|
||||
*
|
||||
* @note These enum values should be compatible with the corresponding register
|
||||
* field values.
|
||||
*/
|
||||
typedef enum {
|
||||
WDT_RESET_SIG_LENGTH_100ns = 0, /*!< 100 ns */
|
||||
WDT_RESET_SIG_LENGTH_200ns = 1, /*!< 200 ns */
|
||||
WDT_RESET_SIG_LENGTH_300ns = 2, /*!< 300 ns */
|
||||
WDT_RESET_SIG_LENGTH_400ns = 3, /*!< 400 ns */
|
||||
WDT_RESET_SIG_LENGTH_500ns = 4, /*!< 500 ns */
|
||||
WDT_RESET_SIG_LENGTH_800ns = 5, /*!< 800 ns */
|
||||
WDT_RESET_SIG_LENGTH_1_6us = 6, /*!< 1.6 us */
|
||||
WDT_RESET_SIG_LENGTH_3_2us = 7 /*!< 3.2 us */
|
||||
} wdt_reset_sig_length_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
56
tools/sdk/esp32/include/soc/include/soc/compare_set.h
Normal file
56
tools/sdk/esp32/include/soc/include/soc/compare_set.h
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __COMPARE_SET_H
|
||||
#define __COMPARE_SET_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "xtensa/xtruntime.h"
|
||||
|
||||
|
||||
static inline void __attribute__((always_inline)) compare_and_set_native(volatile uint32_t *addr, uint32_t compare, uint32_t *set)
|
||||
{
|
||||
#if (XCHAL_HAVE_S32C1I > 0)
|
||||
__asm__ __volatile__ (
|
||||
"WSR %2,SCOMPARE1 \n"
|
||||
"S32C1I %0, %1, 0 \n"
|
||||
:"=r"(*set)
|
||||
:"r"(addr), "r"(compare), "0"(*set)
|
||||
);
|
||||
#else
|
||||
// No S32C1I, so do this by disabling and re-enabling interrupts (slower)
|
||||
uint32_t intlevel, old_value;
|
||||
__asm__ __volatile__ ("rsil %0, " XTSTR(XCHAL_EXCM_LEVEL) "\n"
|
||||
: "=r"(intlevel));
|
||||
|
||||
old_value = *addr;
|
||||
if (old_value == compare) {
|
||||
*addr = *set;
|
||||
}
|
||||
|
||||
__asm__ __volatile__ ("memw \n"
|
||||
"wsr %0, ps\n"
|
||||
:: "r"(intlevel));
|
||||
|
||||
*set = old_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void compare_and_set_extram(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
|
||||
|
||||
#endif
|
||||
103
tools/sdk/esp32/include/soc/include/soc/cpu.h
Normal file
103
tools/sdk/esp32/include/soc/include/soc/cpu.h
Normal file
@@ -0,0 +1,103 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_CPU_H
|
||||
#define _SOC_CPU_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "xtensa/corebits.h"
|
||||
#include "xtensa/config/core.h"
|
||||
|
||||
#include "xtensa/config/specreg.h"
|
||||
#include "xt_instr_macros.h"
|
||||
|
||||
#include "hal/cpu_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Read current stack pointer address
|
||||
*
|
||||
*/
|
||||
static inline void *get_sp(void)
|
||||
{
|
||||
return cpu_hal_get_sp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stall CPU using RTC controller
|
||||
* @param cpu_id ID of the CPU to stall (0 = PRO, 1 = APP)
|
||||
*/
|
||||
void esp_cpu_stall(int cpu_id);
|
||||
|
||||
/**
|
||||
* @brief Un-stall CPU using RTC controller
|
||||
* @param cpu_id ID of the CPU to un-stall (0 = PRO, 1 = APP)
|
||||
*/
|
||||
void esp_cpu_unstall(int cpu_id);
|
||||
|
||||
/**
|
||||
* @brief Reset CPU using RTC controller
|
||||
* @param cpu_id ID of the CPU to reset (0 = PRO, 1 = APP)
|
||||
*/
|
||||
void esp_cpu_reset(int cpu_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns true if a JTAG debugger is attached to CPU
|
||||
* OCD (on chip debug) port.
|
||||
*
|
||||
* @note If "Make exception and panic handlers JTAG/OCD aware"
|
||||
* is disabled, this function always returns false.
|
||||
*/
|
||||
bool esp_cpu_in_ocd_debug_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Convert the PC register value to its true address
|
||||
*
|
||||
* The address of the current instruction is not stored as an exact uint32_t
|
||||
* representation in PC register. This function will convert the value stored in
|
||||
* the PC register to a uint32_t address.
|
||||
*
|
||||
* @param pc_raw The PC as stored in register format.
|
||||
*
|
||||
* @return Address in uint32_t format
|
||||
*/
|
||||
static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc)
|
||||
{
|
||||
if (pc & 0x80000000) {
|
||||
//Top two bits of a0 (return address) specify window increment. Overwrite to map to address space.
|
||||
pc = (pc & 0x3fffffff) | 0x40000000;
|
||||
}
|
||||
//Minus 3 to get PC of previous instruction (i.e. instruction executed before return address)
|
||||
return pc - 3;
|
||||
}
|
||||
|
||||
typedef uint32_t esp_cpu_ccount_t;
|
||||
|
||||
static inline esp_cpu_ccount_t esp_cpu_get_ccount(void)
|
||||
{
|
||||
uint32_t result;
|
||||
RSR(CCOUNT, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
53
tools/sdk/esp32/include/soc/include/soc/lldesc.h
Normal file
53
tools/sdk/esp32/include/soc/include/soc/lldesc.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright 2010-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/lldesc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/lldesc.h"
|
||||
#endif
|
||||
|
||||
//the size field has 12 bits, but 0 not for 4096.
|
||||
//to avoid possible problem when the size is not word-aligned, we only use 4096-4 per desc.
|
||||
/** Maximum size of data in the buffer that a DMA descriptor can hold. */
|
||||
#define LLDESC_MAX_NUM_PER_DESC (4096-4)
|
||||
|
||||
/**
|
||||
* Generate a linked list pointing to a (huge) buffer in an descriptor array.
|
||||
*
|
||||
* The caller should ensure there is enough size to hold the array, by calling
|
||||
* ``lldesc_get_required_num``.
|
||||
*
|
||||
* @param out_desc_array Output of a descriptor array, the head should be fed to the DMA.
|
||||
* @param buffer Buffer for the descriptors to point to.
|
||||
* @param size Size (or length for TX) of the buffer
|
||||
* @param isrx The RX DMA may require the buffer to be word-aligned, set to true for a RX link, otherwise false.
|
||||
*/
|
||||
void lldesc_setup_link(lldesc_t *out_desc_array, const void *buffer, int size, bool isrx);
|
||||
|
||||
/**
|
||||
* Get the number of descriptors required for a given buffer size.
|
||||
*
|
||||
* @param data_size Size to check descriptor num.
|
||||
*
|
||||
* @return Numbers required.
|
||||
*/
|
||||
static inline int lldesc_get_required_num(int data_size)
|
||||
{
|
||||
return (data_size + LLDESC_MAX_NUM_PER_DESC - 1) / LLDESC_MAX_NUM_PER_DESC;
|
||||
}
|
||||
198
tools/sdk/esp32/include/soc/include/soc/rtc_wdt.h
Normal file
198
tools/sdk/esp32/include/soc/include/soc/rtc_wdt.h
Normal file
@@ -0,0 +1,198 @@
|
||||
// Copyright 2018 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/* Recommendation of using API RTC_WDT.
|
||||
1) Setting and enabling rtc_wdt:
|
||||
@code
|
||||
rtc_wdt_protect_off();
|
||||
rtc_wdt_disable();
|
||||
rtc_wdt_set_length_of_reset_signal(RTC_WDT_SYS_RESET_SIG, RTC_WDT_LENGTH_3_2us);
|
||||
rtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_RESET_SYSTEM); //RTC_WDT_STAGE_ACTION_RESET_SYSTEM or RTC_WDT_STAGE_ACTION_RESET_RTC
|
||||
rtc_wdt_set_time(RTC_WDT_STAGE0, 7000); // timeout rtd_wdt 7000ms.
|
||||
rtc_wdt_enable();
|
||||
rtc_wdt_protect_on();
|
||||
@endcode
|
||||
|
||||
* If you use this option RTC_WDT_STAGE_ACTION_RESET_SYSTEM then after reset you can see these messages.
|
||||
They can help to understand where the CPUs were when the WDT was triggered.
|
||||
W (30) boot: PRO CPU has been reset by WDT.
|
||||
W (30) boot: WDT reset info: PRO CPU PC=0x400xxxxx
|
||||
... function where it happened
|
||||
|
||||
W (31) boot: WDT reset info: APP CPU PC=0x400xxxxx
|
||||
... function where it happened
|
||||
|
||||
* If you use this option RTC_WDT_STAGE_ACTION_RESET_RTC then you will see message (rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT))
|
||||
without description where were CPUs when it happened.
|
||||
|
||||
2) Reset counter of rtc_wdt:
|
||||
@code
|
||||
rtc_wdt_feed();
|
||||
@endcode
|
||||
|
||||
3) Disable rtc_wdt:
|
||||
@code
|
||||
rtc_wdt_disable();
|
||||
@endcode
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/rtc_periph.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// List of stage of rtc watchdog. WDT has 4 stage.
|
||||
typedef enum {
|
||||
RTC_WDT_STAGE0 = 0, /*!< Stage 0 */
|
||||
RTC_WDT_STAGE1 = 1, /*!< Stage 1 */
|
||||
RTC_WDT_STAGE2 = 2, /*!< Stage 2 */
|
||||
RTC_WDT_STAGE3 = 3 /*!< Stage 3 */
|
||||
} rtc_wdt_stage_t;
|
||||
|
||||
/// List of action. When the time of stage expires this action will be triggered.
|
||||
typedef enum {
|
||||
RTC_WDT_STAGE_ACTION_OFF = RTC_WDT_STG_SEL_OFF, /*!< Disabled. This stage will have no effects on the system. */
|
||||
RTC_WDT_STAGE_ACTION_INTERRUPT = RTC_WDT_STG_SEL_INT, /*!< Trigger an interrupt. When the stage expires an interrupt is triggered. */
|
||||
RTC_WDT_STAGE_ACTION_RESET_CPU = RTC_WDT_STG_SEL_RESET_CPU, /*!< Reset a CPU core. */
|
||||
RTC_WDT_STAGE_ACTION_RESET_SYSTEM = RTC_WDT_STG_SEL_RESET_SYSTEM, /*!< Reset the main system includes the CPU and all peripherals. The RTC is an exception to this, and it will not be reset. */
|
||||
RTC_WDT_STAGE_ACTION_RESET_RTC = RTC_WDT_STG_SEL_RESET_RTC /*!< Reset the main system and the RTC. */
|
||||
} rtc_wdt_stage_action_t;
|
||||
|
||||
/// Type of reset signal
|
||||
typedef enum {
|
||||
RTC_WDT_SYS_RESET_SIG = 0, /*!< System reset signal length selection */
|
||||
RTC_WDT_CPU_RESET_SIG = 1 /*!< CPU reset signal length selection */
|
||||
} rtc_wdt_reset_sig_t;
|
||||
|
||||
/// Length of reset signal
|
||||
typedef enum {
|
||||
RTC_WDT_LENGTH_100ns = 0, /*!< 100 ns */
|
||||
RTC_WDT_LENGTH_200ns = 1, /*!< 200 ns */
|
||||
RTC_WDT_LENGTH_300ns = 2, /*!< 300 ns */
|
||||
RTC_WDT_LENGTH_400ns = 3, /*!< 400 ns */
|
||||
RTC_WDT_LENGTH_500ns = 4, /*!< 500 ns */
|
||||
RTC_WDT_LENGTH_800ns = 5, /*!< 800 ns */
|
||||
RTC_WDT_LENGTH_1_6us = 6, /*!< 1.6 us */
|
||||
RTC_WDT_LENGTH_3_2us = 7 /*!< 3.2 us */
|
||||
} rtc_wdt_length_sig_t;
|
||||
|
||||
/**
|
||||
* @brief Get status of protect of rtc_wdt.
|
||||
*
|
||||
* @return
|
||||
* - True if the protect of RTC_WDT is set
|
||||
*/
|
||||
bool rtc_wdt_get_protect_status(void);
|
||||
|
||||
/**
|
||||
* @brief Set protect of rtc_wdt.
|
||||
*/
|
||||
void rtc_wdt_protect_on(void);
|
||||
|
||||
/**
|
||||
* @brief Reset protect of rtc_wdt.
|
||||
*/
|
||||
void rtc_wdt_protect_off(void);
|
||||
|
||||
/**
|
||||
* @brief Enable rtc_wdt.
|
||||
*/
|
||||
void rtc_wdt_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Enable the flash boot protection procedure for WDT.
|
||||
*
|
||||
* Do not recommend to use it in the app.
|
||||
* This function was added to be compatibility with the old bootloaders.
|
||||
* This mode is disabled in bootloader or using rtc_wdt_disable() function.
|
||||
*/
|
||||
void rtc_wdt_flashboot_mode_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable rtc_wdt.
|
||||
*/
|
||||
void rtc_wdt_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Reset counter rtc_wdt.
|
||||
*
|
||||
* It returns to stage 0 and its expiry counter restarts from 0.
|
||||
*/
|
||||
void rtc_wdt_feed(void);
|
||||
|
||||
/**
|
||||
* @brief Set time for required stage.
|
||||
*
|
||||
* @param[in] stage Stage of rtc_wdt.
|
||||
* @param[in] timeout_ms Timeout for this stage.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK In case of success
|
||||
* - ESP_ERR_INVALID_ARG If stage has invalid value
|
||||
*/
|
||||
esp_err_t rtc_wdt_set_time(rtc_wdt_stage_t stage, unsigned int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Get the timeout set for the required stage.
|
||||
*
|
||||
* @param[in] stage Stage of rtc_wdt.
|
||||
* @param[out] timeout_ms Timeout set for this stage. (not elapsed time).
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK In case of success
|
||||
* - ESP_ERR_INVALID_ARG If stage has invalid value
|
||||
*/
|
||||
esp_err_t rtc_wdt_get_timeout(rtc_wdt_stage_t stage, unsigned int* timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Set an action for required stage.
|
||||
*
|
||||
* @param[in] stage Stage of rtc_wdt.
|
||||
* @param[in] stage_sel Action for this stage. When the time of stage expires this action will be triggered.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK In case of success
|
||||
* - ESP_ERR_INVALID_ARG If stage or stage_sel have invalid value
|
||||
*/
|
||||
esp_err_t rtc_wdt_set_stage(rtc_wdt_stage_t stage, rtc_wdt_stage_action_t stage_sel);
|
||||
|
||||
/**
|
||||
* @brief Set a length of reset signal.
|
||||
*
|
||||
* @param[in] reset_src Type of reset signal.
|
||||
* @param[in] reset_signal_length A length of reset signal.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK In case of success
|
||||
* - ESP_ERR_INVALID_ARG If reset_src or reset_signal_length have invalid value
|
||||
*/
|
||||
esp_err_t rtc_wdt_set_length_of_reset_signal(rtc_wdt_reset_sig_t reset_src, rtc_wdt_length_sig_t reset_signal_length);
|
||||
|
||||
/**
|
||||
* @brief Return true if rtc_wdt is enabled.
|
||||
*
|
||||
* @return
|
||||
* - True rtc_wdt is enabled
|
||||
*/
|
||||
bool rtc_wdt_is_on(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
285
tools/sdk/esp32/include/soc/include/soc/soc_memory_layout.h
Normal file
285
tools/sdk/esp32/include/soc/include/soc/soc_memory_layout.h
Normal file
@@ -0,0 +1,285 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#ifdef CONFIG_BT_ENABLED
|
||||
|
||||
#define SOC_MEM_BT_DATA_START 0x3ffae6e0
|
||||
#define SOC_MEM_BT_DATA_END 0x3ffaff10
|
||||
#define SOC_MEM_BT_EM_START 0x3ffb0000
|
||||
#define SOC_MEM_BT_EM_END 0x3ffb7cd8
|
||||
#define SOC_MEM_BT_EM_BTDM0_START 0x3ffb0000
|
||||
#define SOC_MEM_BT_EM_BTDM0_END 0x3ffb09a8
|
||||
#define SOC_MEM_BT_EM_BLE_START 0x3ffb09a8
|
||||
#define SOC_MEM_BT_EM_BLE_END 0x3ffb1ddc
|
||||
#define SOC_MEM_BT_EM_BTDM1_START 0x3ffb1ddc
|
||||
#define SOC_MEM_BT_EM_BTDM1_END 0x3ffb2730
|
||||
#define SOC_MEM_BT_EM_BREDR_START 0x3ffb2730
|
||||
#define SOC_MEM_BT_EM_BREDR_NO_SYNC_END 0x3ffb6388 //Not calculate with synchronize connection support
|
||||
#define SOC_MEM_BT_EM_BREDR_END 0x3ffb7cd8 //Calculate with synchronize connection support
|
||||
#define SOC_MEM_BT_EM_SYNC0_START 0x3ffb6388
|
||||
#define SOC_MEM_BT_EM_SYNC0_END 0x3ffb6bf8
|
||||
#define SOC_MEM_BT_EM_SYNC1_START 0x3ffb6bf8
|
||||
#define SOC_MEM_BT_EM_SYNC1_END 0x3ffb7468
|
||||
#define SOC_MEM_BT_EM_SYNC2_START 0x3ffb7468
|
||||
#define SOC_MEM_BT_EM_SYNC2_END 0x3ffb7cd8
|
||||
#define SOC_MEM_BT_BSS_START 0x3ffb8000
|
||||
#define SOC_MEM_BT_BSS_END 0x3ffb9a20
|
||||
#define SOC_MEM_BT_MISC_START 0x3ffbdb28
|
||||
#define SOC_MEM_BT_MISC_END 0x3ffbdb5c
|
||||
|
||||
#define SOC_MEM_BT_EM_PER_SYNC_SIZE 0x870
|
||||
|
||||
#define SOC_MEM_BT_EM_BREDR_REAL_END (SOC_MEM_BT_EM_BREDR_NO_SYNC_END + CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF * SOC_MEM_BT_EM_PER_SYNC_SIZE)
|
||||
|
||||
#endif //CONFIG_BT_ENABLED
|
||||
|
||||
#define SOC_MEMORY_TYPE_NO_PRIOS 3
|
||||
|
||||
/* Type descriptor holds a description for a particular type of memory on a particular SoC.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *name; ///< Name of this memory type
|
||||
uint32_t caps[SOC_MEMORY_TYPE_NO_PRIOS]; ///< Capabilities for this memory type (as a prioritised set)
|
||||
bool aliased_iram; ///< If true, this is data memory that is is also mapped in IRAM
|
||||
bool startup_stack; ///< If true, memory of this type is used for ROM stack during startup
|
||||
} soc_memory_type_desc_t;
|
||||
|
||||
/* Constant table of tag descriptors for all this SoC's tags */
|
||||
extern const soc_memory_type_desc_t soc_memory_types[];
|
||||
extern const size_t soc_memory_type_count;
|
||||
|
||||
/* Region descriptor holds a description for a particular region of memory on a particular SoC.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
intptr_t start; ///< Start address of the region
|
||||
size_t size; ///< Size of the region in bytes
|
||||
size_t type; ///< Type of the region (index into soc_memory_types array)
|
||||
intptr_t iram_address; ///< If non-zero, is equivalent address in IRAM
|
||||
} soc_memory_region_t;
|
||||
|
||||
extern const soc_memory_region_t soc_memory_regions[];
|
||||
extern const size_t soc_memory_region_count;
|
||||
|
||||
/* Region descriptor holds a description for a particular region of
|
||||
memory reserved on this SoC for a particular use (ie not available
|
||||
for stack/heap usage.) */
|
||||
typedef struct
|
||||
{
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
} soc_reserved_region_t;
|
||||
|
||||
/* Use this macro to reserved a fixed region of RAM (hardcoded addresses)
|
||||
* for a particular purpose.
|
||||
*
|
||||
* Usually used to mark out memory addresses needed for hardware or ROM code
|
||||
* purposes.
|
||||
*
|
||||
* Don't call this macro from user code which can use normal C static allocation
|
||||
* instead.
|
||||
*
|
||||
* @param START Start address to be reserved.
|
||||
* @param END One after the address of the last byte to be reserved. (ie length of
|
||||
* the reserved region is (END - START) in bytes.
|
||||
* @param NAME Name for the reserved region. Must be a valid variable name,
|
||||
* unique to this source file.
|
||||
*/
|
||||
#define SOC_RESERVE_MEMORY_REGION(START, END, NAME) \
|
||||
__attribute__((section(".reserved_memory_address"))) __attribute__((used)) \
|
||||
static soc_reserved_region_t reserved_region_##NAME = { START, END };
|
||||
|
||||
/* Return available memory regions for this SoC. Each available memory
|
||||
* region is a contiguous piece of memory which is not being used by
|
||||
* static data, used by ROM code, or reserved by a component using
|
||||
* the SOC_RESERVE_MEMORY_REGION() macro.
|
||||
*
|
||||
* This result is soc_memory_regions[] minus all regions reserved
|
||||
* via the SOC_RESERVE_MEMORY_REGION() macro (which may also split
|
||||
* some regions up.)
|
||||
*
|
||||
* At startup, all available memory returned by this function is
|
||||
* registered as heap space.
|
||||
*
|
||||
* @note OS-level startup function only, not recommended to call from
|
||||
* app code.
|
||||
*
|
||||
* @param regions Pointer to an array for reading available regions into.
|
||||
* Size of the array should be at least the result of
|
||||
* soc_get_available_memory_region_max_count(). Entries in the array
|
||||
* will be ordered by memory address.
|
||||
*
|
||||
* @return Number of entries copied to 'regions'. Will be no greater than
|
||||
* the result of soc_get_available_memory_region_max_count().
|
||||
*/
|
||||
size_t soc_get_available_memory_regions(soc_memory_region_t *regions);
|
||||
|
||||
/* Return the maximum number of available memory regions which could be
|
||||
* returned by soc_get_available_memory_regions(). Used to size the
|
||||
* array passed to that function.
|
||||
*/
|
||||
size_t soc_get_available_memory_region_max_count(void);
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_dma_capable(const void *p)
|
||||
{
|
||||
return (intptr_t)p >= SOC_DMA_LOW && (intptr_t)p < SOC_DMA_HIGH;
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_dma_ext_capable(const void *p)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
return (intptr_t)p >= SOC_DMA_EXT_LOW && (intptr_t)p < SOC_DMA_EXT_HIGH;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_word_aligned(const void *p)
|
||||
{
|
||||
return ((intptr_t)p) % 4 == 0;
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_executable(const void *p)
|
||||
{
|
||||
intptr_t ip = (intptr_t) p;
|
||||
return (ip >= SOC_IROM_LOW && ip < SOC_IROM_HIGH)
|
||||
|| (ip >= SOC_IRAM_LOW && ip < SOC_IRAM_HIGH)
|
||||
|| (ip >= SOC_IROM_MASK_LOW && ip < SOC_IROM_MASK_HIGH)
|
||||
#if defined(SOC_CACHE_APP_LOW) && defined(CONFIG_FREERTOS_UNICORE)
|
||||
|| (ip >= SOC_CACHE_APP_LOW && ip < SOC_CACHE_APP_HIGH)
|
||||
#endif
|
||||
|| (ip >= SOC_RTC_IRAM_LOW && ip < SOC_RTC_IRAM_HIGH);
|
||||
}
|
||||
|
||||
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_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));
|
||||
#else
|
||||
r |= (ip >= SOC_EXTRAM_DATA_LOW && ip < (SOC_EXTRAM_DATA_HIGH));
|
||||
#endif
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
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);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_external_ram(const void *p) {
|
||||
return ((intptr_t)p >= SOC_EXTRAM_DATA_LOW && (intptr_t)p < SOC_EXTRAM_DATA_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_iram(const void *p) {
|
||||
#if !CONFIG_FREERTOS_UNICORE || CONFIG_IDF_TARGET_ESP32S2
|
||||
return ((intptr_t)p >= SOC_IRAM_LOW && (intptr_t)p < SOC_IRAM_HIGH);
|
||||
#else
|
||||
return ((intptr_t)p >= SOC_CACHE_APP_LOW && (intptr_t)p < SOC_IRAM_HIGH);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_drom(const void *p) {
|
||||
return ((intptr_t)p >= SOC_DROM_LOW && (intptr_t)p < SOC_DROM_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_dram(const void *p) {
|
||||
return ((intptr_t)p >= SOC_DRAM_LOW && (intptr_t)p < SOC_DRAM_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_diram_dram(const void *p) {
|
||||
return ((intptr_t)p >= SOC_DIRAM_DRAM_LOW && (intptr_t)p < SOC_DIRAM_DRAM_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_diram_iram(const void *p) {
|
||||
return ((intptr_t)p >= SOC_DIRAM_IRAM_LOW && (intptr_t)p < SOC_DIRAM_IRAM_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_rtc_iram_fast(const void *p) {
|
||||
return ((intptr_t)p >= SOC_RTC_IRAM_LOW && (intptr_t)p < SOC_RTC_IRAM_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_rtc_dram_fast(const void *p) {
|
||||
return ((intptr_t)p >= SOC_RTC_DRAM_LOW && (intptr_t)p < SOC_RTC_DRAM_HIGH);
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_ptr_in_rtc_slow(const void *p) {
|
||||
return ((intptr_t)p >= SOC_RTC_DATA_LOW && (intptr_t)p < SOC_RTC_DATA_HIGH);
|
||||
}
|
||||
|
||||
/* Convert a D/IRAM DRAM pointer to equivalent word address in IRAM
|
||||
|
||||
- Address must be word aligned
|
||||
- Address must pass esp_ptr_in_diram_dram() test, or result will be invalid pointer
|
||||
*/
|
||||
inline static void * IRAM_ATTR esp_ptr_diram_dram_to_iram(const void *p) {
|
||||
#if SOC_DIRAM_INVERTED
|
||||
return (void *) ( SOC_DIRAM_IRAM_LOW + (SOC_DIRAM_DRAM_HIGH - (intptr_t)p) - 4);
|
||||
#else
|
||||
return (void *) ( SOC_DIRAM_IRAM_LOW + ((intptr_t)p - SOC_DIRAM_DRAM_LOW) );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert a D/IRAM IRAM pointer to equivalent word address in DRAM
|
||||
|
||||
- Address must be word aligned
|
||||
- Address must pass esp_ptr_in_diram_iram() test, or result will be invalid pointer
|
||||
*/
|
||||
inline static void * IRAM_ATTR esp_ptr_diram_iram_to_dram(const void *p) {
|
||||
#if SOC_DIRAM_INVERTED
|
||||
return (void *) ( SOC_DIRAM_DRAM_LOW + (SOC_DIRAM_IRAM_HIGH - (intptr_t)p) - 4);
|
||||
#else
|
||||
return (void *) ( SOC_DIRAM_DRAM_LOW + ((intptr_t)p - SOC_DIRAM_IRAM_LOW) );
|
||||
#endif
|
||||
}
|
||||
|
||||
inline static bool IRAM_ATTR esp_stack_ptr_in_dram(uint32_t sp)
|
||||
{
|
||||
//Check if stack ptr is in between SOC_DRAM_LOW and SOC_DRAM_HIGH, and 16 byte aligned.
|
||||
return !(sp < SOC_DRAM_LOW + 0x10 || sp > SOC_DRAM_HIGH - 0x10 || ((sp & 0xF) != 0));
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
inline static bool IRAM_ATTR esp_stack_ptr_in_extram(uint32_t sp)
|
||||
{
|
||||
//Check if stack ptr is in between SOC_EXTRAM_DATA_LOW and SOC_EXTRAM_DATA_HIGH, and 16 byte aligned.
|
||||
return !(sp < SOC_EXTRAM_DATA_LOW + 0x10 || sp > SOC_EXTRAM_DATA_HIGH - 0x10 || ((sp & 0xF) != 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline static bool IRAM_ATTR esp_stack_ptr_is_sane(uint32_t sp)
|
||||
{
|
||||
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
return (esp_stack_ptr_in_dram(sp) || esp_stack_ptr_in_extram(sp));
|
||||
#else
|
||||
return esp_stack_ptr_in_dram(sp);
|
||||
#endif
|
||||
}
|
||||
|
||||
159
tools/sdk/esp32/include/soc/include/soc/spinlock.h
Normal file
159
tools/sdk/esp32/include/soc/include/soc/spinlock.h
Normal file
@@ -0,0 +1,159 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef __SOC_SPINLOCK_H
|
||||
#define __SOC_SPINLOCK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "soc/compare_set.h"
|
||||
#include "xtensa/xtruntime.h"
|
||||
|
||||
|
||||
#ifdef CONFIG_SPIRAM_WORKAROUND_NEED_VOLATILE_SPINLOCK
|
||||
#define NEED_VOLATILE_MUX volatile
|
||||
#else
|
||||
#define NEED_VOLATILE_MUX
|
||||
#endif
|
||||
|
||||
#define SPINLOCK_FREE 0xB33FFFFF
|
||||
#define SPINLOCK_WAIT_FOREVER (-1)
|
||||
#define SPINLOCK_NO_WAIT 0
|
||||
#define SPINLOCK_INITIALIZER {.owner = SPINLOCK_FREE,.count = 0}
|
||||
#define CORE_ID_REGVAL_XOR_SWAP (0xCDCD ^ 0xABAB)
|
||||
|
||||
typedef struct {
|
||||
NEED_VOLATILE_MUX uint32_t owner;
|
||||
NEED_VOLATILE_MUX uint32_t count;
|
||||
}spinlock_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize a lock to its default state - unlocked
|
||||
* @param lock - spinlock object to initialize
|
||||
*/
|
||||
static inline void __attribute__((always_inline)) spinlock_initialize(spinlock_t *lock)
|
||||
{
|
||||
assert(lock);
|
||||
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
lock->owner = SPINLOCK_FREE;
|
||||
lock->count = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Top level spinlock acquire function, spins until get the lock
|
||||
* @param lock - target spinlock object
|
||||
* @param timeout - cycles to wait, passing SPINLOCK_WAIT_FOREVER blocs indefinitely
|
||||
*/
|
||||
static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *lock, int32_t timeout)
|
||||
{
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
uint32_t result;
|
||||
uint32_t irq_status;
|
||||
uint32_t ccount_start;
|
||||
uint32_t core_id, other_core_id;
|
||||
|
||||
assert(lock);
|
||||
irq_status = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
|
||||
|
||||
if(timeout != SPINLOCK_WAIT_FOREVER){
|
||||
RSR(CCOUNT, ccount_start);
|
||||
}
|
||||
|
||||
/*spin until we own a core */
|
||||
RSR(PRID, core_id);
|
||||
|
||||
/* Note: coreID is the full 32 bit core ID (CORE_ID_REGVAL_PRO/CORE_ID_REGVAL_APP) */
|
||||
|
||||
other_core_id = CORE_ID_REGVAL_XOR_SWAP ^ core_id;
|
||||
do {
|
||||
|
||||
/* lock->owner should be one of SPINLOCK_FREE, CORE_ID_REGVAL_PRO,
|
||||
* CORE_ID_REGVAL_APP:
|
||||
* - If SPINLOCK_FREE, we want to atomically set to 'core_id'.
|
||||
* - If "our" core_id, we can drop through immediately.
|
||||
* - If "other_core_id", we spin here.
|
||||
*/
|
||||
result = core_id;
|
||||
|
||||
#if defined(CONFIG_ESP32_SPIRAM_SUPPORT)
|
||||
if (esp_ptr_external_ram(lock)) {
|
||||
compare_and_set_extram(&lock->owner, SPINLOCK_FREE, &result);
|
||||
} else {
|
||||
#endif
|
||||
compare_and_set_native(&lock->owner, SPINLOCK_FREE, &result);
|
||||
#if defined(CONFIG_ESP32_SPIRAM_SUPPORT)
|
||||
}
|
||||
#endif
|
||||
if(result != other_core_id) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (timeout != SPINLOCK_WAIT_FOREVER) {
|
||||
uint32_t ccount_now;
|
||||
RSR(CCOUNT, ccount_now);
|
||||
if (ccount_now - ccount_start > (unsigned)timeout) {
|
||||
XTOS_RESTORE_INTLEVEL(irq_status);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}while(1);
|
||||
|
||||
/* any other value implies memory corruption or uninitialized mux */
|
||||
assert(result == core_id || result == SPINLOCK_FREE);
|
||||
assert((result == SPINLOCK_FREE) == (lock->count == 0)); /* we're first to lock iff count is zero */
|
||||
assert(lock->count < 0xFF); /* Bad count value implies memory corruption */
|
||||
|
||||
lock->count++;
|
||||
XTOS_RESTORE_INTLEVEL(irq_status);
|
||||
return true;
|
||||
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Top level spinlock unlock function, unlocks a previously locked spinlock
|
||||
* @param lock - target, locked before, spinlock object
|
||||
*/
|
||||
static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *lock)
|
||||
{
|
||||
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
uint32_t irq_status;
|
||||
uint32_t core_id;
|
||||
|
||||
assert(lock);
|
||||
irq_status = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
|
||||
|
||||
RSR(PRID, core_id);
|
||||
assert(core_id == lock->owner); // This is a mutex we didn't lock, or it's corrupt
|
||||
lock->count--;
|
||||
|
||||
if(!lock->count) {
|
||||
lock->owner = SPINLOCK_FREE;
|
||||
} else {
|
||||
assert(lock->count < 0x100); // Indicates memory corruption
|
||||
}
|
||||
|
||||
XTOS_RESTORE_INTLEVEL(irq_status);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
46
tools/sdk/esp32/include/soc/include/soc_log.h
Normal file
46
tools/sdk/esp32/include/soc/include/soc_log.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2016-2017 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file soc_log.h
|
||||
* @brief SOC library logging functions
|
||||
*
|
||||
* To make SOC library compatible with environments which don't use ESP-IDF,
|
||||
* this header file provides wrappers for logging functions.
|
||||
*/
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_log.h"
|
||||
#define SOC_LOGE(tag, fmt, ...) ESP_EARLY_LOGE(tag, fmt, ##__VA_ARGS__)
|
||||
#define SOC_LOGW(tag, fmt, ...) ESP_EARLY_LOGW(tag, fmt, ##__VA_ARGS__)
|
||||
#define SOC_LOGI(tag, fmt, ...) ESP_EARLY_LOGI(tag, fmt, ##__VA_ARGS__)
|
||||
#define SOC_LOGD(tag, fmt, ...) ESP_EARLY_LOGD(tag, fmt, ##__VA_ARGS__)
|
||||
#define SOC_LOGV(tag, fmt, ...) ESP_EARLY_LOGV(tag, fmt, ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#endif
|
||||
|
||||
#define SOC_LOGE(tag, fmt, ...) ets_printf("%s(err): " fmt, tag, ##__VA_ARGS__)
|
||||
#define SOC_LOGW(tag, fmt, ...) ets_printf("%s(warn): " fmt, tag, ##__VA_ARGS__)
|
||||
#define SOC_LOGI(tag, fmt, ...) ets_printf("%s(info): " fmt, tag, ##__VA_ARGS__)
|
||||
#define SOC_LOGD(tag, fmt, ...) ets_printf("%s(dbg): " fmt, tag, ##__VA_ARGS__)
|
||||
#define SOC_LOGV(tag, fmt, ...) ets_printf("%s: " fmt, tag, ##__VA_ARGS__)
|
||||
#endif //ESP_PLATFORM
|
||||
136
tools/sdk/esp32/include/soc/soc/esp32/i2c_apll.h
Normal file
136
tools/sdk/esp32/include/soc/soc/esp32/i2c_apll.h
Normal file
@@ -0,0 +1,136 @@
|
||||
// Copyright 2015-2017 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file i2c_apll.h
|
||||
* @brief Register definitions for audio PLL (APLL)
|
||||
*
|
||||
* This file lists register fields of APLL, located on an internal configuration
|
||||
* bus. These definitions are used via macros defined in i2c_rtc_clk.h, by
|
||||
* rtc_clk_apll_enable function in rtc_clk.c.
|
||||
*/
|
||||
|
||||
#define I2C_APLL 0X6D
|
||||
#define I2C_APLL_HOSTID 3
|
||||
|
||||
#define I2C_APLL_IR_CAL_DELAY 0
|
||||
#define I2C_APLL_IR_CAL_DELAY_MSB 3
|
||||
#define I2C_APLL_IR_CAL_DELAY_LSB 0
|
||||
|
||||
#define I2C_APLL_IR_CAL_RSTB 0
|
||||
#define I2C_APLL_IR_CAL_RSTB_MSB 4
|
||||
#define I2C_APLL_IR_CAL_RSTB_LSB 4
|
||||
|
||||
#define I2C_APLL_IR_CAL_START 0
|
||||
#define I2C_APLL_IR_CAL_START_MSB 5
|
||||
#define I2C_APLL_IR_CAL_START_LSB 5
|
||||
|
||||
#define I2C_APLL_IR_CAL_UNSTOP 0
|
||||
#define I2C_APLL_IR_CAL_UNSTOP_MSB 6
|
||||
#define I2C_APLL_IR_CAL_UNSTOP_LSB 6
|
||||
|
||||
#define I2C_APLL_OC_ENB_FCAL 0
|
||||
#define I2C_APLL_OC_ENB_FCAL_MSB 7
|
||||
#define I2C_APLL_OC_ENB_FCAL_LSB 7
|
||||
|
||||
#define I2C_APLL_IR_CAL_EXT_CAP 1
|
||||
#define I2C_APLL_IR_CAL_EXT_CAP_MSB 4
|
||||
#define I2C_APLL_IR_CAL_EXT_CAP_LSB 0
|
||||
|
||||
#define I2C_APLL_IR_CAL_ENX_CAP 1
|
||||
#define I2C_APLL_IR_CAL_ENX_CAP_MSB 5
|
||||
#define I2C_APLL_IR_CAL_ENX_CAP_LSB 5
|
||||
|
||||
#define I2C_APLL_OC_LBW 1
|
||||
#define I2C_APLL_OC_LBW_MSB 6
|
||||
#define I2C_APLL_OC_LBW_LSB 6
|
||||
|
||||
#define I2C_APLL_IR_CAL_CK_DIV 2
|
||||
#define I2C_APLL_IR_CAL_CK_DIV_MSB 3
|
||||
#define I2C_APLL_IR_CAL_CK_DIV_LSB 0
|
||||
|
||||
#define I2C_APLL_OC_DCHGP 2
|
||||
#define I2C_APLL_OC_DCHGP_MSB 6
|
||||
#define I2C_APLL_OC_DCHGP_LSB 4
|
||||
|
||||
#define I2C_APLL_OC_ENB_VCON 2
|
||||
#define I2C_APLL_OC_ENB_VCON_MSB 7
|
||||
#define I2C_APLL_OC_ENB_VCON_LSB 7
|
||||
|
||||
#define I2C_APLL_OR_CAL_CAP 3
|
||||
#define I2C_APLL_OR_CAL_CAP_MSB 4
|
||||
#define I2C_APLL_OR_CAL_CAP_LSB 0
|
||||
|
||||
#define I2C_APLL_OR_CAL_UDF 3
|
||||
#define I2C_APLL_OR_CAL_UDF_MSB 5
|
||||
#define I2C_APLL_OR_CAL_UDF_LSB 5
|
||||
|
||||
#define I2C_APLL_OR_CAL_OVF 3
|
||||
#define I2C_APLL_OR_CAL_OVF_MSB 6
|
||||
#define I2C_APLL_OR_CAL_OVF_LSB 6
|
||||
|
||||
#define I2C_APLL_OR_CAL_END 3
|
||||
#define I2C_APLL_OR_CAL_END_MSB 7
|
||||
#define I2C_APLL_OR_CAL_END_LSB 7
|
||||
|
||||
#define I2C_APLL_OR_OUTPUT_DIV 4
|
||||
#define I2C_APLL_OR_OUTPUT_DIV_MSB 4
|
||||
#define I2C_APLL_OR_OUTPUT_DIV_LSB 0
|
||||
|
||||
#define I2C_APLL_OC_TSCHGP 4
|
||||
#define I2C_APLL_OC_TSCHGP_MSB 6
|
||||
#define I2C_APLL_OC_TSCHGP_LSB 6
|
||||
|
||||
#define I2C_APLL_EN_FAST_CAL 4
|
||||
#define I2C_APLL_EN_FAST_CAL_MSB 7
|
||||
#define I2C_APLL_EN_FAST_CAL_LSB 7
|
||||
|
||||
#define I2C_APLL_OC_DHREF_SEL 5
|
||||
#define I2C_APLL_OC_DHREF_SEL_MSB 1
|
||||
#define I2C_APLL_OC_DHREF_SEL_LSB 0
|
||||
|
||||
#define I2C_APLL_OC_DLREF_SEL 5
|
||||
#define I2C_APLL_OC_DLREF_SEL_MSB 3
|
||||
#define I2C_APLL_OC_DLREF_SEL_LSB 2
|
||||
|
||||
#define I2C_APLL_SDM_DITHER 5
|
||||
#define I2C_APLL_SDM_DITHER_MSB 4
|
||||
#define I2C_APLL_SDM_DITHER_LSB 4
|
||||
|
||||
#define I2C_APLL_SDM_STOP 5
|
||||
#define I2C_APLL_SDM_STOP_MSB 5
|
||||
#define I2C_APLL_SDM_STOP_LSB 5
|
||||
|
||||
#define I2C_APLL_SDM_RSTB 5
|
||||
#define I2C_APLL_SDM_RSTB_MSB 6
|
||||
#define I2C_APLL_SDM_RSTB_LSB 6
|
||||
|
||||
#define I2C_APLL_OC_DVDD 6
|
||||
#define I2C_APLL_OC_DVDD_MSB 4
|
||||
#define I2C_APLL_OC_DVDD_LSB 0
|
||||
|
||||
#define I2C_APLL_DSDM2 7
|
||||
#define I2C_APLL_DSDM2_MSB 5
|
||||
#define I2C_APLL_DSDM2_LSB 0
|
||||
|
||||
#define I2C_APLL_DSDM1 8
|
||||
#define I2C_APLL_DSDM1_MSB 7
|
||||
#define I2C_APLL_DSDM1_LSB 0
|
||||
|
||||
#define I2C_APLL_DSDM0 9
|
||||
#define I2C_APLL_DSDM0_MSB 7
|
||||
#define I2C_APLL_DSDM0_LSB 0
|
||||
|
||||
208
tools/sdk/esp32/include/soc/soc/esp32/i2c_bbpll.h
Normal file
208
tools/sdk/esp32/include/soc/soc/esp32/i2c_bbpll.h
Normal file
@@ -0,0 +1,208 @@
|
||||
// Copyright 2015-2017 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file i2c_apll.h
|
||||
* @brief Register definitions for digital PLL (BBPLL)
|
||||
*
|
||||
* This file lists register fields of BBPLL, located on an internal configuration
|
||||
* bus. These definitions are used via macros defined in i2c_rtc_clk.h, by
|
||||
* rtc_clk_cpu_freq_set function in rtc_clk.c.
|
||||
*/
|
||||
|
||||
#define I2C_BBPLL 0x66
|
||||
#define I2C_BBPLL_HOSTID 4
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_DELAY 0
|
||||
#define I2C_BBPLL_IR_CAL_DELAY_MSB 3
|
||||
#define I2C_BBPLL_IR_CAL_DELAY_LSB 0
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_CK_DIV 0
|
||||
#define I2C_BBPLL_IR_CAL_CK_DIV_MSB 7
|
||||
#define I2C_BBPLL_IR_CAL_CK_DIV_LSB 4
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_EXT_CAP 1
|
||||
#define I2C_BBPLL_IR_CAL_EXT_CAP_MSB 3
|
||||
#define I2C_BBPLL_IR_CAL_EXT_CAP_LSB 0
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_ENX_CAP 1
|
||||
#define I2C_BBPLL_IR_CAL_ENX_CAP_MSB 4
|
||||
#define I2C_BBPLL_IR_CAL_ENX_CAP_LSB 4
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_RSTB 1
|
||||
#define I2C_BBPLL_IR_CAL_RSTB_MSB 5
|
||||
#define I2C_BBPLL_IR_CAL_RSTB_LSB 5
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_START 1
|
||||
#define I2C_BBPLL_IR_CAL_START_MSB 6
|
||||
#define I2C_BBPLL_IR_CAL_START_LSB 6
|
||||
|
||||
#define I2C_BBPLL_IR_CAL_UNSTOP 1
|
||||
#define I2C_BBPLL_IR_CAL_UNSTOP_MSB 7
|
||||
#define I2C_BBPLL_IR_CAL_UNSTOP_LSB 7
|
||||
|
||||
#define I2C_BBPLL_OC_REF_DIV 2
|
||||
#define I2C_BBPLL_OC_REF_DIV_MSB 3
|
||||
#define I2C_BBPLL_OC_REF_DIV_LSB 0
|
||||
|
||||
#define I2C_BBPLL_OC_DIV_10_8 2
|
||||
#define I2C_BBPLL_OC_DIV_10_8_MSB 6
|
||||
#define I2C_BBPLL_OC_DIV_10_8_LSB 4
|
||||
|
||||
#define I2C_BBPLL_OC_LREF 2
|
||||
#define I2C_BBPLL_OC_LREF_MSB 7
|
||||
#define I2C_BBPLL_OC_LREF_LSB 7
|
||||
|
||||
#define I2C_BBPLL_OC_DIV_7_0 3
|
||||
#define I2C_BBPLL_OC_DIV_7_0_MSB 7
|
||||
#define I2C_BBPLL_OC_DIV_7_0_LSB 0
|
||||
|
||||
#define I2C_BBPLL_OC_ENB_FCAL 4
|
||||
#define I2C_BBPLL_OC_ENB_FCAL_MSB 0
|
||||
#define I2C_BBPLL_OC_ENB_FCAL_LSB 0
|
||||
|
||||
#define I2C_BBPLL_OC_DCHGP 4
|
||||
#define I2C_BBPLL_OC_DCHGP_MSB 3
|
||||
#define I2C_BBPLL_OC_DCHGP_LSB 1
|
||||
|
||||
#define I2C_BBPLL_OC_DHREF_SEL 4
|
||||
#define I2C_BBPLL_OC_DHREF_SEL_MSB 5
|
||||
#define I2C_BBPLL_OC_DHREF_SEL_LSB 4
|
||||
|
||||
#define I2C_BBPLL_OC_DLREF_SEL 4
|
||||
#define I2C_BBPLL_OC_DLREF_SEL_MSB 7
|
||||
#define I2C_BBPLL_OC_DLREF_SEL_LSB 6
|
||||
|
||||
#define I2C_BBPLL_OC_DCUR 5
|
||||
#define I2C_BBPLL_OC_DCUR_MSB 2
|
||||
#define I2C_BBPLL_OC_DCUR_LSB 0
|
||||
|
||||
#define I2C_BBPLL_OC_BST_DIV 5
|
||||
#define I2C_BBPLL_OC_BST_DIV_MSB 3
|
||||
#define I2C_BBPLL_OC_BST_DIV_LSB 3
|
||||
|
||||
#define I2C_BBPLL_OC_BST_E2C 5
|
||||
#define I2C_BBPLL_OC_BST_E2C_MSB 4
|
||||
#define I2C_BBPLL_OC_BST_E2C_LSB 4
|
||||
|
||||
#define I2C_BBPLL_OC_TSCHGP 5
|
||||
#define I2C_BBPLL_OC_TSCHGP_MSB 5
|
||||
#define I2C_BBPLL_OC_TSCHGP_LSB 5
|
||||
|
||||
#define I2C_BBPLL_OC_BW 5
|
||||
#define I2C_BBPLL_OC_BW_MSB 7
|
||||
#define I2C_BBPLL_OC_BW_LSB 6
|
||||
|
||||
#define I2C_BBPLL_OR_LOCK1 6
|
||||
#define I2C_BBPLL_OR_LOCK1_MSB 0
|
||||
#define I2C_BBPLL_OR_LOCK1_LSB 0
|
||||
|
||||
#define I2C_BBPLL_OR_LOCK2 6
|
||||
#define I2C_BBPLL_OR_LOCK2_MSB 1
|
||||
#define I2C_BBPLL_OR_LOCK2_LSB 1
|
||||
|
||||
#define I2C_BBPLL_OR_CAL_CAP 7
|
||||
#define I2C_BBPLL_OR_CAL_CAP_MSB 3
|
||||
#define I2C_BBPLL_OR_CAL_CAP_LSB 0
|
||||
|
||||
#define I2C_BBPLL_OR_CAL_UDF 7
|
||||
#define I2C_BBPLL_OR_CAL_UDF_MSB 4
|
||||
#define I2C_BBPLL_OR_CAL_UDF_LSB 4
|
||||
|
||||
#define I2C_BBPLL_OR_CAL_OVF 7
|
||||
#define I2C_BBPLL_OR_CAL_OVF_MSB 5
|
||||
#define I2C_BBPLL_OR_CAL_OVF_LSB 5
|
||||
|
||||
#define I2C_BBPLL_OR_CAL_END 7
|
||||
#define I2C_BBPLL_OR_CAL_END_MSB 6
|
||||
#define I2C_BBPLL_OR_CAL_END_LSB 6
|
||||
|
||||
#define I2C_BBPLL_BBADC_DELAY1 8
|
||||
#define I2C_BBPLL_BBADC_DELAY1_MSB 1
|
||||
#define I2C_BBPLL_BBADC_DELAY1_LSB 0
|
||||
|
||||
#define I2C_BBPLL_BBADC_DELAY2 8
|
||||
#define I2C_BBPLL_BBADC_DELAY2_MSB 3
|
||||
#define I2C_BBPLL_BBADC_DELAY2_LSB 2
|
||||
|
||||
#define I2C_BBPLL_BBADC_DELAY3 8
|
||||
#define I2C_BBPLL_BBADC_DELAY3_MSB 5
|
||||
#define I2C_BBPLL_BBADC_DELAY3_LSB 4
|
||||
|
||||
#define I2C_BBPLL_BBADC_DELAY4 8
|
||||
#define I2C_BBPLL_BBADC_DELAY4_MSB 7
|
||||
#define I2C_BBPLL_BBADC_DELAY4_LSB 6
|
||||
|
||||
#define I2C_BBPLL_BBADC_DELAY5 9
|
||||
#define I2C_BBPLL_BBADC_DELAY5_MSB 1
|
||||
#define I2C_BBPLL_BBADC_DELAY5_LSB 0
|
||||
|
||||
#define I2C_BBPLL_BBADC_DELAY6 9
|
||||
#define I2C_BBPLL_BBADC_DELAY6_MSB 3
|
||||
#define I2C_BBPLL_BBADC_DELAY6_LSB 2
|
||||
|
||||
#define I2C_BBPLL_BBADC_DSMP 9
|
||||
#define I2C_BBPLL_BBADC_DSMP_MSB 7
|
||||
#define I2C_BBPLL_BBADC_DSMP_LSB 4
|
||||
|
||||
#define I2C_BBPLL_DTEST 10
|
||||
#define I2C_BBPLL_DTEST_MSB 1
|
||||
#define I2C_BBPLL_DTEST_LSB 0
|
||||
|
||||
#define I2C_BBPLL_ENT_ADC 10
|
||||
#define I2C_BBPLL_ENT_ADC_MSB 3
|
||||
#define I2C_BBPLL_ENT_ADC_LSB 2
|
||||
|
||||
#define I2C_BBPLL_BBADC_DIV 10
|
||||
#define I2C_BBPLL_BBADC_DIV_MSB 5
|
||||
#define I2C_BBPLL_BBADC_DIV_LSB 4
|
||||
|
||||
#define I2C_BBPLL_ENT_PLL 10
|
||||
#define I2C_BBPLL_ENT_PLL_MSB 6
|
||||
#define I2C_BBPLL_ENT_PLL_LSB 6
|
||||
|
||||
#define I2C_BBPLL_OC_ENB_VCON 10
|
||||
#define I2C_BBPLL_OC_ENB_VCON_MSB 7
|
||||
#define I2C_BBPLL_OC_ENB_VCON_LSB 7
|
||||
|
||||
#define I2C_BBPLL_DIV_DAC 11
|
||||
#define I2C_BBPLL_DIV_DAC_MSB 0
|
||||
#define I2C_BBPLL_DIV_DAC_LSB 0
|
||||
|
||||
#define I2C_BBPLL_DIV_CPU 11
|
||||
#define I2C_BBPLL_DIV_CPU_MSB 1
|
||||
#define I2C_BBPLL_DIV_CPU_LSB 1
|
||||
|
||||
#define I2C_BBPLL_BBADC_INPUT_SHORT 11
|
||||
#define I2C_BBPLL_BBADC_INPUT_SHORT_MSB 2
|
||||
#define I2C_BBPLL_BBADC_INPUT_SHORT_LSB 2
|
||||
|
||||
#define I2C_BBPLL_BBADC_CAL_9_8 11
|
||||
#define I2C_BBPLL_BBADC_CAL_9_8_MSB 4
|
||||
#define I2C_BBPLL_BBADC_CAL_9_8_LSB 3
|
||||
|
||||
#define I2C_BBPLL_BBADC_DCM 11
|
||||
#define I2C_BBPLL_BBADC_DCM_MSB 6
|
||||
#define I2C_BBPLL_BBADC_DCM_LSB 5
|
||||
|
||||
#define I2C_BBPLL_ENDIV5 11
|
||||
#define I2C_BBPLL_ENDIV5_MSB 7
|
||||
#define I2C_BBPLL_ENDIV5_LSB 7
|
||||
|
||||
#define I2C_BBPLL_BBADC_CAL_7_0 12
|
||||
#define I2C_BBPLL_BBADC_CAL_7_0_MSB 7
|
||||
#define I2C_BBPLL_BBADC_CAL_7_0_LSB 0
|
||||
|
||||
29
tools/sdk/esp32/include/soc/soc/esp32/include/soc/adc_caps.h
Normal file
29
tools/sdk/esp32/include/soc/soc/esp32/include/soc/adc_caps.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#define SOC_ADC_PERIPH_NUM (2)
|
||||
#define SOC_ADC_PATT_LEN_MAX (16)
|
||||
|
||||
#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 8: 10)
|
||||
#define SOC_ADC_MAX_CHANNEL_NUM (10)
|
||||
|
||||
#define SOC_ADC1_DATA_INVERT_DEFAULT (1)
|
||||
#define SOC_ADC2_DATA_INVERT_DEFAULT (1)
|
||||
|
||||
#define SOC_ADC_DIGI_DATA_INVERT_DEFAULT(PERIPH_NUM) (1)
|
||||
|
||||
#define SOC_ADC_FSM_RSTB_WAIT_DEFAULT (8)
|
||||
#define SOC_ADC_FSM_START_WAIT_DEFAULT (5)
|
||||
#define SOC_ADC_FSM_STANDBY_WAIT_DEFAULT (100)
|
||||
#define ADC_FSM_SAMPLE_CYCLE_DEFAULT (2)
|
||||
|
||||
/**
|
||||
* Check if adc support digital controller (DMA) mode.
|
||||
* @value
|
||||
* - 1 : support;
|
||||
* - 0 : not support;
|
||||
*/
|
||||
#define SOC_ADC_SUPPORT_DMA_MODE(PERIPH_NUM) ((PERIPH_NUM==0)? 1: 0)
|
||||
|
||||
#define SOC_ADC_PWDET_CCT_DEFAULT (4)
|
||||
|
||||
#define SOC_ADC_SAR_CLK_DIV_DEFAULT(PERIPH_NUM) (2)
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_ADC_CHANNEL_H
|
||||
#define _SOC_ADC_CHANNEL_H
|
||||
|
||||
#define ADC1_GPIO36_CHANNEL ADC1_CHANNEL_0
|
||||
#define ADC1_CHANNEL_0_GPIO_NUM 36
|
||||
|
||||
#define ADC1_GPIO37_CHANNEL ADC1_CHANNEL_1
|
||||
#define ADC1_CHANNEL_1_GPIO_NUM 37
|
||||
|
||||
#define ADC1_GPIO38_CHANNEL ADC1_CHANNEL_2
|
||||
#define ADC1_CHANNEL_2_GPIO_NUM 38
|
||||
|
||||
#define ADC1_GPIO39_CHANNEL ADC1_CHANNEL_3
|
||||
#define ADC1_CHANNEL_3_GPIO_NUM 39
|
||||
|
||||
#define ADC1_GPIO32_CHANNEL ADC1_CHANNEL_4
|
||||
#define ADC1_CHANNEL_4_GPIO_NUM 32
|
||||
|
||||
#define ADC1_GPIO33_CHANNEL ADC1_CHANNEL_5
|
||||
#define ADC1_CHANNEL_5_GPIO_NUM 33
|
||||
|
||||
#define ADC1_GPIO34_CHANNEL ADC1_CHANNEL_6
|
||||
#define ADC1_CHANNEL_6_GPIO_NUM 34
|
||||
|
||||
#define ADC1_GPIO35_CHANNEL ADC1_CHANNEL_7
|
||||
#define ADC1_CHANNEL_7_GPIO_NUM 35
|
||||
|
||||
#define ADC2_GPIO4_CHANNEL ADC2_CHANNEL_0
|
||||
#define ADC2_CHANNEL_0_GPIO_NUM 4
|
||||
|
||||
#define ADC2_GPIO0_CHANNEL ADC2_CHANNEL_1
|
||||
#define ADC2_CHANNEL_1_GPIO_NUM 0
|
||||
|
||||
#define ADC2_GPIO2_CHANNEL ADC2_CHANNEL_2
|
||||
#define ADC2_CHANNEL_2_GPIO_NUM 2
|
||||
|
||||
#define ADC2_GPIO15_CHANNEL ADC2_CHANNEL_3
|
||||
#define ADC2_CHANNEL_3_GPIO_NUM 15
|
||||
|
||||
#define ADC2_GPIO13_CHANNEL ADC2_CHANNEL_4
|
||||
#define ADC2_CHANNEL_4_GPIO_NUM 13
|
||||
|
||||
#define ADC2_GPIO12_CHANNEL ADC2_CHANNEL_5
|
||||
#define ADC2_CHANNEL_5_GPIO_NUM 12
|
||||
|
||||
#define ADC2_GPIO14_CHANNEL ADC2_CHANNEL_6
|
||||
#define ADC2_CHANNEL_6_GPIO_NUM 14
|
||||
|
||||
#define ADC2_GPIO27_CHANNEL ADC2_CHANNEL_7
|
||||
#define ADC2_CHANNEL_7_GPIO_NUM 27
|
||||
|
||||
#define ADC2_GPIO25_CHANNEL ADC2_CHANNEL_8
|
||||
#define ADC2_CHANNEL_8_GPIO_NUM 25
|
||||
|
||||
#define ADC2_GPIO26_CHANNEL ADC2_CHANNEL_9
|
||||
#define ADC2_CHANNEL_9_GPIO_NUM 26
|
||||
|
||||
#endif /* _SOC_ADC_CHANNEL_H_ */
|
||||
294
tools/sdk/esp32/include/soc/soc/esp32/include/soc/apb_ctrl_reg.h
Normal file
294
tools/sdk/esp32/include/soc/soc/esp32/include/soc/apb_ctrl_reg.h
Normal file
@@ -0,0 +1,294 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_APB_CTRL_REG_H_
|
||||
#define _SOC_APB_CTRL_REG_H_
|
||||
|
||||
#include "soc.h"
|
||||
#define APB_CTRL_SYSCLK_CONF_REG (DR_REG_APB_CTRL_BASE + 0x0)
|
||||
/* APB_CTRL_QUICK_CLK_CHNG : R/W ;bitpos:[13] ;default: 1'b1 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_QUICK_CLK_CHNG (BIT(13))
|
||||
#define APB_CTRL_QUICK_CLK_CHNG_M (BIT(13))
|
||||
#define APB_CTRL_QUICK_CLK_CHNG_V 0x1
|
||||
#define APB_CTRL_QUICK_CLK_CHNG_S 13
|
||||
/* APB_CTRL_RST_TICK_CNT : R/W ;bitpos:[12] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_RST_TICK_CNT (BIT(12))
|
||||
#define APB_CTRL_RST_TICK_CNT_M (BIT(12))
|
||||
#define APB_CTRL_RST_TICK_CNT_V 0x1
|
||||
#define APB_CTRL_RST_TICK_CNT_S 12
|
||||
/* APB_CTRL_CLK_EN : R/W ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_CLK_EN (BIT(11))
|
||||
#define APB_CTRL_CLK_EN_M (BIT(11))
|
||||
#define APB_CTRL_CLK_EN_V 0x1
|
||||
#define APB_CTRL_CLK_EN_S 11
|
||||
/* APB_CTRL_CLK_320M_EN : R/W ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_CLK_320M_EN (BIT(10))
|
||||
#define APB_CTRL_CLK_320M_EN_M (BIT(10))
|
||||
#define APB_CTRL_CLK_320M_EN_V 0x1
|
||||
#define APB_CTRL_CLK_320M_EN_S 10
|
||||
/* APB_CTRL_PRE_DIV_CNT : R/W ;bitpos:[9:0] ;default: 10'h0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_PRE_DIV_CNT 0x000003FF
|
||||
#define APB_CTRL_PRE_DIV_CNT_M ((APB_CTRL_PRE_DIV_CNT_V)<<(APB_CTRL_PRE_DIV_CNT_S))
|
||||
#define APB_CTRL_PRE_DIV_CNT_V 0x3FF
|
||||
#define APB_CTRL_PRE_DIV_CNT_S 0
|
||||
|
||||
#define APB_CTRL_XTAL_TICK_CONF_REG (DR_REG_APB_CTRL_BASE + 0x4)
|
||||
/* APB_CTRL_XTAL_TICK_NUM : R/W ;bitpos:[7:0] ;default: 8'd39 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_XTAL_TICK_NUM 0x000000FF
|
||||
#define APB_CTRL_XTAL_TICK_NUM_M ((APB_CTRL_XTAL_TICK_NUM_V)<<(APB_CTRL_XTAL_TICK_NUM_S))
|
||||
#define APB_CTRL_XTAL_TICK_NUM_V 0xFF
|
||||
#define APB_CTRL_XTAL_TICK_NUM_S 0
|
||||
|
||||
#define APB_CTRL_PLL_TICK_CONF_REG (DR_REG_APB_CTRL_BASE + 0x8)
|
||||
/* APB_CTRL_PLL_TICK_NUM : R/W ;bitpos:[7:0] ;default: 8'd79 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_PLL_TICK_NUM 0x000000FF
|
||||
#define APB_CTRL_PLL_TICK_NUM_M ((APB_CTRL_PLL_TICK_NUM_V)<<(APB_CTRL_PLL_TICK_NUM_S))
|
||||
#define APB_CTRL_PLL_TICK_NUM_V 0xFF
|
||||
#define APB_CTRL_PLL_TICK_NUM_S 0
|
||||
|
||||
#define APB_CTRL_CK8M_TICK_CONF_REG (DR_REG_APB_CTRL_BASE + 0xC)
|
||||
/* APB_CTRL_CK8M_TICK_NUM : R/W ;bitpos:[7:0] ;default: 8'd11 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_CK8M_TICK_NUM 0x000000FF
|
||||
#define APB_CTRL_CK8M_TICK_NUM_M ((APB_CTRL_CK8M_TICK_NUM_V)<<(APB_CTRL_CK8M_TICK_NUM_S))
|
||||
#define APB_CTRL_CK8M_TICK_NUM_V 0xFF
|
||||
#define APB_CTRL_CK8M_TICK_NUM_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_CTRL_REG (DR_REG_APB_CTRL_BASE + 0x10)
|
||||
/* APB_CTRL_SARADC_DATA_TO_I2S : R/W ;bitpos:[26] ;default: 1'b0 ; */
|
||||
/*description: 1: I2S input data is from SAR ADC (for DMA) 0: I2S input data
|
||||
is from GPIO matrix*/
|
||||
#define APB_CTRL_SARADC_DATA_TO_I2S (BIT(26))
|
||||
#define APB_CTRL_SARADC_DATA_TO_I2S_M (BIT(26))
|
||||
#define APB_CTRL_SARADC_DATA_TO_I2S_V 0x1
|
||||
#define APB_CTRL_SARADC_DATA_TO_I2S_S 26
|
||||
/* APB_CTRL_SARADC_DATA_SAR_SEL : R/W ;bitpos:[25] ;default: 1'b0 ; */
|
||||
/*description: 1: sar_sel will be coded by the MSB of the 16-bit output data
|
||||
in this case the resolution should not be larger than 11 bits.*/
|
||||
#define APB_CTRL_SARADC_DATA_SAR_SEL (BIT(25))
|
||||
#define APB_CTRL_SARADC_DATA_SAR_SEL_M (BIT(25))
|
||||
#define APB_CTRL_SARADC_DATA_SAR_SEL_V 0x1
|
||||
#define APB_CTRL_SARADC_DATA_SAR_SEL_S 25
|
||||
/* APB_CTRL_SARADC_SAR2_PATT_P_CLEAR : R/W ;bitpos:[24] ;default: 1'd0 ; */
|
||||
/*description: clear the pointer of pattern table for DIG ADC2 CTRL*/
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_P_CLEAR (BIT(24))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_P_CLEAR_M (BIT(24))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_P_CLEAR_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_P_CLEAR_S 24
|
||||
/* APB_CTRL_SARADC_SAR1_PATT_P_CLEAR : R/W ;bitpos:[23] ;default: 1'd0 ; */
|
||||
/*description: clear the pointer of pattern table for DIG ADC1 CTRL*/
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_P_CLEAR (BIT(23))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_P_CLEAR_M (BIT(23))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_P_CLEAR_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_P_CLEAR_S 23
|
||||
/* APB_CTRL_SARADC_SAR2_PATT_LEN : R/W ;bitpos:[22:19] ;default: 4'd15 ; */
|
||||
/*description: 0 ~ 15 means length 1 ~ 16*/
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_LEN 0x0000000F
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_LEN_M ((APB_CTRL_SARADC_SAR2_PATT_LEN_V)<<(APB_CTRL_SARADC_SAR2_PATT_LEN_S))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_LEN_V 0xF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_LEN_S 19
|
||||
/* APB_CTRL_SARADC_SAR1_PATT_LEN : R/W ;bitpos:[18:15] ;default: 4'd15 ; */
|
||||
/*description: 0 ~ 15 means length 1 ~ 16*/
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_LEN 0x0000000F
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_LEN_M ((APB_CTRL_SARADC_SAR1_PATT_LEN_V)<<(APB_CTRL_SARADC_SAR1_PATT_LEN_S))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_LEN_V 0xF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_LEN_S 15
|
||||
/* APB_CTRL_SARADC_SAR_CLK_DIV : R/W ;bitpos:[14:7] ;default: 8'd4 ; */
|
||||
/*description: SAR clock divider*/
|
||||
#define APB_CTRL_SARADC_SAR_CLK_DIV 0x000000FF
|
||||
#define APB_CTRL_SARADC_SAR_CLK_DIV_M ((APB_CTRL_SARADC_SAR_CLK_DIV_V)<<(APB_CTRL_SARADC_SAR_CLK_DIV_S))
|
||||
#define APB_CTRL_SARADC_SAR_CLK_DIV_V 0xFF
|
||||
#define APB_CTRL_SARADC_SAR_CLK_DIV_S 7
|
||||
/* APB_CTRL_SARADC_SAR_CLK_GATED : R/W ;bitpos:[6] ;default: 1'b1 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_SAR_CLK_GATED (BIT(6))
|
||||
#define APB_CTRL_SARADC_SAR_CLK_GATED_M (BIT(6))
|
||||
#define APB_CTRL_SARADC_SAR_CLK_GATED_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR_CLK_GATED_S 6
|
||||
/* APB_CTRL_SARADC_SAR_SEL : R/W ;bitpos:[5] ;default: 1'd0 ; */
|
||||
/*description: 0: SAR1 1: SAR2 only work for single SAR mode*/
|
||||
#define APB_CTRL_SARADC_SAR_SEL (BIT(5))
|
||||
#define APB_CTRL_SARADC_SAR_SEL_M (BIT(5))
|
||||
#define APB_CTRL_SARADC_SAR_SEL_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR_SEL_S 5
|
||||
/* APB_CTRL_SARADC_WORK_MODE : R/W ;bitpos:[4:3] ;default: 2'd0 ; */
|
||||
/*description: 0: single mode 1: double mode 2: alternate mode*/
|
||||
#define APB_CTRL_SARADC_WORK_MODE 0x00000003
|
||||
#define APB_CTRL_SARADC_WORK_MODE_M ((APB_CTRL_SARADC_WORK_MODE_V)<<(APB_CTRL_SARADC_WORK_MODE_S))
|
||||
#define APB_CTRL_SARADC_WORK_MODE_V 0x3
|
||||
#define APB_CTRL_SARADC_WORK_MODE_S 3
|
||||
/* APB_CTRL_SARADC_SAR2_MUX : R/W ;bitpos:[2] ;default: 1'd0 ; */
|
||||
/*description: 1: SAR ADC2 is controlled by DIG ADC2 CTRL 0: SAR ADC2 is controlled
|
||||
by PWDET CTRL*/
|
||||
#define APB_CTRL_SARADC_SAR2_MUX (BIT(2))
|
||||
#define APB_CTRL_SARADC_SAR2_MUX_M (BIT(2))
|
||||
#define APB_CTRL_SARADC_SAR2_MUX_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR2_MUX_S 2
|
||||
/* APB_CTRL_SARADC_START : R/W ;bitpos:[1] ;default: 1'd0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_START (BIT(1))
|
||||
#define APB_CTRL_SARADC_START_M (BIT(1))
|
||||
#define APB_CTRL_SARADC_START_V 0x1
|
||||
#define APB_CTRL_SARADC_START_S 1
|
||||
/* APB_CTRL_SARADC_START_FORCE : R/W ;bitpos:[0] ;default: 1'd0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_START_FORCE (BIT(0))
|
||||
#define APB_CTRL_SARADC_START_FORCE_M (BIT(0))
|
||||
#define APB_CTRL_SARADC_START_FORCE_V 0x1
|
||||
#define APB_CTRL_SARADC_START_FORCE_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_CTRL2_REG (DR_REG_APB_CTRL_BASE + 0x14)
|
||||
/* APB_CTRL_SARADC_SAR2_INV : R/W ;bitpos:[10] ;default: 1'd0 ; */
|
||||
/*description: 1: data to DIG ADC2 CTRL is inverted otherwise not*/
|
||||
#define APB_CTRL_SARADC_SAR2_INV (BIT(10))
|
||||
#define APB_CTRL_SARADC_SAR2_INV_M (BIT(10))
|
||||
#define APB_CTRL_SARADC_SAR2_INV_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR2_INV_S 10
|
||||
/* APB_CTRL_SARADC_SAR1_INV : R/W ;bitpos:[9] ;default: 1'd0 ; */
|
||||
/*description: 1: data to DIG ADC1 CTRL is inverted otherwise not*/
|
||||
#define APB_CTRL_SARADC_SAR1_INV (BIT(9))
|
||||
#define APB_CTRL_SARADC_SAR1_INV_M (BIT(9))
|
||||
#define APB_CTRL_SARADC_SAR1_INV_V 0x1
|
||||
#define APB_CTRL_SARADC_SAR1_INV_S 9
|
||||
/* APB_CTRL_SARADC_MAX_MEAS_NUM : R/W ;bitpos:[8:1] ;default: 8'd255 ; */
|
||||
/*description: max conversion number*/
|
||||
#define APB_CTRL_SARADC_MAX_MEAS_NUM 0x000000FF
|
||||
#define APB_CTRL_SARADC_MAX_MEAS_NUM_M ((APB_CTRL_SARADC_MAX_MEAS_NUM_V)<<(APB_CTRL_SARADC_MAX_MEAS_NUM_S))
|
||||
#define APB_CTRL_SARADC_MAX_MEAS_NUM_V 0xFF
|
||||
#define APB_CTRL_SARADC_MAX_MEAS_NUM_S 1
|
||||
/* APB_CTRL_SARADC_MEAS_NUM_LIMIT : R/W ;bitpos:[0] ;default: 1'd0 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_MEAS_NUM_LIMIT (BIT(0))
|
||||
#define APB_CTRL_SARADC_MEAS_NUM_LIMIT_M (BIT(0))
|
||||
#define APB_CTRL_SARADC_MEAS_NUM_LIMIT_V 0x1
|
||||
#define APB_CTRL_SARADC_MEAS_NUM_LIMIT_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_FSM_REG (DR_REG_APB_CTRL_BASE + 0x18)
|
||||
/* APB_CTRL_SARADC_SAMPLE_CYCLE : R/W ;bitpos:[31:24] ;default: 8'd2 ; */
|
||||
/*description: sample cycles*/
|
||||
#define APB_CTRL_SARADC_SAMPLE_CYCLE 0x000000FF
|
||||
#define APB_CTRL_SARADC_SAMPLE_CYCLE_M ((APB_CTRL_SARADC_SAMPLE_CYCLE_V)<<(APB_CTRL_SARADC_SAMPLE_CYCLE_S))
|
||||
#define APB_CTRL_SARADC_SAMPLE_CYCLE_V 0xFF
|
||||
#define APB_CTRL_SARADC_SAMPLE_CYCLE_S 24
|
||||
/* APB_CTRL_SARADC_START_WAIT : R/W ;bitpos:[23:16] ;default: 8'd8 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_START_WAIT 0x000000FF
|
||||
#define APB_CTRL_SARADC_START_WAIT_M ((APB_CTRL_SARADC_START_WAIT_V)<<(APB_CTRL_SARADC_START_WAIT_S))
|
||||
#define APB_CTRL_SARADC_START_WAIT_V 0xFF
|
||||
#define APB_CTRL_SARADC_START_WAIT_S 16
|
||||
/* APB_CTRL_SARADC_STANDBY_WAIT : R/W ;bitpos:[15:8] ;default: 8'd255 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_STANDBY_WAIT 0x000000FF
|
||||
#define APB_CTRL_SARADC_STANDBY_WAIT_M ((APB_CTRL_SARADC_STANDBY_WAIT_V)<<(APB_CTRL_SARADC_STANDBY_WAIT_S))
|
||||
#define APB_CTRL_SARADC_STANDBY_WAIT_V 0xFF
|
||||
#define APB_CTRL_SARADC_STANDBY_WAIT_S 8
|
||||
/* APB_CTRL_SARADC_RSTB_WAIT : R/W ;bitpos:[7:0] ;default: 8'd8 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_SARADC_RSTB_WAIT 0x000000FF
|
||||
#define APB_CTRL_SARADC_RSTB_WAIT_M ((APB_CTRL_SARADC_RSTB_WAIT_V)<<(APB_CTRL_SARADC_RSTB_WAIT_S))
|
||||
#define APB_CTRL_SARADC_RSTB_WAIT_V 0xFF
|
||||
#define APB_CTRL_SARADC_RSTB_WAIT_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR1_PATT_TAB1_REG (DR_REG_APB_CTRL_BASE + 0x1C)
|
||||
/* APB_CTRL_SARADC_SAR1_PATT_TAB1 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: item 0 ~ 3 for pattern table 1 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB1 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB1_M ((APB_CTRL_SARADC_SAR1_PATT_TAB1_V)<<(APB_CTRL_SARADC_SAR1_PATT_TAB1_S))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB1_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB1_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR1_PATT_TAB2_REG (DR_REG_APB_CTRL_BASE + 0x20)
|
||||
/* APB_CTRL_SARADC_SAR1_PATT_TAB2 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: Item 4 ~ 7 for pattern table 1 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB2 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB2_M ((APB_CTRL_SARADC_SAR1_PATT_TAB2_V)<<(APB_CTRL_SARADC_SAR1_PATT_TAB2_S))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB2_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB2_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR1_PATT_TAB3_REG (DR_REG_APB_CTRL_BASE + 0x24)
|
||||
/* APB_CTRL_SARADC_SAR1_PATT_TAB3 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: Item 8 ~ 11 for pattern table 1 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB3 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB3_M ((APB_CTRL_SARADC_SAR1_PATT_TAB3_V)<<(APB_CTRL_SARADC_SAR1_PATT_TAB3_S))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB3_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB3_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR1_PATT_TAB4_REG (DR_REG_APB_CTRL_BASE + 0x28)
|
||||
/* APB_CTRL_SARADC_SAR1_PATT_TAB4 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: Item 12 ~ 15 for pattern table 1 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB4 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB4_M ((APB_CTRL_SARADC_SAR1_PATT_TAB4_V)<<(APB_CTRL_SARADC_SAR1_PATT_TAB4_S))
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB4_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR1_PATT_TAB4_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR2_PATT_TAB1_REG (DR_REG_APB_CTRL_BASE + 0x2C)
|
||||
/* APB_CTRL_SARADC_SAR2_PATT_TAB1 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: item 0 ~ 3 for pattern table 2 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB1 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB1_M ((APB_CTRL_SARADC_SAR2_PATT_TAB1_V)<<(APB_CTRL_SARADC_SAR2_PATT_TAB1_S))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB1_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB1_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR2_PATT_TAB2_REG (DR_REG_APB_CTRL_BASE + 0x30)
|
||||
/* APB_CTRL_SARADC_SAR2_PATT_TAB2 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: Item 4 ~ 7 for pattern table 2 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB2 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB2_M ((APB_CTRL_SARADC_SAR2_PATT_TAB2_V)<<(APB_CTRL_SARADC_SAR2_PATT_TAB2_S))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB2_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB2_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR2_PATT_TAB3_REG (DR_REG_APB_CTRL_BASE + 0x34)
|
||||
/* APB_CTRL_SARADC_SAR2_PATT_TAB3 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: Item 8 ~ 11 for pattern table 2 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB3 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB3_M ((APB_CTRL_SARADC_SAR2_PATT_TAB3_V)<<(APB_CTRL_SARADC_SAR2_PATT_TAB3_S))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB3_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB3_S 0
|
||||
|
||||
#define APB_CTRL_APB_SARADC_SAR2_PATT_TAB4_REG (DR_REG_APB_CTRL_BASE + 0x38)
|
||||
/* APB_CTRL_SARADC_SAR2_PATT_TAB4 : R/W ;bitpos:[31:0] ;default: 32'hf0f0f0f ; */
|
||||
/*description: Item 12 ~ 15 for pattern table 2 (each item one byte)*/
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB4 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB4_M ((APB_CTRL_SARADC_SAR2_PATT_TAB4_V)<<(APB_CTRL_SARADC_SAR2_PATT_TAB4_S))
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB4_V 0xFFFFFFFF
|
||||
#define APB_CTRL_SARADC_SAR2_PATT_TAB4_S 0
|
||||
|
||||
#define APB_CTRL_APLL_TICK_CONF_REG (DR_REG_APB_CTRL_BASE + 0x3C)
|
||||
/* APB_CTRL_APLL_TICK_NUM : R/W ;bitpos:[7:0] ;default: 8'd99 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_APLL_TICK_NUM 0x000000FF
|
||||
#define APB_CTRL_APLL_TICK_NUM_M ((APB_CTRL_APLL_TICK_NUM_V)<<(APB_CTRL_APLL_TICK_NUM_S))
|
||||
#define APB_CTRL_APLL_TICK_NUM_V 0xFF
|
||||
#define APB_CTRL_APLL_TICK_NUM_S 0
|
||||
|
||||
#define APB_CTRL_DATE_REG (DR_REG_APB_CTRL_BASE + 0x7C)
|
||||
/* APB_CTRL_DATE : R/W ;bitpos:[31:0] ;default: 32'h16042000 ; */
|
||||
/*description: */
|
||||
#define APB_CTRL_DATE 0xFFFFFFFF
|
||||
#define APB_CTRL_DATE_M ((APB_CTRL_DATE_V)<<(APB_CTRL_DATE_S))
|
||||
#define APB_CTRL_DATE_V 0xFFFFFFFF
|
||||
#define APB_CTRL_DATE_S 0
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*_SOC_APB_CTRL_REG_H_ */
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_APB_CTRL_STRUCT_H_
|
||||
#define _SOC_APB_CTRL_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct apb_ctrl_dev_s {
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t pre_div: 10;
|
||||
volatile uint32_t clk_320m_en: 1;
|
||||
volatile uint32_t clk_en: 1;
|
||||
volatile uint32_t rst_tick: 1;
|
||||
volatile uint32_t quick_clk_chng: 1;
|
||||
volatile uint32_t reserved14: 18;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}clk_conf;
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t xtal_tick: 8;
|
||||
volatile uint32_t reserved8: 24;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}xtal_tick_conf;
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t pll_tick: 8;
|
||||
volatile uint32_t reserved8: 24;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}pll_tick_conf;
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t ck8m_tick: 8;
|
||||
volatile uint32_t reserved8: 24;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}ck8m_tick_conf;
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t start_force: 1;
|
||||
volatile uint32_t start: 1;
|
||||
volatile uint32_t sar2_mux: 1; /*1: SAR ADC2 is controlled by DIG ADC2 CTRL 0: SAR ADC2 is controlled by PWDET CTRL*/
|
||||
volatile uint32_t work_mode: 2; /*0: single mode 1: double mode 2: alternate mode*/
|
||||
volatile uint32_t sar_sel: 1; /*0: SAR1 1: SAR2 only work for single SAR mode*/
|
||||
volatile uint32_t sar_clk_gated: 1;
|
||||
volatile uint32_t sar_clk_div: 8; /*SAR clock divider*/
|
||||
volatile uint32_t sar1_patt_len: 4; /*0 ~ 15 means length 1 ~ 16*/
|
||||
volatile uint32_t sar2_patt_len: 4; /*0 ~ 15 means length 1 ~ 16*/
|
||||
volatile uint32_t sar1_patt_p_clear: 1; /*clear the pointer of pattern table for DIG ADC1 CTRL*/
|
||||
volatile uint32_t sar2_patt_p_clear: 1; /*clear the pointer of pattern table for DIG ADC2 CTRL*/
|
||||
volatile uint32_t data_sar_sel: 1; /*1: sar_sel will be coded by the MSB of the 16-bit output data in this case the resolution should not be larger than 11 bits.*/
|
||||
volatile uint32_t data_to_i2s: 1; /*1: I2S input data is from SAR ADC (for DMA) 0: I2S input data is from GPIO matrix*/
|
||||
volatile uint32_t reserved27: 5;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}saradc_ctrl;
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t meas_num_limit: 1;
|
||||
volatile uint32_t max_meas_num: 8; /*max conversion number*/
|
||||
volatile uint32_t sar1_inv: 1; /*1: data to DIG ADC1 CTRL is inverted otherwise not*/
|
||||
volatile uint32_t sar2_inv: 1; /*1: data to DIG ADC2 CTRL is inverted otherwise not*/
|
||||
volatile uint32_t reserved11: 21;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}saradc_ctrl2;
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t rstb_wait: 8;
|
||||
volatile uint32_t standby_wait: 8;
|
||||
volatile uint32_t start_wait: 8;
|
||||
volatile uint32_t sample_cycle: 8; /*sample cycles*/
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}saradc_fsm;
|
||||
volatile uint32_t saradc_sar1_patt_tab1; /*item 0 ~ 3 for pattern table 1 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar1_patt_tab2; /*Item 4 ~ 7 for pattern table 1 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar1_patt_tab3; /*Item 8 ~ 11 for pattern table 1 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar1_patt_tab4; /*Item 12 ~ 15 for pattern table 1 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar2_patt_tab1; /*item 0 ~ 3 for pattern table 2 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar2_patt_tab2; /*Item 4 ~ 7 for pattern table 2 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar2_patt_tab3; /*Item 8 ~ 11 for pattern table 2 (each item one byte)*/
|
||||
volatile uint32_t saradc_sar2_patt_tab4; /*Item 12 ~ 15 for pattern table 2 (each item one byte)*/
|
||||
union {
|
||||
struct {
|
||||
volatile uint32_t apll_tick: 8;
|
||||
volatile uint32_t reserved8: 24;
|
||||
};
|
||||
volatile uint32_t val;
|
||||
}apll_tick_conf;
|
||||
volatile uint32_t reserved_40;
|
||||
volatile uint32_t reserved_44;
|
||||
volatile uint32_t reserved_48;
|
||||
volatile uint32_t reserved_4c;
|
||||
volatile uint32_t reserved_50;
|
||||
volatile uint32_t reserved_54;
|
||||
volatile uint32_t reserved_58;
|
||||
volatile uint32_t reserved_5c;
|
||||
volatile uint32_t reserved_60;
|
||||
volatile uint32_t reserved_64;
|
||||
volatile uint32_t reserved_68;
|
||||
volatile uint32_t reserved_6c;
|
||||
volatile uint32_t reserved_70;
|
||||
volatile uint32_t reserved_74;
|
||||
volatile uint32_t reserved_78;
|
||||
volatile uint32_t date; /**/
|
||||
} apb_ctrl_dev_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_APB_CTRL_STRUCT_H_ */
|
||||
42
tools/sdk/esp32/include/soc/soc/esp32/include/soc/bb_reg.h
Normal file
42
tools/sdk/esp32/include/soc/soc/esp32/include/soc/bb_reg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_BB_REG_H_
|
||||
#define _SOC_BB_REG_H_
|
||||
|
||||
/* Some of the baseband control registers.
|
||||
* PU/PD fields defined here are used in sleep related functions.
|
||||
*/
|
||||
|
||||
#define BBPD_CTRL (DR_REG_BB_BASE + 0x0054)
|
||||
#define BB_FFT_FORCE_PU (BIT(3))
|
||||
#define BB_FFT_FORCE_PU_M (BIT(3))
|
||||
#define BB_FFT_FORCE_PU_V 1
|
||||
#define BB_FFT_FORCE_PU_S 3
|
||||
#define BB_FFT_FORCE_PD (BIT(2))
|
||||
#define BB_FFT_FORCE_PD_M (BIT(2))
|
||||
#define BB_FFT_FORCE_PD_V 1
|
||||
#define BB_FFT_FORCE_PD_S 2
|
||||
#define BB_DC_EST_FORCE_PU (BIT(1))
|
||||
#define BB_DC_EST_FORCE_PU_M (BIT(1))
|
||||
#define BB_DC_EST_FORCE_PU_V 1
|
||||
#define BB_DC_EST_FORCE_PU_S 1
|
||||
#define BB_DC_EST_FORCE_PD (BIT(0))
|
||||
#define BB_DC_EST_FORCE_PD_M (BIT(0))
|
||||
#define BB_DC_EST_FORCE_PD_V 1
|
||||
#define BB_DC_EST_FORCE_PD_S 0
|
||||
|
||||
|
||||
#endif /* _SOC_BB_REG_H_ */
|
||||
|
||||
104
tools/sdk/esp32/include/soc/soc/esp32/include/soc/boot_mode.h
Normal file
104
tools/sdk/esp32/include/soc/soc/esp32/include/soc/boot_mode.h
Normal file
@@ -0,0 +1,104 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_BOOT_MODE_H_
|
||||
#define _SOC_BOOT_MODE_H_
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
/*SPI Boot*/
|
||||
#define IS_1XXXX(v) (((v)&0x10)==0x10)
|
||||
|
||||
/*HSPI Boot*/
|
||||
#define IS_010XX(v) (((v)&0x1c)==0x08)
|
||||
|
||||
/*Download Boot, SDIO/UART0/UART1*/
|
||||
#define IS_00XXX(v) (((v)&0x18)==0x00)
|
||||
|
||||
/*Download Boot, SDIO/UART0/UART1,FEI_FEO V2*/
|
||||
#define IS_00X00(v) (((v)&0x1b)==0x00)
|
||||
|
||||
/*Download Boot, SDIO/UART0/UART1,FEI_REO V2*/
|
||||
#define IS_00X01(v) (((v)&0x1b)==0x01)
|
||||
|
||||
/*Download Boot, SDIO/UART0/UART1,REI_FEO V2*/
|
||||
#define IS_00X10(v) (((v)&0x1b)==0x02)
|
||||
|
||||
/*Download Boot, SDIO/UART0/UART1,REI_FEO V2*/
|
||||
#define IS_00X11(v) (((v)&0x1b)==0x03)
|
||||
|
||||
/*ATE/ANALOG Mode*/
|
||||
#define IS_01110(v) (((v)&0x1f)==0x0e)
|
||||
|
||||
/*Diagnostic Mode+UART0 download Mode*/
|
||||
#define IS_01111(v) (((v)&0x1f)==0x0f)
|
||||
|
||||
/*legacy SPI Boot*/
|
||||
#define IS_01100(v) (((v)&0x1f)==0x0c)
|
||||
|
||||
/*SDIO_Slave download Mode V1.1*/
|
||||
#define IS_01101(v) (((v)&0x1f)==0x0d)
|
||||
|
||||
|
||||
|
||||
#define BOOT_MODE_GET() (GPIO_REG_READ(GPIO_STRAP))
|
||||
|
||||
/*do not include download mode*/
|
||||
#define ETS_IS_UART_BOOT() IS_01111(BOOT_MODE_GET())
|
||||
|
||||
/*all spi boot including spi/hspi/legacy*/
|
||||
#define ETS_IS_FLASH_BOOT() (IS_1XXXX(BOOT_MODE_GET()) || IS_010XX(BOOT_MODE_GET()) || IS_01100(BOOT_MODE_GET()))
|
||||
|
||||
/*all faster spi boot including spi/hspi*/
|
||||
#define ETS_IS_FAST_FLASH_BOOT() (IS_1XXXX(BOOT_MODE_GET()) || IS_010XX(BOOT_MODE_GET()))
|
||||
|
||||
/*all spi boot including spi/legacy*/
|
||||
#define ETS_IS_SPI_FLASH_BOOT() (IS_1XXXX(BOOT_MODE_GET()) || IS_01100(BOOT_MODE_GET()))
|
||||
|
||||
/*all spi boot including hspi/legacy*/
|
||||
#define ETS_IS_HSPI_FLASH_BOOT() IS_010XX(BOOT_MODE_GET())
|
||||
|
||||
/*all sdio V2 of failing edge input, failing edge output*/
|
||||
#define ETS_IS_SDIO_FEI_FEO_V2_BOOT() IS_00X00(BOOT_MODE_GET())
|
||||
|
||||
/*all sdio V2 of failing edge input, raising edge output*/
|
||||
#define ETS_IS_SDIO_FEI_REO_V2_BOOT() IS_00X01(BOOT_MODE_GET())
|
||||
|
||||
/*all sdio V2 of raising edge input, failing edge output*/
|
||||
#define ETS_IS_SDIO_REI_FEO_V2_BOOT() IS_00X10(BOOT_MODE_GET())
|
||||
|
||||
/*all sdio V2 of raising edge input, raising edge output*/
|
||||
#define ETS_IS_SDIO_REI_REO_V2_BOOT() IS_00X11(BOOT_MODE_GET())
|
||||
|
||||
/*all sdio V1 of raising edge input, failing edge output*/
|
||||
#define ETS_IS_SDIO_REI_FEO_V1_BOOT() IS_01101(BOOT_MODE_GET())
|
||||
|
||||
/*do not include download mode*/
|
||||
#define ETS_IS_SDIO_BOOT() IS_01101(BOOT_MODE_GET())
|
||||
|
||||
/*joint download boot*/
|
||||
#define ETS_IS_SDIO_UART_BOOT() IS_00XXX(BOOT_MODE_GET())
|
||||
|
||||
/*ATE mode*/
|
||||
#define ETS_IS_ATE_BOOT() IS_01110(BOOT_MODE_GET())
|
||||
|
||||
/*A bit to control flash boot print*/
|
||||
#define ETS_IS_PRINT_BOOT() (BOOT_MODE_GET() & 0x2)
|
||||
|
||||
/*used by ETS_IS_SDIO_UART_BOOT*/
|
||||
#define SEL_NO_BOOT 0
|
||||
#define SEL_SDIO_BOOT BIT0
|
||||
#define SEL_UART_BOOT BIT1
|
||||
|
||||
#endif /* _SOC_BOOT_MODE_H_ */
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if __DOXYGEN__ || (CONFIG_ESP32_REV_MIN >= 1)
|
||||
#define SOC_BROWNOUT_RESET_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
39
tools/sdk/esp32/include/soc/soc/esp32/include/soc/can_caps.h
Normal file
39
tools/sdk/esp32/include/soc/soc/esp32/include/soc/can_caps.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if __DOXYGEN__ || (CONFIG_ESP32_REV_MIN >= 2)
|
||||
#define CAN_BRP_DIV_SUPPORTED 1
|
||||
#define CAN_BRP_DIV_THRESH 128
|
||||
//Any even number from 2 to 128, or multiples of 4 from 132 to 256
|
||||
#define CAN_BRP_IS_VALID(brp) (((brp) >= 2 && (brp) <= 128 && ((brp) & 0x1) == 0) || ((brp) >= 132 && (brp) <= 256 && ((brp) & 0x3) == 0))
|
||||
#else
|
||||
//Any even number from 2 to 128
|
||||
#define CAN_BRP_IS_VALID(brp) ((brp) >= 2 && (brp) <= 128 && ((brp) & 0x1) == 0)
|
||||
#endif
|
||||
|
||||
//Todo: Add FIFO overrun errata workaround
|
||||
//Todo: Add ECC decode capabilities
|
||||
//Todo: Add ALC decode capability
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
210
tools/sdk/esp32/include/soc/soc/esp32/include/soc/can_struct.h
Normal file
210
tools/sdk/esp32/include/soc/soc/esp32/include/soc/can_struct.h
Normal file
@@ -0,0 +1,210 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* ---------------------------- Register Layout ------------------------------ */
|
||||
|
||||
/* The CAN peripheral's registers are 8bits, however the ESP32 can only access
|
||||
* peripheral registers every 32bits. Therefore each CAN register is mapped to
|
||||
* the least significant byte of every 32bits.
|
||||
*/
|
||||
|
||||
typedef volatile struct can_dev_s {
|
||||
//Configuration and Control Registers
|
||||
union {
|
||||
struct {
|
||||
uint32_t rm: 1; /* MOD.0 Reset Mode */
|
||||
uint32_t lom: 1; /* MOD.1 Listen Only Mode */
|
||||
uint32_t stm: 1; /* MOD.2 Self Test Mode */
|
||||
uint32_t afm: 1; /* MOD.3 Acceptance Filter Mode */
|
||||
uint32_t reserved28: 28; /* Internal Reserved. MOD.4 Sleep Mode not supported */
|
||||
};
|
||||
uint32_t val;
|
||||
} mode_reg; /* Address 0 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t tr: 1; /* CMR.0 Transmission Request */
|
||||
uint32_t at: 1; /* CMR.1 Abort Transmission */
|
||||
uint32_t rrb: 1; /* CMR.2 Release Receive Buffer */
|
||||
uint32_t cdo: 1; /* CMR.3 Clear Data Overrun */
|
||||
uint32_t srr: 1; /* CMR.4 Self Reception Request */
|
||||
uint32_t reserved27: 27; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} command_reg; /* Address 1 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t rbs: 1; /* SR.0 Receive Buffer Status */
|
||||
uint32_t dos: 1; /* SR.1 Data Overrun Status */
|
||||
uint32_t tbs: 1; /* SR.2 Transmit Buffer Status */
|
||||
uint32_t tcs: 1; /* SR.3 Transmission Complete Status */
|
||||
uint32_t rs: 1; /* SR.4 Receive Status */
|
||||
uint32_t ts: 1; /* SR.5 Transmit Status */
|
||||
uint32_t es: 1; /* SR.6 Error Status */
|
||||
uint32_t bs: 1; /* SR.7 Bus Status */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} status_reg; /* Address 2 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t ri: 1; /* IR.0 Receive Interrupt */
|
||||
uint32_t ti: 1; /* IR.1 Transmit Interrupt */
|
||||
uint32_t ei: 1; /* IR.2 Error Interrupt */
|
||||
uint32_t reserved2: 2; /* Internal Reserved (Data Overrun interrupt and Wake-up not supported) */
|
||||
uint32_t epi: 1; /* IR.5 Error Passive Interrupt */
|
||||
uint32_t ali: 1; /* IR.6 Arbitration Lost Interrupt */
|
||||
uint32_t bei: 1; /* IR.7 Bus Error Interrupt */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} interrupt_reg; /* Address 3 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t rie: 1; /* IER.0 Receive Interrupt Enable */
|
||||
uint32_t tie: 1; /* IER.1 Transmit Interrupt Enable */
|
||||
uint32_t eie: 1; /* IER.2 Error Interrupt Enable */
|
||||
uint32_t doie: 1; /* IER.3 Data Overrun Interrupt Enable */
|
||||
uint32_t brp_div: 1; /* THIS IS NOT AN INTERRUPT. brp_div will prescale BRP by 2. Only available on ESP32 Revision 2 or later. Reserved otherwise */
|
||||
uint32_t epie: 1; /* IER.5 Error Passive Interrupt Enable */
|
||||
uint32_t alie: 1; /* IER.6 Arbitration Lost Interrupt Enable */
|
||||
uint32_t beie: 1; /* IER.7 Bus Error Interrupt Enable */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} interrupt_enable_reg; /* Address 4 */
|
||||
uint32_t reserved_05; /* Address 5 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t brp: 6; /* BTR0[5:0] Baud Rate Prescaler */
|
||||
uint32_t sjw: 2; /* BTR0[7:6] Synchronization Jump Width*/
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} bus_timing_0_reg; /* Address 6 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t tseg1: 4; /* BTR1[3:0] Timing Segment 1 */
|
||||
uint32_t tseg2: 3; /* BTR1[6:4] Timing Segment 2 */
|
||||
uint32_t sam: 1; /* BTR1.7 Sampling*/
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} bus_timing_1_reg; /* Address 7 */
|
||||
uint32_t reserved_08; /* Address 8 (Output control not supported) */
|
||||
uint32_t reserved_09; /* Address 9 (Test Register not supported) */
|
||||
uint32_t reserved_10; /* Address 10 */
|
||||
|
||||
//Capture and Counter Registers
|
||||
union {
|
||||
struct {
|
||||
uint32_t alc: 5; /* ALC[4:0] Arbitration lost capture */
|
||||
uint32_t reserved27: 27; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} arbitration_lost_captue_reg; /* Address 11 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t seg: 5; /* ECC[4:0] Error Code Segment 0 to 5 */
|
||||
uint32_t dir: 1; /* ECC.5 Error Direction (TX/RX) */
|
||||
uint32_t errc: 2; /* ECC[7:6] Error Code */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} error_code_capture_reg; /* Address 12 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t ewl: 8; /* EWL[7:0] Error Warning Limit */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} error_warning_limit_reg; /* EWLR[7:0] Error Warning Limit: Address 13 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t rxerr: 8; /* RXERR[7:0] Receive Error Counter */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} rx_error_counter_reg; /* Address 12 */
|
||||
union {
|
||||
struct {
|
||||
uint32_t txerr: 8; /* TXERR[7:0] Receive Error Counter */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} tx_error_counter_reg; /* Address 15 */
|
||||
|
||||
//Shared Registers (TX Buff/RX Buff/Acc Filter)
|
||||
union {
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t byte: 8; /* ACRx[7:0] Acceptance Code */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} acr[4];
|
||||
union {
|
||||
struct {
|
||||
uint32_t byte: 8; /* AMRx[7:0] Acceptance Mask */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} amr[4];
|
||||
uint32_t reserved32[5];
|
||||
} acceptance_filter;
|
||||
union {
|
||||
struct {
|
||||
uint32_t byte: 8;
|
||||
uint32_t reserved24: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} tx_rx_buffer[13];
|
||||
}; /* Address 16-28 TX/RX Buffer and Acc Filter*/;
|
||||
|
||||
//Misc Registers
|
||||
union {
|
||||
struct {
|
||||
uint32_t rmc: 5; /* RMC[4:0] RX Message Counter */
|
||||
uint32_t reserved27: 27; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} rx_message_counter_reg; /* Address 29 */
|
||||
uint32_t reserved_30; /* Address 30 (RX Buffer Start Address not supported) */
|
||||
union {
|
||||
struct {
|
||||
uint32_t cd: 3; /* CDR[2:0] CLKOUT frequency selector based of fOSC */
|
||||
uint32_t co: 1; /* CDR.3 CLKOUT enable/disable */
|
||||
uint32_t reserved3: 3; /* Internal Reserved. RXINTEN and CBP not supported */
|
||||
uint32_t cm: 1; /* CDR.7 BasicCAN:0 PeliCAN:1 */
|
||||
uint32_t reserved24: 24; /* Internal Reserved */
|
||||
};
|
||||
uint32_t val;
|
||||
} clock_divider_reg; /* Address 31 */
|
||||
} can_dev_t;
|
||||
|
||||
_Static_assert(sizeof(can_dev_t) == 128, "CAN registers should be 32 * 4 bytes");
|
||||
|
||||
extern can_dev_t CAN;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_CLKOUT_CHANNEL_H
|
||||
#define _SOC_CLKOUT_CHANNEL_H
|
||||
|
||||
//CLKOUT channels
|
||||
#define CLKOUT_GPIO0_DIRECT_CHANNEL CLKOUT_CHANNEL_1
|
||||
#define CLKOUT_CHANNEL_1_DIRECT_GPIO_NUM 0
|
||||
#define CLKOUT_GPIO3_DIRECT_CHANNEL CLKOUT_CHANNEL_2
|
||||
#define CLKOUT_CHANNEL_2_DIRECT_GPIO_NUM 3
|
||||
#define CLKOUT_GPIO1_DIRECT_CHANNEL CLKOUT_CHANNEL_3
|
||||
#define CLKOUT_CHANNEL_3_DIRECT_GPIO_NUM 1
|
||||
|
||||
#endif
|
||||
20
tools/sdk/esp32/include/soc/soc/esp32/include/soc/cpu_caps.h
Normal file
20
tools/sdk/esp32/include/soc/soc/esp32/include/soc/cpu_caps.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SOC_CPU_BREAKPOINTS_NUM 2
|
||||
#define SOC_CPU_WATCHPOINTS_NUM 2
|
||||
|
||||
#define SOC_CPU_WATCHPOINT_SIZE 64 // bytes
|
||||
22
tools/sdk/esp32/include/soc/soc/esp32/include/soc/dac_caps.h
Normal file
22
tools/sdk/esp32/include/soc/soc/esp32/include/soc/dac_caps.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_RTC_DAC_CAPS_H_
|
||||
#define _SOC_RTC_DAC_CAPS_H_
|
||||
|
||||
#define SOC_DAC_PERIPH_NUM 2
|
||||
|
||||
#define SOC_DAC_RESOLUTION 8 // DAC resolution ratio 8 bit
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2010-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_DAC_CHANNEL_H
|
||||
#define _SOC_DAC_CHANNEL_H
|
||||
|
||||
#define DAC_GPIO25_CHANNEL DAC_CHANNEL_1
|
||||
#define DAC_CHANNEL_1_GPIO_NUM 25
|
||||
|
||||
#define DAC_GPIO26_CHANNEL DAC_CHANNEL_2
|
||||
#define DAC_CHANNEL_2_GPIO_NUM 26
|
||||
|
||||
#endif
|
||||
202
tools/sdk/esp32/include/soc/soc/esp32/include/soc/dport_access.h
Normal file
202
tools/sdk/esp32/include/soc/soc/esp32/include/soc/dport_access.h
Normal file
@@ -0,0 +1,202 @@
|
||||
// Copyright 2010-2017 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _DPORT_ACCESS_H_
|
||||
#define _DPORT_ACCESS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp32/dport_access.h"
|
||||
#include "soc.h"
|
||||
#include "uart_reg.h"
|
||||
#include "xtensa/xtruntime.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//Registers Operation {{
|
||||
|
||||
// The _DPORT_xxx register read macros access DPORT memory directly (as opposed to
|
||||
// DPORT_REG_READ which applies SMP-safe protections).
|
||||
//
|
||||
// There are several ways to read the DPORT registers:
|
||||
// 1) Use DPORT_REG_READ versions to be SMP-safe in IDF apps.
|
||||
// This method uses the pre-read APB implementation(*) without stall other CPU.
|
||||
// This is beneficial for single readings.
|
||||
// 2) If you want to make a sequence of DPORT reads to buffer,
|
||||
// use dport_read_buffer(buff_out, address, num_words),
|
||||
// it is the faster method and it doesn't stop other CPU.
|
||||
// 3) If you want to make a sequence of DPORT reads, but you don't want to stop other CPU
|
||||
// and you want to do it faster then you need use DPORT_SEQUENCE_REG_READ().
|
||||
// The difference from the first is that the user himself must disable interrupts while DPORT reading.
|
||||
// Note that disable interrupt need only if the chip has two cores.
|
||||
// 4) If you want to make a sequence of DPORT reads,
|
||||
// use DPORT_STALL_OTHER_CPU_START() macro explicitly
|
||||
// and then use _DPORT_REG_READ macro while other CPU is stalled.
|
||||
// After completing read operations, use DPORT_STALL_OTHER_CPU_END().
|
||||
// This method uses stall other CPU while reading DPORT registers.
|
||||
// Useful for compatibility, as well as for large consecutive readings.
|
||||
// This method is slower, but must be used if ROM functions or
|
||||
// other code is called which accesses DPORT without any other workaround.
|
||||
// *) The pre-readable APB register before reading the DPORT register
|
||||
// helps synchronize the operation of the two CPUs,
|
||||
// so that reading on different CPUs no longer causes random errors APB register.
|
||||
|
||||
// _DPORT_REG_WRITE & DPORT_REG_WRITE are equivalent.
|
||||
#define _DPORT_REG_READ(_r) (*(volatile uint32_t *)(_r))
|
||||
#define _DPORT_REG_WRITE(_r, _v) (*(volatile uint32_t *)(_r)) = (_v)
|
||||
|
||||
// Write value to DPORT register (does not require protecting)
|
||||
#define DPORT_REG_WRITE(_r, _v) _DPORT_REG_WRITE((_r), (_v))
|
||||
|
||||
/**
|
||||
* @brief Read value from register, SMP-safe version.
|
||||
*
|
||||
* This method uses the pre-reading of the APB register before reading the register of the DPORT.
|
||||
* This implementation is useful for reading DORT registers for single reading without stall other CPU.
|
||||
* There is disable/enable interrupt.
|
||||
*
|
||||
* @param reg Register address
|
||||
* @return Value
|
||||
*/
|
||||
static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg)
|
||||
{
|
||||
#if defined(BOOTLOADER_BUILD) || !defined(CONFIG_ESP32_DPORT_WORKAROUND) || !defined(ESP_PLATFORM)
|
||||
return _DPORT_REG_READ(reg);
|
||||
#else
|
||||
return esp_dport_access_reg_read(reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read value from register, NOT SMP-safe version.
|
||||
*
|
||||
* This method uses the pre-reading of the APB register before reading the register of the DPORT.
|
||||
* There is not disable/enable interrupt.
|
||||
* The difference from DPORT_REG_READ() is that the user himself must disable interrupts while DPORT reading.
|
||||
* This implementation is useful for reading DORT registers in loop without stall other CPU. Note the usage example.
|
||||
* The recommended way to read registers sequentially without stall other CPU
|
||||
* is to use the method esp_dport_read_buffer(buff_out, address, num_words). It allows you to read registers in the buffer.
|
||||
*
|
||||
* \code{c}
|
||||
* // This example shows how to use it.
|
||||
* { // Use curly brackets to limit the visibility of variables in macros DPORT_INTERRUPT_DISABLE/RESTORE.
|
||||
* DPORT_INTERRUPT_DISABLE(); // Disable interrupt only on current CPU.
|
||||
* for (i = 0; i < max; ++i) {
|
||||
* array[i] = DPORT_SEQUENCE_REG_READ(Address + i * 4); // reading DPORT registers
|
||||
* }
|
||||
* DPORT_INTERRUPT_RESTORE(); // restore the previous interrupt level
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* @param reg Register address
|
||||
* @return Value
|
||||
*/
|
||||
static inline uint32_t IRAM_ATTR DPORT_SEQUENCE_REG_READ(uint32_t reg)
|
||||
{
|
||||
#if defined(BOOTLOADER_BUILD) || !defined(CONFIG_ESP32_DPORT_WORKAROUND) || !defined(ESP_PLATFORM)
|
||||
return _DPORT_REG_READ(reg);
|
||||
#else
|
||||
return esp_dport_access_sequence_reg_read(reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
//get bit or get bits from register
|
||||
#define DPORT_REG_GET_BIT(_r, _b) (DPORT_REG_READ(_r) & (_b))
|
||||
|
||||
//set bit or set bits to register
|
||||
#define DPORT_REG_SET_BIT(_r, _b) DPORT_REG_WRITE((_r), (DPORT_REG_READ(_r)|(_b)))
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define DPORT_REG_CLR_BIT(_r, _b) DPORT_REG_WRITE((_r), (DPORT_REG_READ(_r) & (~(_b))))
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define DPORT_REG_SET_BITS(_r, _b, _m) DPORT_REG_WRITE((_r), ((DPORT_REG_READ(_r) & (~(_m))) | ((_b) & (_m))))
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define DPORT_REG_GET_FIELD(_r, _f) ((DPORT_REG_READ(_r) >> (_f##_S)) & (_f##_V))
|
||||
|
||||
//set field to register, used when _f is not left shifted by _f##_S
|
||||
#define DPORT_REG_SET_FIELD(_r, _f, _v) DPORT_REG_WRITE((_r), ((DPORT_REG_READ(_r) & (~((_f##_V) << (_f##_S))))|(((_v) & (_f##_V))<<(_f##_S))))
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define DPORT_VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
|
||||
//get field value from a variable, used when _f is left shifted by _f##_S
|
||||
#define DPORT_VALUE_GET_FIELD2(_r, _f) (((_r) & (_f))>> (_f##_S))
|
||||
|
||||
//set field value to a variable, used when _f is not left shifted by _f##_S
|
||||
#define DPORT_VALUE_SET_FIELD(_r, _f, _v) ((_r)=(((_r) & ~((_f) << (_f##_S)))|((_v)<<(_f##_S))))
|
||||
|
||||
//set field value to a variable, used when _f is left shifted by _f##_S
|
||||
#define DPORT_VALUE_SET_FIELD2(_r, _f, _v) ((_r)=(((_r) & ~(_f))|((_v)<<(_f##_S))))
|
||||
|
||||
//generate a value from a field value, used when _f is not left shifted by _f##_S
|
||||
#define DPORT_FIELD_TO_VALUE(_f, _v) (((_v)&(_f))<<_f##_S)
|
||||
|
||||
//generate a value from a field value, used when _f is left shifted by _f##_S
|
||||
#define DPORT_FIELD_TO_VALUE2(_f, _v) (((_v)<<_f##_S) & (_f))
|
||||
|
||||
//Register read macros with an underscore prefix access DPORT memory directly. In IDF apps, use the non-underscore versions to be SMP-safe.
|
||||
#define _DPORT_READ_PERI_REG(addr) (*((volatile uint32_t *)(addr)))
|
||||
#define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)(addr))) = (uint32_t)(val)
|
||||
#define _DPORT_REG_SET_BIT(_r, _b) _DPORT_REG_WRITE((_r), (_DPORT_REG_READ(_r)|(_b)))
|
||||
#define _DPORT_REG_CLR_BIT(_r, _b) _DPORT_REG_WRITE((_r), (_DPORT_REG_READ(_r) & (~(_b))))
|
||||
|
||||
/**
|
||||
* @brief Read value from register, SMP-safe version.
|
||||
*
|
||||
* This method uses the pre-reading of the APB register before reading the register of the DPORT.
|
||||
* This implementation is useful for reading DORT registers for single reading without stall other CPU.
|
||||
*
|
||||
* @param reg Register address
|
||||
* @return Value
|
||||
*/
|
||||
static inline uint32_t IRAM_ATTR DPORT_READ_PERI_REG(uint32_t reg)
|
||||
{
|
||||
#if defined(BOOTLOADER_BUILD) || !defined(CONFIG_ESP32_DPORT_WORKAROUND) || !defined(ESP_PLATFORM)
|
||||
return _DPORT_REG_READ(reg);
|
||||
#else
|
||||
return esp_dport_access_reg_read(reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
//write value to register
|
||||
#define DPORT_WRITE_PERI_REG(addr, val) _DPORT_WRITE_PERI_REG((addr), (val))
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define DPORT_CLEAR_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)&(~(mask))))
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define DPORT_SET_PERI_REG_MASK(reg, mask) DPORT_WRITE_PERI_REG((reg), (DPORT_READ_PERI_REG(reg)|(mask)))
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define DPORT_GET_PERI_REG_MASK(reg, mask) (DPORT_READ_PERI_REG(reg) & (mask))
|
||||
|
||||
//get bits of register controlled by highest bit and lowest bit
|
||||
#define DPORT_GET_PERI_REG_BITS(reg, hipos,lowpos) ((DPORT_READ_PERI_REG(reg)>>(lowpos))&((1<<((hipos)-(lowpos)+1))-1))
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define DPORT_SET_PERI_REG_BITS(reg,bit_map,value,shift) DPORT_WRITE_PERI_REG((reg), ((DPORT_READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift))))
|
||||
|
||||
//get field of register
|
||||
#define DPORT_GET_PERI_REG_BITS2(reg, mask,shift) ((DPORT_READ_PERI_REG(reg)>>(shift))&(mask))
|
||||
//}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DPORT_ACCESS_H_ */
|
||||
4284
tools/sdk/esp32/include/soc/soc/esp32/include/soc/dport_reg.h
Normal file
4284
tools/sdk/esp32/include/soc/soc/esp32/include/soc/dport_reg.h
Normal file
File diff suppressed because it is too large
Load Diff
1188
tools/sdk/esp32/include/soc/soc/esp32/include/soc/efuse_reg.h
Normal file
1188
tools/sdk/esp32/include/soc/soc/esp32/include/soc/efuse_reg.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,162 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef volatile struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t sw_rst : 1; /*When this bit is set the MAC DMA Controller resets the logic and all internal registers of the MAC. It is cleared automatically after the reset operation is complete in all of the ETH_MAC clock domains. Before reprogramming any register of the ETH_MAC you should read a zero (0) value in this bit.*/
|
||||
uint32_t dma_arb_sch : 1; /*This bit specifies the arbitration scheme between the transmit and receive paths.1'b0: weighted round-robin with RX:TX or TX:RX priority specified in PR (bit[15:14]). 1'b1 Fixed priority (Rx priority to Tx).*/
|
||||
uint32_t desc_skip_len : 5; /*This bit specifies the number of Word to skip between two unchained descriptors.The address skipping starts from the end of current descriptor to the start of next descriptor. When the DSL(DESC_SKIP_LEN) value is equal to zero the descriptor table is taken as contiguous by the DMA in Ring mode.*/
|
||||
uint32_t alt_desc_size : 1; /*When set the size of the alternate descriptor increases to 32 bytes.*/
|
||||
uint32_t prog_burst_len : 6; /*These bits indicate the maximum number of beats to be transferred in one DMA transaction. If the number of beats to be transferred is more than 32 then perform the following steps: 1. Set the PBLx8 mode 2. Set the PBL(PROG_BURST_LEN).*/
|
||||
uint32_t pri_ratio : 2; /*These bits control the priority ratio in the weighted round-robin arbitration between the Rx DMA and Tx DMA. These bits are valid only when Bit 1 (DA) is reset. The priority ratio Rx:Tx represented by each bit: 2'b00 -- 1: 1 2'b01 -- 2: 0 2'b10 -- 3: 1 2'b11 -- 4: 1*/
|
||||
uint32_t fixed_burst : 1; /*This bit controls whether the AHB master interface performs fixed burst transfers or not. When set the AHB interface uses only SINGLE INCR4 INCR8 or INCR16 during start of the normal burst transfers. When reset the AHB interface uses SINGLE and INCR burst transfer Operations.*/
|
||||
uint32_t rx_dma_pbl : 6; /*This field indicates the maximum number of beats to be transferred in one Rx DMA transaction. This is the maximum value that is used in a single block Read or Write.The Rx DMA always attempts to burst as specified in the RPBL(RX_DMA_PBL) bit each time it starts a burst transfer on the host bus. You can program RPBL with values of 1 2 4 8 16 and 32. Any other value results in undefined behavior. This field is valid and applicable only when USP(USE_SEP_PBL) is set high.*/
|
||||
uint32_t use_sep_pbl : 1; /*When set high this bit configures the Rx DMA to use the value configured in Bits[22:17] as PBL. The PBL value in Bits[13:8] is applicable only to the Tx DMA operations. When reset to low the PBL value in Bits[13:8] is applicable for both DMA engines.*/
|
||||
uint32_t pblx8_mode : 1; /*When set high this bit multiplies the programmed PBL value (Bits[22:17] and Bits[13:8]) eight times. Therefore the DMA transfers the data in 8 16 32 64 128 and 256 beats depending on the PBL value.*/
|
||||
uint32_t dmaaddralibea : 1; /*When this bit is set high and the FIXED_BURST bit is 1 the AHB interface generates all bursts aligned to the start address LS bits. If the FIXED_BURST bit is 0 the first burst (accessing the start address of data buffer) is not aligned but subsequent bursts are aligned to the address.*/
|
||||
uint32_t dmamixedburst : 1; /*When this bit is set high and the FIXED_BURST bit is low the AHB master interface starts all bursts of a length more than 16 with INCR (undefined burst) whereas it reverts to fixed burst transfers (INCRx and SINGLE) for burst length of 16 and less.*/
|
||||
uint32_t reserved27 : 1;
|
||||
uint32_t reserved28 : 2;
|
||||
uint32_t reserved30 : 1;
|
||||
uint32_t reserved31 : 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} dmabusmode;
|
||||
uint32_t dmatxpolldemand; /*When these bits are written with any value the DMA reads the current descriptor to which the Register (Current Host Transmit Descriptor Register) is pointing. If that descriptor is not available (owned by the Host) the transmission returns to the suspend state and Bit[2] (TU) of Status Register is asserted. If the descriptor is available the transmission resumes.*/
|
||||
uint32_t dmarxpolldemand; /*When these bits are written with any value the DMA reads the current descriptor to which the Current Host Receive Descriptor Register is pointing. If that descriptor is not available (owned by the Host) the reception returns to the Suspended state and Bit[7] (RU) of Status Register is asserted. If the descriptor is available the Rx DMA returns to the active state.*/
|
||||
uint32_t dmarxbaseaddr; /*This field contains the base address of the first descriptor in the Receive Descriptor list. The LSB Bits[1:0] are ignored and internally taken as all-zero by the DMA. Therefore these LSB bits are read-only.*/
|
||||
uint32_t dmatxbaseaddr; /*This field contains the base address of the first descriptor in the Transmit Descriptor list. The LSB Bits[1:0] are ignored and are internally taken as all-zero by the DMA.Therefore these LSB bits are read-only.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t trans_int : 1; /*This bit indicates that the frame transmission is complete. When transmission is complete Bit[31] (OWN) of TDES0 is reset and the specific frame status information is updated in the Descriptor.*/
|
||||
uint32_t trans_proc_stop : 1; /*This bit is set when the transmission is stopped.*/
|
||||
uint32_t trans_buf_unavail : 1; /*This bit indicates that the host owns the Next Descriptor in the Transmit List and the DMA cannot acquire it. Transmission is suspended. Bits[22:20] explain the Transmit Process state transitions. To resume processing Transmit descriptors the host should change the ownership of the descriptor by setting TDES0[31] and then issue a Transmit Poll Demand Command.*/
|
||||
uint32_t trans_jabber_to : 1; /*This bit indicates that the Transmit Jabber Timer expired which happens when the frame size exceeds 2 048 (10 240 bytes when the Jumbo frame is enabled). When the Jabber Timeout occurs the transmission process is aborted and placed in the Stopped state. This causes the Transmit Jabber Timeout TDES0[14] flag to assert.*/
|
||||
uint32_t recv_ovflow : 1; /*This bit indicates that the Receive Buffer had an Overflow during frame reception. If the partial frame is transferred to the application the overflow status is set in RDES0[11].*/
|
||||
uint32_t trans_undflow : 1; /*This bit indicates that the Transmit Buffer had an Underflow during frame transmission. Transmission is suspended and an Underflow Error TDES0[1] is set.*/
|
||||
uint32_t recv_int : 1; /*This bit indicates that the frame reception is complete. When reception is complete the Bit[31] of RDES1 (Disable Interrupt on Completion) is reset in the last Descriptor and the specific frame status information is updated in the descriptor. The reception remains in the Running state.*/
|
||||
uint32_t recv_buf_unavail : 1; /*This bit indicates that the host owns the Next Descriptor in the Receive List and the DMA cannot acquire it. The Receive Process is suspended. To resume processing Receive descriptors the host should change the ownership of the descriptor and issue a Receive Poll Demand command. If no Receive Poll Demand is issued the Receive Process resumes when the next recognized incoming frame is received. This bit is set only when the previous Receive Descriptor is owned by the DMA.*/
|
||||
uint32_t recv_proc_stop : 1; /*This bit is asserted when the Receive Process enters the Stopped state.*/
|
||||
uint32_t recv_wdt_to : 1; /*When set this bit indicates that the Receive Watchdog Timer expired while receiving the current frame and the current frame is truncated after the watchdog timeout.*/
|
||||
uint32_t early_trans_int : 1; /*This bit indicates that the frame to be transmitted is fully transferred to the MTL Transmit FIFO.*/
|
||||
uint32_t reserved11 : 2;
|
||||
uint32_t fatal_bus_err_int : 1; /*This bit indicates that a bus error occurred as described in Bits [25:23]. When this bit is set the corresponding DMA engine disables all of its bus accesses.*/
|
||||
uint32_t early_recv_int : 1; /*This bit indicates that the DMA filled the first data buffer of the packet. This bit is cleared when the software writes 1 to this bit or when Bit[6] (RI) of this register is set (whichever occurs earlier).*/
|
||||
uint32_t abn_int_summ : 1; /*Abnormal Interrupt Summary bit value is the logical OR of the following when the corresponding interrupt bits are enabled in Interrupt Enable Register: Bit[1]: Transmit Process Stopped. Bit[3]: Transmit Jabber Timeout. Bit[4]: Receive FIFO Overflow. Bit[5]: Transmit Underflow. Bit[7]: Receive Buffer Unavailable. Bit[8]: Receive Process Stopped. Bit[9]: Receive Watchdog Timeout. Bit[10]: Early Transmit Interrupt. Bit[13]: Fatal Bus Error. Only unmasked bits affect the Abnormal Interrupt Summary bit. This is a sticky bit and must be cleared (by writing 1 to this bit) each time a corresponding bit which causes AIS to be set is cleared.*/
|
||||
uint32_t norm_int_summ : 1; /*Normal Interrupt Summary bit value is the logical OR of the following bits when the corresponding interrupt bits are enabled in Interrupt Enable Register: Bit[0]: Transmit Interrupt. Bit[2]: Transmit Buffer Unavailable. Bit[6]: Receive Interrupt. Bit[14]: Early Receive Interrupt. Only unmasked bits affect the Normal Interrupt Summary bit.This is a sticky bit and must be cleared (by writing 1 to this bit) each time a corresponding bit which causes NIS to be set is cleared.*/
|
||||
uint32_t recv_proc_state : 3; /*This field indicates the Receive DMA FSM state. This field does not generate an interrupt. 3'b000: Stopped. Reset or Stop Receive Command issued. 3'b001: Running. Fetching Receive Transfer Descriptor. 3'b010: Reserved for future use. 3'b011: Running. Waiting for RX packets. 3'b100: Suspended. Receive Descriptor Unavailable. 3'b101: Running. Closing Receive Descriptor. 3'b110: TIME_STAMP write state. 3'b111: Running. Transferring the TX packets data from receive buffer to host memory.*/
|
||||
uint32_t trans_proc_state : 3; /*This field indicates the Transmit DMA FSM state. This field does not generate an interrupt. 3'b000: Stopped. Reset or Stop Transmit Command issued. 3'b001: Running. Fetching Transmit Transfer Descriptor. 3'b010: Reserved for future use. 3'b011: Running. Waiting for TX packets. 3'b100: Suspended. Receive Descriptor Unavailable. 3'b101: Running. Closing Transmit Descriptor. 3'b110: TIME_STAMP write state. 3'b111: Running. Transferring the TX packets data from transmit buffer to host memory.*/
|
||||
uint32_t error_bits : 3; /*This field indicates the type of error that caused a Bus Error for example error response on the AHB interface. This field is valid only when Bit[13] (FBI) is set. This field does not generate an interrupt. 3'b000: Error during Rx DMA Write Data Transfer. 3'b011: Error during Tx DMA Read Data Transfer. 3'b100: Error during Rx DMA Descriptor Write Access. 3'b101: Error during Tx DMA Descriptor Write Access. 3'b110: Error during Rx DMA Descriptor Read Access. 3'b111: Error during Tx DMA Descriptor Read Access.*/
|
||||
uint32_t reserved26 : 1;
|
||||
uint32_t reserved27 : 1;
|
||||
uint32_t pmt_int : 1; /*This bit indicates an interrupt event in the PMT module of the ETH_MAC. The software must read the PMT Control and Status Register in the MAC to get the exact cause of interrupt and clear its source to reset this bit to 1'b0.*/
|
||||
uint32_t ts_tri_int : 1; /*This bit indicates an interrupt event in the Timestamp Generator block of the ETH_MAC.The software must read the corresponding registers in the ETH_MAC to get the exact cause of the interrupt and clear its source to reset this bit to 1'b0.*/
|
||||
uint32_t reserved30 : 1;
|
||||
uint32_t reserved31 : 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} dmastatus;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0 : 1;
|
||||
uint32_t start_stop_rx : 1; /*When this bit is set the Receive process is placed in the Running state. The DMA attempts to acquire the descriptor from the Receive list and processes the incoming frames.When this bit is cleared the Rx DMA operation is stopped after the transfer of the current frame.*/
|
||||
uint32_t opt_second_frame : 1; /*When this bit is set it instructs the DMA to process the second frame of the Transmit data even before the status for the first frame is obtained.*/
|
||||
uint32_t rx_thresh_ctrl : 2; /*These two bits control the threshold level of the MTL Receive FIFO. Transfer (request) to DMA starts when the frame size within the MTL Receive FIFO is larger than the threshold. 2'b00: 64, 2'b01: 32, 2'b10: 96, 2'b11: 128 .*/
|
||||
uint32_t drop_gfrm : 1; /*When set the MAC drops the received giant frames in the Rx FIFO that is frames that are larger than the computed giant frame limit.*/
|
||||
uint32_t fwd_under_gf : 1; /*When set the Rx FIFO forwards Undersized frames (that is frames with no Error and length less than 64 bytes) including pad-bytes and CRC.*/
|
||||
uint32_t fwd_err_frame : 1; /*When this bit is reset the Rx FIFO drops frames with error status (CRC error collision error giant frame watchdog timeout or overflow).*/
|
||||
uint32_t reserved8 : 1;
|
||||
uint32_t reserved9 : 2;
|
||||
uint32_t reserved11 : 2;
|
||||
uint32_t start_stop_transmission_command : 1; /*When this bit is set transmission is placed in the Running state and the DMA checks the Transmit List at the current position for a frame to be transmitted.When this bit is reset the transmission process is placed in the Stopped state after completing the transmission of the current frame.*/
|
||||
uint32_t tx_thresh_ctrl : 3; /*These bits control the threshold level of the MTL Transmit FIFO. Transmission starts when the frame size within the MTL Transmit FIFO is larger than the threshold. In addition full frames with a length less than the threshold are also transmitted. These bits are used only when Tx_Str_fwd is reset. 3'b000: 64 3'b001: 128 3'b010: 192 3'b011: 256 3'b100: 40 3'b101: 32 3'b110: 24 3'b111: 16 .*/
|
||||
uint32_t reserved17 : 3;
|
||||
uint32_t flush_tx_fifo : 1; /*When this bit is set the transmit FIFO controller logic is reset to its default values and thus all data in the Tx FIFO is lost or flushed. This bit is cleared internally when the flushing operation is complete.*/
|
||||
uint32_t tx_str_fwd : 1; /*When this bit is set transmission starts when a full frame resides in the MTL Transmit FIFO. When this bit is set the Tx_Thresh_Ctrl values specified in Tx_Thresh_Ctrl are ignored.*/
|
||||
uint32_t reserved22 : 1;
|
||||
uint32_t reserved23 : 1;
|
||||
uint32_t dis_flush_recv_frames : 1; /*When this bit is set the Rx DMA does not flush any frames because of the unavailability of receive descriptors or buffers.*/
|
||||
uint32_t rx_store_forward : 1; /*When this bit is set the MTL reads a frame from the Rx FIFO only after the complete frame has been written to it.*/
|
||||
uint32_t dis_drop_tcpip_err_fram : 1; /*When this bit is set the MAC does not drop the frames which only have errors detected by the Receive Checksum engine.When this bit is reset all error frames are dropped if the Fwd_Err_Frame bit is reset.*/
|
||||
uint32_t reserved27 : 5;
|
||||
};
|
||||
uint32_t val;
|
||||
} dmaoperation_mode;
|
||||
union {
|
||||
struct {
|
||||
uint32_t dmain_tie : 1; /*When this bit is set with Normal Interrupt Summary Enable (Bit[16]) the Transmit Interrupt is enabled. When this bit is reset the Transmit Interrupt is disabled.*/
|
||||
uint32_t dmain_tse : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Transmission Stopped Interrupt is enabled. When this bit is reset the Transmission Stopped Interrupt is disabled.*/
|
||||
uint32_t dmain_tbue : 1; /*When this bit is set with Normal Interrupt Summary Enable (Bit 16) the Transmit Buffer Unavailable Interrupt is enabled. When this bit is reset the Transmit Buffer Unavailable Interrupt is Disabled.*/
|
||||
uint32_t dmain_tjte : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Transmit Jabber Timeout Interrupt is enabled. When this bit is reset the Transmit Jabber Timeout Interrupt is disabled.*/
|
||||
uint32_t dmain_oie : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Receive Overflow Interrupt is enabled. When this bit is reset the Overflow Interrupt is disabled.*/
|
||||
uint32_t dmain_uie : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Transmit Underflow Interrupt is enabled. When this bit is reset the Underflow Interrupt is disabled.*/
|
||||
uint32_t dmain_rie : 1; /*When this bit is set with Normal Interrupt Summary Enable (Bit[16]) the Receive Interrupt is enabled. When this bit is reset the Receive Interrupt is disabled.*/
|
||||
uint32_t dmain_rbue : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Receive Buffer Unavailable Interrupt is enabled. When this bit is reset the Receive Buffer Unavailable Interrupt is disabled.*/
|
||||
uint32_t dmain_rse : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Receive Stopped Interrupt is enabled. When this bit is reset the Receive Stopped Interrupt is disabled.*/
|
||||
uint32_t dmain_rwte : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Receive Watchdog Timeout Interrupt is enabled. When this bit is reset the Receive Watchdog Timeout Interrupt is disabled.*/
|
||||
uint32_t dmain_etie : 1; /*When this bit is set with an Abnormal Interrupt Summary Enable (Bit[15]) the Early Transmit Interrupt is enabled. When this bit is reset the Early Transmit Interrupt is disabled.*/
|
||||
uint32_t reserved11 : 2;
|
||||
uint32_t dmain_fbee : 1; /*When this bit is set with Abnormal Interrupt Summary Enable (Bit[15]) the Fatal Bus Error Interrupt is enabled. When this bit is reset the Fatal Bus Error Enable Interrupt is disabled.*/
|
||||
uint32_t dmain_erie : 1; /*When this bit is set with Normal Interrupt Summary Enable (Bit[16]) the Early Receive Interrupt is enabled. When this bit is reset the Early Receive Interrupt is disabled.*/
|
||||
uint32_t dmain_aise : 1; /*When this bit is set abnormal interrupt summary is enabled. When this bit is reset the abnormal interrupt summary is disabled. This bit enables the following interrupts in Status Register: Bit[1]: Transmit Process Stopped. Bit[3]: Transmit Jabber Timeout. Bit[4]: Receive Overflow. Bit[5]: Transmit Underflow. Bit[7]: Receive Buffer Unavailable. Bit[8]: Receive Process Stopped. Bit[9]: Receive Watchdog Timeout. Bit[10]: Early Transmit Interrupt. Bit[13]: Fatal Bus Error.*/
|
||||
uint32_t dmain_nise : 1; /*When this bit is set normal interrupt summary is enabled. When this bit is reset normal interrupt summary is disabled. This bit enables the following interrupts in Status Register: Bit[0]: Transmit Interrupt. Bit[2]: Transmit Buffer Unavailable. Bit[6]: Receive Interrupt. Bit[14]: Early Receive Interrupt.*/
|
||||
uint32_t reserved17 : 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} dmain_en;
|
||||
union {
|
||||
struct {
|
||||
uint32_t missed_fc : 16; /*This field indicates the number of frames missed by the controller because of the Host Receive Buffer being unavailable. This counter is incremented each time the DMA discards an incoming frame. The counter is cleared when this register is read.*/
|
||||
uint32_t overflow_bmfc : 1; /*This bit is set every time Missed Frame Counter (Bits[15:0]) overflows that is the DMA discards an incoming frame because of the Host Receive Buffer being unavailable with the missed frame counter at maximum value. In such a scenario the Missed frame counter is reset to all-zeros and this bit indicates that the rollover happened.*/
|
||||
uint32_t overflow_fc : 11; /*This field indicates the number of frames missed by the application. This counter is incremented each time the MTL FIFO overflows. The counter is cleared when this register is read.*/
|
||||
uint32_t overflow_bfoc : 1; /*This bit is set every time the Overflow Frame Counter (Bits[27:17]) overflows that is the Rx FIFO overflows with the overflow frame counter at maximum value. In such a scenario the overflow frame counter is reset to all-zeros and this bit indicates that the rollover happened.*/
|
||||
uint32_t reserved29 : 3;
|
||||
};
|
||||
uint32_t val;
|
||||
} dmamissedfr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t riwtc : 8; /*This bit indicates the number of system clock cycles multiplied by 256 for which the watchdog timer is set. The watchdog timer gets triggered with the programmed value after the Rx DMA completes the transfer of a frame for which the RI(RECV_INT) status bit is not set because of the setting in the corresponding descriptor RDES1[31]. When the watchdog timer runs out the RI bit is set and the timer is stopped. The watchdog timer is reset when the RI bit is set high because of automatic setting of RI as per RDES1[31] of any received frame.*/
|
||||
uint32_t reserved8 : 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} dmarintwdtimer;
|
||||
uint32_t reserved_28;
|
||||
uint32_t reserved_2c;
|
||||
uint32_t reserved_30;
|
||||
uint32_t reserved_34;
|
||||
uint32_t reserved_38;
|
||||
uint32_t reserved_3c;
|
||||
uint32_t reserved_40;
|
||||
uint32_t reserved_44;
|
||||
uint32_t dmatxcurrdesc; /*The address of the current receive descriptor list. Cleared on Reset.Pointer updated by the DMA during operation.*/
|
||||
uint32_t dmarxcurrdesc; /*The address of the current receive descriptor list. Cleared on Reset.Pointer updated by the DMA during operation.*/
|
||||
uint32_t dmatxcurraddr_buf; /*The address of the current receive descriptor list. Cleared on Reset.Pointer updated by the DMA during operation.*/
|
||||
uint32_t dmarxcurraddr_buf; /*The address of the current receive descriptor list. Cleared on Reset.Pointer updated by the DMA during operation.*/
|
||||
} emac_dma_dev_t;
|
||||
|
||||
extern emac_dma_dev_t EMAC_DMA;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef volatile struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t div_num : 4;
|
||||
uint32_t h_div_num : 4;
|
||||
uint32_t reserved8 : 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} ex_clkout_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t div_num_10m : 6;
|
||||
uint32_t h_div_num_10m : 6;
|
||||
uint32_t div_num_100m : 6;
|
||||
uint32_t h_div_num_100m : 6;
|
||||
uint32_t clk_sel : 1;
|
||||
uint32_t reserved25 : 7;
|
||||
};
|
||||
uint32_t val;
|
||||
} ex_oscclk_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t ext_en : 1;
|
||||
uint32_t int_en : 1;
|
||||
uint32_t reserved2 : 1;
|
||||
uint32_t mii_clk_tx_en : 1;
|
||||
uint32_t mii_clk_rx_en : 1;
|
||||
uint32_t reserved5 : 27;
|
||||
};
|
||||
uint32_t val;
|
||||
} ex_clk_ctrl;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0 : 13;
|
||||
uint32_t phy_intf_sel : 3;
|
||||
uint32_t reserved16 : 16;
|
||||
};
|
||||
uint32_t val;
|
||||
} ex_phyinf_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t ram_pd_en : 2;
|
||||
uint32_t reserved2 : 30;
|
||||
};
|
||||
uint32_t val;
|
||||
} pd_sel;
|
||||
} emac_ext_dev_t;
|
||||
|
||||
extern emac_ext_dev_t EMAC_EXT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,345 @@
|
||||
// Copyright 2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef volatile struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t pltf : 2; /*These bits control the number of preamble bytes that are added to the beginning of every Transmit frame. The preamble reduction occurs only when the MAC is operating in the full-duplex mode.2'b00: 7 bytes of preamble. 2'b01: 5 bytes of preamble. 2'b10: 3 bytes of preamble.*/
|
||||
uint32_t rx : 1; /*When this bit is set the receiver state machine of the MAC is enabled for receiving frames from the MII. When this bit is reset the MAC receive state machine is disabled after the completion of the reception of the current frame and does not receive any further frames from the MII.*/
|
||||
uint32_t tx : 1; /*When this bit is set the transmit state machine of the MAC is enabled for transmission on the MII. When this bit is reset the MAC transmit state machine is disabled after the completion of the transmission of the current frame and does not transmit any further frames.*/
|
||||
uint32_t deferralcheck : 1; /*Deferral Check.*/
|
||||
uint32_t backofflimit : 2; /*The Back-Off limit determines the random integer number (r) of slot time delays (512 bit times for 10/100 Mbps) for which the MAC waits before rescheduling a transmission attempt during retries after a collision. This bit is applicable only in the half-duplex mode. 00: k= min (n 10). 01: k = min (n 8). 10: k = min (n 4). 11: k = min (n 1) n = retransmission attempt. The random integer r takes the value in the Range 0 ~ 2000.*/
|
||||
uint32_t padcrcstrip : 1; /*When this bit is set the MAC strips the Pad or FCS field on the incoming frames only if the value of the length field is less than 1 536 bytes. All received frames with length field greater than or equal to 1 536 bytes are passed to the application without stripping the Pad or FCS field. When this bit is reset the MAC passes all incoming frames without modifying them to the Host.*/
|
||||
uint32_t reserved8 : 1;
|
||||
uint32_t retry : 1; /*When this bit is set the MAC attempts only one transmission. When a collision occurs on the MII interface the MAC ignores the current frame transmission and reports a Frame Abort with excessive collision error in the transmit frame status. When this bit is reset the MAC attempts retries based on the settings of the BL field (Bits [6:5]). This bit is applicable only in the half-duplex Mode.*/
|
||||
uint32_t rxipcoffload : 1; /*When this bit is set the MAC calculates the 16-bit one's complement of the one's complement sum of all received Ethernet frame payloads. It also checks whether the IPv4 Header checksum (assumed to be bytes 25/26 or 29/30 (VLAN-tagged) of the received Ethernet frame) is correct for the received frame and gives the status in the receive status word. The MAC also appends the 16-bit checksum calculated for the IP header datagram payload (bytes after the IPv4 header) and appends it to the Ethernet frame transferred to the application (when Type 2 COE is deselected). When this bit is reset this function is disabled.*/
|
||||
uint32_t duplex : 1; /*When this bit is set the MAC operates in the full-duplex mode where it can transmit and receive simultaneously. This bit is read only with default value of 1'b1 in the full-duplex-mode.*/
|
||||
uint32_t loopback : 1; /*When this bit is set the MAC operates in the loopback mode MII. The MII Receive clock input (CLK_RX) is required for the loopback to work properly because the transmit clock is not looped-back internally.*/
|
||||
uint32_t rxown : 1; /*When this bit is set the MAC disables the reception of frames when the TX_EN is asserted in the half-duplex mode. When this bit is reset the MAC receives all packets that are given by the PHY while transmitting. This bit is not applicable if the MAC is operating in the full duplex mode.*/
|
||||
uint32_t fespeed : 1; /*This bit selects the speed in the MII RMII interface. 0: 10 Mbps. 1: 100 Mbps.*/
|
||||
uint32_t mii : 1; /*This bit selects the Ethernet line speed. It should be set to 1 for 10 or 100 Mbps operations.In 10 or 100 Mbps operations this bit along with FES(EMACFESPEED) bit it selects the exact linespeed. In the 10/100 Mbps-only operations the bit is always 1.*/
|
||||
uint32_t disablecrs : 1; /*When set high this bit makes the MAC transmitter ignore the MII CRS signal during frame transmission in the half-duplex mode. This request results in no errors generated because of Loss of Carrier or No Carrier during such transmission. When this bit is low the MAC transmitter generates such errors because of Carrier Sense and can even abort the transmissions.*/
|
||||
uint32_t interframegap : 3; /*These bits control the minimum IFG between frames during transmission. 3'b000: 96 bit times. 3'b001: 88 bit times. 3'b010: 80 bit times. 3'b111: 40 bit times. In the half-duplex mode the minimum IFG can be configured only for 64 bit times (IFG = 100). Lower values are not considered.*/
|
||||
uint32_t jumboframe : 1; /*When this bit is set the MAC allows Jumbo frames of 9 018 bytes (9 022 bytes for VLAN tagged frames) without reporting a giant frame error in the receive frame status.*/
|
||||
uint32_t reserved21 : 1;
|
||||
uint32_t jabber : 1; /*When this bit is set the MAC disables the jabber timer on the transmitter. The MAC can transfer frames of up to 16 383 bytes. When this bit is reset the MAC cuts off the transmitter if the application sends out more than 2 048 bytes of data (10 240 if JE is set high) during Transmission.*/
|
||||
uint32_t watchdog : 1; /*When this bit is set the MAC disables the watchdog timer on the receiver. The MAC can receive frames of up to 16 383 bytes. When this bit is reset the MAC does not allow a receive frame which more than 2 048 bytes (10 240 if JE is set high) or the value programmed in Register (Watchdog Timeout Register). The MAC cuts off any bytes received after the watchdog limit number of bytes.*/
|
||||
uint32_t reserved24 : 1;
|
||||
uint32_t reserved25 : 1;
|
||||
uint32_t reserved26 : 1;
|
||||
uint32_t ass2kp : 1; /*When set the MAC considers all frames with up to 2 000 bytes length as normal packets.When Bit[20] (JE) is not set the MAC considers all received frames of size more than 2K bytes as Giant frames. When this bit is reset and Bit[20] (JE) is not set the MAC considers all received frames of size more than 1 518 bytes (1 522 bytes for tagged) as Giant frames. When Bit[20] is set setting this bit has no effect on Giant Frame status.*/
|
||||
uint32_t sairc : 3; /*This field controls the source address insertion or replacement for all transmitted frames.Bit[30] specifies which MAC Address register (0 or 1) is used for source address insertion or replacement based on the values of Bits [29:28]: 2'b0x: The input signals mti_sa_ctrl_i and ati_sa_ctrl_i control the SA field generation. 2'b10: If Bit[30] is set to 0 the MAC inserts the content of the MAC Address 0 registers in the SA field of all transmitted frames. If Bit[30] is set to 1 the MAC inserts the content of the MAC Address 1 registers in the SA field of all transmitted frames. 2'b11: If Bit[30] is set to 0 the MAC replaces the content of the MAC Address 0 registers in the SA field of all transmitted frames. If Bit[30] is set to 1 the MAC replaces the content of the MAC Address 1 registers in the SA field of all transmitted frames.*/
|
||||
uint32_t reserved31 : 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} gmacconfig;
|
||||
union {
|
||||
struct {
|
||||
uint32_t pmode : 1; /*When this bit is set the Address Filter module passes all incoming frames irrespective of the destination or source address. The SA or DA Filter Fails status bits of the Receive Status Word are always cleared when PR(PRI_RATIO) is set.*/
|
||||
uint32_t reserved1 : 1;
|
||||
uint32_t reserved2 : 1;
|
||||
uint32_t daif : 1; /*When this bit is set the Address Check block operates in inverse filtering mode for the DA address comparison for both unicast and multicast frames. When reset normal filtering of frames is performed.*/
|
||||
uint32_t pam : 1; /*When set this bit indicates that all received frames with a multicast destination address (first bit in the destination address field is '1') are passed.*/
|
||||
uint32_t dbf : 1; /*When this bit is set the AFM(Address Filtering Module) module blocks all incoming broadcast frames. In addition it overrides all other filter settings. When this bit is reset the AFM module passes all received broadcast Frames.*/
|
||||
uint32_t pcf : 2; /*These bits control the forwarding of all control frames (including unicast and multicast Pause frames). 2'b00: MAC filters all control frames from reaching the application. 2'b01: MAC forwards all control frames except Pause frames to application even if they fail the Address filter. 2'b10: MAC forwards all control frames to application even if they fail the Address Filter. 2'b11: MAC forwards control frames that pass the Address Filter.The following conditions should be true for the Pause frames processing: Condition 1: The MAC is in the full-duplex mode and flow control is enabled by setting Bit 2 (RFE) of Register (Flow Control Register) to 1. Condition 2: The destination address (DA) of the received frame matches the special multicast address or the MAC Address 0 when Bit 3 (UP) of the Register(Flow Control Register) is set. Condition 3: The Type field of the received frame is 0x8808 and the OPCODE field is 0x0001.*/
|
||||
uint32_t saif : 1; /*When this bit is set the Address Check block operates in inverse filtering mode for the SA address comparison. The frames whose SA matches the SA registers are marked as failing the SA Address filter. When this bit is reset frames whose SA does not match the SA registers are marked as failing the SA Address filter.*/
|
||||
uint32_t safe : 1; /*When this bit is set the MAC compares the SA field of the received frames with the values programmed in the enabled SA registers. If the comparison fails the MAC drops the frame. When this bit is reset the MAC forwards the received frame to the application with updated SAF bit of the Rx Status depending on the SA address comparison.*/
|
||||
uint32_t reserved10 : 1;
|
||||
uint32_t reserved11 : 5;
|
||||
uint32_t reserved16 : 1;
|
||||
uint32_t reserved17 : 3;
|
||||
uint32_t reserved20 : 1;
|
||||
uint32_t reserved21 : 1;
|
||||
uint32_t reserved22 : 9;
|
||||
uint32_t receive_all : 1; /*When this bit is set the MAC Receiver module passes all received frames irrespective of whether they pass the address filter or not to the Application. The result of the SA or DA filtering is updated (pass or fail) in the corresponding bits in the Receive Status Word. When this bit is reset the Receiver module passes only those frames to the Application that pass the SA or DA address Filter.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} gmacff;
|
||||
uint32_t reserved_1008;
|
||||
uint32_t reserved_100c;
|
||||
union {
|
||||
struct {
|
||||
uint32_t miibusy : 1; /*This bit should read logic 0 before writing to PHY Addr Register and PHY data Register.During a PHY register access the software sets this bit to 1'b1 to indicate that a Read or Write access is in progress. PHY data Register is invalid until this bit is cleared by the MAC. Therefore PHY data Register (MII Data) should be kept valid until the MAC clears this bit during a PHY Write operation. Similarly for a read operation the contents of Register 5 are not valid until this bit is cleared. The subsequent read or write operation should happen only after the previous operation is complete. Because there is no acknowledgment from the PHY to MAC after a read or write operation is completed there is no change in the functionality of this bit even when the PHY is not Present.*/
|
||||
uint32_t miiwrite : 1; /*When set this bit indicates to the PHY that this is a Write operation using the MII Data register. If this bit is not set it indicates that this is a Read operation that is placing the data in the MII Data register.*/
|
||||
uint32_t miicsrclk : 4; /*CSR clock range: 1.0 MHz ~ 2.5 MHz. 4'b0000: When the APB clock frequency is 80 MHz the MDC clock frequency is APB CLK/42 4'b0000: When the APB clock frequency is 40 MHz the MDC clock frequency is APB CLK/26.*/
|
||||
uint32_t miireg : 5; /*These bits select the desired MII register in the selected PHY device.*/
|
||||
uint32_t miidev : 5; /*This field indicates which of the 32 possible PHY devices are being accessed.*/
|
||||
uint32_t reserved16 : 16;
|
||||
};
|
||||
uint32_t val;
|
||||
} emacgmiiaddr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t mii_data : 16; /*This field contains the 16-bit data value read from the PHY after a Management Read operation or the 16-bit data value to be written to the PHY before a Management Write operation.*/
|
||||
uint32_t reserved16 : 16;
|
||||
};
|
||||
uint32_t val;
|
||||
} emacmiidata;
|
||||
union {
|
||||
struct {
|
||||
uint32_t fcbba : 1; /*This bit initiates a Pause frame in the full-duplex mode and activates the backpressure function in the half-duplex mode if the TFCE bit is set. In the full-duplex mode this bit should be read as 1'b0 before writing to the Flow Control register. To initiate a Pause frame the Application must set this bit to 1'b1. During a transfer of the Control Frame this bit continues to be set to signify that a frame transmission is in progress. After the completion of Pause frame transmission the MAC resets this bit to 1'b0. The Flow Control register should not be written to until this bit is cleared. In the half-duplex mode when this bit is set (and TFCE is set) then backpressure is asserted by the MAC. During backpressure when the MAC receives a new frame the transmitter starts sending a JAM pattern resulting in a collision. When the MAC is configured for the full-duplex mode the BPA(backpressure activate) is automatically disabled.*/
|
||||
uint32_t tfce : 1; /*In the full-duplex mode when this bit is set the MAC enables the flow control operation to transmit Pause frames. When this bit is reset the flow control operation in the MAC is disabled and the MAC does not transmit any Pause frames. In the half-duplex mode when this bit is set the MAC enables the backpressure operation. When this bit is reset the backpressure feature is Disabled.*/
|
||||
uint32_t rfce : 1; /*When this bit is set the MAC decodes the received Pause frame and disables its transmitter for a specified (Pause) time. When this bit is reset the decode function of the Pause frame is disabled.*/
|
||||
uint32_t upfd : 1; /*A pause frame is processed when it has the unique multicast address specified in the IEEE Std 802.3. When this bit is set the MAC can also detect Pause frames with unicast address of the station. This unicast address should be as specified in the EMACADDR0 High Register and EMACADDR0 Low Register. When this bit is reset the MAC only detects Pause frames with unique multicast address.*/
|
||||
uint32_t plt : 2; /*This field configures the threshold of the Pause timer automatic retransmission of the Pause frame.The threshold values should be always less than the Pause Time configured in Bits[31:16]. For example if PT = 100H (256 slot-times) and PLT = 01 then a second Pause frame is automatically transmitted at 228 (256-28) slot times after the first Pause frame is transmitted. The following list provides the threshold values for different values: 2'b00: The threshold is Pause time minus 4 slot times (PT-4 slot times). 2'b01: The threshold is Pause time minus 28 slot times (PT-28 slot times). 2'b10: The threshold is Pause time minus 144 slot times (PT-144 slot times). 2'b11: The threshold is Pause time minus 256 slot times (PT-256 slot times). The slot time is defined as the time taken to transmit 512 bits (64 bytes) on the MII interface.*/
|
||||
uint32_t reserved6 : 1;
|
||||
uint32_t dzpq : 1; /*When this bit is set it disables the automatic generation of the Zero-Quanta Pause frames on the de-assertion of the flow-control signal from the FIFO layer. When this bit is reset normal operation with automatic Zero-Quanta Pause frame generation is enabled.*/
|
||||
uint32_t reserved8 : 8;
|
||||
uint32_t pause_time : 16; /*This field holds the value to be used in the Pause Time field in the transmit control frame. If the Pause Time bits is configured to be double-synchronized to the MII clock domain then consecutive writes to this register should be performed only after at least four clock cycles in the destination clock domain.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} gmacfc;
|
||||
uint32_t reserved_101c;
|
||||
uint32_t reserved_1020;
|
||||
union {
|
||||
struct {
|
||||
uint32_t macrpes : 1; /*When high this bit indicates that the MAC MII receive protocol engine is actively receiving data and not in IDLE state.*/
|
||||
uint32_t macrffcs : 2; /*When high this field indicates the active state of the FIFO Read and Write controllers of the MAC Receive Frame Controller Module. MACRFFCS[1] represents the status of FIFO Read controller. MACRFFCS[0] represents the status of small FIFO Write controller.*/
|
||||
uint32_t reserved3 : 1;
|
||||
uint32_t mtlrfwcas : 1; /*When high this bit indicates that the MTL Rx FIFO Write Controller is active and is transferring a received frame to the FIFO.*/
|
||||
uint32_t mtlrfrcs : 2; /*This field gives the state of the Rx FIFO read Controller: 2'b00: IDLE state.2'b01: Reading frame data.2'b10: Reading frame status (or timestamp).2'b11: Flushing the frame data and status.*/
|
||||
uint32_t reserved7 : 1;
|
||||
uint32_t mtlrffls : 2; /*This field gives the status of the fill-level of the Rx FIFO: 2'b00: Rx FIFO Empty. 2'b01: Rx FIFO fill-level below flow-control deactivate threshold. 2'b10: Rx FIFO fill-level above flow-control activate threshold. 2'b11: Rx FIFO Full.*/
|
||||
uint32_t reserved10 : 6;
|
||||
uint32_t mactpes : 1; /*When high this bit indicates that the MAC MII transmit protocol engine is actively transmitting data and is not in the IDLE state.*/
|
||||
uint32_t mactfcs : 2; /*This field indicates the state of the MAC Transmit Frame Controller module: 2'b00: IDLE state. 2'b01: Waiting for status of previous frame or IFG or backoff period to be over. 2'b10: Generating and transmitting a Pause frame (in the full-duplex mode). 2'b11: Transferring input frame for transmission.*/
|
||||
uint32_t mactp : 1; /*When high this bit indicates that the MAC transmitter is in the Pause condition (in the full-duplex-mode) and hence does not schedule any frame for transmission.*/
|
||||
uint32_t mtltfrcs : 2; /*This field indicates the state of the Tx FIFO Read Controller: 2'b00: IDLE state. 2'b01: READ state (transferring data to the MAC transmitter). 2'b10: Waiting for TxStatus from the MAC transmitter. 2'b11: Writing the received TxStatus or flushing the Tx FIFO.*/
|
||||
uint32_t mtltfwcs : 1; /*When high this bit indicates that the MTL Tx FIFO Write Controller is active and is transferring data to the Tx FIFO.*/
|
||||
uint32_t reserved23 : 1;
|
||||
uint32_t mtltfnes : 1; /*When high this bit indicates that the MTL Tx FIFO is not empty and some data is left for Transmission.*/
|
||||
uint32_t mtltsffs : 1; /*When high this bit indicates that the MTL TxStatus FIFO is full. Therefore the MTL cannot accept any more frames for transmission.*/
|
||||
uint32_t reserved26 : 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} emacdebug;
|
||||
uint32_t pmt_rwuffr; /*The MSB (31st bit) must be zero.Bit j[30:0] is the byte mask. If Bit 1/2/3/4 (byte number) of the byte mask is set the CRC block processes the Filter 1/2/3/4 Offset + j of the incoming packet(PWKPTR is 0/1/2/3).RWKPTR is 0:Filter 0 Byte Mask .RWKPTR is 1:Filter 1 Byte Mask RWKPTR is 2:Filter 2 Byte Mask RWKPTR is 3:Filter 3 Byte Mask RWKPTR is 4:Bit 3/11/19/27 specifies the address type defining the destination address type of the pattern.When the bit is set the pattern applies to only multicast packets*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t pwrdwn : 1; /*When set the MAC receiver drops all received frames until it receives the expected magic packet or remote wake-up frame.This bit must only be set when MGKPKTEN GLBLUCAST or RWKPKTEN bit is set high.*/
|
||||
uint32_t mgkpkten : 1; /*When set enables generation of a power management event because of magic packet reception.*/
|
||||
uint32_t rwkpkten : 1; /*When set enables generation of a power management event because of remote wake-up frame reception*/
|
||||
uint32_t reserved3 : 2;
|
||||
uint32_t mgkprcvd : 1; /*When set this bit indicates that the power management event is generated because of the reception of a magic packet. This bit is cleared by a Read into this register.*/
|
||||
uint32_t rwkprcvd : 1; /*When set this bit indicates the power management event is generated because of the reception of a remote wake-up frame. This bit is cleared by a Read into this register.*/
|
||||
uint32_t reserved7 : 2;
|
||||
uint32_t glblucast : 1; /*When set enables any unicast packet filtered by the MAC (DAFilter) address recognition to be a remote wake-up frame.*/
|
||||
uint32_t reserved10 : 14;
|
||||
uint32_t rwkptr : 5; /*The maximum value of the pointer is 7 the detail information please refer to PMT_RWUFFR.*/
|
||||
uint32_t reserved29 : 2;
|
||||
uint32_t rwkfiltrst : 1; /*When this bit is set it resets the RWKPTR register to 3’b000.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} pmt_csr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tlpien : 1; /*When set this bit indicates that the MAC Transmitter has entered the LPI state because of the setting of the LPIEN bit. This bit is cleared by a read into this register.*/
|
||||
uint32_t tlpiex : 1; /*When set this bit indicates that the MAC transmitter has exited the LPI state after the user has cleared the LPIEN bit and the LPI_TW_Timer has expired.This bit is cleared by a read into this register.*/
|
||||
uint32_t rlpien : 1; /*When set this bit indicates that the MAC Receiver has received an LPI pattern and entered the LPI state. This bit is cleared by a read into this register.*/
|
||||
uint32_t rlpiex : 1; /*When set this bit indicates that the MAC Receiver has stopped receiving the LPI pattern on the MII interface exited the LPI state and resumed the normal reception. This bit is cleared by a read into this register.*/
|
||||
uint32_t reserved4 : 4;
|
||||
uint32_t tlpist : 1; /*When set this bit indicates that the MAC is transmitting the LPI pattern on the MII interface.*/
|
||||
uint32_t rlpist : 1; /*When set this bit indicates that the MAC is receiving the LPI pattern on the MII interface.*/
|
||||
uint32_t reserved10 : 6;
|
||||
uint32_t lpien : 1; /*When set this bit instructs the MAC Transmitter to enter the LPI state. When reset this bit instructs the MAC to exit the LPI state and resume normal transmission.This bit is cleared when the LPITXA bit is set and the MAC exits the LPI state because of the arrival of a new packet for transmission.*/
|
||||
uint32_t pls : 1; /*This bit indicates the link status of the PHY.When set the link is considered to be okay (up) and when reset the link is considered to be down.*/
|
||||
uint32_t reserved18 : 1;
|
||||
uint32_t lpitxa : 1; /*This bit controls the behavior of the MAC when it is entering or coming out of the LPI mode on the transmit side.If the LPITXA and LPIEN bits are set to 1 the MAC enters the LPI mode only after all outstanding frames and pending frames have been transmitted. The MAC comes out of the LPI mode when the application sends any frame.When this bit is 0 the LPIEN bit directly controls behavior of the MAC when it is entering or coming out of the LPI mode.*/
|
||||
uint32_t reserved20 : 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} gmaclpi_crs;
|
||||
union {
|
||||
struct {
|
||||
uint32_t lpi_tw_timer : 16; /*This field specifies the minimum time (in microseconds) for which the MAC waits after it stops transmitting the LPI pattern to the PHY and before it resumes the normal transmission. The TLPIEX status bit is set after the expiry of this timer.*/
|
||||
uint32_t lpi_ls_timer : 10; /*This field specifies the minimum time (in milliseconds) for which the link status from the PHY should be up (OKAY) before the LPI pattern can be transmitted to the PHY. The MAC does not transmit the LPI pattern even when the LPIEN bit is set unless the LPI_LS_Timer reaches the programmed terminal count. The default value of the LPI_LS_Timer is 1000 (1 sec) as defined in the IEEE standard.*/
|
||||
uint32_t reserved26 : 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} gmaclpitimerscontrol;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0 : 1;
|
||||
uint32_t reserved1 : 1;
|
||||
uint32_t reserved2 : 1;
|
||||
uint32_t pmtints : 1; /*This bit is set when a magic packet or remote wake-up frame is received in the power-down mode (see Bit[5] and Bit[6] in the PMT Control and Status Register). This bit is cleared when both Bits[6:5] are cleared because of a read operation to the PMT Control and Status register. This bit is valid only when you select the optional PMT module during core configuration.*/
|
||||
uint32_t reserved4 : 1;
|
||||
uint32_t reserved5 : 1;
|
||||
uint32_t reserved6 : 1;
|
||||
uint32_t reserved7 : 1;
|
||||
uint32_t reserved8 : 1;
|
||||
uint32_t reserved9 : 1;
|
||||
uint32_t lpiis : 1; /*When the Energy Efficient Ethernet feature is enabled this bit is set for any LPI state entry or exit in the MAC Transmitter or Receiver. This bit is cleared on reading Bit[0] of Register (LPI Control and Status Register).*/
|
||||
uint32_t reserved11 : 1;
|
||||
uint32_t reserved12 : 20;
|
||||
};
|
||||
uint32_t val;
|
||||
} emacints;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0 : 1;
|
||||
uint32_t reserved1 : 1;
|
||||
uint32_t reserved2 : 1;
|
||||
uint32_t pmtintmask : 1; /*When set this bit disables the assertion of the interrupt signal because of the setting of PMT Interrupt Status bit in Register (Interrupt Status Register).*/
|
||||
uint32_t reserved4 : 5;
|
||||
uint32_t reserved9 : 1;
|
||||
uint32_t lpiintmask : 1; /*When set this bit disables the assertion of the interrupt signal because of the setting of the LPI Interrupt Status bit in Register (Interrupt Status Register).*/
|
||||
uint32_t reserved11 : 21;
|
||||
};
|
||||
uint32_t val;
|
||||
} emacintmask;
|
||||
union {
|
||||
struct {
|
||||
uint32_t address0_hi : 16; /*This field contains the upper 16 bits (47:32) of the first 6-byte MAC address.The MAC uses this field for filtering the received frames and inserting the MAC address in the Transmit Flow Control (Pause) Frames.*/
|
||||
uint32_t reserved16 : 15;
|
||||
uint32_t address_enable0 : 1; /*This bit is always set to 1.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr0high;
|
||||
uint32_t emacaddr0low; /*This field contains the lower 32 bits of the first 6-byte MAC address. This is used by the MAC for filtering the received frames and inserting the MAC address in the Transmit Flow Control (Pause) Frames.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address1_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the second 6-byte MAC Address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control : 6; /*These bits are mask control bits for comparison of each of the EMACADDR1 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR1 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR1 High [15:8]. Bit[28]: EMACADDR1 High [7:0]. Bit[27]: EMACADDR1 Low [31:24]. Bit[24]: EMACADDR1 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address : 1; /*When this bit is set the EMACADDR1[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR1[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable1 : 1; /*When this bit is set the address filter module uses the second MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr1high;
|
||||
uint32_t emacaddr1low; /*This field contains the lower 32 bits of the second 6-byte MAC address.The content of this field is undefined so the register needs to be configured after the initialization Process.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address2_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the third 6-byte MAC address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control2 : 6; /*These bits are mask control bits for comparison of each of the EMACADDR2 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR2 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR2 High [15:8]. Bit[28]: EMACADDR2 High [7:0]. Bit[27]: EMACADDR2 Low [31:24]. Bit[24]: EMACADDR2 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address2 : 1; /*When this bit is set the EMACADDR2[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR2[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable2 : 1; /*When this bit is set the address filter module uses the third MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr2high;
|
||||
uint32_t emacaddr2low; /*This field contains the lower 32 bits of the third 6-byte MAC address. The content of this field is undefined so the register needs to be configured after the initialization process.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address3_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the fourth 6-byte MAC address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control3 : 6; /*These bits are mask control bits for comparison of each of the EMACADDR3 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR3 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR3 High [15:8]. Bit[28]: EMACADDR3 High [7:0]. Bit[27]: EMACADDR3 Low [31:24]. Bit[24]: EMACADDR3 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address3 : 1; /*When this bit is set the EMACADDR3[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR3[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable3 : 1; /*When this bit is set the address filter module uses the fourth MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr3high;
|
||||
uint32_t emacaddr3low; /*This field contains the lower 32 bits of the fourth 6-byte MAC address.The content of this field is undefined so the register needs to be configured after the initialization Process.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address4_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the fifth 6-byte MAC address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control4 : 6; /*These bits are mask control bits for comparison of each of the EMACADDR4 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR4 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR4 High [15:8]. Bit[28]: EMACADDR4 High [7:0]. Bit[27]: EMACADDR4 Low [31:24]. Bit[24]: EMACADDR4 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address4 : 1; /*When this bit is set the EMACADDR4[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR4[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable4 : 1; /*When this bit is set the address filter module uses the fifth MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr4high;
|
||||
uint32_t emacaddr4low; /*This field contains the lower 32 bits of the fifth 6-byte MAC address. The content of this field is undefined so the register needs to be configured after the initialization process.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address5_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the sixth 6-byte MAC address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control5 : 6; /*These bits are mask control bits for comparison of each of the EMACADDR5 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR5 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR5 High [15:8]. Bit[28]: EMACADDR5 High [7:0]. Bit[27]: EMACADDR5 Low [31:24]. Bit[24]: EMACADDR5 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address5 : 1; /*When this bit is set the EMACADDR5[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR5[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable5 : 1; /*When this bit is set the address filter module uses the sixth MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr5high;
|
||||
uint32_t emacaddr5low; /*This field contains the lower 32 bits of the sixth 6-byte MAC address. The content of this field is undefined so the register needs to be configured after the initialization process.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address6_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the seventh 6-byte MAC Address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control6 : 6; /*These bits are mask control bits for comparison of each of the EMACADDR6 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR6 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR6 High [15:8]. Bit[28]: EMACADDR6 High [7:0]. Bit[27]: EMACADDR6 Low [31:24]. Bit[24]: EMACADDR6 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address6 : 1; /*When this bit is set the EMACADDR6[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR6[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable6 : 1; /*When this bit is set the address filter module uses the seventh MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr6high;
|
||||
uint32_t emacaddr6low; /*This field contains the lower 32 bits of the seventh 6-byte MAC address.The content of this field is undefined so the register needs to be configured after the initialization Process.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t mac_address7_hi : 16; /*This field contains the upper 16 bits Bits[47:32] of the eighth 6-byte MAC Address.*/
|
||||
uint32_t reserved16 : 8;
|
||||
uint32_t mask_byte_control7 : 6; /*These bits are mask control bits for comparison of each of the EMACADDR7 bytes. When set high the MAC does not compare the corresponding byte of received DA or SA with the contents of EMACADDR7 registers. Each bit controls the masking of the bytes as follows: Bit[29]: EMACADDR7 High [15:8]. Bit[28]: EMACADDR7 High [7:0]. Bit[27]: EMACADDR7 Low [31:24]. Bit[24]: EMACADDR7 Low [7:0].You can filter a group of addresses (known as group address filtering) by masking one or more bytes of the address.*/
|
||||
uint32_t source_address7 : 1; /*When this bit is set the EMACADDR7[47:0] is used to compare with the SA fields of the received frame. When this bit is reset the EMACADDR7[47:0] is used to compare with the DA fields of the received frame.*/
|
||||
uint32_t address_enable7 : 1; /*When this bit is set the address filter module uses the eighth MAC address for perfect filtering. When this bit is reset the address filter module ignores the address for filtering.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} emacaddr7high;
|
||||
uint32_t emacaddr7low; /*This field contains the lower 32 bits of the eighth 6-byte MAC address.The content of this field is undefined so the register needs to be configured after the initialization Process.*/
|
||||
uint32_t reserved_1080;
|
||||
uint32_t reserved_1084;
|
||||
uint32_t reserved_1088;
|
||||
uint32_t reserved_108c;
|
||||
uint32_t reserved_1090;
|
||||
uint32_t reserved_1094;
|
||||
uint32_t reserved_1098;
|
||||
uint32_t reserved_109c;
|
||||
uint32_t reserved_10a0;
|
||||
uint32_t reserved_10a4;
|
||||
uint32_t reserved_10a8;
|
||||
uint32_t reserved_10ac;
|
||||
uint32_t reserved_10b0;
|
||||
uint32_t reserved_10b4;
|
||||
uint32_t reserved_10b8;
|
||||
uint32_t reserved_10bc;
|
||||
uint32_t reserved_10c0;
|
||||
uint32_t reserved_10c4;
|
||||
uint32_t reserved_10c8;
|
||||
uint32_t reserved_10cc;
|
||||
uint32_t reserved_10d0;
|
||||
uint32_t reserved_10d4;
|
||||
union {
|
||||
struct {
|
||||
uint32_t link_mode : 1; /*This bit indicates the current mode of operation of the link: 1'b0: Half-duplex mode. 1'b1: Full-duplex mode.*/
|
||||
uint32_t link_speed : 2; /*This bit indicates the current speed of the link: 2'b00: 2.5 MHz. 2'b01: 25 MHz. 2'b10: 125 MHz.*/
|
||||
uint32_t reserved3 : 1;
|
||||
uint32_t jabber_timeout : 1; /*This bit indicates whether there is jabber timeout error (1'b1) in the received Frame.*/
|
||||
uint32_t reserved5 : 1;
|
||||
uint32_t reserved6 : 10;
|
||||
uint32_t reserved16 : 1;
|
||||
uint32_t reserved17 : 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} emaccstatus;
|
||||
union {
|
||||
struct {
|
||||
uint32_t wdogto : 14; /*When Bit[16] (PWE) is set and Bit[23] (WD) of EMACCONFIG_REG is reset this field is used as watchdog timeout for a received frame. If the length of a received frame exceeds the value of this field such frame is terminated and declared as an error frame.*/
|
||||
uint32_t reserved14 : 2;
|
||||
uint32_t pwdogen : 1; /*When this bit is set and Bit[23] (WD) of EMACCONFIG_REG is reset the WTO field (Bits[13:0]) is used as watchdog timeout for a received frame. When this bit is cleared the watchdog timeout for a received frame is controlled by the setting of Bit[23] (WD) and Bit[20] (JE) in EMACCONFIG_REG.*/
|
||||
uint32_t reserved17 : 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} emacwdogto;
|
||||
} emac_mac_dev_t;
|
||||
|
||||
extern emac_mac_dev_t EMAC_MAC;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
41
tools/sdk/esp32/include/soc/soc/esp32/include/soc/fe_reg.h
Normal file
41
tools/sdk/esp32/include/soc/soc/esp32/include/soc/fe_reg.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc.h"
|
||||
|
||||
/* Some of the RF frontend control registers.
|
||||
* PU/PD fields defined here are used in sleep related functions.
|
||||
*/
|
||||
|
||||
#define FE_GEN_CTRL (DR_REG_FE_BASE + 0x0090)
|
||||
#define FE_IQ_EST_FORCE_PU (BIT(5))
|
||||
#define FE_IQ_EST_FORCE_PU_M (BIT(5))
|
||||
#define FE_IQ_EST_FORCE_PU_V 1
|
||||
#define FE_IQ_EST_FORCE_PU_S 5
|
||||
#define FE_IQ_EST_FORCE_PD (BIT(4))
|
||||
#define FE_IQ_EST_FORCE_PD_M (BIT(4))
|
||||
#define FE_IQ_EST_FORCE_PD_V 1
|
||||
#define FE_IQ_EST_FORCE_PD_S 4
|
||||
|
||||
#define FE2_TX_INTERP_CTRL (DR_REG_FE2_BASE + 0x00f0)
|
||||
#define FE2_TX_INF_FORCE_PU (BIT(10))
|
||||
#define FE2_TX_INF_FORCE_PU_M (BIT(10))
|
||||
#define FE2_TX_INF_FORCE_PU_V 1
|
||||
#define FE2_TX_INF_FORCE_PU_S 10
|
||||
#define FE2_TX_INF_FORCE_PD (BIT(9))
|
||||
#define FE2_TX_INF_FORCE_PD_M (BIT(9))
|
||||
#define FE2_TX_INF_FORCE_PD_V 1
|
||||
#define FE2_TX_INF_FORCE_PD_S 9
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _SOC_FRC_TIMER_REG_H_
|
||||
#define _SOC_FRC_TIMER_REG_H_
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
/**
|
||||
* These are the register definitions for "legacy" timers
|
||||
*/
|
||||
|
||||
#define REG_FRC_TIMER_BASE(i) (DR_REG_FRC_TIMER_BASE + i*0x20)
|
||||
|
||||
#define FRC_TIMER_LOAD_REG(i) (REG_FRC_TIMER_BASE(i) + 0x0) // timer load value (23 bit for i==0, 32 bit for i==1)
|
||||
#define FRC_TIMER_LOAD_VALUE(i) ((i == 0)?0x007FFFFF:0xffffffff)
|
||||
#define FRC_TIMER_LOAD_VALUE_S 0
|
||||
|
||||
#define FRC_TIMER_COUNT_REG(i) (REG_FRC_TIMER_BASE(i) + 0x4) // timer count value (23 bit for i==0, 32 bit for i==1)
|
||||
#define FRC_TIMER_COUNT ((i == 0)?0x007FFFFF:0xffffffff)
|
||||
#define FRC_TIMER_COUNT_S 0
|
||||
|
||||
#define FRC_TIMER_CTRL_REG(i) (REG_FRC_TIMER_BASE(i) + 0x8)
|
||||
#define FRC_TIMER_INT_STATUS (BIT(8)) // interrupt status (RO)
|
||||
#define FRC_TIMER_ENABLE (BIT(7)) // enable timer
|
||||
#define FRC_TIMER_AUTOLOAD (BIT(6)) // enable autoload
|
||||
#define FRC_TIMER_PRESCALER 0x00000007
|
||||
#define FRC_TIMER_PRESCALER_S 1
|
||||
#define FRC_TIMER_PRESCALER_1 (0 << FRC_TIMER_PRESCALER_S)
|
||||
#define FRC_TIMER_PRESCALER_16 (2 << FRC_TIMER_PRESCALER_S)
|
||||
#define FRC_TIMER_PRESCALER_256 (4 << FRC_TIMER_PRESCALER_S)
|
||||
#define FRC_TIMER_LEVEL_INT (BIT(0)) // 1: level, 0: edge
|
||||
|
||||
#define FRC_TIMER_INT_REG(i) (REG_FRC_TIMER_BASE(i) + 0xC)
|
||||
#define FRC_TIMER_INT_CLR (BIT(0)) // clear interrupt
|
||||
|
||||
#define FRC_TIMER_ALARM_REG(i) (REG_FRC_TIMER_BASE(i) + 0x10) // timer alarm value; register only present for i == 1
|
||||
#define FRC_TIMER_ALARM 0xFFFFFFFF
|
||||
#define FRC_TIMER_ALARM_S 0
|
||||
|
||||
#endif //_SOC_FRC_TIMER_REG_H_
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ESP32 has 1 GPIO peripheral
|
||||
#define SOC_GPIO_PORT (1)
|
||||
#define GPIO_PIN_COUNT (40)
|
||||
|
||||
// On ESP32 those PADs which have RTC functions must set pullup/down/capability via RTC register.
|
||||
// On ESP32-S2, Digital IOs have their own registers to control pullup/down/capability, independent with RTC registers.
|
||||
#define GPIO_SUPPORTS_RTC_INDEPENDENT (0)
|
||||
// Force hold is a new function of ESP32-S2
|
||||
#define GPIO_SUPPORTS_FORCE_HOLD (0)
|
||||
|
||||
#define GPIO_APP_CPU_INTR_ENA (BIT(0))
|
||||
#define GPIO_APP_CPU_NMI_INTR_ENA (BIT(1))
|
||||
#define GPIO_PRO_CPU_INTR_ENA (BIT(2))
|
||||
#define GPIO_PRO_CPU_NMI_INTR_ENA (BIT(3))
|
||||
#define GPIO_SDIO_EXT_INTR_ENA (BIT(4))
|
||||
|
||||
#define GPIO_MODE_DEF_DISABLE (0)
|
||||
#define GPIO_MODE_DEF_INPUT (BIT0)
|
||||
#define GPIO_MODE_DEF_OUTPUT (BIT1)
|
||||
#define GPIO_MODE_DEF_OD (BIT2)
|
||||
|
||||
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num < GPIO_PIN_COUNT && GPIO_PIN_MUX_REG[gpio_num] != 0)) /*!< Check whether it is a valid GPIO number */
|
||||
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((GPIO_IS_VALID_GPIO(gpio_num)) && (gpio_num < 34)) /*!< Check whether it can be a valid GPIO number of output mode */
|
||||
#define GPIO_MASK_CONTAIN_INPUT_GPIO(gpio_mask) ((gpio_mask & (GPIO_SEL_34 | GPIO_SEL_35 | GPIO_SEL_36 | GPIO_SEL_37 | GPIO_SEL_38 | GPIO_SEL_39))) /*!< Check whether it contains input io */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
8238
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_reg.h
Normal file
8238
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_reg.h
Normal file
File diff suppressed because it is too large
Load Diff
160
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_sd_reg.h
Normal file
160
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_sd_reg.h
Normal file
@@ -0,0 +1,160 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_GPIO_SD_REG_H_
|
||||
#define _SOC_GPIO_SD_REG_H_
|
||||
|
||||
#include "soc.h"
|
||||
#define GPIO_SIGMADELTA0_REG (DR_REG_GPIO_SD_BASE + 0x0000)
|
||||
/* GPIO_SD0_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD0_PRESCALE 0x000000FF
|
||||
#define GPIO_SD0_PRESCALE_M ((GPIO_SD0_PRESCALE_V)<<(GPIO_SD0_PRESCALE_S))
|
||||
#define GPIO_SD0_PRESCALE_V 0xFF
|
||||
#define GPIO_SD0_PRESCALE_S 8
|
||||
/* GPIO_SD0_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD0_IN 0x000000FF
|
||||
#define GPIO_SD0_IN_M ((GPIO_SD0_IN_V)<<(GPIO_SD0_IN_S))
|
||||
#define GPIO_SD0_IN_V 0xFF
|
||||
#define GPIO_SD0_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA1_REG (DR_REG_GPIO_SD_BASE + 0x0004)
|
||||
/* GPIO_SD1_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD1_PRESCALE 0x000000FF
|
||||
#define GPIO_SD1_PRESCALE_M ((GPIO_SD1_PRESCALE_V)<<(GPIO_SD1_PRESCALE_S))
|
||||
#define GPIO_SD1_PRESCALE_V 0xFF
|
||||
#define GPIO_SD1_PRESCALE_S 8
|
||||
/* GPIO_SD1_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD1_IN 0x000000FF
|
||||
#define GPIO_SD1_IN_M ((GPIO_SD1_IN_V)<<(GPIO_SD1_IN_S))
|
||||
#define GPIO_SD1_IN_V 0xFF
|
||||
#define GPIO_SD1_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA2_REG (DR_REG_GPIO_SD_BASE + 0x0008)
|
||||
/* GPIO_SD2_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD2_PRESCALE 0x000000FF
|
||||
#define GPIO_SD2_PRESCALE_M ((GPIO_SD2_PRESCALE_V)<<(GPIO_SD2_PRESCALE_S))
|
||||
#define GPIO_SD2_PRESCALE_V 0xFF
|
||||
#define GPIO_SD2_PRESCALE_S 8
|
||||
/* GPIO_SD2_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD2_IN 0x000000FF
|
||||
#define GPIO_SD2_IN_M ((GPIO_SD2_IN_V)<<(GPIO_SD2_IN_S))
|
||||
#define GPIO_SD2_IN_V 0xFF
|
||||
#define GPIO_SD2_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA3_REG (DR_REG_GPIO_SD_BASE + 0x000c)
|
||||
/* GPIO_SD3_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD3_PRESCALE 0x000000FF
|
||||
#define GPIO_SD3_PRESCALE_M ((GPIO_SD3_PRESCALE_V)<<(GPIO_SD3_PRESCALE_S))
|
||||
#define GPIO_SD3_PRESCALE_V 0xFF
|
||||
#define GPIO_SD3_PRESCALE_S 8
|
||||
/* GPIO_SD3_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD3_IN 0x000000FF
|
||||
#define GPIO_SD3_IN_M ((GPIO_SD3_IN_V)<<(GPIO_SD3_IN_S))
|
||||
#define GPIO_SD3_IN_V 0xFF
|
||||
#define GPIO_SD3_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA4_REG (DR_REG_GPIO_SD_BASE + 0x0010)
|
||||
/* GPIO_SD4_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD4_PRESCALE 0x000000FF
|
||||
#define GPIO_SD4_PRESCALE_M ((GPIO_SD4_PRESCALE_V)<<(GPIO_SD4_PRESCALE_S))
|
||||
#define GPIO_SD4_PRESCALE_V 0xFF
|
||||
#define GPIO_SD4_PRESCALE_S 8
|
||||
/* GPIO_SD4_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD4_IN 0x000000FF
|
||||
#define GPIO_SD4_IN_M ((GPIO_SD4_IN_V)<<(GPIO_SD4_IN_S))
|
||||
#define GPIO_SD4_IN_V 0xFF
|
||||
#define GPIO_SD4_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA5_REG (DR_REG_GPIO_SD_BASE + 0x0014)
|
||||
/* GPIO_SD5_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD5_PRESCALE 0x000000FF
|
||||
#define GPIO_SD5_PRESCALE_M ((GPIO_SD5_PRESCALE_V)<<(GPIO_SD5_PRESCALE_S))
|
||||
#define GPIO_SD5_PRESCALE_V 0xFF
|
||||
#define GPIO_SD5_PRESCALE_S 8
|
||||
/* GPIO_SD5_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD5_IN 0x000000FF
|
||||
#define GPIO_SD5_IN_M ((GPIO_SD5_IN_V)<<(GPIO_SD5_IN_S))
|
||||
#define GPIO_SD5_IN_V 0xFF
|
||||
#define GPIO_SD5_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA6_REG (DR_REG_GPIO_SD_BASE + 0x0018)
|
||||
/* GPIO_SD6_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD6_PRESCALE 0x000000FF
|
||||
#define GPIO_SD6_PRESCALE_M ((GPIO_SD6_PRESCALE_V)<<(GPIO_SD6_PRESCALE_S))
|
||||
#define GPIO_SD6_PRESCALE_V 0xFF
|
||||
#define GPIO_SD6_PRESCALE_S 8
|
||||
/* GPIO_SD6_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD6_IN 0x000000FF
|
||||
#define GPIO_SD6_IN_M ((GPIO_SD6_IN_V)<<(GPIO_SD6_IN_S))
|
||||
#define GPIO_SD6_IN_V 0xFF
|
||||
#define GPIO_SD6_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA7_REG (DR_REG_GPIO_SD_BASE + 0x001c)
|
||||
/* GPIO_SD7_PRESCALE : R/W ;bitpos:[15:8] ;default: 8'hff ; */
|
||||
/*description: */
|
||||
#define GPIO_SD7_PRESCALE 0x000000FF
|
||||
#define GPIO_SD7_PRESCALE_M ((GPIO_SD7_PRESCALE_V)<<(GPIO_SD7_PRESCALE_S))
|
||||
#define GPIO_SD7_PRESCALE_V 0xFF
|
||||
#define GPIO_SD7_PRESCALE_S 8
|
||||
/* GPIO_SD7_IN : R/W ;bitpos:[7:0] ;default: 8'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD7_IN 0x000000FF
|
||||
#define GPIO_SD7_IN_M ((GPIO_SD7_IN_V)<<(GPIO_SD7_IN_S))
|
||||
#define GPIO_SD7_IN_V 0xFF
|
||||
#define GPIO_SD7_IN_S 0
|
||||
|
||||
#define GPIO_SIGMADELTA_CG_REG (DR_REG_GPIO_SD_BASE + 0x0020)
|
||||
/* GPIO_SD_CLK_EN : R/W ;bitpos:[31] ;default: 1'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD_CLK_EN (BIT(31))
|
||||
#define GPIO_SD_CLK_EN_M (BIT(31))
|
||||
#define GPIO_SD_CLK_EN_V 0x1
|
||||
#define GPIO_SD_CLK_EN_S 31
|
||||
|
||||
#define GPIO_SIGMADELTA_MISC_REG (DR_REG_GPIO_SD_BASE + 0x0024)
|
||||
/* GPIO_SPI_SWAP : R/W ;bitpos:[31] ;default: 1'h0 ; */
|
||||
/*description: */
|
||||
#define GPIO_SPI_SWAP (BIT(31))
|
||||
#define GPIO_SPI_SWAP_M (BIT(31))
|
||||
#define GPIO_SPI_SWAP_V 0x1
|
||||
#define GPIO_SPI_SWAP_S 31
|
||||
|
||||
#define GPIO_SIGMADELTA_VERSION_REG (DR_REG_GPIO_SD_BASE + 0x0028)
|
||||
/* GPIO_SD_DATE : R/W ;bitpos:[27:0] ;default: 28'h1506190 ; */
|
||||
/*description: */
|
||||
#define GPIO_SD_DATE 0x0FFFFFFF
|
||||
#define GPIO_SD_DATE_M ((GPIO_SD_DATE_V)<<(GPIO_SD_DATE_S))
|
||||
#define GPIO_SD_DATE_V 0xFFFFFFF
|
||||
#define GPIO_SD_DATE_S 0
|
||||
#define SIGMADELTA_GPIO_SD_DATE_VERSION 0x1506190
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*_SOC_GPIO_SD_REG_H_ */
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_GPIO_SD_STRUCT_H_
|
||||
#define _SOC_GPIO_SD_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct gpio_sd_dev_s {
|
||||
union {
|
||||
struct {
|
||||
uint32_t duty: 8;
|
||||
uint32_t prescale: 8;
|
||||
uint32_t reserved16: 16;
|
||||
};
|
||||
uint32_t val;
|
||||
} channel[8];
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0: 31;
|
||||
uint32_t clk_en: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} cg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0: 31;
|
||||
uint32_t spi_swap: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} misc;
|
||||
union {
|
||||
struct {
|
||||
uint32_t date: 28;
|
||||
uint32_t reserved28: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} version;
|
||||
} gpio_sd_dev_t;
|
||||
extern gpio_sd_dev_t SIGMADELTA;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_GPIO_SD_STRUCT_H_ */
|
||||
422
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_sig_map.h
Normal file
422
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_sig_map.h
Normal file
@@ -0,0 +1,422 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_GPIO_SIG_MAP_H_
|
||||
#define _SOC_GPIO_SIG_MAP_H_
|
||||
|
||||
#define SPICLK_IN_IDX 0
|
||||
#define SPICLK_OUT_IDX 0
|
||||
#define SPIQ_IN_IDX 1
|
||||
#define SPIQ_OUT_IDX 1
|
||||
#define SPID_IN_IDX 2
|
||||
#define SPID_OUT_IDX 2
|
||||
#define SPIHD_IN_IDX 3
|
||||
#define SPIHD_OUT_IDX 3
|
||||
#define SPIWP_IN_IDX 4
|
||||
#define SPIWP_OUT_IDX 4
|
||||
#define SPICS0_IN_IDX 5
|
||||
#define SPICS0_OUT_IDX 5
|
||||
#define SPICS1_IN_IDX 6
|
||||
#define SPICS1_OUT_IDX 6
|
||||
#define SPICS2_IN_IDX 7
|
||||
#define SPICS2_OUT_IDX 7
|
||||
#define HSPICLK_IN_IDX 8
|
||||
#define HSPICLK_OUT_IDX 8
|
||||
#define HSPIQ_IN_IDX 9
|
||||
#define HSPIQ_OUT_IDX 9
|
||||
#define HSPID_IN_IDX 10
|
||||
#define HSPID_OUT_IDX 10
|
||||
#define HSPICS0_IN_IDX 11
|
||||
#define HSPICS0_OUT_IDX 11
|
||||
#define HSPIHD_IN_IDX 12
|
||||
#define HSPIHD_OUT_IDX 12
|
||||
#define HSPIWP_IN_IDX 13
|
||||
#define HSPIWP_OUT_IDX 13
|
||||
#define U0RXD_IN_IDX 14
|
||||
#define U0TXD_OUT_IDX 14
|
||||
#define U0CTS_IN_IDX 15
|
||||
#define U0RTS_OUT_IDX 15
|
||||
#define U0DSR_IN_IDX 16
|
||||
#define U0DTR_OUT_IDX 16
|
||||
#define U1RXD_IN_IDX 17
|
||||
#define U1TXD_OUT_IDX 17
|
||||
#define U1CTS_IN_IDX 18
|
||||
#define U1RTS_OUT_IDX 18
|
||||
#define I2CM_SCL_O_IDX 19
|
||||
#define I2CM_SDA_I_IDX 20
|
||||
#define I2CM_SDA_O_IDX 20
|
||||
#define EXT_I2C_SCL_O_IDX 21
|
||||
#define EXT_I2C_SDA_O_IDX 22
|
||||
#define EXT_I2C_SDA_I_IDX 22
|
||||
#define I2S0O_BCK_IN_IDX 23
|
||||
#define I2S0O_BCK_OUT_IDX 23
|
||||
#define I2S1O_BCK_IN_IDX 24
|
||||
#define I2S1O_BCK_OUT_IDX 24
|
||||
#define I2S0O_WS_IN_IDX 25
|
||||
#define I2S0O_WS_OUT_IDX 25
|
||||
#define I2S1O_WS_IN_IDX 26
|
||||
#define I2S1O_WS_OUT_IDX 26
|
||||
#define I2S0I_BCK_IN_IDX 27
|
||||
#define I2S0I_BCK_OUT_IDX 27
|
||||
#define I2S0I_WS_IN_IDX 28
|
||||
#define I2S0I_WS_OUT_IDX 28
|
||||
#define I2CEXT0_SCL_IN_IDX 29
|
||||
#define I2CEXT0_SCL_OUT_IDX 29
|
||||
#define I2CEXT0_SDA_IN_IDX 30
|
||||
#define I2CEXT0_SDA_OUT_IDX 30
|
||||
#define PWM0_SYNC0_IN_IDX 31
|
||||
#define SDIO_TOHOST_INT_OUT_IDX 31
|
||||
#define PWM0_SYNC1_IN_IDX 32
|
||||
#define PWM0_OUT0A_IDX 32
|
||||
#define PWM0_SYNC2_IN_IDX 33
|
||||
#define PWM0_OUT0B_IDX 33
|
||||
#define PWM0_F0_IN_IDX 34
|
||||
#define PWM0_OUT1A_IDX 34
|
||||
#define PWM0_F1_IN_IDX 35
|
||||
#define PWM0_OUT1B_IDX 35
|
||||
#define PWM0_F2_IN_IDX 36
|
||||
#define PWM0_OUT2A_IDX 36
|
||||
#define GPIO_BT_ACTIVE_IDX 37
|
||||
#define PWM0_OUT2B_IDX 37
|
||||
#define GPIO_BT_PRIORITY_IDX 38
|
||||
#define PCNT_SIG_CH0_IN0_IDX 39
|
||||
#define PCNT_SIG_CH1_IN0_IDX 40
|
||||
#define GPIO_WLAN_ACTIVE_IDX 40
|
||||
#define PCNT_CTRL_CH0_IN0_IDX 41
|
||||
#define BB_DIAG0_IDX 41
|
||||
#define PCNT_CTRL_CH1_IN0_IDX 42
|
||||
#define BB_DIAG1_IDX 42
|
||||
#define PCNT_SIG_CH0_IN1_IDX 43
|
||||
#define BB_DIAG2_IDX 43
|
||||
#define PCNT_SIG_CH1_IN1_IDX 44
|
||||
#define BB_DIAG3_IDX 44
|
||||
#define PCNT_CTRL_CH0_IN1_IDX 45
|
||||
#define BB_DIAG4_IDX 45
|
||||
#define PCNT_CTRL_CH1_IN1_IDX 46
|
||||
#define BB_DIAG5_IDX 46
|
||||
#define PCNT_SIG_CH0_IN2_IDX 47
|
||||
#define BB_DIAG6_IDX 47
|
||||
#define PCNT_SIG_CH1_IN2_IDX 48
|
||||
#define BB_DIAG7_IDX 48
|
||||
#define PCNT_CTRL_CH0_IN2_IDX 49
|
||||
#define BB_DIAG8_IDX 49
|
||||
#define PCNT_CTRL_CH1_IN2_IDX 50
|
||||
#define BB_DIAG9_IDX 50
|
||||
#define PCNT_SIG_CH0_IN3_IDX 51
|
||||
#define BB_DIAG10_IDX 51
|
||||
#define PCNT_SIG_CH1_IN3_IDX 52
|
||||
#define BB_DIAG11_IDX 52
|
||||
#define PCNT_CTRL_CH0_IN3_IDX 53
|
||||
#define BB_DIAG12_IDX 53
|
||||
#define PCNT_CTRL_CH1_IN3_IDX 54
|
||||
#define BB_DIAG13_IDX 54
|
||||
#define PCNT_SIG_CH0_IN4_IDX 55
|
||||
#define BB_DIAG14_IDX 55
|
||||
#define PCNT_SIG_CH1_IN4_IDX 56
|
||||
#define BB_DIAG15_IDX 56
|
||||
#define PCNT_CTRL_CH0_IN4_IDX 57
|
||||
#define BB_DIAG16_IDX 57
|
||||
#define PCNT_CTRL_CH1_IN4_IDX 58
|
||||
#define BB_DIAG17_IDX 58
|
||||
#define BB_DIAG18_IDX 59
|
||||
#define BB_DIAG19_IDX 60
|
||||
#define HSPICS1_IN_IDX 61
|
||||
#define HSPICS1_OUT_IDX 61
|
||||
#define HSPICS2_IN_IDX 62
|
||||
#define HSPICS2_OUT_IDX 62
|
||||
#define VSPICLK_IN_IDX 63
|
||||
#define VSPICLK_OUT_IDX 63
|
||||
#define VSPIQ_IN_IDX 64
|
||||
#define VSPIQ_OUT_IDX 64
|
||||
#define VSPID_IN_IDX 65
|
||||
#define VSPID_OUT_IDX 65
|
||||
#define VSPIHD_IN_IDX 66
|
||||
#define VSPIHD_OUT_IDX 66
|
||||
#define VSPIWP_IN_IDX 67
|
||||
#define VSPIWP_OUT_IDX 67
|
||||
#define VSPICS0_IN_IDX 68
|
||||
#define VSPICS0_OUT_IDX 68
|
||||
#define VSPICS1_IN_IDX 69
|
||||
#define VSPICS1_OUT_IDX 69
|
||||
#define VSPICS2_IN_IDX 70
|
||||
#define VSPICS2_OUT_IDX 70
|
||||
#define PCNT_SIG_CH0_IN5_IDX 71
|
||||
#define LEDC_HS_SIG_OUT0_IDX 71
|
||||
#define PCNT_SIG_CH1_IN5_IDX 72
|
||||
#define LEDC_HS_SIG_OUT1_IDX 72
|
||||
#define PCNT_CTRL_CH0_IN5_IDX 73
|
||||
#define LEDC_HS_SIG_OUT2_IDX 73
|
||||
#define PCNT_CTRL_CH1_IN5_IDX 74
|
||||
#define LEDC_HS_SIG_OUT3_IDX 74
|
||||
#define PCNT_SIG_CH0_IN6_IDX 75
|
||||
#define LEDC_HS_SIG_OUT4_IDX 75
|
||||
#define PCNT_SIG_CH1_IN6_IDX 76
|
||||
#define LEDC_HS_SIG_OUT5_IDX 76
|
||||
#define PCNT_CTRL_CH0_IN6_IDX 77
|
||||
#define LEDC_HS_SIG_OUT6_IDX 77
|
||||
#define PCNT_CTRL_CH1_IN6_IDX 78
|
||||
#define LEDC_HS_SIG_OUT7_IDX 78
|
||||
#define PCNT_SIG_CH0_IN7_IDX 79
|
||||
#define LEDC_LS_SIG_OUT0_IDX 79
|
||||
#define PCNT_SIG_CH1_IN7_IDX 80
|
||||
#define LEDC_LS_SIG_OUT1_IDX 80
|
||||
#define PCNT_CTRL_CH0_IN7_IDX 81
|
||||
#define LEDC_LS_SIG_OUT2_IDX 81
|
||||
#define PCNT_CTRL_CH1_IN7_IDX 82
|
||||
#define LEDC_LS_SIG_OUT3_IDX 82
|
||||
#define RMT_SIG_IN0_IDX 83
|
||||
#define LEDC_LS_SIG_OUT4_IDX 83
|
||||
#define RMT_SIG_IN1_IDX 84
|
||||
#define LEDC_LS_SIG_OUT5_IDX 84
|
||||
#define RMT_SIG_IN2_IDX 85
|
||||
#define LEDC_LS_SIG_OUT6_IDX 85
|
||||
#define RMT_SIG_IN3_IDX 86
|
||||
#define LEDC_LS_SIG_OUT7_IDX 86
|
||||
#define RMT_SIG_IN4_IDX 87
|
||||
#define RMT_SIG_OUT0_IDX 87
|
||||
#define RMT_SIG_IN5_IDX 88
|
||||
#define RMT_SIG_OUT1_IDX 88
|
||||
#define RMT_SIG_IN6_IDX 89
|
||||
#define RMT_SIG_OUT2_IDX 89
|
||||
#define RMT_SIG_IN7_IDX 90
|
||||
#define RMT_SIG_OUT3_IDX 90
|
||||
#define RMT_SIG_OUT4_IDX 91
|
||||
#define RMT_SIG_OUT5_IDX 92
|
||||
#define EXT_ADC_START_IDX 93
|
||||
#define RMT_SIG_OUT6_IDX 93
|
||||
#define CAN_RX_IDX 94
|
||||
#define RMT_SIG_OUT7_IDX 94
|
||||
#define I2CEXT1_SCL_IN_IDX 95
|
||||
#define I2CEXT1_SCL_OUT_IDX 95
|
||||
#define I2CEXT1_SDA_IN_IDX 96
|
||||
#define I2CEXT1_SDA_OUT_IDX 96
|
||||
#define HOST_CARD_DETECT_N_1_IDX 97
|
||||
#define HOST_CCMD_OD_PULLUP_EN_N_IDX 97
|
||||
#define HOST_CARD_DETECT_N_2_IDX 98
|
||||
#define HOST_RST_N_1_IDX 98
|
||||
#define HOST_CARD_WRITE_PRT_1_IDX 99
|
||||
#define HOST_RST_N_2_IDX 99
|
||||
#define HOST_CARD_WRITE_PRT_2_IDX 100
|
||||
#define GPIO_SD0_OUT_IDX 100
|
||||
#define HOST_CARD_INT_N_1_IDX 101
|
||||
#define GPIO_SD1_OUT_IDX 101
|
||||
#define HOST_CARD_INT_N_2_IDX 102
|
||||
#define GPIO_SD2_OUT_IDX 102
|
||||
#define PWM1_SYNC0_IN_IDX 103
|
||||
#define GPIO_SD3_OUT_IDX 103
|
||||
#define PWM1_SYNC1_IN_IDX 104
|
||||
#define GPIO_SD4_OUT_IDX 104
|
||||
#define PWM1_SYNC2_IN_IDX 105
|
||||
#define GPIO_SD5_OUT_IDX 105
|
||||
#define PWM1_F0_IN_IDX 106
|
||||
#define GPIO_SD6_OUT_IDX 106
|
||||
#define PWM1_F1_IN_IDX 107
|
||||
#define GPIO_SD7_OUT_IDX 107
|
||||
#define PWM1_F2_IN_IDX 108
|
||||
#define PWM1_OUT0A_IDX 108
|
||||
#define PWM0_CAP0_IN_IDX 109
|
||||
#define PWM1_OUT0B_IDX 109
|
||||
#define PWM0_CAP1_IN_IDX 110
|
||||
#define PWM1_OUT1A_IDX 110
|
||||
#define PWM0_CAP2_IN_IDX 111
|
||||
#define PWM1_OUT1B_IDX 111
|
||||
#define PWM1_CAP0_IN_IDX 112
|
||||
#define PWM1_OUT2A_IDX 112
|
||||
#define PWM1_CAP1_IN_IDX 113
|
||||
#define PWM1_OUT2B_IDX 113
|
||||
#define PWM1_CAP2_IN_IDX 114
|
||||
#define PWM2_OUT1H_IDX 114
|
||||
#define PWM2_FLTA_IDX 115
|
||||
#define PWM2_OUT1L_IDX 115
|
||||
#define PWM2_FLTB_IDX 116
|
||||
#define PWM2_OUT2H_IDX 116
|
||||
#define PWM2_CAP1_IN_IDX 117
|
||||
#define PWM2_OUT2L_IDX 117
|
||||
#define PWM2_CAP2_IN_IDX 118
|
||||
#define PWM2_OUT3H_IDX 118
|
||||
#define PWM2_CAP3_IN_IDX 119
|
||||
#define PWM2_OUT3L_IDX 119
|
||||
#define PWM3_FLTA_IDX 120
|
||||
#define PWM2_OUT4H_IDX 120
|
||||
#define PWM3_FLTB_IDX 121
|
||||
#define PWM2_OUT4L_IDX 121
|
||||
#define PWM3_CAP1_IN_IDX 122
|
||||
#define PWM3_CAP2_IN_IDX 123
|
||||
#define CAN_TX_IDX 123
|
||||
#define PWM3_CAP3_IN_IDX 124
|
||||
#define CAN_BUS_OFF_ON_IDX 124
|
||||
#define CAN_CLKOUT_IDX 125
|
||||
#define SPID4_IN_IDX 128
|
||||
#define SPID4_OUT_IDX 128
|
||||
#define SPID5_IN_IDX 129
|
||||
#define SPID5_OUT_IDX 129
|
||||
#define SPID6_IN_IDX 130
|
||||
#define SPID6_OUT_IDX 130
|
||||
#define SPID7_IN_IDX 131
|
||||
#define SPID7_OUT_IDX 131
|
||||
#define HSPID4_IN_IDX 132
|
||||
#define HSPID4_OUT_IDX 132
|
||||
#define HSPID5_IN_IDX 133
|
||||
#define HSPID5_OUT_IDX 133
|
||||
#define HSPID6_IN_IDX 134
|
||||
#define HSPID6_OUT_IDX 134
|
||||
#define HSPID7_IN_IDX 135
|
||||
#define HSPID7_OUT_IDX 135
|
||||
#define VSPID4_IN_IDX 136
|
||||
#define VSPID4_OUT_IDX 136
|
||||
#define VSPID5_IN_IDX 137
|
||||
#define VSPID5_OUT_IDX 137
|
||||
#define VSPID6_IN_IDX 138
|
||||
#define VSPID6_OUT_IDX 138
|
||||
#define VSPID7_IN_IDX 139
|
||||
#define VSPID7_OUT_IDX 139
|
||||
#define I2S0I_DATA_IN0_IDX 140
|
||||
#define I2S0O_DATA_OUT0_IDX 140
|
||||
#define I2S0I_DATA_IN1_IDX 141
|
||||
#define I2S0O_DATA_OUT1_IDX 141
|
||||
#define I2S0I_DATA_IN2_IDX 142
|
||||
#define I2S0O_DATA_OUT2_IDX 142
|
||||
#define I2S0I_DATA_IN3_IDX 143
|
||||
#define I2S0O_DATA_OUT3_IDX 143
|
||||
#define I2S0I_DATA_IN4_IDX 144
|
||||
#define I2S0O_DATA_OUT4_IDX 144
|
||||
#define I2S0I_DATA_IN5_IDX 145
|
||||
#define I2S0O_DATA_OUT5_IDX 145
|
||||
#define I2S0I_DATA_IN6_IDX 146
|
||||
#define I2S0O_DATA_OUT6_IDX 146
|
||||
#define I2S0I_DATA_IN7_IDX 147
|
||||
#define I2S0O_DATA_OUT7_IDX 147
|
||||
#define I2S0I_DATA_IN8_IDX 148
|
||||
#define I2S0O_DATA_OUT8_IDX 148
|
||||
#define I2S0I_DATA_IN9_IDX 149
|
||||
#define I2S0O_DATA_OUT9_IDX 149
|
||||
#define I2S0I_DATA_IN10_IDX 150
|
||||
#define I2S0O_DATA_OUT10_IDX 150
|
||||
#define I2S0I_DATA_IN11_IDX 151
|
||||
#define I2S0O_DATA_OUT11_IDX 151
|
||||
#define I2S0I_DATA_IN12_IDX 152
|
||||
#define I2S0O_DATA_OUT12_IDX 152
|
||||
#define I2S0I_DATA_IN13_IDX 153
|
||||
#define I2S0O_DATA_OUT13_IDX 153
|
||||
#define I2S0I_DATA_IN14_IDX 154
|
||||
#define I2S0O_DATA_OUT14_IDX 154
|
||||
#define I2S0I_DATA_IN15_IDX 155
|
||||
#define I2S0O_DATA_OUT15_IDX 155
|
||||
#define I2S0O_DATA_OUT16_IDX 156
|
||||
#define I2S0O_DATA_OUT17_IDX 157
|
||||
#define I2S0O_DATA_OUT18_IDX 158
|
||||
#define I2S0O_DATA_OUT19_IDX 159
|
||||
#define I2S0O_DATA_OUT20_IDX 160
|
||||
#define I2S0O_DATA_OUT21_IDX 161
|
||||
#define I2S0O_DATA_OUT22_IDX 162
|
||||
#define I2S0O_DATA_OUT23_IDX 163
|
||||
#define I2S1I_BCK_IN_IDX 164
|
||||
#define I2S1I_BCK_OUT_IDX 164
|
||||
#define I2S1I_WS_IN_IDX 165
|
||||
#define I2S1I_WS_OUT_IDX 165
|
||||
#define I2S1I_DATA_IN0_IDX 166
|
||||
#define I2S1O_DATA_OUT0_IDX 166
|
||||
#define I2S1I_DATA_IN1_IDX 167
|
||||
#define I2S1O_DATA_OUT1_IDX 167
|
||||
#define I2S1I_DATA_IN2_IDX 168
|
||||
#define I2S1O_DATA_OUT2_IDX 168
|
||||
#define I2S1I_DATA_IN3_IDX 169
|
||||
#define I2S1O_DATA_OUT3_IDX 169
|
||||
#define I2S1I_DATA_IN4_IDX 170
|
||||
#define I2S1O_DATA_OUT4_IDX 170
|
||||
#define I2S1I_DATA_IN5_IDX 171
|
||||
#define I2S1O_DATA_OUT5_IDX 171
|
||||
#define I2S1I_DATA_IN6_IDX 172
|
||||
#define I2S1O_DATA_OUT6_IDX 172
|
||||
#define I2S1I_DATA_IN7_IDX 173
|
||||
#define I2S1O_DATA_OUT7_IDX 173
|
||||
#define I2S1I_DATA_IN8_IDX 174
|
||||
#define I2S1O_DATA_OUT8_IDX 174
|
||||
#define I2S1I_DATA_IN9_IDX 175
|
||||
#define I2S1O_DATA_OUT9_IDX 175
|
||||
#define I2S1I_DATA_IN10_IDX 176
|
||||
#define I2S1O_DATA_OUT10_IDX 176
|
||||
#define I2S1I_DATA_IN11_IDX 177
|
||||
#define I2S1O_DATA_OUT11_IDX 177
|
||||
#define I2S1I_DATA_IN12_IDX 178
|
||||
#define I2S1O_DATA_OUT12_IDX 178
|
||||
#define I2S1I_DATA_IN13_IDX 179
|
||||
#define I2S1O_DATA_OUT13_IDX 179
|
||||
#define I2S1I_DATA_IN14_IDX 180
|
||||
#define I2S1O_DATA_OUT14_IDX 180
|
||||
#define I2S1I_DATA_IN15_IDX 181
|
||||
#define I2S1O_DATA_OUT15_IDX 181
|
||||
#define I2S1O_DATA_OUT16_IDX 182
|
||||
#define I2S1O_DATA_OUT17_IDX 183
|
||||
#define I2S1O_DATA_OUT18_IDX 184
|
||||
#define I2S1O_DATA_OUT19_IDX 185
|
||||
#define I2S1O_DATA_OUT20_IDX 186
|
||||
#define I2S1O_DATA_OUT21_IDX 187
|
||||
#define I2S1O_DATA_OUT22_IDX 188
|
||||
#define I2S1O_DATA_OUT23_IDX 189
|
||||
#define I2S0I_H_SYNC_IDX 190
|
||||
#define PWM3_OUT1H_IDX 190
|
||||
#define I2S0I_V_SYNC_IDX 191
|
||||
#define PWM3_OUT1L_IDX 191
|
||||
#define I2S0I_H_ENABLE_IDX 192
|
||||
#define PWM3_OUT2H_IDX 192
|
||||
#define I2S1I_H_SYNC_IDX 193
|
||||
#define PWM3_OUT2L_IDX 193
|
||||
#define I2S1I_V_SYNC_IDX 194
|
||||
#define PWM3_OUT3H_IDX 194
|
||||
#define I2S1I_H_ENABLE_IDX 195
|
||||
#define PWM3_OUT3L_IDX 195
|
||||
#define PWM3_OUT4H_IDX 196
|
||||
#define PWM3_OUT4L_IDX 197
|
||||
#define U2RXD_IN_IDX 198
|
||||
#define U2TXD_OUT_IDX 198
|
||||
#define U2CTS_IN_IDX 199
|
||||
#define U2RTS_OUT_IDX 199
|
||||
#define EMAC_MDC_I_IDX 200
|
||||
#define EMAC_MDC_O_IDX 200
|
||||
#define EMAC_MDI_I_IDX 201
|
||||
#define EMAC_MDO_O_IDX 201
|
||||
#define EMAC_CRS_I_IDX 202
|
||||
#define EMAC_CRS_O_IDX 202
|
||||
#define EMAC_COL_I_IDX 203
|
||||
#define EMAC_COL_O_IDX 203
|
||||
#define PCMFSYNC_IN_IDX 204
|
||||
#define BT_AUDIO0_IRQ_IDX 204
|
||||
#define PCMCLK_IN_IDX 205
|
||||
#define BT_AUDIO1_IRQ_IDX 205
|
||||
#define PCMDIN_IDX 206
|
||||
#define BT_AUDIO2_IRQ_IDX 206
|
||||
#define BLE_AUDIO0_IRQ_IDX 207
|
||||
#define BLE_AUDIO1_IRQ_IDX 208
|
||||
#define BLE_AUDIO2_IRQ_IDX 209
|
||||
#define PCMFSYNC_OUT_IDX 210
|
||||
#define PCMCLK_OUT_IDX 211
|
||||
#define PCMDOUT_IDX 212
|
||||
#define BLE_AUDIO_SYNC0_P_IDX 213
|
||||
#define BLE_AUDIO_SYNC1_P_IDX 214
|
||||
#define BLE_AUDIO_SYNC2_P_IDX 215
|
||||
#define ANT_SEL0_IDX 216
|
||||
#define ANT_SEL1_IDX 217
|
||||
#define ANT_SEL2_IDX 218
|
||||
#define ANT_SEL3_IDX 219
|
||||
#define ANT_SEL4_IDX 220
|
||||
#define ANT_SEL5_IDX 221
|
||||
#define ANT_SEL6_IDX 222
|
||||
#define ANT_SEL7_IDX 223
|
||||
#define SIG_IN_FUNC224_IDX 224
|
||||
#define SIG_IN_FUNC225_IDX 225
|
||||
#define SIG_IN_FUNC226_IDX 226
|
||||
#define SIG_IN_FUNC227_IDX 227
|
||||
#define SIG_IN_FUNC228_IDX 228
|
||||
#define SIG_GPIO_OUT_IDX 256
|
||||
#endif /* _SOC_GPIO_SIG_MAP_H_ */
|
||||
216
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_struct.h
Normal file
216
tools/sdk/esp32/include/soc/soc/esp32/include/soc/gpio_struct.h
Normal file
@@ -0,0 +1,216 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_GPIO_STRUCT_H_
|
||||
#define _SOC_GPIO_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct gpio_dev_s {
|
||||
uint32_t bt_select; /*NA*/
|
||||
uint32_t out; /*GPIO0~31 output value*/
|
||||
uint32_t out_w1ts; /*GPIO0~31 output value write 1 to set*/
|
||||
uint32_t out_w1tc; /*GPIO0~31 output value write 1 to clear*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 output value*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} out1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 output value write 1 to set*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} out1_w1ts;
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 output value write 1 to clear*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} out1_w1tc;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sel: 8; /*SDIO PADS on/off control from outside*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} sdio_select;
|
||||
uint32_t enable; /*GPIO0~31 output enable*/
|
||||
uint32_t enable_w1ts; /*GPIO0~31 output enable write 1 to set*/
|
||||
uint32_t enable_w1tc; /*GPIO0~31 output enable write 1 to clear*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 output enable*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} enable1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 output enable write 1 to set*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} enable1_w1ts;
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 output enable write 1 to clear*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} enable1_w1tc;
|
||||
union {
|
||||
struct {
|
||||
uint32_t strapping: 16; /*GPIO strapping results: {2'd0 boot_sel_dig[7:1] vsdio_boot_sel boot_sel_chip[5:0]} . Boot_sel_dig[7:1]: {U0RXD SD_CLK SD_CMD SD_DATA0 SD_DATA1 SD_DATA2 SD_DATA3} . vsdio_boot_sel: MTDI. boot_sel_chip[5:0]: {GPIO0 U0TXD GPIO2 GPIO4 MTDO GPIO5} */
|
||||
uint32_t reserved16:16;
|
||||
};
|
||||
uint32_t val;
|
||||
} strap;
|
||||
uint32_t in; /*GPIO0~31 input value*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t data: 8; /*GPIO32~39 input value*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} in1;
|
||||
uint32_t status; /*GPIO0~31 interrupt status*/
|
||||
uint32_t status_w1ts; /*GPIO0~31 interrupt status write 1 to set*/
|
||||
uint32_t status_w1tc; /*GPIO0~31 interrupt status write 1 to clear*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr_st: 8; /*GPIO32~39 interrupt status*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} status1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr_st: 8; /*GPIO32~39 interrupt status write 1 to set*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} status1_w1ts;
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr_st: 8; /*GPIO32~39 interrupt status write 1 to clear*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} status1_w1tc;
|
||||
uint32_t reserved_5c;
|
||||
uint32_t acpu_int; /*GPIO0~31 APP CPU interrupt status*/
|
||||
uint32_t acpu_nmi_int; /*GPIO0~31 APP CPU non-maskable interrupt status*/
|
||||
uint32_t pcpu_int; /*GPIO0~31 PRO CPU interrupt status*/
|
||||
uint32_t pcpu_nmi_int; /*GPIO0~31 PRO CPU non-maskable interrupt status*/
|
||||
uint32_t cpusdio_int; /*SDIO's extent GPIO0~31 interrupt*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr: 8; /*GPIO32~39 APP CPU interrupt status*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} acpu_int1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr: 8; /*GPIO32~39 APP CPU non-maskable interrupt status*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} acpu_nmi_int1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr: 8; /*GPIO32~39 PRO CPU interrupt status*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} pcpu_int1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr: 8; /*GPIO32~39 PRO CPU non-maskable interrupt status*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} pcpu_nmi_int1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t intr: 8; /*SDIO's extent GPIO32~39 interrupt*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} cpusdio_int1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0: 2;
|
||||
uint32_t pad_driver: 1; /*if set to 0: normal output if set to 1: open drain*/
|
||||
uint32_t reserved3: 4;
|
||||
uint32_t int_type: 3; /*if set to 0: GPIO interrupt disable if set to 1: rising edge trigger if set to 2: falling edge trigger if set to 3: any edge trigger if set to 4: low level trigger if set to 5: high level trigger*/
|
||||
uint32_t wakeup_enable: 1; /*GPIO wake up enable only available in light sleep*/
|
||||
uint32_t config: 2; /*NA*/
|
||||
uint32_t int_ena: 5; /*bit0: APP CPU interrupt enable bit1: APP CPU non-maskable interrupt enable bit3: PRO CPU interrupt enable bit4: PRO CPU non-maskable interrupt enable bit5: SDIO's extent interrupt enable*/
|
||||
uint32_t reserved18: 14;
|
||||
};
|
||||
uint32_t val;
|
||||
} pin[40];
|
||||
union {
|
||||
struct {
|
||||
uint32_t rtc_max: 10;
|
||||
uint32_t reserved10: 21;
|
||||
uint32_t start: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} cali_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t value_sync2: 20;
|
||||
uint32_t reserved20: 10;
|
||||
uint32_t rdy_real: 1;
|
||||
uint32_t rdy_sync2: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} cali_data;
|
||||
union {
|
||||
struct {
|
||||
uint32_t func_sel: 6; /*select one of the 256 inputs*/
|
||||
uint32_t sig_in_inv: 1; /*revert the value of the input if you want to revert please set the value to 1*/
|
||||
uint32_t sig_in_sel: 1; /*if the slow signal bypass the io matrix or not if you want setting the value to 1*/
|
||||
uint32_t reserved8: 24; /*The 256 registers below are selection control for 256 input signals connected to GPIO matrix's 40 GPIO input if GPIO_FUNCx_IN_SEL is set to n(0<=n<40): it means GPIOn input is used for input signal x if GPIO_FUNCx_IN_SEL is set to 0x38: the input signal x is set to 1 if GPIO_FUNCx_IN_SEL is set to 0x30: the input signal x is set to 0*/
|
||||
};
|
||||
uint32_t val;
|
||||
} func_in_sel_cfg[256];
|
||||
union {
|
||||
struct {
|
||||
uint32_t func_sel: 9; /*select one of the 256 output to 40 GPIO*/
|
||||
uint32_t inv_sel: 1; /*invert the output value if you want to revert the output value setting the value to 1*/
|
||||
uint32_t oen_sel: 1; /*weather using the logical oen signal or not using the value setting by the register*/
|
||||
uint32_t oen_inv_sel: 1; /*invert the output enable value if you want to revert the output enable value setting the value to 1*/
|
||||
uint32_t reserved12: 20; /*The 40 registers below are selection control for 40 GPIO output if GPIO_FUNCx_OUT_SEL is set to n(0<=n<256): it means GPIOn input is used for output signal x if GPIO_FUNCx_OUT_INV_SEL is set to 1 the output signal x is set to ~value. if GPIO_FUNC0_OUT_SEL is 256 or GPIO_FUNC0_OEN_SEL is 1 using GPIO_ENABLE_DATA[x] for the enable value else using the signal enable*/
|
||||
};
|
||||
uint32_t val;
|
||||
} func_out_sel_cfg[40];
|
||||
} gpio_dev_t;
|
||||
extern gpio_dev_t GPIO;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_GPIO_STRUCT_H_ */
|
||||
248
tools/sdk/esp32/include/soc/soc/esp32/include/soc/hinf_reg.h
Normal file
248
tools/sdk/esp32/include/soc/soc/esp32/include/soc/hinf_reg.h
Normal file
@@ -0,0 +1,248 @@
|
||||
// Copyright 2015-2018 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_HINF_REG_H_
|
||||
#define _SOC_HINF_REG_H_
|
||||
|
||||
|
||||
#include "soc.h"
|
||||
#define HINF_CFG_DATA0_REG (DR_REG_HINF_BASE + 0x0)
|
||||
/* HINF_DEVICE_ID_FN1 : R/W ;bitpos:[31:16] ;default: 16'h2222 ; */
|
||||
/*description: */
|
||||
#define HINF_DEVICE_ID_FN1 0x0000FFFF
|
||||
#define HINF_DEVICE_ID_FN1_M ((HINF_DEVICE_ID_FN1_V)<<(HINF_DEVICE_ID_FN1_S))
|
||||
#define HINF_DEVICE_ID_FN1_V 0xFFFF
|
||||
#define HINF_DEVICE_ID_FN1_S 16
|
||||
/* HINF_USER_ID_FN1 : R/W ;bitpos:[15:0] ;default: 16'h6666 ; */
|
||||
/*description: */
|
||||
#define HINF_USER_ID_FN1 0x0000FFFF
|
||||
#define HINF_USER_ID_FN1_M ((HINF_USER_ID_FN1_V)<<(HINF_USER_ID_FN1_S))
|
||||
#define HINF_USER_ID_FN1_V 0xFFFF
|
||||
#define HINF_USER_ID_FN1_S 0
|
||||
|
||||
#define HINF_CFG_DATA1_REG (DR_REG_HINF_BASE + 0x4)
|
||||
/* HINF_SDIO20_CONF1 : R/W ;bitpos:[31:29] ;default: 3'h0 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO20_CONF1 0x00000007
|
||||
#define HINF_SDIO20_CONF1_M ((HINF_SDIO20_CONF1_V)<<(HINF_SDIO20_CONF1_S))
|
||||
#define HINF_SDIO20_CONF1_V 0x7
|
||||
#define HINF_SDIO20_CONF1_S 29
|
||||
/* HINF_FUNC2_EPS : RO ;bitpos:[28] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_FUNC2_EPS (BIT(28))
|
||||
#define HINF_FUNC2_EPS_M (BIT(28))
|
||||
#define HINF_FUNC2_EPS_V 0x1
|
||||
#define HINF_FUNC2_EPS_S 28
|
||||
/* HINF_SDIO_VER : R/W ;bitpos:[27:16] ;default: 12'h111 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_VER 0x00000FFF
|
||||
#define HINF_SDIO_VER_M ((HINF_SDIO_VER_V)<<(HINF_SDIO_VER_S))
|
||||
#define HINF_SDIO_VER_V 0xFFF
|
||||
#define HINF_SDIO_VER_S 16
|
||||
/* HINF_SDIO20_CONF0 : R/W ;bitpos:[15:12] ;default: 4'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO20_CONF0 0x0000000F
|
||||
#define HINF_SDIO20_CONF0_M ((HINF_SDIO20_CONF0_V)<<(HINF_SDIO20_CONF0_S))
|
||||
#define HINF_SDIO20_CONF0_V 0xF
|
||||
#define HINF_SDIO20_CONF0_S 12
|
||||
/* HINF_IOENABLE1 : RO ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_IOENABLE1 (BIT(11))
|
||||
#define HINF_IOENABLE1_M (BIT(11))
|
||||
#define HINF_IOENABLE1_V 0x1
|
||||
#define HINF_IOENABLE1_S 11
|
||||
/* HINF_EMP : RO ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_EMP (BIT(10))
|
||||
#define HINF_EMP_M (BIT(10))
|
||||
#define HINF_EMP_V 0x1
|
||||
#define HINF_EMP_S 10
|
||||
/* HINF_FUNC1_EPS : RO ;bitpos:[9] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_FUNC1_EPS (BIT(9))
|
||||
#define HINF_FUNC1_EPS_M (BIT(9))
|
||||
#define HINF_FUNC1_EPS_V 0x1
|
||||
#define HINF_FUNC1_EPS_S 9
|
||||
/* HINF_CD_DISABLE : RO ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_CD_DISABLE (BIT(8))
|
||||
#define HINF_CD_DISABLE_M (BIT(8))
|
||||
#define HINF_CD_DISABLE_V 0x1
|
||||
#define HINF_CD_DISABLE_S 8
|
||||
/* HINF_IOENABLE2 : RO ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_IOENABLE2 (BIT(7))
|
||||
#define HINF_IOENABLE2_M (BIT(7))
|
||||
#define HINF_IOENABLE2_V 0x1
|
||||
#define HINF_IOENABLE2_S 7
|
||||
/* HINF_SDIO_INT_MASK : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_INT_MASK (BIT(6))
|
||||
#define HINF_SDIO_INT_MASK_M (BIT(6))
|
||||
#define HINF_SDIO_INT_MASK_V 0x1
|
||||
#define HINF_SDIO_INT_MASK_S 6
|
||||
/* HINF_SDIO_IOREADY2 : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_IOREADY2 (BIT(5))
|
||||
#define HINF_SDIO_IOREADY2_M (BIT(5))
|
||||
#define HINF_SDIO_IOREADY2_V 0x1
|
||||
#define HINF_SDIO_IOREADY2_S 5
|
||||
/* HINF_SDIO_CD_ENABLE : R/W ;bitpos:[4] ;default: 1'b1 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_CD_ENABLE (BIT(4))
|
||||
#define HINF_SDIO_CD_ENABLE_M (BIT(4))
|
||||
#define HINF_SDIO_CD_ENABLE_V 0x1
|
||||
#define HINF_SDIO_CD_ENABLE_S 4
|
||||
/* HINF_HIGHSPEED_MODE : RO ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_HIGHSPEED_MODE (BIT(3))
|
||||
#define HINF_HIGHSPEED_MODE_M (BIT(3))
|
||||
#define HINF_HIGHSPEED_MODE_V 0x1
|
||||
#define HINF_HIGHSPEED_MODE_S 3
|
||||
/* HINF_HIGHSPEED_ENABLE : R/W ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_HIGHSPEED_ENABLE (BIT(2))
|
||||
#define HINF_HIGHSPEED_ENABLE_M (BIT(2))
|
||||
#define HINF_HIGHSPEED_ENABLE_V 0x1
|
||||
#define HINF_HIGHSPEED_ENABLE_S 2
|
||||
/* HINF_SDIO_IOREADY1 : R/W ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_IOREADY1 (BIT(1))
|
||||
#define HINF_SDIO_IOREADY1_M (BIT(1))
|
||||
#define HINF_SDIO_IOREADY1_V 0x1
|
||||
#define HINF_SDIO_IOREADY1_S 1
|
||||
/* HINF_SDIO_ENABLE : R/W ;bitpos:[0] ;default: 1'b1 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_ENABLE (BIT(0))
|
||||
#define HINF_SDIO_ENABLE_M (BIT(0))
|
||||
#define HINF_SDIO_ENABLE_V 0x1
|
||||
#define HINF_SDIO_ENABLE_S 0
|
||||
|
||||
#define HINF_CFG_DATA7_REG (DR_REG_HINF_BASE + 0x1C)
|
||||
/* HINF_SDIO_IOREADY0 : R/W ;bitpos:[17] ;default: 1'b1 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_IOREADY0 (BIT(17))
|
||||
#define HINF_SDIO_IOREADY0_M (BIT(17))
|
||||
#define HINF_SDIO_IOREADY0_V 0x1
|
||||
#define HINF_SDIO_IOREADY0_S 17
|
||||
/* HINF_SDIO_RST : R/W ;bitpos:[16] ;default: 1'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_RST (BIT(16))
|
||||
#define HINF_SDIO_RST_M (BIT(16))
|
||||
#define HINF_SDIO_RST_V 0x1
|
||||
#define HINF_SDIO_RST_S 16
|
||||
/* HINF_CHIP_STATE : R/W ;bitpos:[15:8] ;default: 8'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_CHIP_STATE 0x000000FF
|
||||
#define HINF_CHIP_STATE_M ((HINF_CHIP_STATE_V)<<(HINF_CHIP_STATE_S))
|
||||
#define HINF_CHIP_STATE_V 0xFF
|
||||
#define HINF_CHIP_STATE_S 8
|
||||
/* HINF_PIN_STATE : R/W ;bitpos:[7:0] ;default: 8'b0 ; */
|
||||
/*description: */
|
||||
#define HINF_PIN_STATE 0x000000FF
|
||||
#define HINF_PIN_STATE_M ((HINF_PIN_STATE_V)<<(HINF_PIN_STATE_S))
|
||||
#define HINF_PIN_STATE_V 0xFF
|
||||
#define HINF_PIN_STATE_S 0
|
||||
|
||||
#define HINF_CIS_CONF0_REG (DR_REG_HINF_BASE + 0x20)
|
||||
/* HINF_CIS_CONF_W0 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W0 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W0_M ((HINF_CIS_CONF_W0_V)<<(HINF_CIS_CONF_W0_S))
|
||||
#define HINF_CIS_CONF_W0_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W0_S 0
|
||||
|
||||
#define HINF_CIS_CONF1_REG (DR_REG_HINF_BASE + 0x24)
|
||||
/* HINF_CIS_CONF_W1 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W1 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W1_M ((HINF_CIS_CONF_W1_V)<<(HINF_CIS_CONF_W1_S))
|
||||
#define HINF_CIS_CONF_W1_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W1_S 0
|
||||
|
||||
#define HINF_CIS_CONF2_REG (DR_REG_HINF_BASE + 0x28)
|
||||
/* HINF_CIS_CONF_W2 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W2 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W2_M ((HINF_CIS_CONF_W2_V)<<(HINF_CIS_CONF_W2_S))
|
||||
#define HINF_CIS_CONF_W2_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W2_S 0
|
||||
|
||||
#define HINF_CIS_CONF3_REG (DR_REG_HINF_BASE + 0x2C)
|
||||
/* HINF_CIS_CONF_W3 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W3 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W3_M ((HINF_CIS_CONF_W3_V)<<(HINF_CIS_CONF_W3_S))
|
||||
#define HINF_CIS_CONF_W3_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W3_S 0
|
||||
|
||||
#define HINF_CIS_CONF4_REG (DR_REG_HINF_BASE + 0x30)
|
||||
/* HINF_CIS_CONF_W4 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W4 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W4_M ((HINF_CIS_CONF_W4_V)<<(HINF_CIS_CONF_W4_S))
|
||||
#define HINF_CIS_CONF_W4_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W4_S 0
|
||||
|
||||
#define HINF_CIS_CONF5_REG (DR_REG_HINF_BASE + 0x34)
|
||||
/* HINF_CIS_CONF_W5 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W5 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W5_M ((HINF_CIS_CONF_W5_V)<<(HINF_CIS_CONF_W5_S))
|
||||
#define HINF_CIS_CONF_W5_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W5_S 0
|
||||
|
||||
#define HINF_CIS_CONF6_REG (DR_REG_HINF_BASE + 0x38)
|
||||
/* HINF_CIS_CONF_W6 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W6 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W6_M ((HINF_CIS_CONF_W6_V)<<(HINF_CIS_CONF_W6_S))
|
||||
#define HINF_CIS_CONF_W6_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W6_S 0
|
||||
|
||||
#define HINF_CIS_CONF7_REG (DR_REG_HINF_BASE + 0x3C)
|
||||
/* HINF_CIS_CONF_W7 : R/W ;bitpos:[31:0] ;default: 32'hffffffff ; */
|
||||
/*description: */
|
||||
#define HINF_CIS_CONF_W7 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W7_M ((HINF_CIS_CONF_W7_V)<<(HINF_CIS_CONF_W7_S))
|
||||
#define HINF_CIS_CONF_W7_V 0xFFFFFFFF
|
||||
#define HINF_CIS_CONF_W7_S 0
|
||||
|
||||
#define HINF_CFG_DATA16_REG (DR_REG_HINF_BASE + 0x40)
|
||||
/* HINF_DEVICE_ID_FN2 : R/W ;bitpos:[31:16] ;default: 16'h3333 ; */
|
||||
/*description: */
|
||||
#define HINF_DEVICE_ID_FN2 0x0000FFFF
|
||||
#define HINF_DEVICE_ID_FN2_M ((HINF_DEVICE_ID_FN2_V)<<(HINF_DEVICE_ID_FN2_S))
|
||||
#define HINF_DEVICE_ID_FN2_V 0xFFFF
|
||||
#define HINF_DEVICE_ID_FN2_S 16
|
||||
/* HINF_USER_ID_FN2 : R/W ;bitpos:[15:0] ;default: 16'h6666 ; */
|
||||
/*description: */
|
||||
#define HINF_USER_ID_FN2 0x0000FFFF
|
||||
#define HINF_USER_ID_FN2_M ((HINF_USER_ID_FN2_V)<<(HINF_USER_ID_FN2_S))
|
||||
#define HINF_USER_ID_FN2_V 0xFFFF
|
||||
#define HINF_USER_ID_FN2_S 0
|
||||
|
||||
#define HINF_DATE_REG (DR_REG_HINF_BASE + 0xFC)
|
||||
/* HINF_SDIO_DATE : R/W ;bitpos:[31:0] ;default: 32'h15030200 ; */
|
||||
/*description: */
|
||||
#define HINF_SDIO_DATE 0xFFFFFFFF
|
||||
#define HINF_SDIO_DATE_M ((HINF_SDIO_DATE_V)<<(HINF_SDIO_DATE_S))
|
||||
#define HINF_SDIO_DATE_V 0xFFFFFFFF
|
||||
#define HINF_SDIO_DATE_S 0
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*_SOC_HINF_REG_H_ */
|
||||
|
||||
|
||||
136
tools/sdk/esp32/include/soc/soc/esp32/include/soc/hinf_struct.h
Normal file
136
tools/sdk/esp32/include/soc/soc/esp32/include/soc/hinf_struct.h
Normal file
@@ -0,0 +1,136 @@
|
||||
// Copyright 2015-2018 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_HINF_STRUCT_H_
|
||||
#define _SOC_HINF_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct hinf_dev_s {
|
||||
union {
|
||||
struct {
|
||||
uint32_t user_id_fn1: 16;
|
||||
uint32_t device_id_fn1:16;
|
||||
};
|
||||
uint32_t val;
|
||||
} cfg_data0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sdio_enable: 1;
|
||||
uint32_t sdio_ioready1: 1;
|
||||
uint32_t highspeed_enable: 1;
|
||||
uint32_t highspeed_mode: 1;
|
||||
uint32_t sdio_cd_enable: 1;
|
||||
uint32_t sdio_ioready2: 1;
|
||||
uint32_t sdio_int_mask: 1;
|
||||
uint32_t ioenable2: 1;
|
||||
uint32_t cd_disable: 1;
|
||||
uint32_t func1_eps: 1;
|
||||
uint32_t emp: 1;
|
||||
uint32_t ioenable1: 1;
|
||||
uint32_t sdio20_conf0: 4;
|
||||
uint32_t sdio_ver: 12;
|
||||
uint32_t func2_eps: 1;
|
||||
uint32_t sdio20_conf1: 3;
|
||||
};
|
||||
uint32_t val;
|
||||
} cfg_data1;
|
||||
uint32_t reserved_8;
|
||||
uint32_t reserved_c;
|
||||
uint32_t reserved_10;
|
||||
uint32_t reserved_14;
|
||||
uint32_t reserved_18;
|
||||
union {
|
||||
struct {
|
||||
uint32_t pin_state: 8;
|
||||
uint32_t chip_state: 8;
|
||||
uint32_t sdio_rst: 1;
|
||||
uint32_t sdio_ioready0: 1;
|
||||
uint32_t reserved18: 14;
|
||||
};
|
||||
uint32_t val;
|
||||
} cfg_data7;
|
||||
uint32_t cis_conf0; /**/
|
||||
uint32_t cis_conf1; /**/
|
||||
uint32_t cis_conf2; /**/
|
||||
uint32_t cis_conf3; /**/
|
||||
uint32_t cis_conf4; /**/
|
||||
uint32_t cis_conf5; /**/
|
||||
uint32_t cis_conf6; /**/
|
||||
uint32_t cis_conf7; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t user_id_fn2: 16;
|
||||
uint32_t device_id_fn2:16;
|
||||
};
|
||||
uint32_t val;
|
||||
} cfg_data16;
|
||||
uint32_t reserved_44;
|
||||
uint32_t reserved_48;
|
||||
uint32_t reserved_4c;
|
||||
uint32_t reserved_50;
|
||||
uint32_t reserved_54;
|
||||
uint32_t reserved_58;
|
||||
uint32_t reserved_5c;
|
||||
uint32_t reserved_60;
|
||||
uint32_t reserved_64;
|
||||
uint32_t reserved_68;
|
||||
uint32_t reserved_6c;
|
||||
uint32_t reserved_70;
|
||||
uint32_t reserved_74;
|
||||
uint32_t reserved_78;
|
||||
uint32_t reserved_7c;
|
||||
uint32_t reserved_80;
|
||||
uint32_t reserved_84;
|
||||
uint32_t reserved_88;
|
||||
uint32_t reserved_8c;
|
||||
uint32_t reserved_90;
|
||||
uint32_t reserved_94;
|
||||
uint32_t reserved_98;
|
||||
uint32_t reserved_9c;
|
||||
uint32_t reserved_a0;
|
||||
uint32_t reserved_a4;
|
||||
uint32_t reserved_a8;
|
||||
uint32_t reserved_ac;
|
||||
uint32_t reserved_b0;
|
||||
uint32_t reserved_b4;
|
||||
uint32_t reserved_b8;
|
||||
uint32_t reserved_bc;
|
||||
uint32_t reserved_c0;
|
||||
uint32_t reserved_c4;
|
||||
uint32_t reserved_c8;
|
||||
uint32_t reserved_cc;
|
||||
uint32_t reserved_d0;
|
||||
uint32_t reserved_d4;
|
||||
uint32_t reserved_d8;
|
||||
uint32_t reserved_dc;
|
||||
uint32_t reserved_e0;
|
||||
uint32_t reserved_e4;
|
||||
uint32_t reserved_e8;
|
||||
uint32_t reserved_ec;
|
||||
uint32_t reserved_f0;
|
||||
uint32_t reserved_f4;
|
||||
uint32_t reserved_f8;
|
||||
uint32_t date; /**/
|
||||
} hinf_dev_t;
|
||||
extern hinf_dev_t HINF;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_HINF_STRUCT_H_ */
|
||||
3144
tools/sdk/esp32/include/soc/soc/esp32/include/soc/host_reg.h
Normal file
3144
tools/sdk/esp32/include/soc/soc/esp32/include/soc/host_reg.h
Normal file
File diff suppressed because it is too large
Load Diff
893
tools/sdk/esp32/include/soc/soc/esp32/include/soc/host_struct.h
Normal file
893
tools/sdk/esp32/include/soc/soc/esp32/include/soc/host_struct.h
Normal file
@@ -0,0 +1,893 @@
|
||||
// Copyright 2015-2018 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_HOST_STRUCT_H_
|
||||
#define _SOC_HOST_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct host_dev_s {
|
||||
uint32_t reserved_0;
|
||||
uint32_t reserved_4;
|
||||
uint32_t reserved_8;
|
||||
uint32_t reserved_c;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reserved0: 24;
|
||||
uint32_t func2_int: 1;
|
||||
uint32_t reserved25: 7;
|
||||
};
|
||||
uint32_t val;
|
||||
} func2_0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t func2_int_en: 1;
|
||||
uint32_t reserved1: 31;
|
||||
};
|
||||
uint32_t val;
|
||||
} func2_1;
|
||||
uint32_t reserved_18;
|
||||
uint32_t reserved_1c;
|
||||
union {
|
||||
struct {
|
||||
uint32_t func1_mdstat: 1;
|
||||
uint32_t reserved1: 31;
|
||||
};
|
||||
uint32_t val;
|
||||
} func2_2;
|
||||
uint32_t reserved_24;
|
||||
uint32_t reserved_28;
|
||||
uint32_t reserved_2c;
|
||||
uint32_t reserved_30;
|
||||
uint32_t gpio_status0; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t sdio_int1: 8;
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} gpio_status1;
|
||||
uint32_t gpio_in0; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t sdio_in1: 8;
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} gpio_in1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t token0: 12;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t reserved13: 3;
|
||||
uint32_t reg_token1: 12;
|
||||
uint32_t rx_pf_eof: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_token_rdata;
|
||||
uint32_t slc0_pf; /**/
|
||||
uint32_t slc1_pf; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t gpio_sdio: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_int_raw;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t wifi_rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t bt_rx_new_packet: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_int_raw;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t gpio_sdio: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_int_st;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t wifi_rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t bt_rx_new_packet: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_int_st;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reg_slc0_len: 20;
|
||||
uint32_t reg_slc0_len_check:12;
|
||||
};
|
||||
uint32_t val;
|
||||
} pkt_len;
|
||||
union {
|
||||
struct {
|
||||
uint32_t state0: 8;
|
||||
uint32_t state1: 8;
|
||||
uint32_t state2: 8;
|
||||
uint32_t state3: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} state_w0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t state4: 8;
|
||||
uint32_t state5: 8;
|
||||
uint32_t state6: 8;
|
||||
uint32_t state7: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} state_w1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf0: 8;
|
||||
uint32_t conf1: 8;
|
||||
uint32_t conf2: 8;
|
||||
uint32_t conf3: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf4: 8;
|
||||
uint32_t conf5: 8;
|
||||
uint32_t conf6: 8;
|
||||
uint32_t conf7: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf8: 8;
|
||||
uint32_t conf9: 8;
|
||||
uint32_t conf10: 8;
|
||||
uint32_t conf11: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w2;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf12: 8;
|
||||
uint32_t conf13: 8;
|
||||
uint32_t conf14: 8;
|
||||
uint32_t conf15: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w3;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf16: 8; /*SLC timeout value*/
|
||||
uint32_t conf17: 8; /*SLC timeout enable*/
|
||||
uint32_t conf18: 8;
|
||||
uint32_t conf19: 8; /*Interrupt to target CPU*/
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w4;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf20: 8;
|
||||
uint32_t conf21: 8;
|
||||
uint32_t conf22: 8;
|
||||
uint32_t conf23: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w5;
|
||||
uint32_t win_cmd; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf24: 8;
|
||||
uint32_t conf25: 8;
|
||||
uint32_t conf26: 8;
|
||||
uint32_t conf27: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w6;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf28: 8;
|
||||
uint32_t conf29: 8;
|
||||
uint32_t conf30: 8;
|
||||
uint32_t conf31: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w7;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reg_slc0_len0:20;
|
||||
uint32_t reserved20: 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} pkt_len0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reg_slc0_len1:20;
|
||||
uint32_t reserved20: 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} pkt_len1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t reg_slc0_len2:20;
|
||||
uint32_t reserved20: 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} pkt_len2;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf32: 8;
|
||||
uint32_t conf33: 8;
|
||||
uint32_t conf34: 8;
|
||||
uint32_t conf35: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w8;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf36: 8;
|
||||
uint32_t conf37: 8;
|
||||
uint32_t conf38: 8;
|
||||
uint32_t conf39: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w9;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf40: 8;
|
||||
uint32_t conf41: 8;
|
||||
uint32_t conf42: 8;
|
||||
uint32_t conf43: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w10;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf44: 8;
|
||||
uint32_t conf45: 8;
|
||||
uint32_t conf46: 8;
|
||||
uint32_t conf47: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w11;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf48: 8;
|
||||
uint32_t conf49: 8;
|
||||
uint32_t conf50: 8;
|
||||
uint32_t conf51: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w12;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf52: 8;
|
||||
uint32_t conf53: 8;
|
||||
uint32_t conf54: 8;
|
||||
uint32_t conf55: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w13;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf56: 8;
|
||||
uint32_t conf57: 8;
|
||||
uint32_t conf58: 8;
|
||||
uint32_t conf59: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w14;
|
||||
union {
|
||||
struct {
|
||||
uint32_t conf60: 8;
|
||||
uint32_t conf61: 8;
|
||||
uint32_t conf62: 8;
|
||||
uint32_t conf63: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_w15;
|
||||
uint32_t check_sum0; /**/
|
||||
uint32_t check_sum1; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t token0: 12;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t reserved13: 3;
|
||||
uint32_t reg_token1: 12;
|
||||
uint32_t rx_pf_eof: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_token_rdata;
|
||||
union {
|
||||
struct {
|
||||
uint32_t token0_wd: 12;
|
||||
uint32_t reserved12: 4;
|
||||
uint32_t token1_wd: 12;
|
||||
uint32_t reserved28: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_token_wdata;
|
||||
union {
|
||||
struct {
|
||||
uint32_t token0_wd: 12;
|
||||
uint32_t reserved12: 4;
|
||||
uint32_t token1_wd: 12;
|
||||
uint32_t reserved28: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_token_wdata;
|
||||
union {
|
||||
struct {
|
||||
uint32_t slc0_token0_dec: 1;
|
||||
uint32_t slc0_token1_dec: 1;
|
||||
uint32_t slc0_token0_wr: 1;
|
||||
uint32_t slc0_token1_wr: 1;
|
||||
uint32_t slc1_token0_dec: 1;
|
||||
uint32_t slc1_token1_dec: 1;
|
||||
uint32_t slc1_token0_wr: 1;
|
||||
uint32_t slc1_token1_wr: 1;
|
||||
uint32_t slc0_len_wr: 1;
|
||||
uint32_t reserved9: 23;
|
||||
};
|
||||
uint32_t val;
|
||||
} token_con;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t gpio_sdio: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_int_clr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t wifi_rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t bt_rx_new_packet: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_int_clr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t gpio_sdio: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_func1_int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t wifi_rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t bt_rx_new_packet: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_func1_int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t gpio_sdio: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_func2_int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t wifi_rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t bt_rx_new_packet: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_func2_int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t gpio_sdio: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit0: 1;
|
||||
uint32_t tohost_bit1: 1;
|
||||
uint32_t tohost_bit2: 1;
|
||||
uint32_t tohost_bit3: 1;
|
||||
uint32_t tohost_bit4: 1;
|
||||
uint32_t tohost_bit5: 1;
|
||||
uint32_t tohost_bit6: 1;
|
||||
uint32_t tohost_bit7: 1;
|
||||
uint32_t token0_1to0: 1;
|
||||
uint32_t token1_1to0: 1;
|
||||
uint32_t token0_0to1: 1;
|
||||
uint32_t token1_0to1: 1;
|
||||
uint32_t rx_sof: 1;
|
||||
uint32_t rx_eof: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_udf: 1;
|
||||
uint32_t tx_ovf: 1;
|
||||
uint32_t rx_pf_valid: 1;
|
||||
uint32_t ext_bit0: 1;
|
||||
uint32_t ext_bit1: 1;
|
||||
uint32_t ext_bit2: 1;
|
||||
uint32_t ext_bit3: 1;
|
||||
uint32_t wifi_rx_new_packet: 1;
|
||||
uint32_t rd_retry: 1;
|
||||
uint32_t bt_rx_new_packet: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t infor: 20;
|
||||
uint32_t reserved20: 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_rx_infor;
|
||||
union {
|
||||
struct {
|
||||
uint32_t infor: 20;
|
||||
uint32_t reserved20: 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_rx_infor;
|
||||
uint32_t slc0_len_wd; /**/
|
||||
uint32_t apbwin_wdata; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t addr: 28;
|
||||
uint32_t wr: 1;
|
||||
uint32_t start: 1;
|
||||
uint32_t reserved30: 2;
|
||||
};
|
||||
uint32_t val;
|
||||
} apbwin_conf;
|
||||
uint32_t apbwin_rdata; /**/
|
||||
union {
|
||||
struct {
|
||||
uint32_t bit7_clraddr: 9;
|
||||
uint32_t bit6_clraddr: 9;
|
||||
uint32_t reserved18: 14;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_rdclr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t bit7_clraddr: 9;
|
||||
uint32_t bit6_clraddr: 9;
|
||||
uint32_t reserved18: 14;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_rdclr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit01: 1;
|
||||
uint32_t tohost_bit11: 1;
|
||||
uint32_t tohost_bit21: 1;
|
||||
uint32_t tohost_bit31: 1;
|
||||
uint32_t tohost_bit41: 1;
|
||||
uint32_t tohost_bit51: 1;
|
||||
uint32_t tohost_bit61: 1;
|
||||
uint32_t tohost_bit71: 1;
|
||||
uint32_t token0_1to01: 1;
|
||||
uint32_t token1_1to01: 1;
|
||||
uint32_t token0_0to11: 1;
|
||||
uint32_t token1_0to11: 1;
|
||||
uint32_t rx_sof1: 1;
|
||||
uint32_t rx_eof1: 1;
|
||||
uint32_t rx_start1: 1;
|
||||
uint32_t tx_start1: 1;
|
||||
uint32_t rx_udf1: 1;
|
||||
uint32_t tx_ovf1: 1;
|
||||
uint32_t rx_pf_valid1: 1;
|
||||
uint32_t ext_bit01: 1;
|
||||
uint32_t ext_bit11: 1;
|
||||
uint32_t ext_bit21: 1;
|
||||
uint32_t ext_bit31: 1;
|
||||
uint32_t rx_new_packet1: 1;
|
||||
uint32_t rd_retry1: 1;
|
||||
uint32_t gpio_sdio1: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc0_int_ena1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tohost_bit01: 1;
|
||||
uint32_t tohost_bit11: 1;
|
||||
uint32_t tohost_bit21: 1;
|
||||
uint32_t tohost_bit31: 1;
|
||||
uint32_t tohost_bit41: 1;
|
||||
uint32_t tohost_bit51: 1;
|
||||
uint32_t tohost_bit61: 1;
|
||||
uint32_t tohost_bit71: 1;
|
||||
uint32_t token0_1to01: 1;
|
||||
uint32_t token1_1to01: 1;
|
||||
uint32_t token0_0to11: 1;
|
||||
uint32_t token1_0to11: 1;
|
||||
uint32_t rx_sof1: 1;
|
||||
uint32_t rx_eof1: 1;
|
||||
uint32_t rx_start1: 1;
|
||||
uint32_t tx_start1: 1;
|
||||
uint32_t rx_udf1: 1;
|
||||
uint32_t tx_ovf1: 1;
|
||||
uint32_t rx_pf_valid1: 1;
|
||||
uint32_t ext_bit01: 1;
|
||||
uint32_t ext_bit11: 1;
|
||||
uint32_t ext_bit21: 1;
|
||||
uint32_t ext_bit31: 1;
|
||||
uint32_t wifi_rx_new_packet1: 1;
|
||||
uint32_t rd_retry1: 1;
|
||||
uint32_t bt_rx_new_packet1: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} slc1_int_ena1;
|
||||
uint32_t reserved_11c;
|
||||
uint32_t reserved_120;
|
||||
uint32_t reserved_124;
|
||||
uint32_t reserved_128;
|
||||
uint32_t reserved_12c;
|
||||
uint32_t reserved_130;
|
||||
uint32_t reserved_134;
|
||||
uint32_t reserved_138;
|
||||
uint32_t reserved_13c;
|
||||
uint32_t reserved_140;
|
||||
uint32_t reserved_144;
|
||||
uint32_t reserved_148;
|
||||
uint32_t reserved_14c;
|
||||
uint32_t reserved_150;
|
||||
uint32_t reserved_154;
|
||||
uint32_t reserved_158;
|
||||
uint32_t reserved_15c;
|
||||
uint32_t reserved_160;
|
||||
uint32_t reserved_164;
|
||||
uint32_t reserved_168;
|
||||
uint32_t reserved_16c;
|
||||
uint32_t reserved_170;
|
||||
uint32_t reserved_174;
|
||||
uint32_t date; /**/
|
||||
uint32_t id; /**/
|
||||
uint32_t reserved_180;
|
||||
uint32_t reserved_184;
|
||||
uint32_t reserved_188;
|
||||
uint32_t reserved_18c;
|
||||
uint32_t reserved_190;
|
||||
uint32_t reserved_194;
|
||||
uint32_t reserved_198;
|
||||
uint32_t reserved_19c;
|
||||
uint32_t reserved_1a0;
|
||||
uint32_t reserved_1a4;
|
||||
uint32_t reserved_1a8;
|
||||
uint32_t reserved_1ac;
|
||||
uint32_t reserved_1b0;
|
||||
uint32_t reserved_1b4;
|
||||
uint32_t reserved_1b8;
|
||||
uint32_t reserved_1bc;
|
||||
uint32_t reserved_1c0;
|
||||
uint32_t reserved_1c4;
|
||||
uint32_t reserved_1c8;
|
||||
uint32_t reserved_1cc;
|
||||
uint32_t reserved_1d0;
|
||||
uint32_t reserved_1d4;
|
||||
uint32_t reserved_1d8;
|
||||
uint32_t reserved_1dc;
|
||||
uint32_t reserved_1e0;
|
||||
uint32_t reserved_1e4;
|
||||
uint32_t reserved_1e8;
|
||||
uint32_t reserved_1ec;
|
||||
union {
|
||||
struct {
|
||||
uint32_t frc_sdio11: 5;
|
||||
uint32_t frc_sdio20: 5;
|
||||
uint32_t frc_neg_samp: 5;
|
||||
uint32_t frc_pos_samp: 5;
|
||||
uint32_t frc_quick_in: 5;
|
||||
uint32_t sdio20_int_delay: 1;
|
||||
uint32_t sdio_pad_pullup: 1;
|
||||
uint32_t hspeed_con_en: 1;
|
||||
uint32_t reserved28: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sdio20_mode: 5;
|
||||
uint32_t sdio_neg_samp: 5;
|
||||
uint32_t sdio_quick_in: 5;
|
||||
uint32_t reserved15: 17;
|
||||
};
|
||||
uint32_t val;
|
||||
} inf_st;
|
||||
} host_dev_t;
|
||||
extern host_dev_t HOST;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_HOST_STRUCT_H_ */
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef __HWCRYPTO_REG_H__
|
||||
#define __HWCRYPTO_REG_H__
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
/* registers for RSA acceleration via Multiple Precision Integer ops */
|
||||
#define RSA_MEM_M_BLOCK_BASE ((DR_REG_RSA_BASE)+0x000)
|
||||
/* RB & Z use the same memory block, depending on phase of operation */
|
||||
#define RSA_MEM_RB_BLOCK_BASE ((DR_REG_RSA_BASE)+0x200)
|
||||
#define RSA_MEM_Z_BLOCK_BASE ((DR_REG_RSA_BASE)+0x200)
|
||||
#define RSA_MEM_Y_BLOCK_BASE ((DR_REG_RSA_BASE)+0x400)
|
||||
#define RSA_MEM_X_BLOCK_BASE ((DR_REG_RSA_BASE)+0x600)
|
||||
|
||||
#define RSA_M_DASH_REG (DR_REG_RSA_BASE + 0x800)
|
||||
#define RSA_MODEXP_MODE_REG (DR_REG_RSA_BASE + 0x804)
|
||||
#define RSA_MODEXP_START_REG (DR_REG_RSA_BASE + 0x808)
|
||||
#define RSA_MULT_MODE_REG (DR_REG_RSA_BASE + 0x80c)
|
||||
#define RSA_MULT_START_REG (DR_REG_RSA_BASE + 0x810)
|
||||
|
||||
#define RSA_CLEAR_INTERRUPT_REG (DR_REG_RSA_BASE + 0x814)
|
||||
#define RSA_QUERY_INTERRUPT_REG (DR_REG_RSA_BASE + 0x814) /* same */
|
||||
|
||||
#define RSA_QUERY_CLEAN_REG (DR_REG_RSA_BASE + 0x818)
|
||||
|
||||
/* Backwards compatibility register names used pre-ESP32S2 */
|
||||
#define RSA_CLEAN_REG (RSA_QUERY_CLEAN_REG)
|
||||
#define RSA_INTERRUPT_REG (RSA_CLEAR_INTERRUPT_REG)
|
||||
#define RSA_START_MODEXP_REG (RSA_MODEXP_START_REG)
|
||||
|
||||
/* SHA acceleration registers */
|
||||
#define SHA_TEXT_BASE ((DR_REG_SHA_BASE) + 0x00)
|
||||
|
||||
#define SHA_1_START_REG ((DR_REG_SHA_BASE) + 0x80)
|
||||
#define SHA_1_CONTINUE_REG ((DR_REG_SHA_BASE) + 0x84)
|
||||
#define SHA_1_LOAD_REG ((DR_REG_SHA_BASE) + 0x88)
|
||||
#define SHA_1_BUSY_REG ((DR_REG_SHA_BASE) + 0x8c)
|
||||
|
||||
#define SHA_256_START_REG ((DR_REG_SHA_BASE) + 0x90)
|
||||
#define SHA_256_CONTINUE_REG ((DR_REG_SHA_BASE) + 0x94)
|
||||
#define SHA_256_LOAD_REG ((DR_REG_SHA_BASE) + 0x98)
|
||||
#define SHA_256_BUSY_REG ((DR_REG_SHA_BASE) + 0x9c)
|
||||
|
||||
#define SHA_384_START_REG ((DR_REG_SHA_BASE) + 0xa0)
|
||||
#define SHA_384_CONTINUE_REG ((DR_REG_SHA_BASE) + 0xa4)
|
||||
#define SHA_384_LOAD_REG ((DR_REG_SHA_BASE) + 0xa8)
|
||||
#define SHA_384_BUSY_REG ((DR_REG_SHA_BASE) + 0xac)
|
||||
|
||||
#define SHA_512_START_REG ((DR_REG_SHA_BASE) + 0xb0)
|
||||
#define SHA_512_CONTINUE_REG ((DR_REG_SHA_BASE) + 0xb4)
|
||||
#define SHA_512_LOAD_REG ((DR_REG_SHA_BASE) + 0xb8)
|
||||
#define SHA_512_BUSY_REG ((DR_REG_SHA_BASE) + 0xbc)
|
||||
|
||||
/* AES acceleration registers */
|
||||
#define AES_START_REG ((DR_REG_AES_BASE) + 0x00)
|
||||
#define AES_IDLE_REG ((DR_REG_AES_BASE) + 0x04)
|
||||
#define AES_MODE_REG ((DR_REG_AES_BASE) + 0x08)
|
||||
#define AES_KEY_BASE ((DR_REG_AES_BASE) + 0x10)
|
||||
#define AES_TEXT_BASE ((DR_REG_AES_BASE) + 0x30)
|
||||
#define AES_ENDIAN ((DR_REG_AES_BASE) + 0x40)
|
||||
|
||||
#endif
|
||||
36
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2c_caps.h
Normal file
36
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2c_caps.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2010-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ESP32 have 2 I2C.
|
||||
#define SOC_I2C_NUM (2)
|
||||
|
||||
#define SOC_I2C_FIFO_LEN (32) /*!< I2C hardware FIFO depth */
|
||||
#define I2C_INTR_MASK (0x3fff) /*!< I2C all interrupt bitmap */
|
||||
|
||||
//ESP32 do not support hardware FSM reset
|
||||
#define I2C_SUPPORT_HW_FSM_RST (0)
|
||||
//ESP32 do not support hardware clear bus
|
||||
#define I2C_SUPPORT_HW_CLR_BUS (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
951
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2c_reg.h
Normal file
951
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2c_reg.h
Normal file
@@ -0,0 +1,951 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_I2C_REG_H_
|
||||
#define _SOC_I2C_REG_H_
|
||||
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
#define REG_I2C_BASE(i) (DR_REG_I2C_EXT_BASE + (i) * 0x14000 )
|
||||
|
||||
#define I2C_SCL_LOW_PERIOD_REG(i) (REG_I2C_BASE(i) + 0x0000)
|
||||
/* I2C_SCL_LOW_PERIOD : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This register is used to configure the low level width of SCL clock.*/
|
||||
#define I2C_SCL_LOW_PERIOD 0x00003FFF
|
||||
#define I2C_SCL_LOW_PERIOD_M ((I2C_SCL_LOW_PERIOD_V)<<(I2C_SCL_LOW_PERIOD_S))
|
||||
#define I2C_SCL_LOW_PERIOD_V 0x3FFF
|
||||
#define I2C_SCL_LOW_PERIOD_S 0
|
||||
|
||||
#define I2C_CTR_REG(i) (REG_I2C_BASE(i) + 0x0004)
|
||||
/* I2C_CLK_EN : R/W ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: This is the clock gating control bit for reading or writing registers.*/
|
||||
#define I2C_CLK_EN (BIT(8))
|
||||
#define I2C_CLK_EN_M (BIT(8))
|
||||
#define I2C_CLK_EN_V 0x1
|
||||
#define I2C_CLK_EN_S 8
|
||||
/* I2C_RX_LSB_FIRST : R/W ;bitpos:[7] ;default: 1'h0 ; */
|
||||
/*description: This bit is used to control the storage mode for received datas.
|
||||
1: receive data from most significant bit 0: receive data from least significant bit*/
|
||||
#define I2C_RX_LSB_FIRST (BIT(7))
|
||||
#define I2C_RX_LSB_FIRST_M (BIT(7))
|
||||
#define I2C_RX_LSB_FIRST_V 0x1
|
||||
#define I2C_RX_LSB_FIRST_S 7
|
||||
/* I2C_TX_LSB_FIRST : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: This bit is used to control the sending mode for data need to
|
||||
be send. 1: receive data from most significant bit 0: receive data from least significant bit*/
|
||||
#define I2C_TX_LSB_FIRST (BIT(6))
|
||||
#define I2C_TX_LSB_FIRST_M (BIT(6))
|
||||
#define I2C_TX_LSB_FIRST_V 0x1
|
||||
#define I2C_TX_LSB_FIRST_S 6
|
||||
/* I2C_TRANS_START : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to start sending data in txfifo.*/
|
||||
#define I2C_TRANS_START (BIT(5))
|
||||
#define I2C_TRANS_START_M (BIT(5))
|
||||
#define I2C_TRANS_START_V 0x1
|
||||
#define I2C_TRANS_START_S 5
|
||||
/* I2C_MS_MODE : R/W ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to configure the module as i2c master clear this
|
||||
bit to configure the module as i2c slave.*/
|
||||
#define I2C_MS_MODE (BIT(4))
|
||||
#define I2C_MS_MODE_M (BIT(4))
|
||||
#define I2C_MS_MODE_V 0x1
|
||||
#define I2C_MS_MODE_S 4
|
||||
/* I2C_SAMPLE_SCL_LEVEL : R/W ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to sample data in SCL low level. clear this bit
|
||||
to sample data in SCL high level.*/
|
||||
#define I2C_SAMPLE_SCL_LEVEL (BIT(2))
|
||||
#define I2C_SAMPLE_SCL_LEVEL_M (BIT(2))
|
||||
#define I2C_SAMPLE_SCL_LEVEL_V 0x1
|
||||
#define I2C_SAMPLE_SCL_LEVEL_S 2
|
||||
/* I2C_SCL_FORCE_OUT : R/W ;bitpos:[1] ;default: 1'b1 ; */
|
||||
/*description: 1: normally ouput scl clock 0: exchange the function of scl_o
|
||||
and scl_oe (scl_o is the original internal output scl signal scl_oe is the enable bit for the internal output scl signal)*/
|
||||
#define I2C_SCL_FORCE_OUT (BIT(1))
|
||||
#define I2C_SCL_FORCE_OUT_M (BIT(1))
|
||||
#define I2C_SCL_FORCE_OUT_V 0x1
|
||||
#define I2C_SCL_FORCE_OUT_S 1
|
||||
/* I2C_SDA_FORCE_OUT : R/W ;bitpos:[0] ;default: 1'b1 ; */
|
||||
/*description: 1: normally ouput sda data 0: exchange the function of sda_o
|
||||
and sda_oe (sda_o is the original internal output sda signal sda_oe is the enable bit for the internal output sda signal)*/
|
||||
#define I2C_SDA_FORCE_OUT (BIT(0))
|
||||
#define I2C_SDA_FORCE_OUT_M (BIT(0))
|
||||
#define I2C_SDA_FORCE_OUT_V 0x1
|
||||
#define I2C_SDA_FORCE_OUT_S 0
|
||||
|
||||
#define I2C_SR_REG(i) (REG_I2C_BASE(i) + 0x0008)
|
||||
/* I2C_SCL_STATE_LAST : RO ;bitpos:[30:28] ;default: 3'b0 ; */
|
||||
/*description: This register stores the value of state machine to produce SCL.
|
||||
3'h0: SCL_IDLE 3'h1:SCL_START 3'h2:SCL_LOW_EDGE 3'h3: SCL_LOW 3'h4:SCL_HIGH_EDGE 3'h5:SCL_HIGH 3'h6:SCL_STOP*/
|
||||
#define I2C_SCL_STATE_LAST 0x00000007
|
||||
#define I2C_SCL_STATE_LAST_M ((I2C_SCL_STATE_LAST_V)<<(I2C_SCL_STATE_LAST_S))
|
||||
#define I2C_SCL_STATE_LAST_V 0x7
|
||||
#define I2C_SCL_STATE_LAST_S 28
|
||||
/* I2C_SCL_MAIN_STATE_LAST : RO ;bitpos:[26:24] ;default: 3'b0 ; */
|
||||
/*description: This register stores the value of state machine for i2c module.
|
||||
3'h0: SCL_MAIN_IDLE 3'h1: SCL_ADDRESS_SHIFT 3'h2: SCL_ACK_ADDRESS 3'h3: SCL_RX_DATA 3'h4 SCL_TX_DATA 3'h5:SCL_SEND_ACK 3'h6:SCL_WAIT_ACK*/
|
||||
#define I2C_SCL_MAIN_STATE_LAST 0x00000007
|
||||
#define I2C_SCL_MAIN_STATE_LAST_M ((I2C_SCL_MAIN_STATE_LAST_V)<<(I2C_SCL_MAIN_STATE_LAST_S))
|
||||
#define I2C_SCL_MAIN_STATE_LAST_V 0x7
|
||||
#define I2C_SCL_MAIN_STATE_LAST_S 24
|
||||
/* I2C_TXFIFO_CNT : RO ;bitpos:[23:18] ;default: 6'b0 ; */
|
||||
/*description: This register stores the amount of received data in ram.*/
|
||||
#define I2C_TXFIFO_CNT 0x0000003F
|
||||
#define I2C_TXFIFO_CNT_M ((I2C_TXFIFO_CNT_V)<<(I2C_TXFIFO_CNT_S))
|
||||
#define I2C_TXFIFO_CNT_V 0x3F
|
||||
#define I2C_TXFIFO_CNT_S 18
|
||||
/* I2C_RXFIFO_CNT : RO ;bitpos:[13:8] ;default: 6'b0 ; */
|
||||
/*description: This register represent the amount of data need to send.*/
|
||||
#define I2C_RXFIFO_CNT 0x0000003F
|
||||
#define I2C_RXFIFO_CNT_M ((I2C_RXFIFO_CNT_V)<<(I2C_RXFIFO_CNT_S))
|
||||
#define I2C_RXFIFO_CNT_V 0x3F
|
||||
#define I2C_RXFIFO_CNT_S 8
|
||||
/* I2C_BYTE_TRANS : RO ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: This register changes to high level when one byte is transferred.*/
|
||||
#define I2C_BYTE_TRANS (BIT(6))
|
||||
#define I2C_BYTE_TRANS_M (BIT(6))
|
||||
#define I2C_BYTE_TRANS_V 0x1
|
||||
#define I2C_BYTE_TRANS_S 6
|
||||
/* I2C_SLAVE_ADDRESSED : RO ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: when configured as i2c slave and the address send by master
|
||||
is equal to slave's address then this bit will be high level.*/
|
||||
#define I2C_SLAVE_ADDRESSED (BIT(5))
|
||||
#define I2C_SLAVE_ADDRESSED_M (BIT(5))
|
||||
#define I2C_SLAVE_ADDRESSED_V 0x1
|
||||
#define I2C_SLAVE_ADDRESSED_S 5
|
||||
/* I2C_BUS_BUSY : RO ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: 1:I2C bus is busy transferring data. 0:I2C bus is in idle state.*/
|
||||
#define I2C_BUS_BUSY (BIT(4))
|
||||
#define I2C_BUS_BUSY_M (BIT(4))
|
||||
#define I2C_BUS_BUSY_V 0x1
|
||||
#define I2C_BUS_BUSY_S 4
|
||||
/* I2C_ARB_LOST : RO ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: when I2C lost control of SDA line this register changes to high level.*/
|
||||
#define I2C_ARB_LOST (BIT(3))
|
||||
#define I2C_ARB_LOST_M (BIT(3))
|
||||
#define I2C_ARB_LOST_V 0x1
|
||||
#define I2C_ARB_LOST_S 3
|
||||
/* I2C_TIME_OUT : RO ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: when I2C takes more than time_out_reg clocks to receive a data
|
||||
then this register changes to high level.*/
|
||||
#define I2C_TIME_OUT (BIT(2))
|
||||
#define I2C_TIME_OUT_M (BIT(2))
|
||||
#define I2C_TIME_OUT_V 0x1
|
||||
#define I2C_TIME_OUT_S 2
|
||||
/* I2C_SLAVE_RW : RO ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: when in slave mode 1: master read slave 0: master write slave.*/
|
||||
#define I2C_SLAVE_RW (BIT(1))
|
||||
#define I2C_SLAVE_RW_M (BIT(1))
|
||||
#define I2C_SLAVE_RW_V 0x1
|
||||
#define I2C_SLAVE_RW_S 1
|
||||
/* I2C_ACK_REC : RO ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: This register stores the value of ACK bit.*/
|
||||
#define I2C_ACK_REC (BIT(0))
|
||||
#define I2C_ACK_REC_M (BIT(0))
|
||||
#define I2C_ACK_REC_V 0x1
|
||||
#define I2C_ACK_REC_S 0
|
||||
|
||||
#define I2C_TO_REG(i) (REG_I2C_BASE(i) + 0x000c)
|
||||
/* I2C_TIME_OUT_REG : R/W ;bitpos:[19:0] ;default: 20'b0 ; */
|
||||
/*description: This register is used to configure the max clock number of receiving a data.*/
|
||||
#define I2C_TIME_OUT_REG 0x000FFFFF
|
||||
#define I2C_TIME_OUT_REG_M ((I2C_TIME_OUT_REG_V)<<(I2C_TIME_OUT_REG_S))
|
||||
#define I2C_TIME_OUT_REG_V 0xFFFFF
|
||||
#define I2C_TIME_OUT_REG_S 0
|
||||
|
||||
#define I2C_SLAVE_ADDR_REG(i) (REG_I2C_BASE(i) + 0x0010)
|
||||
/* I2C_ADDR_10BIT_EN : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: This register is used to enable slave 10bit address mode.*/
|
||||
#define I2C_ADDR_10BIT_EN (BIT(31))
|
||||
#define I2C_ADDR_10BIT_EN_M (BIT(31))
|
||||
#define I2C_ADDR_10BIT_EN_V 0x1
|
||||
#define I2C_ADDR_10BIT_EN_S 31
|
||||
/* I2C_SLAVE_ADDR : R/W ;bitpos:[14:0] ;default: 15'b0 ; */
|
||||
/*description: when configured as i2c slave this register is used to configure
|
||||
slave's address.*/
|
||||
#define I2C_SLAVE_ADDR 0x00007FFF
|
||||
#define I2C_SLAVE_ADDR_M ((I2C_SLAVE_ADDR_V)<<(I2C_SLAVE_ADDR_S))
|
||||
#define I2C_SLAVE_ADDR_V 0x7FFF
|
||||
#define I2C_SLAVE_ADDR_S 0
|
||||
|
||||
#define I2C_RXFIFO_ST_REG(i) (REG_I2C_BASE(i) + 0x0014)
|
||||
/* I2C_TXFIFO_END_ADDR : RO ;bitpos:[19:15] ;default: 5'b0 ; */
|
||||
/*description: This is the offset address of the last sending data as described
|
||||
in nonfifo_tx_thres register.*/
|
||||
#define I2C_TXFIFO_END_ADDR 0x0000001F
|
||||
#define I2C_TXFIFO_END_ADDR_M ((I2C_TXFIFO_END_ADDR_V)<<(I2C_TXFIFO_END_ADDR_S))
|
||||
#define I2C_TXFIFO_END_ADDR_V 0x1F
|
||||
#define I2C_TXFIFO_END_ADDR_S 15
|
||||
/* I2C_TXFIFO_START_ADDR : RO ;bitpos:[14:10] ;default: 5'b0 ; */
|
||||
/*description: This is the offset address of the first sending data as described
|
||||
in nonfifo_tx_thres register.*/
|
||||
#define I2C_TXFIFO_START_ADDR 0x0000001F
|
||||
#define I2C_TXFIFO_START_ADDR_M ((I2C_TXFIFO_START_ADDR_V)<<(I2C_TXFIFO_START_ADDR_S))
|
||||
#define I2C_TXFIFO_START_ADDR_V 0x1F
|
||||
#define I2C_TXFIFO_START_ADDR_S 10
|
||||
/* I2C_RXFIFO_END_ADDR : RO ;bitpos:[9:5] ;default: 5'b0 ; */
|
||||
/*description: This is the offset address of the first receiving data as described
|
||||
in nonfifo_rx_thres_register.*/
|
||||
#define I2C_RXFIFO_END_ADDR 0x0000001F
|
||||
#define I2C_RXFIFO_END_ADDR_M ((I2C_RXFIFO_END_ADDR_V)<<(I2C_RXFIFO_END_ADDR_S))
|
||||
#define I2C_RXFIFO_END_ADDR_V 0x1F
|
||||
#define I2C_RXFIFO_END_ADDR_S 5
|
||||
/* I2C_RXFIFO_START_ADDR : RO ;bitpos:[4:0] ;default: 5'b0 ; */
|
||||
/*description: This is the offset address of the last receiving data as described
|
||||
in nonfifo_rx_thres_register.*/
|
||||
#define I2C_RXFIFO_START_ADDR 0x0000001F
|
||||
#define I2C_RXFIFO_START_ADDR_M ((I2C_RXFIFO_START_ADDR_V)<<(I2C_RXFIFO_START_ADDR_S))
|
||||
#define I2C_RXFIFO_START_ADDR_V 0x1F
|
||||
#define I2C_RXFIFO_START_ADDR_S 0
|
||||
|
||||
#define I2C_FIFO_CONF_REG(i) (REG_I2C_BASE(i) + 0x0018)
|
||||
/* I2C_NONFIFO_TX_THRES : R/W ;bitpos:[25:20] ;default: 6'h15 ; */
|
||||
/*description: when I2C sends more than nonfifo_tx_thres data it will produce
|
||||
tx_send_empty_int_raw interrupt and update the current offset address of the sending data.*/
|
||||
#define I2C_NONFIFO_TX_THRES 0x0000003F
|
||||
#define I2C_NONFIFO_TX_THRES_M ((I2C_NONFIFO_TX_THRES_V)<<(I2C_NONFIFO_TX_THRES_S))
|
||||
#define I2C_NONFIFO_TX_THRES_V 0x3F
|
||||
#define I2C_NONFIFO_TX_THRES_S 20
|
||||
/* I2C_NONFIFO_RX_THRES : R/W ;bitpos:[19:14] ;default: 6'h15 ; */
|
||||
/*description: when I2C receives more than nonfifo_rx_thres data it will produce
|
||||
rx_send_full_int_raw interrupt and update the current offset address of the receiving data.*/
|
||||
#define I2C_NONFIFO_RX_THRES 0x0000003F
|
||||
#define I2C_NONFIFO_RX_THRES_M ((I2C_NONFIFO_RX_THRES_V)<<(I2C_NONFIFO_RX_THRES_S))
|
||||
#define I2C_NONFIFO_RX_THRES_V 0x3F
|
||||
#define I2C_NONFIFO_RX_THRES_S 14
|
||||
/* I2C_TX_FIFO_RST : R/W ;bitpos:[13] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to reset tx fifo when using apb fifo access.*/
|
||||
#define I2C_TX_FIFO_RST (BIT(13))
|
||||
#define I2C_TX_FIFO_RST_M (BIT(13))
|
||||
#define I2C_TX_FIFO_RST_V 0x1
|
||||
#define I2C_TX_FIFO_RST_S 13
|
||||
/* I2C_RX_FIFO_RST : R/W ;bitpos:[12] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to reset rx fifo when using apb fifo access.*/
|
||||
#define I2C_RX_FIFO_RST (BIT(12))
|
||||
#define I2C_RX_FIFO_RST_M (BIT(12))
|
||||
#define I2C_RX_FIFO_RST_V 0x1
|
||||
#define I2C_RX_FIFO_RST_S 12
|
||||
/* I2C_FIFO_ADDR_CFG_EN : R/W ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: When this bit is set to 1 then the byte after address represent
|
||||
the offset address of I2C Slave's ram.*/
|
||||
#define I2C_FIFO_ADDR_CFG_EN (BIT(11))
|
||||
#define I2C_FIFO_ADDR_CFG_EN_M (BIT(11))
|
||||
#define I2C_FIFO_ADDR_CFG_EN_V 0x1
|
||||
#define I2C_FIFO_ADDR_CFG_EN_S 11
|
||||
/* I2C_NONFIFO_EN : R/W ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to enble apb nonfifo access.*/
|
||||
#define I2C_NONFIFO_EN (BIT(10))
|
||||
#define I2C_NONFIFO_EN_M (BIT(10))
|
||||
#define I2C_NONFIFO_EN_V 0x1
|
||||
#define I2C_NONFIFO_EN_S 10
|
||||
/* I2C_TXFIFO_EMPTY_THRHD : R/W ;bitpos:[9:5] ;default: 5'h4 ; */
|
||||
/*description: Config txfifo empty threhd value when using apb fifo access*/
|
||||
#define I2C_TXFIFO_EMPTY_THRHD 0x0000001F
|
||||
#define I2C_TXFIFO_EMPTY_THRHD_M ((I2C_TXFIFO_EMPTY_THRHD_V)<<(I2C_TXFIFO_EMPTY_THRHD_S))
|
||||
#define I2C_TXFIFO_EMPTY_THRHD_V 0x1F
|
||||
#define I2C_TXFIFO_EMPTY_THRHD_S 5
|
||||
/* I2C_RXFIFO_FULL_THRHD : R/W ;bitpos:[4:0] ;default: 5'hb ; */
|
||||
/*description: */
|
||||
#define I2C_RXFIFO_FULL_THRHD 0x0000001F
|
||||
#define I2C_RXFIFO_FULL_THRHD_M ((I2C_RXFIFO_FULL_THRHD_V)<<(I2C_RXFIFO_FULL_THRHD_S))
|
||||
#define I2C_RXFIFO_FULL_THRHD_V 0x1F
|
||||
#define I2C_RXFIFO_FULL_THRHD_S 0
|
||||
|
||||
#define I2C_DATA_APB_REG(i) (0x60013000 + (i) * 0x14000 + 0x001c)
|
||||
|
||||
#define I2C_DATA_REG(i) (REG_I2C_BASE(i) + 0x001c)
|
||||
/* I2C_FIFO_RDATA : RO ;bitpos:[7:0] ;default: 8'b0 ; */
|
||||
/*description: The register represent the byte data read from rxfifo when use apb fifo access*/
|
||||
#define I2C_FIFO_RDATA 0x000000FF
|
||||
#define I2C_FIFO_RDATA_M ((I2C_FIFO_RDATA_V)<<(I2C_FIFO_RDATA_S))
|
||||
#define I2C_FIFO_RDATA_V 0xFF
|
||||
#define I2C_FIFO_RDATA_S 0
|
||||
|
||||
#define I2C_INT_RAW_REG(i) (REG_I2C_BASE(i) + 0x0020)
|
||||
/* I2C_TX_SEND_EMPTY_INT_RAW : RO ;bitpos:[12] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for tx_send_empty_int interrupt.when
|
||||
I2C sends more data than nonfifo_tx_thres it will produce tx_send_empty_int interrupt..*/
|
||||
#define I2C_TX_SEND_EMPTY_INT_RAW (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_RAW_M (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_RAW_V 0x1
|
||||
#define I2C_TX_SEND_EMPTY_INT_RAW_S 12
|
||||
/* I2C_RX_REC_FULL_INT_RAW : RO ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for rx_rec_full_int interrupt. when
|
||||
I2C receives more data than nonfifo_rx_thres it will produce rx_rec_full_int interrupt.*/
|
||||
#define I2C_RX_REC_FULL_INT_RAW (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_RAW_M (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_RAW_V 0x1
|
||||
#define I2C_RX_REC_FULL_INT_RAW_S 11
|
||||
/* I2C_ACK_ERR_INT_RAW : RO ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for ack_err_int interrupt. when
|
||||
I2C receives a wrong ACK bit it will produce ack_err_int interrupt..*/
|
||||
#define I2C_ACK_ERR_INT_RAW (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_RAW_M (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_RAW_V 0x1
|
||||
#define I2C_ACK_ERR_INT_RAW_S 10
|
||||
/* I2C_TRANS_START_INT_RAW : RO ;bitpos:[9] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for trans_start_int interrupt. when
|
||||
I2C sends the START bit it will produce trans_start_int interrupt.*/
|
||||
#define I2C_TRANS_START_INT_RAW (BIT(9))
|
||||
#define I2C_TRANS_START_INT_RAW_M (BIT(9))
|
||||
#define I2C_TRANS_START_INT_RAW_V 0x1
|
||||
#define I2C_TRANS_START_INT_RAW_S 9
|
||||
/* I2C_TIME_OUT_INT_RAW : RO ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for time_out_int interrupt. when
|
||||
I2C takes a lot of time to receive a data it will produce time_out_int interrupt.*/
|
||||
#define I2C_TIME_OUT_INT_RAW (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_RAW_M (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_RAW_V 0x1
|
||||
#define I2C_TIME_OUT_INT_RAW_S 8
|
||||
/* I2C_TRANS_COMPLETE_INT_RAW : RO ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for trans_complete_int interrupt.
|
||||
when I2C Master finished STOP command it will produce trans_complete_int interrupt.*/
|
||||
#define I2C_TRANS_COMPLETE_INT_RAW (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_RAW_M (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_RAW_V 0x1
|
||||
#define I2C_TRANS_COMPLETE_INT_RAW_S 7
|
||||
/* I2C_MASTER_TRAN_COMP_INT_RAW : RO ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for master_tra_comp_int interrupt.
|
||||
when I2C Master sends or receives a byte it will produce master_tran_comp_int interrupt.*/
|
||||
#define I2C_MASTER_TRAN_COMP_INT_RAW (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_RAW_M (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_RAW_V 0x1
|
||||
#define I2C_MASTER_TRAN_COMP_INT_RAW_S 6
|
||||
/* I2C_ARBITRATION_LOST_INT_RAW : RO ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for arbitration_lost_int interrupt.when
|
||||
I2C lost the usage right of I2C BUS it will produce arbitration_lost_int interrupt.*/
|
||||
#define I2C_ARBITRATION_LOST_INT_RAW (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_RAW_M (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_RAW_V 0x1
|
||||
#define I2C_ARBITRATION_LOST_INT_RAW_S 5
|
||||
/* I2C_SLAVE_TRAN_COMP_INT_RAW : RO ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for slave_tran_comp_int interrupt.
|
||||
when I2C Slave detectsthe STOP bit it will produce slave_tran_comp_int interrupt.*/
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_RAW (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_RAW_M (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_RAW_V 0x1
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_RAW_S 4
|
||||
/* I2C_END_DETECT_INT_RAW : RO ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for end_detect_int interrupt. when
|
||||
I2C deals with the END command it will produce end_detect_int interrupt.*/
|
||||
#define I2C_END_DETECT_INT_RAW (BIT(3))
|
||||
#define I2C_END_DETECT_INT_RAW_M (BIT(3))
|
||||
#define I2C_END_DETECT_INT_RAW_V 0x1
|
||||
#define I2C_END_DETECT_INT_RAW_S 3
|
||||
/* I2C_RXFIFO_OVF_INT_RAW : RO ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for receiving data overflow when
|
||||
use apb fifo access.*/
|
||||
#define I2C_RXFIFO_OVF_INT_RAW (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_RAW_M (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_RAW_V 0x1
|
||||
#define I2C_RXFIFO_OVF_INT_RAW_S 2
|
||||
/* I2C_TXFIFO_EMPTY_INT_RAW : RO ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for txfifo empty when use apb fifo access.*/
|
||||
#define I2C_TXFIFO_EMPTY_INT_RAW (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_RAW_M (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_RAW_V 0x1
|
||||
#define I2C_TXFIFO_EMPTY_INT_RAW_S 1
|
||||
/* I2C_RXFIFO_FULL_INT_RAW : RO ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: The raw interrupt status bit for rxfifo full when use apb fifo access.*/
|
||||
#define I2C_RXFIFO_FULL_INT_RAW (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_RAW_M (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_RAW_V 0x1
|
||||
#define I2C_RXFIFO_FULL_INT_RAW_S 0
|
||||
|
||||
#define I2C_INT_CLR_REG(i) (REG_I2C_BASE(i) + 0x0024)
|
||||
/* I2C_TX_SEND_EMPTY_INT_CLR : WO ;bitpos:[12] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the tx_send_empty_int interrupt.*/
|
||||
#define I2C_TX_SEND_EMPTY_INT_CLR (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_CLR_M (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_CLR_V 0x1
|
||||
#define I2C_TX_SEND_EMPTY_INT_CLR_S 12
|
||||
/* I2C_RX_REC_FULL_INT_CLR : WO ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the rx_rec_full_int interrupt.*/
|
||||
#define I2C_RX_REC_FULL_INT_CLR (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_CLR_M (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_CLR_V 0x1
|
||||
#define I2C_RX_REC_FULL_INT_CLR_S 11
|
||||
/* I2C_ACK_ERR_INT_CLR : WO ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the ack_err_int interrupt.*/
|
||||
#define I2C_ACK_ERR_INT_CLR (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_CLR_M (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_CLR_V 0x1
|
||||
#define I2C_ACK_ERR_INT_CLR_S 10
|
||||
/* I2C_TRANS_START_INT_CLR : WO ;bitpos:[9] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the trans_start_int interrupt.*/
|
||||
#define I2C_TRANS_START_INT_CLR (BIT(9))
|
||||
#define I2C_TRANS_START_INT_CLR_M (BIT(9))
|
||||
#define I2C_TRANS_START_INT_CLR_V 0x1
|
||||
#define I2C_TRANS_START_INT_CLR_S 9
|
||||
/* I2C_TIME_OUT_INT_CLR : WO ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the time_out_int interrupt.*/
|
||||
#define I2C_TIME_OUT_INT_CLR (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_CLR_M (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_CLR_V 0x1
|
||||
#define I2C_TIME_OUT_INT_CLR_S 8
|
||||
/* I2C_TRANS_COMPLETE_INT_CLR : WO ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the trans_complete_int interrupt.*/
|
||||
#define I2C_TRANS_COMPLETE_INT_CLR (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_CLR_M (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_CLR_V 0x1
|
||||
#define I2C_TRANS_COMPLETE_INT_CLR_S 7
|
||||
/* I2C_MASTER_TRAN_COMP_INT_CLR : WO ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the master_tran_comp interrupt.*/
|
||||
#define I2C_MASTER_TRAN_COMP_INT_CLR (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_CLR_M (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_CLR_V 0x1
|
||||
#define I2C_MASTER_TRAN_COMP_INT_CLR_S 6
|
||||
/* I2C_ARBITRATION_LOST_INT_CLR : WO ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the arbitration_lost_int interrupt.*/
|
||||
#define I2C_ARBITRATION_LOST_INT_CLR (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_CLR_M (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_CLR_V 0x1
|
||||
#define I2C_ARBITRATION_LOST_INT_CLR_S 5
|
||||
/* I2C_SLAVE_TRAN_COMP_INT_CLR : WO ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the slave_tran_comp_int interrupt.*/
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_CLR (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_CLR_M (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_CLR_V 0x1
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_CLR_S 4
|
||||
/* I2C_END_DETECT_INT_CLR : WO ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the end_detect_int interrupt.*/
|
||||
#define I2C_END_DETECT_INT_CLR (BIT(3))
|
||||
#define I2C_END_DETECT_INT_CLR_M (BIT(3))
|
||||
#define I2C_END_DETECT_INT_CLR_V 0x1
|
||||
#define I2C_END_DETECT_INT_CLR_S 3
|
||||
/* I2C_RXFIFO_OVF_INT_CLR : WO ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the rxfifo_ovf_int interrupt.*/
|
||||
#define I2C_RXFIFO_OVF_INT_CLR (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_CLR_M (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_CLR_V 0x1
|
||||
#define I2C_RXFIFO_OVF_INT_CLR_S 2
|
||||
/* I2C_TXFIFO_EMPTY_INT_CLR : WO ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the txfifo_empty_int interrupt.*/
|
||||
#define I2C_TXFIFO_EMPTY_INT_CLR (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_CLR_M (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_CLR_V 0x1
|
||||
#define I2C_TXFIFO_EMPTY_INT_CLR_S 1
|
||||
/* I2C_RXFIFO_FULL_INT_CLR : WO ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: Set this bit to clear the rxfifo_full_int interrupt.*/
|
||||
#define I2C_RXFIFO_FULL_INT_CLR (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_CLR_M (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_CLR_V 0x1
|
||||
#define I2C_RXFIFO_FULL_INT_CLR_S 0
|
||||
|
||||
#define I2C_INT_ENA_REG(i) (REG_I2C_BASE(i) + 0x0028)
|
||||
/* I2C_TX_SEND_EMPTY_INT_ENA : R/W ;bitpos:[12] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for tx_send_empty_int interrupt.*/
|
||||
#define I2C_TX_SEND_EMPTY_INT_ENA (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_ENA_M (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_ENA_V 0x1
|
||||
#define I2C_TX_SEND_EMPTY_INT_ENA_S 12
|
||||
/* I2C_RX_REC_FULL_INT_ENA : R/W ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for rx_rec_full_int interrupt.*/
|
||||
#define I2C_RX_REC_FULL_INT_ENA (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_ENA_M (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_ENA_V 0x1
|
||||
#define I2C_RX_REC_FULL_INT_ENA_S 11
|
||||
/* I2C_ACK_ERR_INT_ENA : R/W ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for ack_err_int interrupt.*/
|
||||
#define I2C_ACK_ERR_INT_ENA (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_ENA_M (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_ENA_V 0x1
|
||||
#define I2C_ACK_ERR_INT_ENA_S 10
|
||||
/* I2C_TRANS_START_INT_ENA : R/W ;bitpos:[9] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for trans_start_int interrupt.*/
|
||||
#define I2C_TRANS_START_INT_ENA (BIT(9))
|
||||
#define I2C_TRANS_START_INT_ENA_M (BIT(9))
|
||||
#define I2C_TRANS_START_INT_ENA_V 0x1
|
||||
#define I2C_TRANS_START_INT_ENA_S 9
|
||||
/* I2C_TIME_OUT_INT_ENA : R/W ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for time_out_int interrupt.*/
|
||||
#define I2C_TIME_OUT_INT_ENA (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_ENA_M (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_ENA_V 0x1
|
||||
#define I2C_TIME_OUT_INT_ENA_S 8
|
||||
/* I2C_TRANS_COMPLETE_INT_ENA : R/W ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for trans_complete_int interrupt.*/
|
||||
#define I2C_TRANS_COMPLETE_INT_ENA (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_ENA_M (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_ENA_V 0x1
|
||||
#define I2C_TRANS_COMPLETE_INT_ENA_S 7
|
||||
/* I2C_MASTER_TRAN_COMP_INT_ENA : R/W ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for master_tran_comp_int interrupt.*/
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ENA (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ENA_M (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ENA_V 0x1
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ENA_S 6
|
||||
/* I2C_ARBITRATION_LOST_INT_ENA : R/W ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for arbitration_lost_int interrupt.*/
|
||||
#define I2C_ARBITRATION_LOST_INT_ENA (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_ENA_M (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_ENA_V 0x1
|
||||
#define I2C_ARBITRATION_LOST_INT_ENA_S 5
|
||||
/* I2C_SLAVE_TRAN_COMP_INT_ENA : R/W ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for slave_tran_comp_int interrupt.*/
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ENA (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ENA_M (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ENA_V 0x1
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ENA_S 4
|
||||
/* I2C_END_DETECT_INT_ENA : R/W ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for end_detect_int interrupt.*/
|
||||
#define I2C_END_DETECT_INT_ENA (BIT(3))
|
||||
#define I2C_END_DETECT_INT_ENA_M (BIT(3))
|
||||
#define I2C_END_DETECT_INT_ENA_V 0x1
|
||||
#define I2C_END_DETECT_INT_ENA_S 3
|
||||
/* I2C_RXFIFO_OVF_INT_ENA : R/W ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for rxfifo_ovf_int interrupt.*/
|
||||
#define I2C_RXFIFO_OVF_INT_ENA (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_ENA_M (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_ENA_V 0x1
|
||||
#define I2C_RXFIFO_OVF_INT_ENA_S 2
|
||||
/* I2C_TXFIFO_EMPTY_INT_ENA : R/W ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for txfifo_empty_int interrupt.*/
|
||||
#define I2C_TXFIFO_EMPTY_INT_ENA (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_ENA_M (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_ENA_V 0x1
|
||||
#define I2C_TXFIFO_EMPTY_INT_ENA_S 1
|
||||
/* I2C_RXFIFO_FULL_INT_ENA : R/W ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: The enable bit for rxfifo_full_int interrupt.*/
|
||||
#define I2C_RXFIFO_FULL_INT_ENA (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_ENA_M (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_ENA_V 0x1
|
||||
#define I2C_RXFIFO_FULL_INT_ENA_S 0
|
||||
|
||||
#define I2C_INT_STATUS_REG(i) (REG_I2C_BASE(i) + 0x002c)
|
||||
/* I2C_TX_SEND_EMPTY_INT_ST : RO ;bitpos:[12] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for tx_send_empty_int interrupt.*/
|
||||
#define I2C_TX_SEND_EMPTY_INT_ST (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_ST_M (BIT(12))
|
||||
#define I2C_TX_SEND_EMPTY_INT_ST_V 0x1
|
||||
#define I2C_TX_SEND_EMPTY_INT_ST_S 12
|
||||
/* I2C_RX_REC_FULL_INT_ST : RO ;bitpos:[11] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for rx_rec_full_int interrupt.*/
|
||||
#define I2C_RX_REC_FULL_INT_ST (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_ST_M (BIT(11))
|
||||
#define I2C_RX_REC_FULL_INT_ST_V 0x1
|
||||
#define I2C_RX_REC_FULL_INT_ST_S 11
|
||||
/* I2C_ACK_ERR_INT_ST : RO ;bitpos:[10] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for ack_err_int interrupt.*/
|
||||
#define I2C_ACK_ERR_INT_ST (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_ST_M (BIT(10))
|
||||
#define I2C_ACK_ERR_INT_ST_V 0x1
|
||||
#define I2C_ACK_ERR_INT_ST_S 10
|
||||
/* I2C_TRANS_START_INT_ST : RO ;bitpos:[9] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for trans_start_int interrupt.*/
|
||||
#define I2C_TRANS_START_INT_ST (BIT(9))
|
||||
#define I2C_TRANS_START_INT_ST_M (BIT(9))
|
||||
#define I2C_TRANS_START_INT_ST_V 0x1
|
||||
#define I2C_TRANS_START_INT_ST_S 9
|
||||
/* I2C_TIME_OUT_INT_ST : RO ;bitpos:[8] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for time_out_int interrupt.*/
|
||||
#define I2C_TIME_OUT_INT_ST (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_ST_M (BIT(8))
|
||||
#define I2C_TIME_OUT_INT_ST_V 0x1
|
||||
#define I2C_TIME_OUT_INT_ST_S 8
|
||||
/* I2C_TRANS_COMPLETE_INT_ST : RO ;bitpos:[7] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for trans_complete_int interrupt.*/
|
||||
#define I2C_TRANS_COMPLETE_INT_ST (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_ST_M (BIT(7))
|
||||
#define I2C_TRANS_COMPLETE_INT_ST_V 0x1
|
||||
#define I2C_TRANS_COMPLETE_INT_ST_S 7
|
||||
/* I2C_MASTER_TRAN_COMP_INT_ST : RO ;bitpos:[6] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for master_tran_comp_int interrupt.*/
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ST (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ST_M (BIT(6))
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ST_V 0x1
|
||||
#define I2C_MASTER_TRAN_COMP_INT_ST_S 6
|
||||
/* I2C_ARBITRATION_LOST_INT_ST : RO ;bitpos:[5] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for arbitration_lost_int interrupt.*/
|
||||
#define I2C_ARBITRATION_LOST_INT_ST (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_ST_M (BIT(5))
|
||||
#define I2C_ARBITRATION_LOST_INT_ST_V 0x1
|
||||
#define I2C_ARBITRATION_LOST_INT_ST_S 5
|
||||
/* I2C_SLAVE_TRAN_COMP_INT_ST : RO ;bitpos:[4] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for slave_tran_comp_int interrupt.*/
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ST (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ST_M (BIT(4))
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ST_V 0x1
|
||||
#define I2C_SLAVE_TRAN_COMP_INT_ST_S 4
|
||||
/* I2C_END_DETECT_INT_ST : RO ;bitpos:[3] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for end_detect_int interrupt.*/
|
||||
#define I2C_END_DETECT_INT_ST (BIT(3))
|
||||
#define I2C_END_DETECT_INT_ST_M (BIT(3))
|
||||
#define I2C_END_DETECT_INT_ST_V 0x1
|
||||
#define I2C_END_DETECT_INT_ST_S 3
|
||||
/* I2C_RXFIFO_OVF_INT_ST : RO ;bitpos:[2] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for rxfifo_ovf_int interrupt.*/
|
||||
#define I2C_RXFIFO_OVF_INT_ST (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_ST_M (BIT(2))
|
||||
#define I2C_RXFIFO_OVF_INT_ST_V 0x1
|
||||
#define I2C_RXFIFO_OVF_INT_ST_S 2
|
||||
/* I2C_TXFIFO_EMPTY_INT_ST : RO ;bitpos:[1] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for txfifo_empty_int interrupt.*/
|
||||
#define I2C_TXFIFO_EMPTY_INT_ST (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_ST_M (BIT(1))
|
||||
#define I2C_TXFIFO_EMPTY_INT_ST_V 0x1
|
||||
#define I2C_TXFIFO_EMPTY_INT_ST_S 1
|
||||
/* I2C_RXFIFO_FULL_INT_ST : RO ;bitpos:[0] ;default: 1'b0 ; */
|
||||
/*description: The masked interrupt status for rxfifo_full_int interrupt.*/
|
||||
#define I2C_RXFIFO_FULL_INT_ST (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_ST_M (BIT(0))
|
||||
#define I2C_RXFIFO_FULL_INT_ST_V 0x1
|
||||
#define I2C_RXFIFO_FULL_INT_ST_S 0
|
||||
|
||||
#define I2C_SDA_HOLD_REG(i) (REG_I2C_BASE(i) + 0x0030)
|
||||
/* I2C_SDA_HOLD_TIME : R/W ;bitpos:[9:0] ;default: 10'b0 ; */
|
||||
/*description: This register is used to configure the clock num I2C used to
|
||||
hold the data after the negedge of SCL.*/
|
||||
#define I2C_SDA_HOLD_TIME 0x000003FF
|
||||
#define I2C_SDA_HOLD_TIME_M ((I2C_SDA_HOLD_TIME_V)<<(I2C_SDA_HOLD_TIME_S))
|
||||
#define I2C_SDA_HOLD_TIME_V 0x3FF
|
||||
#define I2C_SDA_HOLD_TIME_S 0
|
||||
|
||||
#define I2C_SDA_SAMPLE_REG(i) (REG_I2C_BASE(i) + 0x0034)
|
||||
/* I2C_SDA_SAMPLE_TIME : R/W ;bitpos:[9:0] ;default: 10'b0 ; */
|
||||
/*description: This register is used to configure the clock num I2C used to
|
||||
sample data on SDA after the posedge of SCL*/
|
||||
#define I2C_SDA_SAMPLE_TIME 0x000003FF
|
||||
#define I2C_SDA_SAMPLE_TIME_M ((I2C_SDA_SAMPLE_TIME_V)<<(I2C_SDA_SAMPLE_TIME_S))
|
||||
#define I2C_SDA_SAMPLE_TIME_V 0x3FF
|
||||
#define I2C_SDA_SAMPLE_TIME_S 0
|
||||
|
||||
#define I2C_SCL_HIGH_PERIOD_REG(i) (REG_I2C_BASE(i) + 0x0038)
|
||||
/* I2C_SCL_HIGH_PERIOD : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This register is used to configure the clock num during SCL is low level.*/
|
||||
#define I2C_SCL_HIGH_PERIOD 0x00003FFF
|
||||
#define I2C_SCL_HIGH_PERIOD_M ((I2C_SCL_HIGH_PERIOD_V)<<(I2C_SCL_HIGH_PERIOD_S))
|
||||
#define I2C_SCL_HIGH_PERIOD_V 0x3FFF
|
||||
#define I2C_SCL_HIGH_PERIOD_S 0
|
||||
|
||||
#define I2C_SCL_START_HOLD_REG(i) (REG_I2C_BASE(i) + 0x0040)
|
||||
/* I2C_SCL_START_HOLD_TIME : R/W ;bitpos:[9:0] ;default: 10'b1000 ; */
|
||||
/*description: This register is used to configure the clock num between the
|
||||
negedge of SDA and negedge of SCL for start mark.*/
|
||||
#define I2C_SCL_START_HOLD_TIME 0x000003FF
|
||||
#define I2C_SCL_START_HOLD_TIME_M ((I2C_SCL_START_HOLD_TIME_V)<<(I2C_SCL_START_HOLD_TIME_S))
|
||||
#define I2C_SCL_START_HOLD_TIME_V 0x3FF
|
||||
#define I2C_SCL_START_HOLD_TIME_S 0
|
||||
|
||||
#define I2C_SCL_RSTART_SETUP_REG(i) (REG_I2C_BASE(i) + 0x0044)
|
||||
/* I2C_SCL_RSTART_SETUP_TIME : R/W ;bitpos:[9:0] ;default: 10'b1000 ; */
|
||||
/*description: This register is used to configure the clock num between the
|
||||
posedge of SCL and the negedge of SDA for restart mark.*/
|
||||
#define I2C_SCL_RSTART_SETUP_TIME 0x000003FF
|
||||
#define I2C_SCL_RSTART_SETUP_TIME_M ((I2C_SCL_RSTART_SETUP_TIME_V)<<(I2C_SCL_RSTART_SETUP_TIME_S))
|
||||
#define I2C_SCL_RSTART_SETUP_TIME_V 0x3FF
|
||||
#define I2C_SCL_RSTART_SETUP_TIME_S 0
|
||||
|
||||
#define I2C_SCL_STOP_HOLD_REG(i) (REG_I2C_BASE(i) + 0x0048)
|
||||
/* I2C_SCL_STOP_HOLD_TIME : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This register is used to configure the clock num after the STOP bit's posedge.*/
|
||||
#define I2C_SCL_STOP_HOLD_TIME 0x00003FFF
|
||||
#define I2C_SCL_STOP_HOLD_TIME_M ((I2C_SCL_STOP_HOLD_TIME_V)<<(I2C_SCL_STOP_HOLD_TIME_S))
|
||||
#define I2C_SCL_STOP_HOLD_TIME_V 0x3FFF
|
||||
#define I2C_SCL_STOP_HOLD_TIME_S 0
|
||||
|
||||
#define I2C_SCL_STOP_SETUP_REG(i) (REG_I2C_BASE(i) + 0x004C)
|
||||
/* I2C_SCL_STOP_SETUP_TIME : R/W ;bitpos:[9:0] ;default: 10'b0 ; */
|
||||
/*description: This register is used to configure the clock num between the
|
||||
posedge of SCL and the posedge of SDA.*/
|
||||
#define I2C_SCL_STOP_SETUP_TIME 0x000003FF
|
||||
#define I2C_SCL_STOP_SETUP_TIME_M ((I2C_SCL_STOP_SETUP_TIME_V)<<(I2C_SCL_STOP_SETUP_TIME_S))
|
||||
#define I2C_SCL_STOP_SETUP_TIME_V 0x3FF
|
||||
#define I2C_SCL_STOP_SETUP_TIME_S 0
|
||||
|
||||
#define I2C_SCL_FILTER_CFG_REG(i) (REG_I2C_BASE(i) + 0x0050)
|
||||
/* I2C_SCL_FILTER_EN : R/W ;bitpos:[3] ;default: 1'b1 ; */
|
||||
/*description: This is the filter enable bit for SCL.*/
|
||||
#define I2C_SCL_FILTER_EN (BIT(3))
|
||||
#define I2C_SCL_FILTER_EN_M (BIT(3))
|
||||
#define I2C_SCL_FILTER_EN_V 0x1
|
||||
#define I2C_SCL_FILTER_EN_S 3
|
||||
/* I2C_SCL_FILTER_THRES : R/W ;bitpos:[2:0] ;default: 3'b0 ; */
|
||||
/*description: When input SCL's pulse width is smaller than this register value
|
||||
I2C ignores this pulse.*/
|
||||
#define I2C_SCL_FILTER_THRES 0x00000007
|
||||
#define I2C_SCL_FILTER_THRES_M ((I2C_SCL_FILTER_THRES_V)<<(I2C_SCL_FILTER_THRES_S))
|
||||
#define I2C_SCL_FILTER_THRES_V 0x7
|
||||
#define I2C_SCL_FILTER_THRES_S 0
|
||||
|
||||
#define I2C_SDA_FILTER_CFG_REG(i) (REG_I2C_BASE(i) + 0x0054)
|
||||
/* I2C_SDA_FILTER_EN : R/W ;bitpos:[3] ;default: 1'b1 ; */
|
||||
/*description: This is the filter enable bit for SDA.*/
|
||||
#define I2C_SDA_FILTER_EN (BIT(3))
|
||||
#define I2C_SDA_FILTER_EN_M (BIT(3))
|
||||
#define I2C_SDA_FILTER_EN_V 0x1
|
||||
#define I2C_SDA_FILTER_EN_S 3
|
||||
/* I2C_SDA_FILTER_THRES : R/W ;bitpos:[2:0] ;default: 3'b0 ; */
|
||||
/*description: When input SCL's pulse width is smaller than this register value
|
||||
I2C ignores this pulse.*/
|
||||
#define I2C_SDA_FILTER_THRES 0x00000007
|
||||
#define I2C_SDA_FILTER_THRES_M ((I2C_SDA_FILTER_THRES_V)<<(I2C_SDA_FILTER_THRES_S))
|
||||
#define I2C_SDA_FILTER_THRES_V 0x7
|
||||
#define I2C_SDA_FILTER_THRES_S 0
|
||||
|
||||
#define I2C_COMD0_REG(i) (REG_I2C_BASE(i) + 0x0058)
|
||||
/* I2C_COMMAND0_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command0 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND0_DONE (BIT(31))
|
||||
#define I2C_COMMAND0_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND0_DONE_V 0x1
|
||||
#define I2C_COMMAND0_DONE_S 31
|
||||
/* I2C_COMMAND0 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command0. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND0 0x00003FFF
|
||||
#define I2C_COMMAND0_M ((I2C_COMMAND0_V)<<(I2C_COMMAND0_S))
|
||||
#define I2C_COMMAND0_V 0x3FFF
|
||||
#define I2C_COMMAND0_S 0
|
||||
|
||||
#define I2C_COMD1_REG(i) (REG_I2C_BASE(i) + 0x005C)
|
||||
/* I2C_COMMAND1_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command1 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND1_DONE (BIT(31))
|
||||
#define I2C_COMMAND1_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND1_DONE_V 0x1
|
||||
#define I2C_COMMAND1_DONE_S 31
|
||||
/* I2C_COMMAND1 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command1. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND1 0x00003FFF
|
||||
#define I2C_COMMAND1_M ((I2C_COMMAND1_V)<<(I2C_COMMAND1_S))
|
||||
#define I2C_COMMAND1_V 0x3FFF
|
||||
#define I2C_COMMAND1_S 0
|
||||
|
||||
#define I2C_COMD2_REG(i) (REG_I2C_BASE(i) + 0x0060)
|
||||
/* I2C_COMMAND2_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command2 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND2_DONE (BIT(31))
|
||||
#define I2C_COMMAND2_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND2_DONE_V 0x1
|
||||
#define I2C_COMMAND2_DONE_S 31
|
||||
/* I2C_COMMAND2 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command2. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND2 0x00003FFF
|
||||
#define I2C_COMMAND2_M ((I2C_COMMAND2_V)<<(I2C_COMMAND2_S))
|
||||
#define I2C_COMMAND2_V 0x3FFF
|
||||
#define I2C_COMMAND2_S 0
|
||||
|
||||
#define I2C_COMD3_REG(i) (REG_I2C_BASE(i) + 0x0064)
|
||||
/* I2C_COMMAND3_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command3 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND3_DONE (BIT(31))
|
||||
#define I2C_COMMAND3_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND3_DONE_V 0x1
|
||||
#define I2C_COMMAND3_DONE_S 31
|
||||
/* I2C_COMMAND3 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command3. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND3 0x00003FFF
|
||||
#define I2C_COMMAND3_M ((I2C_COMMAND3_V)<<(I2C_COMMAND3_S))
|
||||
#define I2C_COMMAND3_V 0x3FFF
|
||||
#define I2C_COMMAND3_S 0
|
||||
|
||||
#define I2C_COMD4_REG(i) (REG_I2C_BASE(i) + 0x0068)
|
||||
/* I2C_COMMAND4_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command4 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND4_DONE (BIT(31))
|
||||
#define I2C_COMMAND4_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND4_DONE_V 0x1
|
||||
#define I2C_COMMAND4_DONE_S 31
|
||||
/* I2C_COMMAND4 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command4. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND4 0x00003FFF
|
||||
#define I2C_COMMAND4_M ((I2C_COMMAND4_V)<<(I2C_COMMAND4_S))
|
||||
#define I2C_COMMAND4_V 0x3FFF
|
||||
#define I2C_COMMAND4_S 0
|
||||
|
||||
#define I2C_COMD5_REG(i) (REG_I2C_BASE(i) + 0x006C)
|
||||
/* I2C_COMMAND5_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command5 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND5_DONE (BIT(31))
|
||||
#define I2C_COMMAND5_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND5_DONE_V 0x1
|
||||
#define I2C_COMMAND5_DONE_S 31
|
||||
/* I2C_COMMAND5 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command5. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND5 0x00003FFF
|
||||
#define I2C_COMMAND5_M ((I2C_COMMAND5_V)<<(I2C_COMMAND5_S))
|
||||
#define I2C_COMMAND5_V 0x3FFF
|
||||
#define I2C_COMMAND5_S 0
|
||||
|
||||
#define I2C_COMD6_REG(i) (REG_I2C_BASE(i) + 0x0070)
|
||||
/* I2C_COMMAND6_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command6 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND6_DONE (BIT(31))
|
||||
#define I2C_COMMAND6_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND6_DONE_V 0x1
|
||||
#define I2C_COMMAND6_DONE_S 31
|
||||
/* I2C_COMMAND6 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command6. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND6 0x00003FFF
|
||||
#define I2C_COMMAND6_M ((I2C_COMMAND6_V)<<(I2C_COMMAND6_S))
|
||||
#define I2C_COMMAND6_V 0x3FFF
|
||||
#define I2C_COMMAND6_S 0
|
||||
|
||||
#define I2C_COMD7_REG(i) (REG_I2C_BASE(i) + 0x0074)
|
||||
/* I2C_COMMAND7_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command7 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND7_DONE (BIT(31))
|
||||
#define I2C_COMMAND7_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND7_DONE_V 0x1
|
||||
#define I2C_COMMAND7_DONE_S 31
|
||||
/* I2C_COMMAND7 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command7. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND7 0x00003FFF
|
||||
#define I2C_COMMAND7_M ((I2C_COMMAND7_V)<<(I2C_COMMAND7_S))
|
||||
#define I2C_COMMAND7_V 0x3FFF
|
||||
#define I2C_COMMAND7_S 0
|
||||
|
||||
#define I2C_COMD8_REG(i) (REG_I2C_BASE(i) + 0x0078)
|
||||
/* I2C_COMMAND8_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command8 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND8_DONE (BIT(31))
|
||||
#define I2C_COMMAND8_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND8_DONE_V 0x1
|
||||
#define I2C_COMMAND8_DONE_S 31
|
||||
/* I2C_COMMAND8 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command8. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND8 0x00003FFF
|
||||
#define I2C_COMMAND8_M ((I2C_COMMAND8_V)<<(I2C_COMMAND8_S))
|
||||
#define I2C_COMMAND8_V 0x3FFF
|
||||
#define I2C_COMMAND8_S 0
|
||||
|
||||
#define I2C_COMD9_REG(i) (REG_I2C_BASE(i) + 0x007C)
|
||||
/* I2C_COMMAND9_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command9 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND9_DONE (BIT(31))
|
||||
#define I2C_COMMAND9_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND9_DONE_V 0x1
|
||||
#define I2C_COMMAND9_DONE_S 31
|
||||
/* I2C_COMMAND9 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command9. It consists of three part. op_code
|
||||
is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND9 0x00003FFF
|
||||
#define I2C_COMMAND9_M ((I2C_COMMAND9_V)<<(I2C_COMMAND9_S))
|
||||
#define I2C_COMMAND9_V 0x3FFF
|
||||
#define I2C_COMMAND9_S 0
|
||||
|
||||
#define I2C_COMD10_REG(i) (REG_I2C_BASE(i) + 0x0080)
|
||||
/* I2C_COMMAND10_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command10 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND10_DONE (BIT(31))
|
||||
#define I2C_COMMAND10_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND10_DONE_V 0x1
|
||||
#define I2C_COMMAND10_DONE_S 31
|
||||
/* I2C_COMMAND10 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command10. It consists of three part.
|
||||
op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND10 0x00003FFF
|
||||
#define I2C_COMMAND10_M ((I2C_COMMAND10_V)<<(I2C_COMMAND10_S))
|
||||
#define I2C_COMMAND10_V 0x3FFF
|
||||
#define I2C_COMMAND10_S 0
|
||||
|
||||
#define I2C_COMD11_REG(i) (REG_I2C_BASE(i) + 0x0084)
|
||||
/* I2C_COMMAND11_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command11 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND11_DONE (BIT(31))
|
||||
#define I2C_COMMAND11_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND11_DONE_V 0x1
|
||||
#define I2C_COMMAND11_DONE_S 31
|
||||
/* I2C_COMMAND11 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command11. It consists of three part.
|
||||
op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND11 0x00003FFF
|
||||
#define I2C_COMMAND11_M ((I2C_COMMAND11_V)<<(I2C_COMMAND11_S))
|
||||
#define I2C_COMMAND11_V 0x3FFF
|
||||
#define I2C_COMMAND11_S 0
|
||||
|
||||
#define I2C_COMD12_REG(i) (REG_I2C_BASE(i) + 0x0088)
|
||||
/* I2C_COMMAND12_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command12 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND12_DONE (BIT(31))
|
||||
#define I2C_COMMAND12_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND12_DONE_V 0x1
|
||||
#define I2C_COMMAND12_DONE_S 31
|
||||
/* I2C_COMMAND12 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command12. It consists of three part.
|
||||
op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND12 0x00003FFF
|
||||
#define I2C_COMMAND12_M ((I2C_COMMAND12_V)<<(I2C_COMMAND12_S))
|
||||
#define I2C_COMMAND12_V 0x3FFF
|
||||
#define I2C_COMMAND12_S 0
|
||||
|
||||
#define I2C_COMD13_REG(i) (REG_I2C_BASE(i) + 0x008C)
|
||||
/* I2C_COMMAND13_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command13 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND13_DONE (BIT(31))
|
||||
#define I2C_COMMAND13_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND13_DONE_V 0x1
|
||||
#define I2C_COMMAND13_DONE_S 31
|
||||
/* I2C_COMMAND13 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command13. It consists of three part.
|
||||
op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND13 0x00003FFF
|
||||
#define I2C_COMMAND13_M ((I2C_COMMAND13_V)<<(I2C_COMMAND13_S))
|
||||
#define I2C_COMMAND13_V 0x3FFF
|
||||
#define I2C_COMMAND13_S 0
|
||||
|
||||
#define I2C_COMD14_REG(i) (REG_I2C_BASE(i) + 0x0090)
|
||||
/* I2C_COMMAND14_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command14 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND14_DONE (BIT(31))
|
||||
#define I2C_COMMAND14_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND14_DONE_V 0x1
|
||||
#define I2C_COMMAND14_DONE_S 31
|
||||
/* I2C_COMMAND14 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command14. It consists of three part.
|
||||
op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND14 0x00003FFF
|
||||
#define I2C_COMMAND14_M ((I2C_COMMAND14_V)<<(I2C_COMMAND14_S))
|
||||
#define I2C_COMMAND14_V 0x3FFF
|
||||
#define I2C_COMMAND14_S 0
|
||||
|
||||
#define I2C_COMD15_REG(i) (REG_I2C_BASE(i) + 0x0094)
|
||||
/* I2C_COMMAND15_DONE : R/W ;bitpos:[31] ;default: 1'b0 ; */
|
||||
/*description: When command15 is done in I2C Master mode this bit changes to high level.*/
|
||||
#define I2C_COMMAND15_DONE (BIT(31))
|
||||
#define I2C_COMMAND15_DONE_M (BIT(31))
|
||||
#define I2C_COMMAND15_DONE_V 0x1
|
||||
#define I2C_COMMAND15_DONE_S 31
|
||||
/* I2C_COMMAND15 : R/W ;bitpos:[13:0] ;default: 14'b0 ; */
|
||||
/*description: This is the content of command15. It consists of three part.
|
||||
op_code is the command 0: RSTART 1: WRITE 2: READ 3: STOP . 4:END. Byte_num represent the number of data need to be send or data need to be received. ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
#define I2C_COMMAND15 0x00003FFF
|
||||
#define I2C_COMMAND15_M ((I2C_COMMAND15_V)<<(I2C_COMMAND15_S))
|
||||
#define I2C_COMMAND15_V 0x3FFF
|
||||
#define I2C_COMMAND15_S 0
|
||||
|
||||
#define I2C_DATE_REG(i) (REG_I2C_BASE(i) + 0x00F8)
|
||||
/* I2C_DATE : R/W ;bitpos:[31:0] ;default: 32'h16042000 ; */
|
||||
/*description: */
|
||||
#define I2C_DATE 0xFFFFFFFF
|
||||
#define I2C_DATE_M ((I2C_DATE_V)<<(I2C_DATE_S))
|
||||
#define I2C_DATE_V 0xFFFFFFFF
|
||||
#define I2C_DATE_S 0
|
||||
|
||||
#define I2C_FIFO_START_ADDR_REG(i) (REG_I2C_BASE(i) + 0x0100)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*_SOC_I2C_REG_H_ */
|
||||
|
||||
|
||||
301
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2c_struct.h
Normal file
301
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2c_struct.h
Normal file
@@ -0,0 +1,301 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_I2C_STRUCT_H_
|
||||
#define _SOC_I2C_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct i2c_dev_s {
|
||||
union {
|
||||
struct {
|
||||
uint32_t period:14; /*This register is used to configure the low level width of SCL clock.*/
|
||||
uint32_t reserved14: 18;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_low_period;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sda_force_out: 1; /*1:normally output sda data 0: exchange the function of sda_o and sda_oe (sda_o is the original internal output sda signal sda_oe is the enable bit for the internal output sda signal)*/
|
||||
uint32_t scl_force_out: 1; /*1:normally output scl clock 0: exchange the function of scl_o and scl_oe (scl_o is the original internal output scl signal scl_oe is the enable bit for the internal output scl signal)*/
|
||||
uint32_t sample_scl_level: 1; /*Set this bit to sample data in SCL low level. clear this bit to sample data in SCL high level.*/
|
||||
uint32_t reserved3: 1;
|
||||
uint32_t ms_mode: 1; /*Set this bit to configure the module as i2c master clear this bit to configure the module as i2c slave.*/
|
||||
uint32_t trans_start: 1; /*Set this bit to start sending data in tx_fifo.*/
|
||||
uint32_t tx_lsb_first: 1; /*This bit is used to control the sending mode for data need to be send. 1:receive data from most significant bit 0:receive data from least significant bit*/
|
||||
uint32_t rx_lsb_first: 1; /*This bit is used to control the storage mode for received data. 1:receive data from most significant bit 0:receive data from least significant bit*/
|
||||
uint32_t clk_en: 1; /*This is the clock gating control bit for reading or writing registers.*/
|
||||
uint32_t reserved9: 23;
|
||||
};
|
||||
uint32_t val;
|
||||
} ctr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t ack_rec: 1; /*This register stores the value of ACK bit.*/
|
||||
uint32_t slave_rw: 1; /*when in slave mode 1:master read slave 0: master write slave.*/
|
||||
uint32_t time_out: 1; /*when I2C takes more than time_out_reg clocks to receive a data then this register changes to high level.*/
|
||||
uint32_t arb_lost: 1; /*when I2C lost control of SDA line this register changes to high level.*/
|
||||
uint32_t bus_busy: 1; /*1:I2C bus is busy transferring data. 0:I2C bus is in idle state.*/
|
||||
uint32_t slave_addressed: 1; /*when configured as i2c slave and the address send by master is equal to slave's address then this bit will be high level.*/
|
||||
uint32_t byte_trans: 1; /*This register changes to high level when one byte is transferred.*/
|
||||
uint32_t reserved7: 1;
|
||||
uint32_t rx_fifo_cnt: 6; /*This register represent the amount of data need to send.*/
|
||||
uint32_t reserved14: 4;
|
||||
uint32_t tx_fifo_cnt: 6; /*This register stores the amount of received data in ram.*/
|
||||
uint32_t scl_main_state_last: 3; /*This register stores the value of state machine for i2c module. 3'h0: SCL_MAIN_IDLE 3'h1: SCL_ADDRESS_SHIFT 3'h2: SCL_ACK_ADDRESS 3'h3: SCL_RX_DATA 3'h4 SCL_TX_DATA 3'h5:SCL_SEND_ACK 3'h6:SCL_WAIT_ACK*/
|
||||
uint32_t reserved27: 1;
|
||||
uint32_t scl_state_last: 3; /*This register stores the value of state machine to produce SCL. 3'h0: SCL_IDLE 3'h1:SCL_START 3'h2:SCL_LOW_EDGE 3'h3: SCL_LOW 3'h4:SCL_HIGH_EDGE 3'h5:SCL_HIGH 3'h6:SCL_STOP*/
|
||||
uint32_t reserved31: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} status_reg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tout: 20; /*This register is used to configure the max clock number of receiving a data, unit: APB clock cycle.*/
|
||||
uint32_t reserved20:12;
|
||||
};
|
||||
uint32_t val;
|
||||
} timeout;
|
||||
union {
|
||||
struct {
|
||||
uint32_t addr: 15; /*when configured as i2c slave this register is used to configure slave's address.*/
|
||||
uint32_t reserved15: 16;
|
||||
uint32_t en_10bit: 1; /*This register is used to enable slave 10bit address mode.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} slave_addr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_fifo_start_addr: 5; /*This is the offset address of the last receiving data as described in nonfifo_rx_thres_register.*/
|
||||
uint32_t rx_fifo_end_addr: 5; /*This is the offset address of the first receiving data as described in nonfifo_rx_thres_register.*/
|
||||
uint32_t tx_fifo_start_addr: 5; /*This is the offset address of the first sending data as described in nonfifo_tx_thres register.*/
|
||||
uint32_t tx_fifo_end_addr: 5; /*This is the offset address of the last sending data as described in nonfifo_tx_thres register.*/
|
||||
uint32_t reserved20: 12;
|
||||
};
|
||||
uint32_t val;
|
||||
} fifo_st;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_fifo_full_thrhd: 5;
|
||||
uint32_t tx_fifo_empty_thrhd:5; /*Config tx_fifo empty threhd value when using apb fifo access*/
|
||||
uint32_t nonfifo_en: 1; /*Set this bit to enble apb nonfifo access.*/
|
||||
uint32_t fifo_addr_cfg_en: 1; /*When this bit is set to 1 then the byte after address represent the offset address of I2C Slave's ram.*/
|
||||
uint32_t rx_fifo_rst: 1; /*Set this bit to reset rx fifo when using apb fifo access.*/
|
||||
uint32_t tx_fifo_rst: 1; /*Set this bit to reset tx fifo when using apb fifo access.*/
|
||||
uint32_t nonfifo_rx_thres: 6; /*when I2C receives more than nonfifo_rx_thres data it will produce rx_send_full_int_raw interrupt and update the current offset address of the receiving data.*/
|
||||
uint32_t nonfifo_tx_thres: 6; /*when I2C sends more than nonfifo_tx_thres data it will produce tx_send_empty_int_raw interrupt and update the current offset address of the sending data.*/
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} fifo_conf;
|
||||
union {
|
||||
struct {
|
||||
uint8_t data; /*The register represent the byte data read from rx_fifo when use apb fifo access*/
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
uint32_t val;
|
||||
} fifo_data;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_fifo_full: 1; /*The raw interrupt status bit for rx_fifo full when use apb fifo access.*/
|
||||
uint32_t tx_fifo_empty: 1; /*The raw interrupt status bit for tx_fifo empty when use apb fifo access.*/
|
||||
uint32_t rx_fifo_ovf: 1; /*The raw interrupt status bit for receiving data overflow when use apb fifo access.*/
|
||||
uint32_t end_detect: 1; /*The raw interrupt status bit for end_detect_int interrupt. when I2C deals with the END command it will produce end_detect_int interrupt.*/
|
||||
uint32_t slave_tran_comp: 1; /*The raw interrupt status bit for slave_tran_comp_int interrupt. when I2C Slave detects the STOP bit it will produce slave_tran_comp_int interrupt.*/
|
||||
uint32_t arbitration_lost: 1; /*The raw interrupt status bit for arbitration_lost_int interrupt.when I2C lost the usage right of I2C BUS it will produce arbitration_lost_int interrupt.*/
|
||||
uint32_t master_tran_comp: 1; /*The raw interrupt status bit for master_tra_comp_int interrupt. when I2C Master sends or receives a byte it will produce master_tran_comp_int interrupt.*/
|
||||
uint32_t trans_complete: 1; /*The raw interrupt status bit for trans_complete_int interrupt. when I2C Master finished STOP command it will produce trans_complete_int interrupt.*/
|
||||
uint32_t time_out: 1; /*The raw interrupt status bit for time_out_int interrupt. when I2C takes a lot of time to receive a data it will produce time_out_int interrupt.*/
|
||||
uint32_t trans_start: 1; /*The raw interrupt status bit for trans_start_int interrupt. when I2C sends the START bit it will produce trans_start_int interrupt.*/
|
||||
uint32_t ack_err: 1; /*The raw interrupt status bit for ack_err_int interrupt. when I2C receives a wrong ACK bit it will produce ack_err_int interrupt..*/
|
||||
uint32_t rx_rec_full: 1; /*The raw interrupt status bit for rx_rec_full_int interrupt. when I2C receives more data than nonfifo_rx_thres it will produce rx_rec_full_int interrupt.*/
|
||||
uint32_t tx_send_empty: 1; /*The raw interrupt status bit for tx_send_empty_int interrupt.when I2C sends more data than nonfifo_tx_thres it will produce tx_send_empty_int interrupt..*/
|
||||
uint32_t reserved13: 19;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_raw;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_fifo_full: 1; /*Set this bit to clear the rx_fifo_full_int interrupt.*/
|
||||
uint32_t tx_fifo_empty: 1; /*Set this bit to clear the tx_fifo_empty_int interrupt.*/
|
||||
uint32_t rx_fifo_ovf: 1; /*Set this bit to clear the rx_fifo_ovf_int interrupt.*/
|
||||
uint32_t end_detect: 1; /*Set this bit to clear the end_detect_int interrupt.*/
|
||||
uint32_t slave_tran_comp: 1; /*Set this bit to clear the slave_tran_comp_int interrupt.*/
|
||||
uint32_t arbitration_lost: 1; /*Set this bit to clear the arbitration_lost_int interrupt.*/
|
||||
uint32_t master_tran_comp: 1; /*Set this bit to clear the master_tran_comp interrupt.*/
|
||||
uint32_t trans_complete: 1; /*Set this bit to clear the trans_complete_int interrupt.*/
|
||||
uint32_t time_out: 1; /*Set this bit to clear the time_out_int interrupt.*/
|
||||
uint32_t trans_start: 1; /*Set this bit to clear the trans_start_int interrupt.*/
|
||||
uint32_t ack_err: 1; /*Set this bit to clear the ack_err_int interrupt.*/
|
||||
uint32_t rx_rec_full: 1; /*Set this bit to clear the rx_rec_full_int interrupt.*/
|
||||
uint32_t tx_send_empty: 1; /*Set this bit to clear the tx_send_empty_int interrupt.*/
|
||||
uint32_t reserved13: 19;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_clr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_fifo_full: 1; /*The enable bit for rx_fifo_full_int interrupt.*/
|
||||
uint32_t tx_fifo_empty: 1; /*The enable bit for tx_fifo_empty_int interrupt.*/
|
||||
uint32_t rx_fifo_ovf: 1; /*The enable bit for rx_fifo_ovf_int interrupt.*/
|
||||
uint32_t end_detect: 1; /*The enable bit for end_detect_int interrupt.*/
|
||||
uint32_t slave_tran_comp: 1; /*The enable bit for slave_tran_comp_int interrupt.*/
|
||||
uint32_t arbitration_lost: 1; /*The enable bit for arbitration_lost_int interrupt.*/
|
||||
uint32_t master_tran_comp: 1; /*The enable bit for master_tran_comp_int interrupt.*/
|
||||
uint32_t trans_complete: 1; /*The enable bit for trans_complete_int interrupt.*/
|
||||
uint32_t time_out: 1; /*The enable bit for time_out_int interrupt.*/
|
||||
uint32_t trans_start: 1; /*The enable bit for trans_start_int interrupt.*/
|
||||
uint32_t ack_err: 1; /*The enable bit for ack_err_int interrupt.*/
|
||||
uint32_t rx_rec_full: 1; /*The enable bit for rx_rec_full_int interrupt.*/
|
||||
uint32_t tx_send_empty: 1; /*The enable bit for tx_send_empty_int interrupt.*/
|
||||
uint32_t reserved13: 19;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_fifo_full: 1; /*The masked interrupt status for rx_fifo_full_int interrupt.*/
|
||||
uint32_t tx_fifo_empty: 1; /*The masked interrupt status for tx_fifo_empty_int interrupt.*/
|
||||
uint32_t rx_fifo_ovf: 1; /*The masked interrupt status for rx_fifo_ovf_int interrupt.*/
|
||||
uint32_t end_detect: 1; /*The masked interrupt status for end_detect_int interrupt.*/
|
||||
uint32_t slave_tran_comp: 1; /*The masked interrupt status for slave_tran_comp_int interrupt.*/
|
||||
uint32_t arbitration_lost: 1; /*The masked interrupt status for arbitration_lost_int interrupt.*/
|
||||
uint32_t master_tran_comp: 1; /*The masked interrupt status for master_tran_comp_int interrupt.*/
|
||||
uint32_t trans_complete: 1; /*The masked interrupt status for trans_complete_int interrupt.*/
|
||||
uint32_t time_out: 1; /*The masked interrupt status for time_out_int interrupt.*/
|
||||
uint32_t trans_start: 1; /*The masked interrupt status for trans_start_int interrupt.*/
|
||||
uint32_t ack_err: 1; /*The masked interrupt status for ack_err_int interrupt.*/
|
||||
uint32_t rx_rec_full: 1; /*The masked interrupt status for rx_rec_full_int interrupt.*/
|
||||
uint32_t tx_send_empty: 1; /*The masked interrupt status for tx_send_empty_int interrupt.*/
|
||||
uint32_t reserved13: 19;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_status;
|
||||
union {
|
||||
struct {
|
||||
uint32_t time: 10; /*This register is used to configure the clock num I2C used to hold the data after the negedge of SCL.*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
} sda_hold;
|
||||
union {
|
||||
struct {
|
||||
uint32_t time: 10; /*This register is used to configure the clock num I2C used to sample data on SDA after the posedge of SCL*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
} sda_sample;
|
||||
union {
|
||||
struct {
|
||||
uint32_t period: 14; /*This register is used to configure the clock num during SCL is low level.*/
|
||||
uint32_t reserved14: 18;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_high_period;
|
||||
uint32_t reserved_3c;
|
||||
union {
|
||||
struct {
|
||||
uint32_t time: 10; /*This register is used to configure the clock num between the negedge of SDA and negedge of SCL for start mark.*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_start_hold;
|
||||
union {
|
||||
struct {
|
||||
uint32_t time: 10; /*This register is used to configure the clock num between the posedge of SCL and the negedge of SDA for restart mark.*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_rstart_setup;
|
||||
union {
|
||||
struct {
|
||||
uint32_t time: 14; /*This register is used to configure the clock num after the STOP bit's posedge.*/
|
||||
uint32_t reserved14: 18;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_stop_hold;
|
||||
union {
|
||||
struct {
|
||||
uint32_t time: 10; /*This register is used to configure the clock num between the posedge of SCL and the posedge of SDA.*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_stop_setup;
|
||||
union {
|
||||
struct {
|
||||
uint32_t thres: 3; /*When input SCL's pulse width is smaller than this register value I2C ignores this pulse.*/
|
||||
uint32_t en: 1; /*This is the filter enable bit for SCL.*/
|
||||
uint32_t reserved4: 28;
|
||||
};
|
||||
uint32_t val;
|
||||
} scl_filter_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t thres: 3; /*When input SCL's pulse width is smaller than this register value I2C ignores this pulse.*/
|
||||
uint32_t en: 1; /*This is the filter enable bit for SDA.*/
|
||||
uint32_t reserved4: 28;
|
||||
};
|
||||
uint32_t val;
|
||||
} sda_filter_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t byte_num: 8; /*Byte_num represent the number of data need to be send or data need to be received.*/
|
||||
uint32_t ack_en: 1; /*ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
uint32_t ack_exp: 1; /*ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
uint32_t ack_val: 1; /*ack_check_en ack_exp and ack value are used to control the ack bit.*/
|
||||
uint32_t op_code: 3; /*op_code is the command 0:RSTART 1:WRITE 2:READ 3:STOP . 4:END.*/
|
||||
uint32_t reserved14: 17;
|
||||
uint32_t done: 1; /*When command0 is done in I2C Master mode this bit changes to high level.*/
|
||||
};
|
||||
uint32_t val;
|
||||
} command[16];
|
||||
uint32_t reserved_98;
|
||||
uint32_t reserved_9c;
|
||||
uint32_t reserved_a0;
|
||||
uint32_t reserved_a4;
|
||||
uint32_t reserved_a8;
|
||||
uint32_t reserved_ac;
|
||||
uint32_t reserved_b0;
|
||||
uint32_t reserved_b4;
|
||||
uint32_t reserved_b8;
|
||||
uint32_t reserved_bc;
|
||||
uint32_t reserved_c0;
|
||||
uint32_t reserved_c4;
|
||||
uint32_t reserved_c8;
|
||||
uint32_t reserved_cc;
|
||||
uint32_t reserved_d0;
|
||||
uint32_t reserved_d4;
|
||||
uint32_t reserved_d8;
|
||||
uint32_t reserved_dc;
|
||||
uint32_t reserved_e0;
|
||||
uint32_t reserved_e4;
|
||||
uint32_t reserved_e8;
|
||||
uint32_t reserved_ec;
|
||||
uint32_t reserved_f0;
|
||||
uint32_t reserved_f4;
|
||||
uint32_t date; /**/
|
||||
uint32_t reserved_fc;
|
||||
uint32_t ram_data[32]; /*This the start address for ram when use apb nonfifo access.*/
|
||||
} i2c_dev_t;
|
||||
extern i2c_dev_t I2C0;
|
||||
extern i2c_dev_t I2C1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_I2C_STRUCT_H_ */
|
||||
37
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2s_caps.h
Normal file
37
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2s_caps.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define APLL_MIN_FREQ (250000000)
|
||||
#define APLL_MAX_FREQ (500000000)
|
||||
#define APLL_I2S_MIN_RATE (10675) //in Hz, I2S Clock rate limited by hardware
|
||||
#define I2S_AD_BCK_FACTOR (2)
|
||||
#define I2S_PDM_BCK_FACTOR (64)
|
||||
#define I2S_MAX_BUFFER_SIZE (4 * 1024 * 1024) //the maximum RAM can be allocated
|
||||
#define I2S_BASE_CLK (2*APB_CLK_FREQ)
|
||||
|
||||
// ESP32 have 2 I2S
|
||||
#define SOC_I2S_NUM (2)
|
||||
|
||||
#define SOC_I2S_SUPPORTS_PDM (1) // ESP32 support PDM
|
||||
#define SOC_I2S_SUPPORTS_DMA_EQUAL (0) // ESP32 don't support dma equal
|
||||
#define SOC_I2S_SUPPORTS_ADC_DAC (1) // ESP32 support ADC and DAC
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
1527
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2s_reg.h
Normal file
1527
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2s_reg.h
Normal file
File diff suppressed because it is too large
Load Diff
472
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2s_struct.h
Normal file
472
tools/sdk/esp32/include/soc/soc/esp32/include/soc/i2s_struct.h
Normal file
@@ -0,0 +1,472 @@
|
||||
// Copyright 2015-2016 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.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_I2S_STRUCT_H_
|
||||
#define _SOC_I2S_STRUCT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct i2s_dev_s {
|
||||
uint32_t reserved_0;
|
||||
uint32_t reserved_4;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_reset: 1;
|
||||
uint32_t rx_reset: 1;
|
||||
uint32_t tx_fifo_reset: 1;
|
||||
uint32_t rx_fifo_reset: 1;
|
||||
uint32_t tx_start: 1;
|
||||
uint32_t rx_start: 1;
|
||||
uint32_t tx_slave_mod: 1;
|
||||
uint32_t rx_slave_mod: 1;
|
||||
uint32_t tx_right_first: 1;
|
||||
uint32_t rx_right_first: 1;
|
||||
uint32_t tx_msb_shift: 1;
|
||||
uint32_t rx_msb_shift: 1;
|
||||
uint32_t tx_short_sync: 1;
|
||||
uint32_t rx_short_sync: 1;
|
||||
uint32_t tx_mono: 1;
|
||||
uint32_t rx_mono: 1;
|
||||
uint32_t tx_msb_right: 1;
|
||||
uint32_t rx_msb_right: 1;
|
||||
uint32_t sig_loopback: 1;
|
||||
uint32_t reserved19: 13;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_take_data: 1;
|
||||
uint32_t tx_put_data: 1;
|
||||
uint32_t rx_wfull: 1;
|
||||
uint32_t rx_rempty: 1;
|
||||
uint32_t tx_wfull: 1;
|
||||
uint32_t tx_rempty: 1;
|
||||
uint32_t rx_hung: 1;
|
||||
uint32_t tx_hung: 1;
|
||||
uint32_t in_done: 1;
|
||||
uint32_t in_suc_eof: 1;
|
||||
uint32_t in_err_eof: 1;
|
||||
uint32_t out_done: 1;
|
||||
uint32_t out_eof: 1;
|
||||
uint32_t in_dscr_err: 1;
|
||||
uint32_t out_dscr_err: 1;
|
||||
uint32_t in_dscr_empty: 1;
|
||||
uint32_t out_total_eof: 1;
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_raw;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_take_data: 1;
|
||||
uint32_t tx_put_data: 1;
|
||||
uint32_t rx_wfull: 1;
|
||||
uint32_t rx_rempty: 1;
|
||||
uint32_t tx_wfull: 1;
|
||||
uint32_t tx_rempty: 1;
|
||||
uint32_t rx_hung: 1;
|
||||
uint32_t tx_hung: 1;
|
||||
uint32_t in_done: 1;
|
||||
uint32_t in_suc_eof: 1;
|
||||
uint32_t in_err_eof: 1;
|
||||
uint32_t out_done: 1;
|
||||
uint32_t out_eof: 1;
|
||||
uint32_t in_dscr_err: 1;
|
||||
uint32_t out_dscr_err: 1;
|
||||
uint32_t in_dscr_empty: 1;
|
||||
uint32_t out_total_eof: 1;
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_st;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_take_data: 1;
|
||||
uint32_t tx_put_data: 1;
|
||||
uint32_t rx_wfull: 1;
|
||||
uint32_t rx_rempty: 1;
|
||||
uint32_t tx_wfull: 1;
|
||||
uint32_t tx_rempty: 1;
|
||||
uint32_t rx_hung: 1;
|
||||
uint32_t tx_hung: 1;
|
||||
uint32_t in_done: 1;
|
||||
uint32_t in_suc_eof: 1;
|
||||
uint32_t in_err_eof: 1;
|
||||
uint32_t out_done: 1;
|
||||
uint32_t out_eof: 1;
|
||||
uint32_t in_dscr_err: 1;
|
||||
uint32_t out_dscr_err: 1;
|
||||
uint32_t in_dscr_empty: 1;
|
||||
uint32_t out_total_eof: 1;
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t take_data: 1;
|
||||
uint32_t put_data: 1;
|
||||
uint32_t rx_wfull: 1;
|
||||
uint32_t rx_rempty: 1;
|
||||
uint32_t tx_wfull: 1;
|
||||
uint32_t tx_rempty: 1;
|
||||
uint32_t rx_hung: 1;
|
||||
uint32_t tx_hung: 1;
|
||||
uint32_t in_done: 1;
|
||||
uint32_t in_suc_eof: 1;
|
||||
uint32_t in_err_eof: 1;
|
||||
uint32_t out_done: 1;
|
||||
uint32_t out_eof: 1;
|
||||
uint32_t in_dscr_err: 1;
|
||||
uint32_t out_dscr_err: 1;
|
||||
uint32_t in_dscr_empty: 1;
|
||||
uint32_t out_total_eof: 1;
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} int_clr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_bck_in_delay: 2;
|
||||
uint32_t tx_ws_in_delay: 2;
|
||||
uint32_t rx_bck_in_delay: 2;
|
||||
uint32_t rx_ws_in_delay: 2;
|
||||
uint32_t rx_sd_in_delay: 2;
|
||||
uint32_t tx_bck_out_delay: 2;
|
||||
uint32_t tx_ws_out_delay: 2;
|
||||
uint32_t tx_sd_out_delay: 2;
|
||||
uint32_t rx_ws_out_delay: 2;
|
||||
uint32_t rx_bck_out_delay: 2;
|
||||
uint32_t tx_dsync_sw: 1;
|
||||
uint32_t rx_dsync_sw: 1;
|
||||
uint32_t data_enable_delay: 2;
|
||||
uint32_t tx_bck_in_inv: 1;
|
||||
uint32_t reserved25: 7;
|
||||
};
|
||||
uint32_t val;
|
||||
} timing;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rx_data_num: 6;
|
||||
uint32_t tx_data_num: 6;
|
||||
uint32_t dscr_en: 1;
|
||||
uint32_t tx_fifo_mod: 3;
|
||||
uint32_t rx_fifo_mod: 3;
|
||||
uint32_t tx_fifo_mod_force_en: 1;
|
||||
uint32_t rx_fifo_mod_force_en: 1;
|
||||
uint32_t reserved21: 11;
|
||||
};
|
||||
uint32_t val;
|
||||
} fifo_conf;
|
||||
uint32_t rx_eof_num;
|
||||
uint32_t conf_single_data;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_chan_mod: 3;
|
||||
uint32_t rx_chan_mod: 2;
|
||||
uint32_t reserved5: 27;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf_chan;
|
||||
union {
|
||||
struct {
|
||||
uint32_t addr: 20;
|
||||
uint32_t reserved20: 8;
|
||||
uint32_t stop: 1;
|
||||
uint32_t start: 1;
|
||||
uint32_t restart: 1;
|
||||
uint32_t park: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} out_link;
|
||||
union {
|
||||
struct {
|
||||
uint32_t addr: 20;
|
||||
uint32_t reserved20: 8;
|
||||
uint32_t stop: 1;
|
||||
uint32_t start: 1;
|
||||
uint32_t restart: 1;
|
||||
uint32_t park: 1;
|
||||
};
|
||||
uint32_t val;
|
||||
} in_link;
|
||||
uint32_t out_eof_des_addr;
|
||||
uint32_t in_eof_des_addr;
|
||||
uint32_t out_eof_bfr_des_addr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t mode: 3;
|
||||
uint32_t reserved3: 1;
|
||||
uint32_t addr: 2;
|
||||
uint32_t reserved6: 26;
|
||||
};
|
||||
uint32_t val;
|
||||
} ahb_test;
|
||||
uint32_t in_link_dscr;
|
||||
uint32_t in_link_dscr_bf0;
|
||||
uint32_t in_link_dscr_bf1;
|
||||
uint32_t out_link_dscr;
|
||||
uint32_t out_link_dscr_bf0;
|
||||
uint32_t out_link_dscr_bf1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t in_rst: 1;
|
||||
uint32_t out_rst: 1;
|
||||
uint32_t ahbm_fifo_rst: 1;
|
||||
uint32_t ahbm_rst: 1;
|
||||
uint32_t out_loop_test: 1;
|
||||
uint32_t in_loop_test: 1;
|
||||
uint32_t out_auto_wrback: 1;
|
||||
uint32_t out_no_restart_clr: 1;
|
||||
uint32_t out_eof_mode: 1;
|
||||
uint32_t outdscr_burst_en: 1;
|
||||
uint32_t indscr_burst_en: 1;
|
||||
uint32_t out_data_burst_en: 1;
|
||||
uint32_t check_owner: 1;
|
||||
uint32_t mem_trans_en: 1;
|
||||
uint32_t reserved14: 18;
|
||||
};
|
||||
uint32_t val;
|
||||
} lc_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t wdata: 9;
|
||||
uint32_t reserved9: 7;
|
||||
uint32_t push: 1;
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} out_fifo_push;
|
||||
union {
|
||||
struct {
|
||||
uint32_t rdata: 12;
|
||||
uint32_t reserved12: 4;
|
||||
uint32_t pop: 1;
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
} in_fifo_pop;
|
||||
uint32_t lc_state0;
|
||||
uint32_t lc_state1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t fifo_timeout: 8;
|
||||
uint32_t fifo_timeout_shift: 3;
|
||||
uint32_t fifo_timeout_ena: 1;
|
||||
uint32_t reserved12: 20;
|
||||
};
|
||||
uint32_t val;
|
||||
} lc_hung_conf;
|
||||
uint32_t reserved_78;
|
||||
uint32_t reserved_7c;
|
||||
union {
|
||||
struct {
|
||||
uint32_t y_max:16;
|
||||
uint32_t y_min:16;
|
||||
};
|
||||
uint32_t val;
|
||||
} cvsd_conf0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sigma_max:16;
|
||||
uint32_t sigma_min:16;
|
||||
};
|
||||
uint32_t val;
|
||||
} cvsd_conf1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cvsd_k: 3;
|
||||
uint32_t cvsd_j: 3;
|
||||
uint32_t cvsd_beta: 10;
|
||||
uint32_t cvsd_h: 3;
|
||||
uint32_t reserved19:13;
|
||||
};
|
||||
uint32_t val;
|
||||
} cvsd_conf2;
|
||||
union {
|
||||
struct {
|
||||
uint32_t good_pack_max: 6;
|
||||
uint32_t n_err_seg: 3;
|
||||
uint32_t shift_rate: 3;
|
||||
uint32_t max_slide_sample: 8;
|
||||
uint32_t pack_len_8k: 5;
|
||||
uint32_t n_min_err: 3;
|
||||
uint32_t reserved28: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
} plc_conf0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t bad_cef_atten_para: 8;
|
||||
uint32_t bad_cef_atten_para_shift: 4;
|
||||
uint32_t bad_ola_win2_para_shift: 4;
|
||||
uint32_t bad_ola_win2_para: 8;
|
||||
uint32_t slide_win_len: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} plc_conf1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cvsd_seg_mod: 2;
|
||||
uint32_t min_period: 5;
|
||||
uint32_t reserved7: 25;
|
||||
};
|
||||
uint32_t val;
|
||||
} plc_conf2;
|
||||
union {
|
||||
struct {
|
||||
uint32_t en: 1;
|
||||
uint32_t chan_mod: 1;
|
||||
uint32_t cvsd_dec_pack_err: 1;
|
||||
uint32_t cvsd_pack_len_8k: 5;
|
||||
uint32_t cvsd_inf_en: 1;
|
||||
uint32_t cvsd_dec_start: 1;
|
||||
uint32_t cvsd_dec_reset: 1;
|
||||
uint32_t plc_en: 1;
|
||||
uint32_t plc2dma_en: 1;
|
||||
uint32_t reserved13: 19;
|
||||
};
|
||||
uint32_t val;
|
||||
} esco_conf0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t with_en: 1;
|
||||
uint32_t no_en: 1;
|
||||
uint32_t cvsd_enc_start: 1;
|
||||
uint32_t cvsd_enc_reset: 1;
|
||||
uint32_t reserved4: 28;
|
||||
};
|
||||
uint32_t val;
|
||||
} sco_conf0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_pcm_conf: 3;
|
||||
uint32_t tx_pcm_bypass: 1;
|
||||
uint32_t rx_pcm_conf: 3;
|
||||
uint32_t rx_pcm_bypass: 1;
|
||||
uint32_t tx_stop_en: 1;
|
||||
uint32_t tx_zeros_rm_en: 1;
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t fifo_force_pd: 1;
|
||||
uint32_t fifo_force_pu: 1;
|
||||
uint32_t plc_mem_force_pd: 1;
|
||||
uint32_t plc_mem_force_pu: 1;
|
||||
uint32_t reserved4: 28;
|
||||
};
|
||||
uint32_t val;
|
||||
} pd_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t camera_en: 1;
|
||||
uint32_t lcd_tx_wrx2_en: 1;
|
||||
uint32_t lcd_tx_sdx2_en: 1;
|
||||
uint32_t data_enable_test_en: 1;
|
||||
uint32_t data_enable: 1;
|
||||
uint32_t lcd_en: 1;
|
||||
uint32_t ext_adc_start_en: 1;
|
||||
uint32_t inter_valid_en: 1;
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
} conf2;
|
||||
union {
|
||||
struct {
|
||||
uint32_t clkm_div_num: 8;
|
||||
uint32_t clkm_div_b: 6;
|
||||
uint32_t clkm_div_a: 6;
|
||||
uint32_t clk_en: 1;
|
||||
uint32_t clka_en: 1;
|
||||
uint32_t reserved22: 10;
|
||||
};
|
||||
uint32_t val;
|
||||
} clkm_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_bck_div_num: 6;
|
||||
uint32_t rx_bck_div_num: 6;
|
||||
uint32_t tx_bits_mod: 6;
|
||||
uint32_t rx_bits_mod: 6;
|
||||
uint32_t reserved24: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
} sample_rate_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_pdm_en: 1;
|
||||
uint32_t rx_pdm_en: 1;
|
||||
uint32_t pcm2pdm_conv_en: 1;
|
||||
uint32_t pdm2pcm_conv_en: 1;
|
||||
uint32_t tx_sinc_osr2: 4;
|
||||
uint32_t tx_prescale: 8;
|
||||
uint32_t tx_hp_in_shift: 2;
|
||||
uint32_t tx_lp_in_shift: 2;
|
||||
uint32_t tx_sinc_in_shift: 2;
|
||||
uint32_t tx_sigmadelta_in_shift: 2;
|
||||
uint32_t rx_sinc_dsr_16_en: 1;
|
||||
uint32_t txhp_bypass: 1;
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
} pdm_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_pdm_fs: 10;
|
||||
uint32_t tx_pdm_fp: 10;
|
||||
uint32_t reserved20:12;
|
||||
};
|
||||
uint32_t val;
|
||||
} pdm_freq_conf;
|
||||
union {
|
||||
struct {
|
||||
uint32_t tx_idle: 1;
|
||||
uint32_t tx_fifo_reset_back: 1;
|
||||
uint32_t rx_fifo_reset_back: 1;
|
||||
uint32_t reserved3: 29;
|
||||
};
|
||||
uint32_t val;
|
||||
} state;
|
||||
uint32_t reserved_c0;
|
||||
uint32_t reserved_c4;
|
||||
uint32_t reserved_c8;
|
||||
uint32_t reserved_cc;
|
||||
uint32_t reserved_d0;
|
||||
uint32_t reserved_d4;
|
||||
uint32_t reserved_d8;
|
||||
uint32_t reserved_dc;
|
||||
uint32_t reserved_e0;
|
||||
uint32_t reserved_e4;
|
||||
uint32_t reserved_e8;
|
||||
uint32_t reserved_ec;
|
||||
uint32_t reserved_f0;
|
||||
uint32_t reserved_f4;
|
||||
uint32_t reserved_f8;
|
||||
uint32_t date; /**/
|
||||
} i2s_dev_t;
|
||||
extern i2s_dev_t I2S0;
|
||||
extern i2s_dev_t I2S1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_I2S_STRUCT_H_ */
|
||||
355
tools/sdk/esp32/include/soc/soc/esp32/include/soc/io_mux_reg.h
Normal file
355
tools/sdk/esp32/include/soc/soc/esp32/include/soc/io_mux_reg.h
Normal file
@@ -0,0 +1,355 @@
|
||||
// Copyright 2015-2017 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef _SOC_IO_MUX_REG_H_
|
||||
#define _SOC_IO_MUX_REG_H_
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
/* The following are the bit fields for PERIPHS_IO_MUX_x_U registers */
|
||||
/* Output enable in sleep mode */
|
||||
#define SLP_OE (BIT(0))
|
||||
#define SLP_OE_M (BIT(0))
|
||||
#define SLP_OE_V 1
|
||||
#define SLP_OE_S 0
|
||||
/* Pin used for wakeup from sleep */
|
||||
#define SLP_SEL (BIT(1))
|
||||
#define SLP_SEL_M (BIT(1))
|
||||
#define SLP_SEL_V 1
|
||||
#define SLP_SEL_S 1
|
||||
/* Pulldown enable in sleep mode */
|
||||
#define SLP_PD (BIT(2))
|
||||
#define SLP_PD_M (BIT(2))
|
||||
#define SLP_PD_V 1
|
||||
#define SLP_PD_S 2
|
||||
/* Pullup enable in sleep mode */
|
||||
#define SLP_PU (BIT(3))
|
||||
#define SLP_PU_M (BIT(3))
|
||||
#define SLP_PU_V 1
|
||||
#define SLP_PU_S 3
|
||||
/* Input enable in sleep mode */
|
||||
#define SLP_IE (BIT(4))
|
||||
#define SLP_IE_M (BIT(4))
|
||||
#define SLP_IE_V 1
|
||||
#define SLP_IE_S 4
|
||||
/* Drive strength in sleep mode */
|
||||
#define SLP_DRV 0x3
|
||||
#define SLP_DRV_M (SLP_DRV_V << SLP_DRV_S)
|
||||
#define SLP_DRV_V 0x3
|
||||
#define SLP_DRV_S 5
|
||||
/* Pulldown enable */
|
||||
#define FUN_PD (BIT(7))
|
||||
#define FUN_PD_M (BIT(7))
|
||||
#define FUN_PD_V 1
|
||||
#define FUN_PD_S 7
|
||||
/* Pullup enable */
|
||||
#define FUN_PU (BIT(8))
|
||||
#define FUN_PU_M (BIT(8))
|
||||
#define FUN_PU_V 1
|
||||
#define FUN_PU_S 8
|
||||
/* Input enable */
|
||||
#define FUN_IE (BIT(9))
|
||||
#define FUN_IE_M (FUN_IE_V << FUN_IE_S)
|
||||
#define FUN_IE_V 1
|
||||
#define FUN_IE_S 9
|
||||
/* Drive strength */
|
||||
#define FUN_DRV 0x3
|
||||
#define FUN_DRV_M (FUN_DRV_V << FUN_DRV_S)
|
||||
#define FUN_DRV_V 0x3
|
||||
#define FUN_DRV_S 10
|
||||
/* Function select (possible values are defined for each pin as FUNC_pinname_function below) */
|
||||
#define MCU_SEL 0x7
|
||||
#define MCU_SEL_M (MCU_SEL_V << MCU_SEL_S)
|
||||
#define MCU_SEL_V 0x7
|
||||
#define MCU_SEL_S 12
|
||||
|
||||
#define PIN_INPUT_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,FUN_IE)
|
||||
#define PIN_INPUT_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,FUN_IE)
|
||||
#define PIN_SET_DRV(PIN_NAME, drv) REG_SET_FIELD(PIN_NAME, FUN_DRV, (drv));
|
||||
|
||||
#define PIN_FUNC_SELECT(PIN_NAME, FUNC) REG_SET_FIELD(PIN_NAME, MCU_SEL, FUNC)
|
||||
|
||||
#define PIN_FUNC_GPIO 2
|
||||
|
||||
#define SPI_CLK_GPIO_NUM 6
|
||||
#define SPI_CS0_GPIO_NUM 11
|
||||
#define SPI_Q_GPIO_NUM 7
|
||||
#define SPI_D_GPIO_NUM 8
|
||||
#define SPI_WP_GPIO_NUM 10
|
||||
#define SPI_HD_GPIO_NUM 9
|
||||
|
||||
#define PIN_CTRL (DR_REG_IO_MUX_BASE +0x00)
|
||||
#define CLK_OUT3 0xf
|
||||
#define CLK_OUT3_V CLK_OUT3
|
||||
#define CLK_OUT3_S 8
|
||||
#define CLK_OUT3_M (CLK_OUT3_V << CLK_OUT3_S)
|
||||
#define CLK_OUT2 0xf
|
||||
#define CLK_OUT2_V CLK_OUT2
|
||||
#define CLK_OUT2_S 4
|
||||
#define CLK_OUT2_M (CLK_OUT2_V << CLK_OUT2_S)
|
||||
#define CLK_OUT1 0xf
|
||||
#define CLK_OUT1_V CLK_OUT1
|
||||
#define CLK_OUT1_S 0
|
||||
#define CLK_OUT1_M (CLK_OUT1_V << CLK_OUT1_S)
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO0_U (DR_REG_IO_MUX_BASE +0x44)
|
||||
#define IO_MUX_GPIO0_REG PERIPHS_IO_MUX_GPIO0_U
|
||||
#define FUNC_GPIO0_EMAC_TX_CLK 5
|
||||
#define FUNC_GPIO0_GPIO0 2
|
||||
#define FUNC_GPIO0_CLK_OUT1 1
|
||||
#define FUNC_GPIO0_GPIO0_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_U0TXD_U (DR_REG_IO_MUX_BASE +0x88)
|
||||
#define IO_MUX_GPIO1_REG PERIPHS_IO_MUX_U0TXD_U
|
||||
#define FUNC_U0TXD_EMAC_RXD2 5
|
||||
#define FUNC_U0TXD_GPIO1 2
|
||||
#define FUNC_U0TXD_CLK_OUT3 1
|
||||
#define FUNC_U0TXD_U0TXD 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO2_U (DR_REG_IO_MUX_BASE +0x40)
|
||||
#define IO_MUX_GPIO2_REG PERIPHS_IO_MUX_GPIO2_U
|
||||
#define FUNC_GPIO2_SD_DATA0 4
|
||||
#define FUNC_GPIO2_HS2_DATA0 3
|
||||
#define FUNC_GPIO2_GPIO2 2
|
||||
#define FUNC_GPIO2_HSPIWP 1
|
||||
#define FUNC_GPIO2_GPIO2_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_U0RXD_U (DR_REG_IO_MUX_BASE +0x84)
|
||||
#define IO_MUX_GPIO3_REG PERIPHS_IO_MUX_U0RXD_U
|
||||
#define FUNC_U0RXD_GPIO3 2
|
||||
#define FUNC_U0RXD_CLK_OUT2 1
|
||||
#define FUNC_U0RXD_U0RXD 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO4_U (DR_REG_IO_MUX_BASE +0x48)
|
||||
#define IO_MUX_GPIO4_REG PERIPHS_IO_MUX_GPIO4_U
|
||||
#define FUNC_GPIO4_EMAC_TX_ER 5
|
||||
#define FUNC_GPIO4_SD_DATA1 4
|
||||
#define FUNC_GPIO4_HS2_DATA1 3
|
||||
#define FUNC_GPIO4_GPIO4 2
|
||||
#define FUNC_GPIO4_HSPIHD 1
|
||||
#define FUNC_GPIO4_GPIO4_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO5_U (DR_REG_IO_MUX_BASE +0x6c)
|
||||
#define IO_MUX_GPIO5_REG PERIPHS_IO_MUX_GPIO5_U
|
||||
#define FUNC_GPIO5_EMAC_RX_CLK 5
|
||||
#define FUNC_GPIO5_HS1_DATA6 3
|
||||
#define FUNC_GPIO5_GPIO5 2
|
||||
#define FUNC_GPIO5_VSPICS0 1
|
||||
#define FUNC_GPIO5_GPIO5_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_SD_CLK_U (DR_REG_IO_MUX_BASE +0x60)
|
||||
#define IO_MUX_GPIO6_REG PERIPHS_IO_MUX_SD_CLK_U
|
||||
#define FUNC_SD_CLK_U1CTS 4
|
||||
#define FUNC_SD_CLK_HS1_CLK 3
|
||||
#define FUNC_SD_CLK_GPIO6 2
|
||||
#define FUNC_SD_CLK_SPICLK 1
|
||||
#define FUNC_SD_CLK_SD_CLK 0
|
||||
|
||||
#define PERIPHS_IO_MUX_SD_DATA0_U (DR_REG_IO_MUX_BASE +0x64)
|
||||
#define IO_MUX_GPIO7_REG PERIPHS_IO_MUX_SD_DATA0_U
|
||||
#define FUNC_SD_DATA0_U2RTS 4
|
||||
#define FUNC_SD_DATA0_HS1_DATA0 3
|
||||
#define FUNC_SD_DATA0_GPIO7 2
|
||||
#define FUNC_SD_DATA0_SPIQ 1
|
||||
#define FUNC_SD_DATA0_SD_DATA0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_SD_DATA1_U (DR_REG_IO_MUX_BASE +0x68)
|
||||
#define IO_MUX_GPIO8_REG PERIPHS_IO_MUX_SD_DATA1_U
|
||||
#define FUNC_SD_DATA1_U2CTS 4
|
||||
#define FUNC_SD_DATA1_HS1_DATA1 3
|
||||
#define FUNC_SD_DATA1_GPIO8 2
|
||||
#define FUNC_SD_DATA1_SPID 1
|
||||
#define FUNC_SD_DATA1_SD_DATA1 0
|
||||
|
||||
#define PERIPHS_IO_MUX_SD_DATA2_U (DR_REG_IO_MUX_BASE +0x54)
|
||||
#define IO_MUX_GPIO9_REG PERIPHS_IO_MUX_SD_DATA2_U
|
||||
#define FUNC_SD_DATA2_U1RXD 4
|
||||
#define FUNC_SD_DATA2_HS1_DATA2 3
|
||||
#define FUNC_SD_DATA2_GPIO9 2
|
||||
#define FUNC_SD_DATA2_SPIHD 1
|
||||
#define FUNC_SD_DATA2_SD_DATA2 0
|
||||
|
||||
#define PERIPHS_IO_MUX_SD_DATA3_U (DR_REG_IO_MUX_BASE +0x58)
|
||||
#define IO_MUX_GPIO10_REG PERIPHS_IO_MUX_SD_DATA3_U
|
||||
#define FUNC_SD_DATA3_U1TXD 4
|
||||
#define FUNC_SD_DATA3_HS1_DATA3 3
|
||||
#define FUNC_SD_DATA3_GPIO10 2
|
||||
#define FUNC_SD_DATA3_SPIWP 1
|
||||
#define FUNC_SD_DATA3_SD_DATA3 0
|
||||
|
||||
#define PERIPHS_IO_MUX_SD_CMD_U (DR_REG_IO_MUX_BASE +0x5c)
|
||||
#define IO_MUX_GPIO11_REG PERIPHS_IO_MUX_SD_CMD_U
|
||||
#define FUNC_SD_CMD_U1RTS 4
|
||||
#define FUNC_SD_CMD_HS1_CMD 3
|
||||
#define FUNC_SD_CMD_GPIO11 2
|
||||
#define FUNC_SD_CMD_SPICS0 1
|
||||
#define FUNC_SD_CMD_SD_CMD 0
|
||||
|
||||
#define PERIPHS_IO_MUX_MTDI_U (DR_REG_IO_MUX_BASE +0x34)
|
||||
#define IO_MUX_GPIO12_REG PERIPHS_IO_MUX_MTDI_U
|
||||
#define FUNC_MTDI_EMAC_TXD3 5
|
||||
#define FUNC_MTDI_SD_DATA2 4
|
||||
#define FUNC_MTDI_HS2_DATA2 3
|
||||
#define FUNC_MTDI_GPIO12 2
|
||||
#define FUNC_MTDI_HSPIQ 1
|
||||
#define FUNC_MTDI_MTDI 0
|
||||
|
||||
#define PERIPHS_IO_MUX_MTCK_U (DR_REG_IO_MUX_BASE +0x38)
|
||||
#define IO_MUX_GPIO13_REG PERIPHS_IO_MUX_MTCK_U
|
||||
#define FUNC_MTCK_EMAC_RX_ER 5
|
||||
#define FUNC_MTCK_SD_DATA3 4
|
||||
#define FUNC_MTCK_HS2_DATA3 3
|
||||
#define FUNC_MTCK_GPIO13 2
|
||||
#define FUNC_MTCK_HSPID 1
|
||||
#define FUNC_MTCK_MTCK 0
|
||||
|
||||
#define PERIPHS_IO_MUX_MTMS_U (DR_REG_IO_MUX_BASE +0x30)
|
||||
#define IO_MUX_GPIO14_REG PERIPHS_IO_MUX_MTMS_U
|
||||
#define FUNC_MTMS_EMAC_TXD2 5
|
||||
#define FUNC_MTMS_SD_CLK 4
|
||||
#define FUNC_MTMS_HS2_CLK 3
|
||||
#define FUNC_MTMS_GPIO14 2
|
||||
#define FUNC_MTMS_HSPICLK 1
|
||||
#define FUNC_MTMS_MTMS 0
|
||||
|
||||
#define PERIPHS_IO_MUX_MTDO_U (DR_REG_IO_MUX_BASE +0x3c)
|
||||
#define IO_MUX_GPIO15_REG PERIPHS_IO_MUX_MTDO_U
|
||||
#define FUNC_MTDO_EMAC_RXD3 5
|
||||
#define FUNC_MTDO_SD_CMD 4
|
||||
#define FUNC_MTDO_HS2_CMD 3
|
||||
#define FUNC_MTDO_GPIO15 2
|
||||
#define FUNC_MTDO_HSPICS0 1
|
||||
#define FUNC_MTDO_MTDO 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO16_U (DR_REG_IO_MUX_BASE +0x4c)
|
||||
#define IO_MUX_GPIO16_REG PERIPHS_IO_MUX_GPIO16_U
|
||||
#define FUNC_GPIO16_EMAC_CLK_OUT 5
|
||||
#define FUNC_GPIO16_U2RXD 4
|
||||
#define FUNC_GPIO16_HS1_DATA4 3
|
||||
#define FUNC_GPIO16_GPIO16 2
|
||||
#define FUNC_GPIO16_GPIO16_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO17_U (DR_REG_IO_MUX_BASE +0x50)
|
||||
#define IO_MUX_GPIO17_REG PERIPHS_IO_MUX_GPIO17_U
|
||||
#define FUNC_GPIO17_EMAC_CLK_OUT_180 5
|
||||
#define FUNC_GPIO17_U2TXD 4
|
||||
#define FUNC_GPIO17_HS1_DATA5 3
|
||||
#define FUNC_GPIO17_GPIO17 2
|
||||
#define FUNC_GPIO17_GPIO17_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO18_U (DR_REG_IO_MUX_BASE +0x70)
|
||||
#define IO_MUX_GPIO18_REG PERIPHS_IO_MUX_GPIO18_U
|
||||
#define FUNC_GPIO18_HS1_DATA7 3
|
||||
#define FUNC_GPIO18_GPIO18 2
|
||||
#define FUNC_GPIO18_VSPICLK 1
|
||||
#define FUNC_GPIO18_GPIO18_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO19_U (DR_REG_IO_MUX_BASE +0x74)
|
||||
#define IO_MUX_GPIO19_REG PERIPHS_IO_MUX_GPIO19_U
|
||||
#define FUNC_GPIO19_EMAC_TXD0 5
|
||||
#define FUNC_GPIO19_U0CTS 3
|
||||
#define FUNC_GPIO19_GPIO19 2
|
||||
#define FUNC_GPIO19_VSPIQ 1
|
||||
#define FUNC_GPIO19_GPIO19_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO20_U (DR_REG_IO_MUX_BASE +0x78)
|
||||
#define IO_MUX_GPIO20_REG PERIPHS_IO_MUX_GPIO20_U
|
||||
#define FUNC_GPIO20_GPIO20 2
|
||||
#define FUNC_GPIO20_GPIO20_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO21_U (DR_REG_IO_MUX_BASE +0x7c)
|
||||
#define IO_MUX_GPIO21_REG PERIPHS_IO_MUX_GPIO21_U
|
||||
#define FUNC_GPIO21_EMAC_TX_EN 5
|
||||
#define FUNC_GPIO21_GPIO21 2
|
||||
#define FUNC_GPIO21_VSPIHD 1
|
||||
#define FUNC_GPIO21_GPIO21_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO22_U (DR_REG_IO_MUX_BASE +0x80)
|
||||
#define IO_MUX_GPIO22_REG PERIPHS_IO_MUX_GPIO22_U
|
||||
#define FUNC_GPIO22_EMAC_TXD1 5
|
||||
#define FUNC_GPIO22_U0RTS 3
|
||||
#define FUNC_GPIO22_GPIO22 2
|
||||
#define FUNC_GPIO22_VSPIWP 1
|
||||
#define FUNC_GPIO22_GPIO22_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO23_U (DR_REG_IO_MUX_BASE +0x8c)
|
||||
#define IO_MUX_GPIO23_REG PERIPHS_IO_MUX_GPIO23_U
|
||||
#define FUNC_GPIO23_HS1_STROBE 3
|
||||
#define FUNC_GPIO23_GPIO23 2
|
||||
#define FUNC_GPIO23_VSPID 1
|
||||
#define FUNC_GPIO23_GPIO23_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO24_U (DR_REG_IO_MUX_BASE +0x90)
|
||||
#define IO_MUX_GPIO24_REG PERIPHS_IO_MUX_GPIO24_U
|
||||
#define FUNC_GPIO24_GPIO24 2
|
||||
#define FUNC_GPIO24_GPIO24_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO25_U (DR_REG_IO_MUX_BASE +0x24)
|
||||
#define IO_MUX_GPIO25_REG PERIPHS_IO_MUX_GPIO25_U
|
||||
#define FUNC_GPIO25_EMAC_RXD0 5
|
||||
#define FUNC_GPIO25_GPIO25 2
|
||||
#define FUNC_GPIO25_GPIO25_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO26_U (DR_REG_IO_MUX_BASE +0x28)
|
||||
#define IO_MUX_GPIO26_REG PERIPHS_IO_MUX_GPIO26_U
|
||||
#define FUNC_GPIO26_EMAC_RXD1 5
|
||||
#define FUNC_GPIO26_GPIO26 2
|
||||
#define FUNC_GPIO26_GPIO26_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO27_U (DR_REG_IO_MUX_BASE +0x2c)
|
||||
#define IO_MUX_GPIO27_REG PERIPHS_IO_MUX_GPIO27_U
|
||||
#define FUNC_GPIO27_EMAC_RX_DV 5
|
||||
#define FUNC_GPIO27_GPIO27 2
|
||||
#define FUNC_GPIO27_GPIO27_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO32_U (DR_REG_IO_MUX_BASE +0x1c)
|
||||
#define IO_MUX_GPIO32_REG PERIPHS_IO_MUX_GPIO32_U
|
||||
#define FUNC_GPIO32_GPIO32 2
|
||||
#define FUNC_GPIO32_GPIO32_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO33_U (DR_REG_IO_MUX_BASE +0x20)
|
||||
#define IO_MUX_GPIO33_REG PERIPHS_IO_MUX_GPIO33_U
|
||||
#define FUNC_GPIO33_GPIO33 2
|
||||
#define FUNC_GPIO33_GPIO33_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO34_U (DR_REG_IO_MUX_BASE +0x14)
|
||||
#define IO_MUX_GPIO34_REG PERIPHS_IO_MUX_GPIO34_U
|
||||
#define FUNC_GPIO34_GPIO34 2
|
||||
#define FUNC_GPIO34_GPIO34_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO35_U (DR_REG_IO_MUX_BASE +0x18)
|
||||
#define IO_MUX_GPIO35_REG PERIPHS_IO_MUX_GPIO35_U
|
||||
#define FUNC_GPIO35_GPIO35 2
|
||||
#define FUNC_GPIO35_GPIO35_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO36_U (DR_REG_IO_MUX_BASE +0x04)
|
||||
#define IO_MUX_GPIO36_REG PERIPHS_IO_MUX_GPIO36_U
|
||||
#define FUNC_GPIO36_GPIO36 2
|
||||
#define FUNC_GPIO36_GPIO36_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO37_U (DR_REG_IO_MUX_BASE +0x08)
|
||||
#define IO_MUX_GPIO37_REG PERIPHS_IO_MUX_GPIO37_U
|
||||
#define FUNC_GPIO37_GPIO37 2
|
||||
#define FUNC_GPIO37_GPIO37_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO38_U (DR_REG_IO_MUX_BASE +0x0c)
|
||||
#define IO_MUX_GPIO38_REG PERIPHS_IO_MUX_GPIO38_U
|
||||
#define FUNC_GPIO38_GPIO38 2
|
||||
#define FUNC_GPIO38_GPIO38_0 0
|
||||
|
||||
#define PERIPHS_IO_MUX_GPIO39_U (DR_REG_IO_MUX_BASE +0x10)
|
||||
#define IO_MUX_GPIO39_REG PERIPHS_IO_MUX_GPIO39_U
|
||||
#define FUNC_GPIO39_GPIO39 2
|
||||
#define FUNC_GPIO39_GPIO39_0 0
|
||||
|
||||
#endif /* _SOC_IO_MUX_REG_H_ */
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2015-2019 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.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SOC_LEDC_SUPPORT_HS_MODE (1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user