mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 21:10:58 +02:00
Update IDF to 9a26296
This commit is contained in:
@ -21,6 +21,8 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/adc_channel.h"
|
||||
|
||||
typedef enum {
|
||||
ADC_ATTEN_0db = 0, /*!<The input voltage of ADC will be reduced to about 1/1 */
|
||||
@ -48,6 +50,20 @@ typedef enum {
|
||||
ADC1_CHANNEL_MAX,
|
||||
} adc1_channel_t;
|
||||
|
||||
typedef enum {
|
||||
ADC2_CHANNEL_0 = 0, /*!< ADC2 channel 0 is GPIO4 */
|
||||
ADC2_CHANNEL_1, /*!< ADC2 channel 1 is GPIO0 */
|
||||
ADC2_CHANNEL_2, /*!< ADC2 channel 2 is GPIO2 */
|
||||
ADC2_CHANNEL_3, /*!< ADC2 channel 3 is GPIO15 */
|
||||
ADC2_CHANNEL_4, /*!< ADC2 channel 4 is GPIO13 */
|
||||
ADC2_CHANNEL_5, /*!< ADC2 channel 5 is GPIO12 */
|
||||
ADC2_CHANNEL_6, /*!< ADC2 channel 6 is GPIO14 */
|
||||
ADC2_CHANNEL_7, /*!< ADC2 channel 7 is GPIO27 */
|
||||
ADC2_CHANNEL_8, /*!< ADC2 channel 8 is GPIO25 */
|
||||
ADC2_CHANNEL_9, /*!< ADC2 channel 9 is GPIO26 */
|
||||
ADC2_CHANNEL_MAX,
|
||||
} adc2_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Configure ADC1 capture width.
|
||||
*
|
||||
@ -66,7 +82,7 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit);
|
||||
*
|
||||
* @note This function also configures the input GPIO pin mux to
|
||||
* connect it to the ADC1 channel. It must be called before calling
|
||||
* adc1_get_voltage() for this channel.
|
||||
* adc1_get_raw() for this channel.
|
||||
*
|
||||
* 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.
|
||||
@ -107,13 +123,22 @@ esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten);
|
||||
* - -1: Parameter error
|
||||
* - Other: ADC1 channel reading.
|
||||
*/
|
||||
int adc1_get_voltage(adc1_channel_t channel);
|
||||
int adc1_get_raw(adc1_channel_t channel);
|
||||
|
||||
/** @cond */ //Doxygen command to hide deprecated function from API Reference
|
||||
/*
|
||||
* @deprecated This function returns an ADC1 reading but is deprecated due to
|
||||
* a misleading name and has been changed to directly call the new function.
|
||||
* Use the new function adc1_get_raw() instead
|
||||
*/
|
||||
int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated));
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Configure ADC1 to be usable by the ULP
|
||||
*
|
||||
* This function reconfigures ADC1 to be controlled by the ULP.
|
||||
* Effect of this function can be reverted using adc1_get_voltage function.
|
||||
* Effect of this function can be reverted using adc1_get_raw function.
|
||||
*
|
||||
* Note that adc1_config_channel_atten, adc1_config_width functions need
|
||||
* to be called to configure ADC1 channels, before ADC1 is used by the ULP.
|
||||
@ -136,6 +161,22 @@ void adc1_ulp_enable();
|
||||
*/
|
||||
int hall_sensor_read();
|
||||
|
||||
/**
|
||||
* @brief Output ADC2 reference voltage to gpio 25 or 26 or 27
|
||||
*
|
||||
* This function utilizes the testing mux exclusive to ADC 2 to route the
|
||||
* reference voltage one of ADC2's channels. Supported gpios are gpios
|
||||
* 25, 26, and 27. This refernce voltage can be manually read from the pin
|
||||
* and used in the esp_adc_cal component.
|
||||
*
|
||||
* @param[in] gpio GPIO number (gpios 25,26,27 supported)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: v_ref successfully routed to selected gpio
|
||||
* - ESP_ERR_INVALID_ARG: Unsupported gpio
|
||||
*/
|
||||
esp_err_t adc2_vref_to_gpio(gpio_num_t gpio);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "soc/dac_channel.h"
|
||||
|
||||
typedef enum {
|
||||
DAC_CHANNEL_1 = 1, /*!< DAC channel 1 is GPIO25 */
|
||||
|
@ -162,7 +162,7 @@ typedef enum {
|
||||
GPIO_NUM_27 = 27, /*!< GPIO27, input and output */
|
||||
|
||||
GPIO_NUM_32 = 32, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO33, input and output */
|
||||
GPIO_NUM_34 = 34, /*!< GPIO34, input mode only */
|
||||
GPIO_NUM_35 = 35, /*!< GPIO35, input mode only */
|
||||
GPIO_NUM_36 = 36, /*!< GPIO36, input mode only */
|
||||
|
@ -44,6 +44,11 @@ typedef enum {
|
||||
PERIPH_SPI_MODULE,
|
||||
PERIPH_HSPI_MODULE,
|
||||
PERIPH_VSPI_MODULE,
|
||||
PERIPH_SPI_DMA_MODULE,
|
||||
PERIPH_SDMMC_MODULE,
|
||||
PERIPH_SDIO_SLAVE_MODULE,
|
||||
PERIPH_CAN_MODULE,
|
||||
PERIPH_EMAC_MODULE,
|
||||
} periph_module_t;
|
||||
|
||||
/**
|
||||
|
@ -677,11 +677,15 @@ esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t* rmt_item, i
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
* @param wait_time Maximum time to wait for transmission to be complete
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK RMT Tx done successfully
|
||||
* - ESP_ERR_TIMEOUT Crossed the 'wait_time' given
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Driver not installed
|
||||
*/
|
||||
esp_err_t rmt_wait_tx_done(rmt_channel_t channel);
|
||||
esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
|
||||
|
||||
/**
|
||||
* @brief Get ringbuffer from UART.
|
||||
@ -690,13 +694,13 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel);
|
||||
*
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
* @param buf_handler Pointer to buffer handler to accept RX ringbuffer handler.
|
||||
* @param buf_handle Pointer to buffer handler to accept RX ringbuffer handler.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t rmt_get_ringbuf_handler(rmt_channel_t channel, RingbufHandle_t* buf_handler);
|
||||
esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_handle);
|
||||
|
||||
/***************************EXAMPLE**********************************
|
||||
*
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/rtc_gpio_channel.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -294,23 +294,67 @@
|
||||
#define SCR_CMD_SUPPORT_CMD20(scr) MMC_RSP_BITS((scr), 32, 1)
|
||||
#define SCR_RESERVED2(scr) MMC_RSP_BITS((scr), 0, 32)
|
||||
|
||||
/* Status of Switch Function */
|
||||
#define SFUNC_STATUS_GROUP(status, group) \
|
||||
(__bitfield((uint32_t *)(status), 400 + (group - 1) * 16, 16))
|
||||
/* Max supply current in SWITCH_FUNC response (in mA) */
|
||||
#define SD_SFUNC_I_MAX(status) (MMC_RSP_BITS((uint32_t *)(status), 496, 16))
|
||||
|
||||
#define SD_ACCESS_MODE_SDR12 0
|
||||
#define SD_ACCESS_MODE_SDR25 1
|
||||
#define SD_ACCESS_MODE_SDR50 2
|
||||
#define SD_ACCESS_MODE_SDR104 3
|
||||
#define SD_ACCESS_MODE_DDR50 4
|
||||
/* Supported flags in SWITCH_FUNC response */
|
||||
#define SD_SFUNC_SUPPORTED(status, group) \
|
||||
(MMC_RSP_BITS((uint32_t *)(status), 400 + (group - 1) * 16, 16))
|
||||
|
||||
/* Selected function in SWITCH_FUNC response */
|
||||
#define SD_SFUNC_SELECTED(status, group) \
|
||||
(MMC_RSP_BITS((uint32_t *)(status), 376 + (group - 1) * 4, 4))
|
||||
|
||||
/* Busy flags in SWITCH_FUNC response */
|
||||
#define SD_SFUNC_BUSY(status, group) \
|
||||
(MMC_RSP_BITS((uint32_t *)(status), 272 + (group - 1) * 16, 16))
|
||||
|
||||
/* Version of SWITCH_FUNC response */
|
||||
#define SD_SFUNC_VER(status) (MMC_RSP_BITS((uint32_t *)(status), 368, 8))
|
||||
|
||||
#define SD_SFUNC_GROUP_MAX 6
|
||||
#define SD_SFUNC_FUNC_MAX 15
|
||||
|
||||
#define SD_ACCESS_MODE 1 /* Function group 1, Access Mode */
|
||||
|
||||
#define SD_ACCESS_MODE_SDR12 0 /* 25 MHz clock */
|
||||
#define SD_ACCESS_MODE_SDR25 1 /* 50 MHz clock */
|
||||
#define SD_ACCESS_MODE_SDR50 2 /* UHS-I, 100 MHz clock */
|
||||
#define SD_ACCESS_MODE_SDR104 3 /* UHS-I, 208 MHz clock */
|
||||
#define SD_ACCESS_MODE_DDR50 4 /* UHS-I, 50 MHz clock, DDR */
|
||||
|
||||
/**
|
||||
* @brief Extract up to 32 sequential bits from an array of 32-bit words
|
||||
*
|
||||
* Bits within the word are numbered in the increasing order from LSB to MSB.
|
||||
*
|
||||
* As an example, consider 2 32-bit words:
|
||||
*
|
||||
* 0x01234567 0x89abcdef
|
||||
*
|
||||
* On a little-endian system, the bytes are stored in memory as follows:
|
||||
*
|
||||
* 67 45 23 01 ef cd ab 89
|
||||
*
|
||||
* MMC_RSP_BITS will extact bits as follows:
|
||||
*
|
||||
* start=0 len=4 -> result=0x00000007
|
||||
* start=0 len=12 -> result=0x00000567
|
||||
* start=28 len=8 -> result=0x000000f0
|
||||
* start=59 len=5 -> result=0x00000011
|
||||
*
|
||||
* @param src array of words to extract bits from
|
||||
* @param start index of the first bit to extract
|
||||
* @param len number of bits to extract, 1 to 32
|
||||
* @return 32-bit word where requested bits start from LSB
|
||||
*/
|
||||
static inline uint32_t MMC_RSP_BITS(uint32_t *src, int start, int len)
|
||||
{
|
||||
uint32_t mask = (len % 32 == 0) ? UINT_MAX : UINT_MAX >> (32 - (len % 32));
|
||||
size_t word = 3 - start / 32;
|
||||
size_t word = start / 32;
|
||||
size_t shift = start % 32;
|
||||
uint32_t right = src[word] >> shift;
|
||||
uint32_t left = (len + shift <= 32) ? 0 : src[word - 1] << ((32 - shift) % 32);
|
||||
uint32_t left = (len + shift <= 32) ? 0 : src[word + 1] << ((32 - shift) % 32);
|
||||
return (left | right) & mask;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,13 @@ typedef struct {
|
||||
*/
|
||||
typedef uint32_t sdmmc_response_t[4];
|
||||
|
||||
/**
|
||||
* SD SWITCH_FUNC response buffer
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t data[512 / 8 / sizeof(uint32_t)]; /*!< response data */
|
||||
} sdmmc_switch_func_rsp_t;
|
||||
|
||||
/**
|
||||
* SD/MMC command information
|
||||
*/
|
||||
|
@ -74,11 +74,30 @@ bool spicommon_periph_claim(spi_host_device_t host);
|
||||
/**
|
||||
* @brief Return the SPI peripheral so another driver can claim it.
|
||||
*
|
||||
* @param host Peripheral to claim
|
||||
* @param host Peripheral to return
|
||||
* @return True if peripheral is returned successfully; false if peripheral was free to claim already.
|
||||
*/
|
||||
bool spicommon_periph_free(spi_host_device_t host);
|
||||
|
||||
/**
|
||||
* @brief Try to claim a SPI DMA channel
|
||||
*
|
||||
* Call this if your driver wants to use SPI with a DMA channnel.
|
||||
*
|
||||
* @param dma_chan channel to claim
|
||||
*
|
||||
* @return True if success; false otherwise.
|
||||
*/
|
||||
bool spicommon_dma_chan_claim(int dma_chan);
|
||||
|
||||
/**
|
||||
* @brief Return the SPI DMA channel so other driver can claim it, or just to power down DMA.
|
||||
*
|
||||
* @param dma_chan channel to return
|
||||
*
|
||||
* @return True if success; false otherwise.
|
||||
*/
|
||||
bool spicommon_dma_chan_free(int dma_chan);
|
||||
|
||||
#define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode
|
||||
#define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode
|
||||
@ -170,9 +189,6 @@ spi_dev_t *spicommon_hw_for_host(spi_host_device_t host);
|
||||
*/
|
||||
int spicommon_irqsource_for_host(spi_host_device_t host);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Callback, to be called when a DMA engine reset is completed
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ extern "C"
|
||||
|
||||
#define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
|
||||
#define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
|
||||
#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||
#define SPI_DEVICE_BIT_LSBFIRST (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
|
||||
#define SPI_DEVICE_3WIRE (1<<2) ///< Use MOSI (=spid) for both sending and receiving data
|
||||
#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
|
||||
#define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
|
||||
@ -67,24 +67,28 @@ typedef struct {
|
||||
#define SPI_TRANS_USE_TXDATA (1<<3) ///< Transmit tx_data member of spi_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this.
|
||||
|
||||
/**
|
||||
* This structure describes one SPI transaction
|
||||
* This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes.
|
||||
*/
|
||||
struct spi_transaction_t {
|
||||
uint32_t flags; ///< Bitwise OR of SPI_TRANS_* flags
|
||||
uint16_t command; ///< Command data. Specific length was given when device was added to the bus.
|
||||
uint64_t address; ///< Address. Specific length was given when device was added to the bus.
|
||||
uint16_t cmd; ///< Command data, of which the length is set in the ``command_bits`` of spi_device_interface_config_t.
|
||||
///< <b>NOTE: this field, used to be "command" in ESP-IDF 2.1 and before, is re-written to be used in a new way in ESP-IDF 3.0.</b>
|
||||
///< - Example: write 0x0123 and command_bits=12 to send command 0x12, 0x3_ (in previous version, you may have to write 0x3_12).
|
||||
uint64_t addr; ///< Address data, of which the length is set in the ``address_bits`` of spi_device_interface_config_t.
|
||||
///< <b>NOTE: this field, used to be "address" in ESP-IDF 2.1 and before, is re-written to be used in a new way in ESP-IDF3.0.</b>
|
||||
///< - Example: write 0x123400 and address_bits=24 to send address of 0x12, 0x34, 0x00 (in previous version, you may have to write 0x12340000).
|
||||
size_t length; ///< Total data length, in bits
|
||||
size_t rxlength; ///< Total data length received, if different from length. (0 defaults this to the value of ``length``)
|
||||
size_t rxlength; ///< Total data length received, should be not greater than ``length`` in full-duplex mode (0 defaults this to the value of ``length``).
|
||||
void *user; ///< User-defined variable. Can be used to store eg transaction ID.
|
||||
union {
|
||||
const void *tx_buffer; ///< Pointer to transmit buffer, or NULL for no MOSI phase
|
||||
uint8_t tx_data[4]; ///< If SPI_USE_TXDATA is set, data set here is sent directly from this variable.
|
||||
};
|
||||
union {
|
||||
void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase
|
||||
void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase. Written by 4 bytes-unit if DMA is used.
|
||||
uint8_t rx_data[4]; ///< If SPI_USE_RXDATA is set, data is received directly to this variable
|
||||
};
|
||||
};
|
||||
} ; //the rx data should start from a 32-bit aligned address to get around dma issue.
|
||||
|
||||
|
||||
typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a SPI bus
|
||||
@ -182,8 +186,9 @@ esp_err_t spi_device_queue_trans(spi_device_handle_t handle, spi_transaction_t *
|
||||
* re-use the buffers.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the
|
||||
* transaction that is executed
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the transaction
|
||||
that is executed. The descriptor should not be modified until the descriptor is returned by
|
||||
spi_device_get_trans_result.
|
||||
* @param ticks_to_wait Ticks to wait until there's a returned item; use portMAX_DELAY to never time
|
||||
out.
|
||||
* @return
|
||||
@ -201,8 +206,7 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio
|
||||
* using spi_device_get_trans_result.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Pointer to variable able to contain a pointer to the description of the
|
||||
* transaction that is executed
|
||||
* @param trans_desc Description of transaction to execute
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
|
@ -20,150 +20,480 @@ extern "C" {
|
||||
#include "esp_intr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#define TOUCH_PAD_SLEEP_CYCLE_CONFIG (0x1000)//The Time is 150Khz,the Max value is 0xffff
|
||||
#define TOUCH_PAD_MEASURE_CYCLE_CONFIG (0xffff)//The Time is 8Mhz,the Max value is 0xffff
|
||||
#include "soc/touch_channel.h"
|
||||
|
||||
typedef enum {
|
||||
TOUCH_PAD_NUM0 = 0, /*!< Touch pad channel 0 is GPIO4 */
|
||||
TOUCH_PAD_NUM1, /*!< Touch pad channel 0 is GPIO0 */
|
||||
TOUCH_PAD_NUM2, /*!< Touch pad channel 0 is GPIO2 */
|
||||
TOUCH_PAD_NUM3, /*!< Touch pad channel 0 is GPIO15 */
|
||||
TOUCH_PAD_NUM4, /*!< Touch pad channel 0 is GPIO13 */
|
||||
TOUCH_PAD_NUM5, /*!< Touch pad channel 0 is GPIO12 */
|
||||
TOUCH_PAD_NUM6, /*!< Touch pad channel 0 is GPIO14 */
|
||||
TOUCH_PAD_NUM7, /*!< Touch pad channel 0 is GPIO27*/
|
||||
TOUCH_PAD_NUM8, /*!< Touch pad channel 0 is GPIO33*/
|
||||
TOUCH_PAD_NUM9, /*!< Touch pad channel 0 is GPIO32*/
|
||||
TOUCH_PAD_NUM1, /*!< Touch pad channel 1 is GPIO0 */
|
||||
TOUCH_PAD_NUM2, /*!< Touch pad channel 2 is GPIO2 */
|
||||
TOUCH_PAD_NUM3, /*!< Touch pad channel 3 is GPIO15*/
|
||||
TOUCH_PAD_NUM4, /*!< Touch pad channel 4 is GPIO13*/
|
||||
TOUCH_PAD_NUM5, /*!< Touch pad channel 5 is GPIO12*/
|
||||
TOUCH_PAD_NUM6, /*!< Touch pad channel 6 is GPIO14*/
|
||||
TOUCH_PAD_NUM7, /*!< Touch pad channel 7 is GPIO27*/
|
||||
TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO32*/
|
||||
TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO33*/
|
||||
TOUCH_PAD_MAX,
|
||||
} touch_pad_t;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
typedef intr_handle_t touch_isr_handle_t;
|
||||
|
||||
#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 (0xffff) /*!<The timer frequency is 8Mhz, the max value is 0xffff */
|
||||
#define TOUCH_FSM_MODE_DEFAULT (TOUCH_FSM_MODE_TIMER) /*!<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 */
|
||||
#define TOUCH_PAD_BIT_MASK_MAX (0x3ff)
|
||||
|
||||
/**
|
||||
* @brief Initialize touch module.
|
||||
*
|
||||
*This function int touch pad module ,enable touch module
|
||||
*
|
||||
* @brief Initialize touch module.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Touch pad init error
|
||||
*
|
||||
*/
|
||||
esp_err_t touch_pad_init();
|
||||
|
||||
/**
|
||||
* @brief Uninstall TouchPad driver.
|
||||
*
|
||||
* @brief Un-install touch pad driver.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Touch pad deinit error
|
||||
* - ESP_FAIL Touch pad driver not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_deinit();
|
||||
|
||||
/**
|
||||
* @brief Configure touch pad interrupt threshold.
|
||||
*
|
||||
*
|
||||
* @param[in] touch_num : config touch num
|
||||
*
|
||||
* @param[in] threshold : interrupt threshold ,When the touch_pad_register less than threshold,
|
||||
* will trigger the touch interrupt.User can use touch_pad_read function
|
||||
* to determine the threshold.
|
||||
*
|
||||
* @return - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*
|
||||
* @brief Configure touch pad interrupt threshold.
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold interrupt threshold,
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG if argument wrong
|
||||
* - ESP_FAIL if touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold);
|
||||
|
||||
/**
|
||||
* @brief get touch pad touch_pad_register counter.
|
||||
*
|
||||
*User can use this function to determine the the interrupt threshold .When you do not touch the
|
||||
*pad ,read the touch_pad_read number(NumNotTouch) by the touch_pad_register.When you touch the pad ,read the touch_pad_register
|
||||
*number(NumTouch) by the touch_pad_read.Normal NumNotTouch>NumTouch,so you can select a interrupt threshold.
|
||||
*
|
||||
* @param[in] touch_num : touch num
|
||||
* @param[out] touch_value : touch output value
|
||||
*
|
||||
* @return - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
* @brief get touch sensor counter value.
|
||||
* Each touch sensor has a counter to count the number of charge/discharge cycles.
|
||||
* When the pad is not 'touched', we can get a number of the counter.
|
||||
* When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance.
|
||||
* User can use this function to determine the interrupt trigger threshold.
|
||||
*
|
||||
* @param touch_num touch pad index
|
||||
* @param touch_value pointer to accept touch sensor value
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t * touch_value);
|
||||
|
||||
/**
|
||||
* @brief register TouchPad interrupt handler, the handler is an ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
*
|
||||
* @param fn Interrupt handler function.
|
||||
* @param arg Parameter for handler function
|
||||
* @param 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.
|
||||
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will
|
||||
* be returned here.
|
||||
* @brief get filtered touch sensor counter value by IIR filter.
|
||||
* @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered.
|
||||
* This function can be called from ISR
|
||||
*
|
||||
* @param touch_num touch pad index
|
||||
* @param touch_value pointer to accept touch sensor value
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Touch pad error
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value);
|
||||
|
||||
/**
|
||||
* @brief Register touch-pad ISR,
|
||||
* @note Deprecated function, users should replace this with touch_pad_isr_register,
|
||||
* because RTC modules share a same interrupt index.
|
||||
* @param fn Pointer to ISR handler
|
||||
* @param arg Parameter for ISR
|
||||
* @param unused Reserved, not used
|
||||
* @param handle_unused Reserved, not used
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*/
|
||||
esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int intr_alloc_flags, touch_isr_handle_t *handle);
|
||||
|
||||
esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int unused, intr_handle_t *handle_unused) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* *************** ATTENTION ********************/
|
||||
/**
|
||||
*@attention
|
||||
*Touch button is through the body's capacitive characteristics,
|
||||
*there is a charge discharge circuit inside the. When the hands touch,
|
||||
*the charge and discharge time will be slow.
|
||||
*Because of the different hardware, each pad needs to be calibrated at the factory.
|
||||
*We use touch_pad_read to determine factory parameters.
|
||||
* @brief Register touch-pad ISR.
|
||||
* The handler will be attached to the same CPU core that this function is running on.
|
||||
* @param fn Pointer to ISR handler
|
||||
* @param arg Parameter for ISR
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*/
|
||||
esp_err_t touch_pad_isr_register(intr_handler_t fn, void* arg);
|
||||
|
||||
/**
|
||||
*----------EXAMPLE TO CONFIGURE GPIO AS OUTPUT ------------ *
|
||||
* @code{c}
|
||||
* touch_pad_init();
|
||||
* void taskA(void* arg)
|
||||
* {
|
||||
* for(;;){
|
||||
* vtaskDelay(20/portTICK_PERIOD_MS);
|
||||
* ets_printf("touch pad value %u\n",touch_pad_read(0));//Take the touched status and untouched status value
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
**/
|
||||
/**
|
||||
*----------EXAMPLE TO SET ISR HANDLER ----------------------
|
||||
* @code{c}
|
||||
* touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL) //hook the isr handler for TouchPad interrupt
|
||||
* @endcode
|
||||
* @brief Deregister the handler previously registered using touch_pad_isr_handler_register
|
||||
* @param fn handler function to call (as passed to touch_pad_isr_handler_register)
|
||||
* @param arg argument of the handler (as passed to touch_pad_isr_handler_register)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if a handler matching both fn and
|
||||
* arg isn't registered
|
||||
*/
|
||||
esp_err_t touch_pad_isr_deregister(void(*fn)(void *), void *arg);
|
||||
|
||||
/**
|
||||
*----------EXAMPLE TO USE TOUCH_PAD------------ *
|
||||
* @code{c}
|
||||
* touch_pad_init();//only init one time
|
||||
* touch_pad_config(0,300);//set the intr threshold,use touch_pad_read to determine this threshold
|
||||
* touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL)
|
||||
* #include "esp_attr.h"
|
||||
* void rtc_intr(void * arg)
|
||||
* {
|
||||
* uint32_t pad_intr = READ_PERI_REG(SARADC_SAR_TOUCH_CTRL2_REG) & 0x3ff;
|
||||
* uint8_t i = 0;
|
||||
* uint32_t rtc_intr = READ_PERI_REG(RTC_CNTL_INT_ST_REG);
|
||||
* WRITE_PERI_REG(RTC_CNTL_INT_CLR_REG, rtc_intr);
|
||||
* SET_PERI_REG_MASK(SARADC_SAR_TOUCH_CTRL2_REG, SARADC_TOUCH_MEAS_EN_CLR);
|
||||
* if (rtc_intr & RTC_CNTL_TOUCH_INT_ST) {
|
||||
* for (i = 0; i < TOUCH_PAD_MAX; ++i) {
|
||||
* if ((pad_intr >> i) & 0x01) {
|
||||
* ets_printf("touch pad intr %u\n",i);
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
**/
|
||||
* @brief Set touch sensor measurement and sleep time
|
||||
* @param sleep_cycle 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.
|
||||
* @param meas_cycle The duration of the touch sensor measurement.
|
||||
* t_meas = meas_cycle / 8M, the maximum measure time is 0xffff / 8M = 8.19 ms
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor measurement and sleep time
|
||||
* @param sleep_cycle Pointer to accept sleep cycle number
|
||||
* @param meas_cycle Pointer to accept measurement cycle count.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor reference voltage, if the voltage gap between high and low reference voltage get less,
|
||||
* the charging and discharging time would be faster, accordingly, the counter value would be larger.
|
||||
* In the case of detecting very slight change of capacitance, we can narrow down the gap so as to increase
|
||||
* the sensitivity. On the other hand, narrow voltage gap would also introduce more noise, but we can use a
|
||||
* software filter to pre-process the counter value.
|
||||
* @param refh the value of DREFH
|
||||
* @param refl the value of DREFL
|
||||
* @param atten the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_voltage(touch_high_volt_t refh, touch_low_volt_t refl, touch_volt_atten_t atten);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor reference voltage,
|
||||
* @param refh pointer to accept DREFH value
|
||||
* @param refl pointer to accept DREFL value
|
||||
* @param atten pointer to accept the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_voltage(touch_high_volt_t *refh, touch_low_volt_t *refl, touch_volt_atten_t *atten);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor charge/discharge speed for each pad.
|
||||
* If the slope is 0, the counter would always be zero.
|
||||
* If the slope is 1, the charging and discharging would be slow, accordingly, the counter value would be small.
|
||||
* If the slope is set 7, which is the maximum value, the charging and discharging would be fast, accordingly, the
|
||||
* counter value would be larger.
|
||||
* @param touch_num touch pad index
|
||||
* @param slope touch pad charge/discharge speed
|
||||
* @param opt the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope, touch_tie_opt_t opt);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor charge/discharge speed for each pad
|
||||
* @param touch_num touch pad index
|
||||
* @param slope pointer to accept touch pad charge/discharge slope
|
||||
* @param opt pointer to accept the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope, touch_tie_opt_t *opt);
|
||||
|
||||
/**
|
||||
* @brief Initialize touch pad GPIO
|
||||
* @param touch_num touch pad index
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_io_init(touch_pad_t touch_num);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor FSM mode, the test action can be triggered by the timer,
|
||||
* as well as by the software.
|
||||
* @param mode FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_fsm_mode(touch_fsm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor FSM mode
|
||||
* @param mode pointer to accept FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Trigger a touch sensor measurement, only support in SW mode of FSM
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_sw_start();
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt threshold
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor interrupt threshold
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold pointer to accept threshold
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt trigger mode.
|
||||
* Interrupt can be triggered either when counter result is less than
|
||||
* threshold or when counter result is more than threshold.
|
||||
* @param mode touch sensor interrupt trigger mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor interrupt trigger mode
|
||||
* @param mode pointer to accept touch sensor interrupt trigger mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt trigger source. There are two sets of touch signals.
|
||||
* Set1 and set2 can be mapped to several touch signals. Either set will be triggered
|
||||
* if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated
|
||||
* if set1 is triggered, or only if both sets are triggered.
|
||||
* @param src touch sensor interrupt trigger source
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor interrupt trigger source
|
||||
* @param src pointer to accept touch sensor interrupt trigger source
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor group mask.
|
||||
* Touch pad module has two sets of signals, 'Touched' signal is triggered only if
|
||||
* at least one of touch pad in this group is "touched".
|
||||
* This function will set the register bits according to the given bitmask.
|
||||
* @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value
|
||||
* @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value
|
||||
* @param en_mask bitmask of touch sensor work enable, it's a 10-bit value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor group mask.
|
||||
* @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value
|
||||
* @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value
|
||||
* @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask);
|
||||
|
||||
/**
|
||||
* @brief Clear touch sensor group mask.
|
||||
* Touch pad module has two sets of signals, Interrupt is triggered only if
|
||||
* at least one of touch pad in this group is "touched".
|
||||
* This function will clear the register bits according to the given bitmask.
|
||||
* @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value
|
||||
* @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value
|
||||
* @param en_mask bitmask of touch sensor work enable, it's a 10-bit value
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask);
|
||||
|
||||
/**
|
||||
* @brief To clear the touch status register, usually use this function in touch ISR to clear status.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_clear_status();
|
||||
|
||||
/**
|
||||
* @brief Get the touch sensor status, usually used in ISR to decide which pads are 'touched'.
|
||||
* @return
|
||||
* - touch status
|
||||
*/
|
||||
uint32_t touch_pad_get_status();
|
||||
|
||||
/**
|
||||
* @brief To enable touch pad interrupt
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_intr_enable();
|
||||
|
||||
/**
|
||||
* @brief To disable touch pad interrupt
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_intr_disable();
|
||||
|
||||
/**
|
||||
* @brief set touch pad filter calibration period, in ms.
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @param new_period_ms filter period, in ms
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms);
|
||||
|
||||
/**
|
||||
* @brief get touch pad filter calibration period, in ms
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @param p_period_ms pointer to accept period
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
*/
|
||||
esp_err_t touch_pad_get_filter_period(uint32_t* p_period_ms);
|
||||
|
||||
/**
|
||||
* @brief start touch pad filter function
|
||||
* This API will start a filter to process the noise in order to prevent false triggering
|
||||
* when detecting slight change of capacitance.
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
*
|
||||
* If filter is not initialized, this API will initialize the filter with given period.
|
||||
* If filter is already initialized, this API will update the filter period.
|
||||
* @note This filter uses FreeRTOS timer, which is dispatched from a task with
|
||||
* priority 1 by default on CPU 0. So if some application task with higher priority
|
||||
* takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected.
|
||||
* You can adjust FreeRTOS timer task priority in menuconfig.
|
||||
* @param filter_period_ms filter calibration period, in ms
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG parameter error
|
||||
* - ESP_ERR_NO_MEM No memory for driver
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_start(uint32_t filter_period_ms);
|
||||
|
||||
/**
|
||||
* @brief stop touch pad filter function
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_stop();
|
||||
|
||||
/**
|
||||
* @brief delete touch pad filter driver and release the memory
|
||||
* Need to call touch_pad_filter_start before all touch filter APIs
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_delete();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ extern "C" {
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include <esp_types.h>
|
||||
#include "soc/uart_channel.h"
|
||||
|
||||
#define UART_FIFO_LEN (128) /*!< Length of the hardware FIFO buffers */
|
||||
#define UART_INTR_MASK 0x1ff /*!< mask of all UART interrupts */
|
||||
|
Reference in New Issue
Block a user