forked from espressif/arduino-esp32
Update IDF to aaf1239 (#1539)
* fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * Initial add of @stickbreaker i2c * Add log_n * fix warnings when log is off * i2c code clean up and reorganization * add flags to interrupt allocator * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * fix errors with latest IDF * fix debug optimization (#1365) incorrect optimization for debugging tick markers. * Fix some missing BT header * Change BTSerial log calls * Update BLE lib * Arduino-ESP32 release management scripted (#1515) * Calculate an absolute path for a custom partitions table (#1452) * * Arduino-ESP32 release management scripted (ready-to-merge) * * secure env for espressif/arduino-esp32 * * build tests enabled * gitter webhook enabled * * gitter room link fixed * better comment * * filepaths fixed * BT Serial adjustments * * don't run sketch builds & tests for tagged builds * Return false from WiFi.hostByName() if hostname is not resolved * Free BT Memory when BT is not used * WIFI_MODE_NULL is not supported anymore * Select some key examples to build with PlatformIO to save some time * Update BLE lib * Fixed BLE lib * Major WiFi overhaul - auto reconnect on connection loss now works - moved to event groups - some code clean up and procedure optimizations - new methods to get a more elaborate system ststus * Add cmake tests to travis * Add initial AsyncUDP * Add NetBIOS lib and fix CMake includes * Add Initial WebServer * Fix WebServer and examples * travis not quiting on build fail * Try different travis build * Update IDF to aaf1239 * Fix WPS Example * fix script permission and add some fail tests to sketch builder * Add missing space in WiFiClient::write(Stream &stream)
This commit is contained in:
@ -192,6 +192,10 @@ esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten);
|
||||
|
||||
/**
|
||||
* @brief Take an ADC1 reading from a single channel.
|
||||
* @note When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
|
||||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
*
|
||||
* @note Call adc1_config_width() before the first time this
|
||||
* function is called.
|
||||
@ -210,6 +214,11 @@ int adc1_get_raw(adc1_channel_t channel);
|
||||
|
||||
/** @cond */ //Doxygen command to hide deprecated function from API Reference
|
||||
/*
|
||||
* @note When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
|
||||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
*
|
||||
* @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
|
||||
@ -288,6 +297,11 @@ void adc1_ulp_enable();
|
||||
/**
|
||||
* @brief Read Hall Sensor
|
||||
*
|
||||
* @note When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
|
||||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
*
|
||||
* @note The Hall Sensor uses channels 0 and 3 of ADC1. Do not configure
|
||||
* these channels for use as ADC channels.
|
||||
*
|
||||
@ -349,6 +363,11 @@ esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten);
|
||||
/**
|
||||
* @brief Take an ADC2 reading on a single channel
|
||||
*
|
||||
* @note When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
|
||||
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
|
||||
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
*
|
||||
* @note For a given channel, ``adc2_config_channel_atten()``
|
||||
* must be called before the first time this function is called. If Wi-Fi is started via ``esp_wifi_start()``, this
|
||||
* function will always fail with ``ESP_ERR_TIMEOUT``.
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "rom/gpio.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -31,11 +32,11 @@ extern "C" {
|
||||
|
||||
#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_2 (BIT(2)) /*!< Pin 2 selected
|
||||
@note There are more macros
|
||||
like that up to pin 39,
|
||||
excluding pins 20, 24 and 28..31.
|
||||
They are not shown here
|
||||
They are not shown here
|
||||
to reduce redundant information. */
|
||||
/** @cond */
|
||||
#define GPIO_SEL_3 (BIT(3)) /*!< Pin 3 selected */
|
||||
@ -121,10 +122,8 @@ extern "C" {
|
||||
#define GPIO_MODE_DEF_OD (BIT2)
|
||||
|
||||
|
||||
#define GPIO_PIN_COUNT 40
|
||||
/** @endcond */
|
||||
|
||||
extern const uint32_t GPIO_PIN_MUX_REG[GPIO_PIN_COUNT];
|
||||
#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 */
|
||||
|
||||
@ -172,7 +171,7 @@ typedef enum {
|
||||
GPIO_NUM_38 = 38, /*!< GPIO38, input mode only */
|
||||
GPIO_NUM_39 = 39, /*!< GPIO39, input mode only */
|
||||
GPIO_NUM_MAX = 40,
|
||||
/** @endcond */
|
||||
/** @endcond */
|
||||
} gpio_num_t;
|
||||
|
||||
typedef enum {
|
||||
@ -248,6 +247,18 @@ typedef intr_handle_t gpio_isr_handle_t;
|
||||
*/
|
||||
esp_err_t gpio_config(const gpio_config_t *pGPIOConfig);
|
||||
|
||||
/**
|
||||
* @brief Reset an gpio to default state (select gpio function, enable pullup and disable input and output).
|
||||
*
|
||||
* @param gpio_num GPIO number.
|
||||
*
|
||||
* @note This function also configures the IOMUX for this pin to the GPIO
|
||||
* function, and disconnects any other peripheral output configured via GPIO
|
||||
* Matrix.
|
||||
*
|
||||
* @return Always return ESP_OK.
|
||||
*/
|
||||
esp_err_t gpio_reset_pin(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief GPIO set interrupt trigger type
|
||||
@ -265,6 +276,10 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type);
|
||||
/**
|
||||
* @brief Enable GPIO module interrupt signal
|
||||
*
|
||||
* @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC.
|
||||
* Please refer to the comments of `adc1_get_raw`.
|
||||
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
|
||||
*
|
||||
* @param gpio_num GPIO number. If you want to enable an interrupt on e.g. GPIO16, gpio_num should be GPIO_NUM_16 (16);
|
||||
*
|
||||
* @return
|
||||
@ -389,6 +404,7 @@ esp_err_t gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
* - ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
|
||||
*/
|
||||
esp_err_t gpio_isr_register(void (*fn)(void*), void * arg, int intr_alloc_flags, gpio_isr_handle_t *handle);
|
||||
|
||||
@ -446,8 +462,10 @@ esp_err_t gpio_pulldown_dis(gpio_num_t gpio_num);
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Operation fail
|
||||
* - ESP_ERR_NO_MEM No memory to install this service
|
||||
* - ESP_ERR_INVALID_STATE ISR service already installed.
|
||||
* - ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
*/
|
||||
esp_err_t gpio_install_isr_service(int intr_alloc_flags);
|
||||
|
||||
@ -518,6 +536,51 @@ esp_err_t gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t streng
|
||||
*/
|
||||
esp_err_t gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t* strength);
|
||||
|
||||
/**
|
||||
* @brief Set 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.
|
||||
*
|
||||
* Power down or call gpio_hold_dis will disable this function.
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output-capable GPIOs
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NOT_SUPPORTED Not support pad hold function
|
||||
*/
|
||||
esp_err_t gpio_hold_en(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Unset gpio pad hold function.
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output-capable GPIOs
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NOT_SUPPORTED Not support pad hold function
|
||||
*/
|
||||
esp_err_t gpio_hold_dis(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Set pad input to a peripheral signal through the IOMUX.
|
||||
* @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``.
|
||||
*/
|
||||
void gpio_iomux_in(uint32_t gpio_num, uint32_t signal_idx);
|
||||
|
||||
/**
|
||||
* @brief Set peripheral output to an GPIO pad through the IOMUX.
|
||||
* @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 inversed, otherwise False.
|
||||
*/
|
||||
void gpio_iomux_out(uint8_t gpio_num, int func, bool oen_inv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
133
tools/sdk/include/driver/driver/i2s.h
Executable file → Normal file
133
tools/sdk/include/driver/driver/i2s.h
Executable file → Normal file
@ -263,42 +263,55 @@ esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num);
|
||||
/**
|
||||
* @brief Write data to I2S DMA transmit buffer.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
* This function is deprecated. Use 'i2s_write' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @param src Source address to write from
|
||||
* @return
|
||||
* - The amount of bytes written, if timeout, the result will be less than the size passed in.
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_write_bytes(i2s_port_t i2s_num, const void *src, size_t size, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Write data to I2S DMA transmit buffer.
|
||||
*
|
||||
* @param size Size of data in bytes
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
|
||||
* @param src Source address to write from
|
||||
*
|
||||
* @param size Size of data in bytes
|
||||
*
|
||||
* @param[out] bytes_written Number of bytes written, if timeout, the result will be less than the size passed in.
|
||||
*
|
||||
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
|
||||
* many ticks pass without space becoming available in the DMA
|
||||
* transmit buffer, then the function will return (note that if the
|
||||
* data is written to the DMA buffer in pieces, the overall operation
|
||||
* may still take longer than this timeout.) Pass portMAX_DELAY for no
|
||||
* timeout.
|
||||
*
|
||||
* Format of the data in source buffer is determined by the I2S
|
||||
* configuration (see i2s_config_t).
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes written, if timeout occurred, bytes written will be less than the size passed.
|
||||
* - ESP_FAIL Parameter error.
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
int i2s_write_bytes(i2s_port_t i2s_num, const char *src, size_t size, TickType_t ticks_to_wait);
|
||||
esp_err_t i2s_write(i2s_port_t i2s_num, const void *src, size_t size, size_t *bytes_written, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Write data to I2S DMA transmit buffer while expanding the number of bits per sample. For example, expanding 16-bit PCM to 32-bit PCM.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param src Source address to write from
|
||||
* @param src Source address to write from
|
||||
*
|
||||
* @param size Size of data in bytes
|
||||
* @param size Size of data in bytes
|
||||
*
|
||||
* @param src_bits Source audio bit
|
||||
* @param src_bits Source audio bit
|
||||
*
|
||||
* @param aim_bits Bit wanted, no more than 32, and must be greater than src_bits
|
||||
* @param aim_bits Bit wanted, no more than 32, and must be greater than src_bits
|
||||
*
|
||||
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
|
||||
* @param[out] bytes_written Number of bytes written, if timeout, the result will be less than the size passed in.
|
||||
*
|
||||
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
|
||||
* many ticks pass without space becoming available in the DMA
|
||||
* transmit buffer, then the function will return (note that if the
|
||||
* data is written to the DMA buffer in pieces, the overall operation
|
||||
@ -309,67 +322,80 @@ int i2s_write_bytes(i2s_port_t i2s_num, const char *src, size_t size, TickType_t
|
||||
* configuration (see i2s_config_t).
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes written, if timeout occurred, bytes written will be less than the size passed.
|
||||
* - ESP_FAIL Parameter error.
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
int i2s_write_expand(i2s_port_t i2s_num, const char *src, int size, int src_bits, int aim_bits, TickType_t ticks_to_wait);
|
||||
esp_err_t i2s_write_expand(i2s_port_t i2s_num, const void *src, size_t size, size_t src_bits, size_t aim_bits, size_t *bytes_written, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Read data from I2S DMA receive buffer
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
* This function is deprecated. Use 'i2s_read' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @param dest Destination address to read into
|
||||
* @return
|
||||
* - The amount of bytes read, if timeout, bytes read will be less than the size passed in
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_read_bytes(i2s_port_t i2s_num, void *dest, size_t size, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Read data from I2S DMA receive buffer
|
||||
*
|
||||
* @param size Size of data in bytes
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param ticks_to_wait RX buffer wait timeout in RTOS ticks. If this many ticks pass without bytes becoming available in the DMA receive buffer, then the function will return (note that if data is read from the DMA buffer in pieces, the overall operation may still take longer than this timeout.) Pass portMAX_DELAY for no timeout.
|
||||
* @param dest Destination address to read into
|
||||
*
|
||||
* @param size Size of data in bytes
|
||||
*
|
||||
* @param[out] bytes_read Number of bytes read, if timeout, bytes read will be less than the size passed in.
|
||||
*
|
||||
* @param ticks_to_wait RX buffer wait timeout in RTOS ticks. If this many ticks pass without bytes becoming available in the DMA receive buffer, then the function will return (note that if data is read from the DMA buffer in pieces, the overall operation may still take longer than this timeout.) Pass portMAX_DELAY for no timeout.
|
||||
*
|
||||
* Format of the data in source buffer is determined by the I2S
|
||||
* configuration (see i2s_config_t).
|
||||
* @note If the built-in ADC mode is enabled, we should call i2s_adc_start and i2s_adc_stop around the whole reading process,
|
||||
* to prevent the data getting corrupted.
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes read, if timeout occurred, bytes written will be less than the size passed.
|
||||
* - ESP_FAIL Parameter error.
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
int i2s_read_bytes(i2s_port_t i2s_num, char* dest, size_t size, TickType_t ticks_to_wait);
|
||||
esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Push (write) a single sample to the I2S DMA TX buffer.
|
||||
* @brief Write a single sample to the I2S DMA TX buffer.
|
||||
*
|
||||
* Size of the sample is determined by the channel_format (mono or stereo)) & bits_per_sample configuration (see i2s_config_t).
|
||||
* This function is deprecated. Use 'i2s_write' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param sample Pointer to buffer containing sample to write. Size of buffer (in bytes) = (number of channels) * bits_per_sample / 8.
|
||||
* @param sample Buffer to read data. Size of buffer (in bytes) = bits_per_sample / 8.
|
||||
*
|
||||
* @param ticks_to_wait Push timeout in RTOS ticks. If space is not available in the DMA TX buffer within this period, no data is written and function returns 0.
|
||||
* @param ticks_to_wait Timeout in RTOS ticks. If a sample is not available in the DMA buffer within this period, no data is read and function returns zero.
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes successfully pushed to DMA buffer, will be either zero or the size of configured sample buffer.
|
||||
* - ESP_FAIL Parameter error.
|
||||
* - Number of bytes successfully pushed to DMA buffer, will be either zero or the size of configured sample buffer (in bytes).
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_push_sample(i2s_port_t i2s_num, const char *sample, TickType_t ticks_to_wait);
|
||||
int i2s_push_sample(i2s_port_t i2s_num, const void *sample, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Pop (read) a single sample from the I2S DMA RX buffer.
|
||||
* @brief Read a single sample from the I2S DMA RX buffer.
|
||||
*
|
||||
* Size of the sample is determined by the channel_format (mono or stereo)) & bits_per_sample configuration (see i2s_config_t).
|
||||
* This function is deprecated. Use 'i2s_read' instead.
|
||||
* This definition will be removed in a future release.
|
||||
*
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
* @param i2s_num I2S_NUM_0, I2S_NUM_1
|
||||
*
|
||||
* @param sample Buffer sample data will be read into. Size of buffer (in bytes) = (number of channels) * bits_per_sample / 8.
|
||||
* @param sample Buffer to write data. Size of buffer (in bytes) = bits_per_sample / 8.
|
||||
*
|
||||
* @param ticks_to_wait Pop timeout in RTOS ticks. If a sample is not available in the DMA buffer within this period, no data is read and function returns zero.
|
||||
* @param ticks_to_wait Timeout in RTOS ticks. If a sample is not available in the DMA buffer within this period, no data is read and function returns zero.
|
||||
*
|
||||
* @return
|
||||
* - Number of bytes successfully read from DMA buffer, will be either zero or the size of configured sample buffer.
|
||||
* - ESP_FAIL Parameter error.
|
||||
* - Number of bytes successfully read from DMA buffer, will be either zero or the size of configured sample buffer (in bytes).
|
||||
* - ESP_FAIL Parameter error
|
||||
*/
|
||||
int i2s_pop_sample(i2s_port_t i2s_num, char *sample, TickType_t ticks_to_wait);
|
||||
|
||||
int i2s_pop_sample(i2s_port_t i2s_num, void *sample, TickType_t ticks_to_wait) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Set sample rate used for I2S RX and TX.
|
||||
@ -385,7 +411,6 @@ int i2s_pop_sample(i2s_port_t i2s_num, char *sample, TickType_t ticks_to_wait);
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL I2s is not initialized
|
||||
* - ESP_ERR_NO_MEM Out of memory
|
||||
*/
|
||||
esp_err_t i2s_set_sample_rates(i2s_port_t i2s_num, uint32_t rate);
|
||||
@ -445,7 +470,6 @@ esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num);
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Not initialized
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM Out of memory
|
||||
*/
|
||||
@ -454,7 +478,7 @@ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t b
|
||||
/**
|
||||
* @brief Set built-in ADC mode for I2S DMA, this function will initialize ADC pad,
|
||||
* and set ADC parameters.
|
||||
* @param adc_unit SAR ADC unit index
|
||||
* @param adc_unit SAR ADC unit index
|
||||
* @param adc_channel ADC channel index
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -469,10 +493,9 @@ esp_err_t i2s_set_adc_mode(adc_unit_t adc_unit, adc1_channel_t adc_channel);
|
||||
*
|
||||
* @param i2s_num i2s port index
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
* - ESP_FAIL Internal driver error
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_INVALID_STATE Driver state error
|
||||
*/
|
||||
esp_err_t i2s_adc_enable(i2s_port_t i2s_num);
|
||||
|
||||
@ -481,9 +504,9 @@ esp_err_t i2s_adc_enable(i2s_port_t i2s_num);
|
||||
* @param i2s_num i2s port index
|
||||
* @note This function would release the lock of ADC so that other tasks can use ADC.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_INVALID_STATE Driver state error
|
||||
*/
|
||||
esp_err_t i2s_adc_disable(i2s_port_t i2s_num);
|
||||
|
||||
|
@ -27,6 +27,7 @@ extern "C" {
|
||||
#define LEDC_APB_CLK_HZ (APB_CLK_FREQ)
|
||||
#define LEDC_REF_CLK_HZ (1*1000000)
|
||||
#define LEDC_ERR_DUTY (0xFFFFFFFF)
|
||||
#define LEDC_ERR_VAL (-1)
|
||||
|
||||
typedef enum {
|
||||
LEDC_HIGH_SPEED_MODE = 0, /*!< LEDC high speed speed_mode */
|
||||
@ -42,6 +43,7 @@ typedef enum {
|
||||
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 {
|
||||
@ -54,6 +56,7 @@ typedef enum {
|
||||
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 {
|
||||
@ -69,12 +72,27 @@ typedef enum {
|
||||
} ledc_channel_t;
|
||||
|
||||
typedef enum {
|
||||
LEDC_TIMER_10_BIT = 10, /*!< LEDC PWM duty resolution of 10 bits */
|
||||
LEDC_TIMER_11_BIT = 11, /*!< LEDC PWM duty resolution of 11 bits */
|
||||
LEDC_TIMER_12_BIT = 12, /*!< LEDC PWM duty resolution of 12 bits */
|
||||
LEDC_TIMER_13_BIT = 13, /*!< LEDC PWM duty resolution of 13 bits */
|
||||
LEDC_TIMER_14_BIT = 14, /*!< LEDC PWM duty resolution of 14 bits */
|
||||
LEDC_TIMER_15_BIT = 15, /*!< LEDC PWM duty resolution of 15 bits */
|
||||
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 {
|
||||
@ -92,7 +110,8 @@ typedef struct {
|
||||
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) - 1] */
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -137,9 +156,11 @@ esp_err_t ledc_timer_config(const ledc_timer_config_t* timer_conf);
|
||||
|
||||
/**
|
||||
* @brief LEDC update channel parameters
|
||||
* Call this function to activate the LEDC updated parameters.
|
||||
* After ledc_set_duty, ledc_set_fade, we need to call this function to update the settings.
|
||||
*
|
||||
* @note Call this function to activate the LEDC updated parameters.
|
||||
* After ledc_set_duty, we need to call this function to update the settings.
|
||||
* @note ledc_set_duty, ledc_set_duty_with_hpoint and ledc_update_duty are not thread-safe, do not call these functions to
|
||||
* control one LEDC channel in different tasks at the same time.
|
||||
* A thread-safe version of API is ledc_set_duty_and_update
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
*
|
||||
@ -191,12 +212,47 @@ esp_err_t ledc_set_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num, uint32_t
|
||||
uint32_t ledc_get_freq(ledc_mode_t speed_mode, ledc_timer_t timer_num);
|
||||
|
||||
/**
|
||||
* @brief LEDC set duty
|
||||
* @brief LEDC set duty and hpoint value
|
||||
* Only after calling ledc_update_duty will the duty update.
|
||||
* @note ledc_set_duty, ledc_set_duty_with_hpoint and ledc_update_duty are not thread-safe, do not call these functions to
|
||||
* control one LEDC channel in different tasks at the same time.
|
||||
* A thread-safe version of API is ledc_set_duty_and_update
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution)]
|
||||
* @param hpoint Set the LEDC hpoint value(max: 0xfffff)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_set_duty_with_hpoint(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty, uint32_t hpoint);
|
||||
|
||||
/**
|
||||
* @brief LEDC get hpoint value, the counter value when the output is set high level.
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution) - 1]
|
||||
* @return
|
||||
* - LEDC_ERR_VAL if parameter error
|
||||
* - Others Current hpoint value of LEDC channel
|
||||
*/
|
||||
int ledc_get_hpoint(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief LEDC set duty
|
||||
* This function do not change the hpoint value of this channel. if needed, please call ledc_set_duty_with_hpoint.
|
||||
* only after calling ledc_update_duty will the duty update.
|
||||
* @note ledc_set_duty, ledc_set_duty_with_hpoint and ledc_update_duty are not thread-safe, do not call these functions to
|
||||
* control one LEDC channel in different tasks at the same time.
|
||||
* A thread-safe version of API is ledc_set_duty_and_update.
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution)]
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -219,20 +275,21 @@ uint32_t ledc_get_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
/**
|
||||
* @brief LEDC set gradient
|
||||
* Set LEDC gradient, After the function calls the ledc_update_duty function, the function can take effect.
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the start of the gradient duty, the range of duty setting is [0, (2**duty_resolution) - 1]
|
||||
* @param gradule_direction Set the direction of the gradient
|
||||
* @param step_num Set the number of the gradient
|
||||
* @param duty_cyle_num Set how many LEDC tick each time the gradient lasts
|
||||
* @param duty_scale Set gradient change amplitude
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the start of the gradient duty, the range of duty setting is [0, (2**duty_resolution)]
|
||||
* @param fade_direction Set the direction of the gradient
|
||||
* @param step_num Set the number of the gradient
|
||||
* @param duty_cyle_num Set how many LEDC tick each time the gradient lasts
|
||||
* @param duty_scale Set gradient change amplitude
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t ledc_set_fade(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty, ledc_duty_direction_t gradule_direction,
|
||||
esp_err_t ledc_set_fade(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty, ledc_duty_direction_t fade_direction,
|
||||
uint32_t step_num, uint32_t duty_cyle_num, uint32_t duty_scale);
|
||||
|
||||
/**
|
||||
@ -259,7 +316,7 @@ esp_err_t ledc_isr_register(void (*fn)(void*), void * arg, int intr_alloc_flags,
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param timer_sel Timer index (0-3), there are 4 timers in LEDC module
|
||||
* @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source
|
||||
* @param duty_resolution Resolution of duty setting in number of bits. The range of duty values is [0, (2**duty_resolution) - 1]
|
||||
* @param duty_resolution Resolution of duty setting in number of bits. The range of duty values is [0, (2**duty_resolution)]
|
||||
* @param clk_src Select LEDC source clock.
|
||||
*
|
||||
* @return
|
||||
@ -319,9 +376,14 @@ esp_err_t ledc_timer_resume(ledc_mode_t speed_mode, uint32_t timer_sel);
|
||||
esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint32_t timer_idx);
|
||||
|
||||
/**
|
||||
* @brief Set LEDC fade function. Should call ledc_fade_func_install() before calling this function.
|
||||
* @brief Set LEDC fade function.
|
||||
* @note Call ledc_fade_func_install() once before calling this function.
|
||||
* Call ledc_fade_start() after this to start fading.
|
||||
*
|
||||
* @note ledc_set_fade_with_step, ledc_set_fade_with_time and ledc_fade_start are not thread-safe, do not call these functions to
|
||||
* control one LEDC channel in different tasks at the same time.
|
||||
* A thread-safe version of API is ledc_set_fade_step_and_start
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param target_duty Target duty of fading [0, (2**duty_resolution) - 1]
|
||||
@ -334,12 +396,17 @@ esp_err_t ledc_bind_channel_timer(ledc_mode_t speed_mode, uint32_t channel, uint
|
||||
* - ESP_ERR_INVALID_STATE Fade function not installed.
|
||||
* - ESP_FAIL Fade function init error
|
||||
*/
|
||||
esp_err_t ledc_set_fade_with_step(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, int scale, int cycle_num);
|
||||
esp_err_t ledc_set_fade_with_step(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, uint32_t scale, uint32_t cycle_num);
|
||||
|
||||
/**
|
||||
* @brief Set LEDC fade function, with a limited time. Should call ledc_fade_func_install() before calling this function.
|
||||
* @brief Set LEDC fade function, with a limited time.
|
||||
* @note Call ledc_fade_func_install() once before calling this function.
|
||||
* Call ledc_fade_start() after this to start fading.
|
||||
*
|
||||
* @note ledc_set_fade_with_step, ledc_set_fade_with_time and ledc_fade_start are not thread-safe, do not call these functions to
|
||||
* control one LEDC channel in different tasks at the same time.
|
||||
* A thread-safe version of API is ledc_set_fade_step_and_start
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param target_duty Target duty of fading.( 0 - (2 ** duty_resolution - 1)))
|
||||
@ -354,8 +421,7 @@ esp_err_t ledc_set_fade_with_step(ledc_mode_t speed_mode, ledc_channel_t channel
|
||||
esp_err_t ledc_set_fade_with_time(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, int max_fade_time_ms);
|
||||
|
||||
/**
|
||||
* @brief Install ledc fade function. This function will occupy interrupt of LEDC module.
|
||||
*
|
||||
* @brief Install LEDC fade function. This function will occupy interrupt of LEDC module.
|
||||
* @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.
|
||||
*
|
||||
@ -373,18 +439,70 @@ void ledc_fade_func_uninstall();
|
||||
|
||||
/**
|
||||
* @brief Start LEDC fading.
|
||||
*
|
||||
* @note Call ledc_fade_func_install() once before calling this function.
|
||||
* Call this API right after ledc_set_fade_with_time or ledc_set_fade_with_step before to start fading.
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel number
|
||||
* @param wait_done Whether to block until fading done.
|
||||
* @param fade_mode Whether to block until fading done.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fade function not installed.
|
||||
* - ESP_ERR_INVALID_ARG Parameter error.
|
||||
*/
|
||||
esp_err_t ledc_fade_start(ledc_mode_t speed_mode, ledc_channel_t channel, ledc_fade_mode_t wait_done);
|
||||
esp_err_t ledc_fade_start(ledc_mode_t speed_mode, ledc_channel_t channel, ledc_fade_mode_t fade_mode);
|
||||
|
||||
/**
|
||||
* @brief A thread-safe API to set duty for LEDC channel and update the settings immediately
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
*
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode
|
||||
* @param channel LEDC channel (0-7), select from ledc_channel_t
|
||||
* @param duty Set the LEDC duty, the range of duty setting is [0, (2**duty_resolution)]
|
||||
* @param hpoint Set the LEDC hpoint value(max: 0xfffff)
|
||||
*
|
||||
*/
|
||||
esp_err_t ledc_set_duty_and_update(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty, uint32_t hpoint);
|
||||
|
||||
/**
|
||||
* @brief A thread-safe API to set and start LEDC fade function, with a limited time.
|
||||
* @note Call ledc_fade_func_install() once, before calling this function.
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param target_duty Target duty of fading.( 0 - (2 ** duty_resolution - 1)))
|
||||
* @param max_fade_time_ms The maximum time of the fading ( ms ).
|
||||
* @param fade_mode choose blocking or non-blocking mode
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fade function not installed.
|
||||
* - ESP_FAIL Fade function init error
|
||||
*/
|
||||
esp_err_t ledc_set_fade_time_and_start(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, uint32_t max_fade_time_ms, ledc_fade_mode_t fade_mode);
|
||||
|
||||
/**
|
||||
* @brief A thread-safe API to set and start LEDC fade function.
|
||||
* @note Call ledc_fade_func_install() once before calling this function.
|
||||
* @note If a fade operation is running in progress on that channel, the driver would not allow it to be stopped.
|
||||
* Other duty operations will have to wait until the fade operation has finished.
|
||||
* @param speed_mode Select the LEDC speed_mode, high-speed mode and low-speed mode,
|
||||
* @param channel LEDC channel index (0-7), select from ledc_channel_t
|
||||
* @param target_duty Target duty of fading [0, (2**duty_resolution) - 1]
|
||||
* @param scale Controls the increase or decrease step scale.
|
||||
* @param cycle_num increase or decrease the duty every cycle_num cycles
|
||||
* @param fade_mode choose blocking or non-blocking mode
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE Fade function not installed.
|
||||
* - ESP_FAIL Fade function init error
|
||||
*/
|
||||
esp_err_t ledc_set_fade_step_and_start(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, uint32_t scale, uint32_t cycle_num, ledc_fade_mode_t fade_mode);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -330,6 +330,61 @@ esp_err_t pcnt_set_mode(pcnt_unit_t unit, pcnt_channel_t channel,
|
||||
pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode,
|
||||
pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode);
|
||||
|
||||
/**
|
||||
* @brief Add ISR handler for specified unit.
|
||||
*
|
||||
* Call this function after using pcnt_isr_service_install() to
|
||||
* install the PCNT driver's ISR handler service.
|
||||
*
|
||||
* The ISR handlers do not need to be declared with IRAM_ATTR,
|
||||
* unless you pass the ESP_INTR_FLAG_IRAM flag when allocating the
|
||||
* ISR in pcnt_isr_service_install().
|
||||
*
|
||||
* This ISR handler will be called from an ISR. So there is a stack
|
||||
* size limit (configurable as "ISR stack size" in menuconfig). This
|
||||
* limit is smaller compared to a global PCNT interrupt handler due
|
||||
* to the additional level of indirection.
|
||||
*
|
||||
* @param unit PCNT unit number
|
||||
* @param isr_handler Interrupt handler function.
|
||||
* @param args Parameter for handler function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t pcnt_isr_handler_add(pcnt_unit_t unit, void(*isr_handler)(void *), void *args);
|
||||
|
||||
/**
|
||||
* @brief Install PCNT ISR service.
|
||||
* @note We can manage different interrupt service for each unit.
|
||||
* Please do not use pcnt_isr_register if this function was called.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NO_MEM No memory to install this service
|
||||
* - ESP_ERR_INVALID_STATE ISR service already installed
|
||||
*/
|
||||
esp_err_t pcnt_isr_service_install(int intr_alloc_flags);
|
||||
|
||||
/**
|
||||
* @brief Uninstall PCNT ISR service, freeing related resources.
|
||||
*/
|
||||
void pcnt_isr_service_uninstall(void);
|
||||
|
||||
/**
|
||||
* @brief Delete ISR handler for specified unit.
|
||||
*
|
||||
* @param unit PCNT unit number
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t pcnt_isr_handler_remove(pcnt_unit_t unit);
|
||||
|
||||
/**
|
||||
* @addtogroup pcnt-examples
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// 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.
|
||||
@ -14,47 +14,16 @@
|
||||
|
||||
#ifndef _DRIVER_PERIPH_CTRL_H_
|
||||
#define _DRIVER_PERIPH_CTRL_H_
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/periph_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PERIPH_LEDC_MODULE = 0,
|
||||
PERIPH_UART0_MODULE,
|
||||
PERIPH_UART1_MODULE,
|
||||
PERIPH_UART2_MODULE,
|
||||
PERIPH_I2C0_MODULE,
|
||||
PERIPH_I2C1_MODULE,
|
||||
PERIPH_I2S0_MODULE,
|
||||
PERIPH_I2S1_MODULE,
|
||||
PERIPH_TIMG0_MODULE,
|
||||
PERIPH_TIMG1_MODULE,
|
||||
PERIPH_PWM0_MODULE,
|
||||
PERIPH_PWM1_MODULE,
|
||||
PERIPH_PWM2_MODULE,
|
||||
PERIPH_PWM3_MODULE,
|
||||
PERIPH_UHCI0_MODULE,
|
||||
PERIPH_UHCI1_MODULE,
|
||||
PERIPH_RMT_MODULE,
|
||||
PERIPH_PCNT_MODULE,
|
||||
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_RNG_MODULE,
|
||||
PERIPH_WIFI_MODULE,
|
||||
PERIPH_BT_MODULE,
|
||||
PERIPH_WIFI_BT_COMMON_MODULE,
|
||||
} periph_module_t;
|
||||
|
||||
/**
|
||||
* @brief enable peripheral module
|
||||
*
|
||||
|
@ -129,6 +129,32 @@ typedef struct {
|
||||
void *arg; /*!< Optional argument passed to function */
|
||||
} rmt_tx_end_callback_t;
|
||||
|
||||
/**
|
||||
* @brief User callback function to convert uint8_t type data to rmt format(rmt_item32_t).
|
||||
*
|
||||
* This function may be called from an ISR, so, the code should be short and efficient.
|
||||
*
|
||||
* @param src Pointer to the buffer storing the raw data that needs to be converted to rmt format.
|
||||
*
|
||||
* @param[out] dest Pointer to the buffer storing the rmt format data.
|
||||
*
|
||||
* @param src_size The raw data size.
|
||||
*
|
||||
* @param wanted_num The number of rmt format data that wanted to get.
|
||||
*
|
||||
* @param[out] translated_size The size of the raw data that has been converted to rmt format,
|
||||
* it should return 0 if no data is converted in user callback.
|
||||
*
|
||||
* @param[out] item_num The number of the rmt format data that actually converted to, it can be less than wanted_num if there is not enough raw data,
|
||||
* but cannot exceed wanted_num. it should return 0 if no data was converted.
|
||||
*
|
||||
* @note
|
||||
* In fact, item_num should be a multiple of translated_size, e.g. :
|
||||
* When we convert each byte of uint8_t type data to rmt format data,
|
||||
* the relation between item_num and translated_size should be `item_num = translated_size*8`.
|
||||
*/
|
||||
typedef void (*sample_to_rmt_t)(const void* src, rmt_item32_t* dest, size_t src_size, size_t wanted_num, size_t* translated_size, size_t* item_num);
|
||||
|
||||
/**
|
||||
* @brief Set RMT clock divider, channel clock is divided from source clock.
|
||||
*
|
||||
@ -632,6 +658,7 @@ esp_err_t rmt_fill_tx_items(rmt_channel_t channel, const rmt_item32_t* item, uin
|
||||
* @param rx_buf_size Size of RMT RX ringbuffer. Can be 0 if the RX ringbuffer is not used.
|
||||
*
|
||||
* @param intr_alloc_flags Flags for the RMT driver interrupt handler. Pass 0 for default flags. See esp_intr_alloc.h for details.
|
||||
* If ESP_INTR_FLAG_IRAM is used, please do not use the memory allocated from psram when calling rmt_write_items.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE Driver is already installed, call rmt_driver_uninstall first.
|
||||
@ -660,6 +687,7 @@ esp_err_t rmt_driver_uninstall(rmt_channel_t channel);
|
||||
* @param channel RMT channel (0 - 7)
|
||||
*
|
||||
* @param rmt_item head point of RMT items array.
|
||||
* If ESP_INTR_FLAG_IRAM is used, please do not use the memory allocated from psram when calling rmt_write_items.
|
||||
*
|
||||
* @param item_num RMT data item number.
|
||||
*
|
||||
@ -712,6 +740,39 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time);
|
||||
*/
|
||||
esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_handle);
|
||||
|
||||
/**
|
||||
* @brief Init rmt translator and register user callback.
|
||||
* The callback will convert the raw data that needs to be sent to rmt format.
|
||||
* If a channel is initialized more than once, tha user callback will be replaced by the later.
|
||||
*
|
||||
* @param channel RMT channel (0 - 7).
|
||||
*
|
||||
* @param fn Point to the data conversion function.
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Init fail.
|
||||
* - ESP_OK Init success.
|
||||
*/
|
||||
esp_err_t rmt_translator_init(rmt_channel_t channel, sample_to_rmt_t fn);
|
||||
|
||||
/**
|
||||
* @brief Translate uint8_t type of data into rmt format and send it out.
|
||||
* Requires rmt_translator_init to init the translator first.
|
||||
*
|
||||
* @param channel RMT channel (0 - 7).
|
||||
*
|
||||
* @param src Pointer to the raw data.
|
||||
*
|
||||
* @param src_size The size of the raw data.
|
||||
*
|
||||
* @param wait_tx_done Set true to wait all data send done.
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Send fail
|
||||
* - ESP_OK Send success
|
||||
*/
|
||||
esp_err_t rmt_write_sample(rmt_channel_t channel, const uint8_t *src, size_t src_size, bool wait_tx_done);
|
||||
|
||||
/**
|
||||
* @brief Registers a callback that will be called when transmission ends.
|
||||
*
|
||||
|
@ -19,33 +19,11 @@
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/rtc_gpio_channel.h"
|
||||
|
||||
#include "soc/rtc_periph.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Pin function information for a single GPIO pad's RTC functions.
|
||||
*
|
||||
* This is an internal function of the driver, and is not usually useful
|
||||
* for external use.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t reg; /*!< Register of RTC pad, or 0 if not an RTC GPIO */
|
||||
uint32_t mux; /*!< Bit mask for selecting digital pad or RTC pad */
|
||||
uint32_t func; /*!< Shift of pad function (FUN_SEL) field */
|
||||
uint32_t ie; /*!< Mask of input enable */
|
||||
uint32_t pullup; /*!< Mask of pullup enable */
|
||||
uint32_t pulldown; /*!< Mask of pulldown enable */
|
||||
uint32_t slpsel; /*!< If slpsel bit is set, slpie will be used as pad input enabled signal in sleep mode */
|
||||
uint32_t slpie; /*!< Mask of input enable in sleep mode */
|
||||
uint32_t hold; /*!< Mask of hold enable */
|
||||
uint32_t hold_force;/*!< Mask of hold_force bit for RTC IO in RTC_CNTL_HOLD_FORCE_REG */
|
||||
uint32_t drv_v; /*!< Mask of drive capability */
|
||||
uint32_t drv_s; /*!< Offset of drive capability */
|
||||
int rtc_num; /*!< RTC IO number, or -1 if not an RTC GPIO */
|
||||
} rtc_gpio_desc_t;
|
||||
|
||||
typedef enum {
|
||||
RTC_GPIO_MODE_INPUT_ONLY , /*!< Pad input */
|
||||
RTC_GPIO_MODE_OUTPUT_ONLY, /*!< Pad output */
|
||||
@ -53,15 +31,6 @@ typedef enum {
|
||||
RTC_GPIO_MODE_DISABLED, /*!< Pad (output + input) disable */
|
||||
} rtc_gpio_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Provides access to a constant table of RTC I/O pin
|
||||
* function information.
|
||||
*
|
||||
* This is an internal function of the driver, and is not usually useful
|
||||
* for external use.
|
||||
*/
|
||||
extern const rtc_gpio_desc_t rtc_gpio_desc[GPIO_PIN_COUNT];
|
||||
|
||||
/**
|
||||
* @brief Determine if the specified GPIO is a valid RTC GPIO.
|
||||
*
|
||||
|
307
tools/sdk/include/driver/driver/sdio_slave.h
Normal file
307
tools/sdk/include/driver/driver/sdio_slave.h
Normal file
@ -0,0 +1,307 @@
|
||||
// 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 _DRIVER_SDIO_SLAVE_H_
|
||||
#define _DRIVER_SDIO_SLAVE_H_
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/portmacro.h"
|
||||
#include "esp_err.h"
|
||||
#include "rom/queue.h"
|
||||
|
||||
#include "soc/sdio_slave_periph.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SDIO_SLAVE_RECV_MAX_BUFFER (4096-4)
|
||||
|
||||
typedef void(*sdio_event_cb_t)(uint8_t event);
|
||||
|
||||
/// Mask of interrupts sending to the host.
|
||||
typedef enum {
|
||||
SDIO_SLAVE_HOSTINT_SEND_NEW_PACKET = HOST_SLC0_RX_NEW_PACKET_INT_ENA, ///< New packet available
|
||||
SDIO_SLAVE_HOSTINT_RECV_OVF = HOST_SLC0_TX_OVF_INT_ENA, ///< Slave receive buffer overflow
|
||||
SDIO_SLAVE_HOSTINT_SEND_UDF = HOST_SLC0_RX_UDF_INT_ENA, ///< Slave sending buffer underflow (this case only happen when the host do not request for packet according to the packet len).
|
||||
SDIO_SLAVE_HOSTINT_BIT7 = HOST_SLC0_TOHOST_BIT7_INT_ENA, ///< General purpose interrupt bits that can be used by the user.
|
||||
SDIO_SLAVE_HOSTINT_BIT6 = HOST_SLC0_TOHOST_BIT6_INT_ENA,
|
||||
SDIO_SLAVE_HOSTINT_BIT5 = HOST_SLC0_TOHOST_BIT5_INT_ENA,
|
||||
SDIO_SLAVE_HOSTINT_BIT4 = HOST_SLC0_TOHOST_BIT4_INT_ENA,
|
||||
SDIO_SLAVE_HOSTINT_BIT3 = HOST_SLC0_TOHOST_BIT3_INT_ENA,
|
||||
SDIO_SLAVE_HOSTINT_BIT2 = HOST_SLC0_TOHOST_BIT2_INT_ENA,
|
||||
SDIO_SLAVE_HOSTINT_BIT1 = HOST_SLC0_TOHOST_BIT1_INT_ENA,
|
||||
SDIO_SLAVE_HOSTINT_BIT0 = HOST_SLC0_TOHOST_BIT0_INT_ENA,
|
||||
} sdio_slave_hostint_t;
|
||||
|
||||
/// Timing of SDIO slave
|
||||
typedef enum {
|
||||
SDIO_SLAVE_TIMING_NSEND_PSAMPLE = 0,///< Send at negedge, and sample at posedge. Default value for SD protocol.
|
||||
SDIO_SLAVE_TIMING_NSEND_NSAMPLE, ///< Send at negedge, and sample at negedge
|
||||
SDIO_SLAVE_TIMING_PSEND_PSAMPLE, ///< Send at posedge, and sample at posedge
|
||||
SDIO_SLAVE_TIMING_PSEND_NSAMPLE, ///< Send at posedge, 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;
|
||||
|
||||
/// Configuration of SDIO slave
|
||||
typedef struct {
|
||||
sdio_slave_timing_t timing; ///< timing of sdio_slave. see `sdio_slave_timing_t`.
|
||||
sdio_slave_sending_mode_t sending_mode; ///< mode of sdio_slave. `SDIO_SLAVE_MODE_STREAM` if the data needs to be sent as much as possible; `SDIO_SLAVE_MODE_PACKET` if the data should be sent in packets.
|
||||
int send_queue_size; ///< max buffers that can be queued before sending.
|
||||
size_t recv_buffer_size;
|
||||
///< If buffer_size is too small, it costs more CPU time to handle larger number of buffers.
|
||||
///< If buffer_size is too large, the space larger than the transaction length is left blank but still counts a buffer, and the buffers are easily run out.
|
||||
///< Should be set according to length of data really transferred.
|
||||
///< All data that do not fully fill a buffer is still counted as one buffer. E.g. 10 bytes data costs 2 buffers if the size is 8 bytes per buffer.
|
||||
///< Buffer size of the slave pre-defined between host and slave before communication. All receive buffer given to the driver should be larger than this.
|
||||
sdio_event_cb_t event_cb; ///< when the host interrupts slave, this callback will be called with interrupt number (0-7).
|
||||
uint32_t flags; ///< Features to be enabled for the slave, combinations of ``SDIO_SLAVE_FLAG_*``.
|
||||
#define SDIO_SLAVE_FLAG_DAT2_DISABLED BIT(0) /**< It is required by the SD specification that all 4 data
|
||||
lines should be used and pulled up even in 1-bit mode or SPI mode. However, as a feature, the user can speicfy
|
||||
this flag to make use of DAT2 pin in 1-bit mode. Note that the host cannot read CCCR registers to know we don't
|
||||
support 4-bit mode anymore, please do this at your own risk.
|
||||
*/
|
||||
#define SDIO_SLAVE_FLAG_HOST_INTR_DISABLED BIT(1) /**< The DAT1 line is used as the interrupt line in SDIO
|
||||
protocol. However, as a feature, the user can speicfy this flag to make use of DAT1 pin of the slave in 1-bit
|
||||
mode. Note that the host has to do polling to the interrupt registers to know whether there are interrupts from
|
||||
the slave. And it cannot read CCCR registers to know we don't support 4-bit mode anymore, please do this at
|
||||
your own risk.
|
||||
*/
|
||||
#define SDIO_SLAVE_FLAG_INTERNAL_PULLUP BIT(2) /**< Enable internal pullups for enabled pins. It is required
|
||||
by the SD specification that all the 4 data lines should be pulled up even in 1-bit mode or SPI mode. Note that
|
||||
the internal pull-ups are not sufficient for stable communication, please do connect external pull-ups on the
|
||||
bus. This is only for example and debug use.
|
||||
*/
|
||||
} sdio_slave_config_t;
|
||||
|
||||
/** Handle of a receive buffer, register a handle by calling ``sdio_slave_recv_register_buf``. Use the handle to load the buffer to the
|
||||
* driver, or call ``sdio_slave_recv_unregister_buf`` if it is no longer used.
|
||||
*/
|
||||
typedef void *sdio_slave_buf_handle_t;
|
||||
|
||||
/** Initialize the sdio slave driver
|
||||
*
|
||||
* @param config Configuration of the sdio slave driver.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_NOT_FOUND if no free interrupt found.
|
||||
* - ESP_ERR_INVALID_STATE if already initialized.
|
||||
* - ESP_ERR_NO_MEM if fail due to memory allocation failed.
|
||||
* - ESP_OK if success
|
||||
*/
|
||||
esp_err_t sdio_slave_initialize(sdio_slave_config_t *config);
|
||||
|
||||
/** De-initialize the sdio slave driver to release the resources.
|
||||
*/
|
||||
void sdio_slave_deinit();
|
||||
|
||||
/** Start hardware for sending and receiving, as well as set the IOREADY1 to 1.
|
||||
*
|
||||
* @note The driver will continue sending from previous data and PKT_LEN counting, keep data received as well as start receiving from current TOKEN1 counting.
|
||||
* See ``sdio_slave_reset``.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_STATE if already started.
|
||||
* - ESP_OK otherwise.
|
||||
*/
|
||||
esp_err_t sdio_slave_start();
|
||||
|
||||
/** Stop hardware from sending and receiving, also set IOREADY1 to 0.
|
||||
*
|
||||
* @note this will not clear the data already in the driver, and also not reset the PKT_LEN and TOKEN1 counting. Call ``sdio_slave_reset`` to do that.
|
||||
*/
|
||||
void sdio_slave_stop();
|
||||
|
||||
/** Clear the data still in the driver, as well as reset the PKT_LEN and TOKEN1 counting.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t sdio_slave_reset();
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Receive
|
||||
*--------------------------------------------------------------------------*/
|
||||
/** Register buffer used for receiving. All buffers should be registered before used, and then can be used (again) in the driver by the handle returned.
|
||||
*
|
||||
* @param start The start address of the buffer.
|
||||
*
|
||||
* @note The driver will use and only use the amount of space specified in the `recv_buffer_size` member set in the `sdio_slave_config_t`.
|
||||
* All buffers should be larger than that. The buffer is used by the DMA, so it should be DMA capable and 32-bit aligned.
|
||||
*
|
||||
* @return The buffer handle if success, otherwise NULL.
|
||||
*/
|
||||
sdio_slave_buf_handle_t sdio_slave_recv_register_buf(uint8_t *start);
|
||||
|
||||
/** Unregister buffer from driver, and free the space used by the descriptor pointing to the buffer.
|
||||
*
|
||||
* @param handle Handle to the buffer to release.
|
||||
*
|
||||
* @return ESP_OK if success, ESP_ERR_INVALID_ARG if the handle is NULL or the buffer is being used.
|
||||
*/
|
||||
esp_err_t sdio_slave_recv_unregister_buf(sdio_slave_buf_handle_t handle);
|
||||
|
||||
/** Load buffer to the queue waiting to receive data. The driver takes ownership of the buffer until the buffer is returned by
|
||||
* ``sdio_slave_send_get_finished`` after the transaction is finished.
|
||||
*
|
||||
* @param handle Handle to the buffer ready to receive data.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if invalid handle or the buffer is already in the queue. Only after the buffer is returened by
|
||||
* ``sdio_slave_recv`` can you load it again.
|
||||
* - ESP_OK if success
|
||||
*/
|
||||
esp_err_t sdio_slave_recv_load_buf(sdio_slave_buf_handle_t handle);
|
||||
|
||||
/** Get received data if exist. The driver returns the ownership of the buffer to the app.
|
||||
*
|
||||
* @param handle_ret Handle to the buffer holding received data. Use this handle in ``sdio_slave_recv_load_buf`` to receive in the same buffer again.
|
||||
* @param[out] out_addr Output of the start address, set to NULL if not needed.
|
||||
* @param[out] out_len Actual length of the data in the buffer, set to NULL if not needed.
|
||||
* @param wait Time to wait before data received.
|
||||
*
|
||||
* @note Call ``sdio_slave_load_buf`` with the handle to re-load the buffer onto the link list, and receive with the same buffer again.
|
||||
* The address and length of the buffer got here is the same as got from `sdio_slave_get_buffer`.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if handle_ret is NULL
|
||||
* - ESP_ERR_TIMEOUT if timeout before receiving new data
|
||||
* - ESP_OK if success
|
||||
*/
|
||||
esp_err_t sdio_slave_recv(sdio_slave_buf_handle_t* handle_ret, uint8_t **out_addr, size_t *out_len, TickType_t wait);
|
||||
|
||||
/** Retrieve the buffer corresponding to a handle.
|
||||
*
|
||||
* @param handle Handle to get the buffer.
|
||||
* @param len_o Output of buffer length
|
||||
*
|
||||
* @return buffer address if success, otherwise NULL.
|
||||
*/
|
||||
uint8_t* sdio_slave_recv_get_buf(sdio_slave_buf_handle_t handle, size_t *len_o);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Send
|
||||
*--------------------------------------------------------------------------*/
|
||||
/** Put a new sending transfer into the send queue. The driver takes ownership of the buffer until the buffer is returned by
|
||||
* ``sdio_slave_send_get_finished`` after the transaction is finished.
|
||||
*
|
||||
* @param addr Address for data to be sent. The buffer should be DMA capable and 32-bit aligned.
|
||||
* @param len Length of the data, should not be longer than 4092 bytes (may support longer in the future).
|
||||
* @param arg Argument to returned in ``sdio_slave_send_get_finished``. The argument can be used to indicate which transaction is done,
|
||||
* or as a parameter for a callback. Set to NULL if not needed.
|
||||
* @param wait Time to wait if the buffer is full.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if the length is not greater than 0.
|
||||
* - ESP_ERR_TIMEOUT if the queue is still full until timeout.
|
||||
* - ESP_OK if success.
|
||||
*/
|
||||
esp_err_t sdio_slave_send_queue(uint8_t* addr, size_t len, void* arg, TickType_t wait);
|
||||
|
||||
/** Return the ownership of a finished transaction.
|
||||
* @param arg_o Argument of the finished transaction.
|
||||
* @param wait Time to wait if there's no finished sending transaction.
|
||||
*
|
||||
* @return ESP_ERR_TIMEOUT if no transaction finished, or ESP_OK if succeed.
|
||||
*/
|
||||
esp_err_t sdio_slave_send_get_finished(void** arg_o, TickType_t wait);
|
||||
|
||||
/** Start a new sending transfer, and wait for it (blocked) to be finished.
|
||||
*
|
||||
* @param addr Start address of the buffer to send
|
||||
* @param len Length of buffer to send.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if the length of descriptor is not greater than 0.
|
||||
* - ESP_ERR_TIMEOUT if the queue is full or host do not start a transfer before timeout.
|
||||
* - ESP_OK if success.
|
||||
*/
|
||||
esp_err_t sdio_slave_transmit(uint8_t* addr, size_t len);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Host
|
||||
*--------------------------------------------------------------------------*/
|
||||
/** Read the spi slave register shared with host.
|
||||
*
|
||||
* @param pos register address, 0-27 or 32-63.
|
||||
*
|
||||
* @note register 28 to 31 are reserved for interrupt vector.
|
||||
*
|
||||
* @return value of the register.
|
||||
*/
|
||||
uint8_t sdio_slave_read_reg(int pos);
|
||||
|
||||
/** Write the spi slave register shared with host.
|
||||
*
|
||||
* @param pos register address, 0-11, 14-15, 18-19, 24-27 and 32-63, other address are reserved.
|
||||
* @param reg the value to write.
|
||||
*
|
||||
* @note register 29 and 31 are used for interrupt vector.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if address wrong, otherwise ESP_OK.
|
||||
*/
|
||||
esp_err_t sdio_slave_write_reg(int pos, uint8_t reg);
|
||||
|
||||
/** Get the interrupt enable for host.
|
||||
*
|
||||
* @return the interrupt mask.
|
||||
*/
|
||||
sdio_slave_hostint_t sdio_slave_get_host_intena();
|
||||
|
||||
/** Set the interrupt enable for host.
|
||||
*
|
||||
* @param ena Enable mask for host interrupt.
|
||||
*/
|
||||
void sdio_slave_set_host_intena(sdio_slave_hostint_t ena);
|
||||
|
||||
/** Interrupt the host by general purpose interrupt.
|
||||
*
|
||||
* @param pos Interrupt num, 0-7.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if interrupt num error
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t sdio_slave_send_host_int(uint8_t pos);
|
||||
|
||||
/** Clear general purpose interrupt to host.
|
||||
*
|
||||
* @param mask Interrupt bits to clear, by bit mask.
|
||||
*/
|
||||
void sdio_slave_clear_host_int(uint8_t mask);
|
||||
|
||||
/** Wait for general purpose interrupt from host.
|
||||
*
|
||||
* @param pos Interrupt source number to wait for.
|
||||
* is set.
|
||||
* @param wait Time to wait before interrupt triggered.
|
||||
*
|
||||
* @note this clears the interrupt at the same time.
|
||||
*
|
||||
* @return ESP_OK if success, ESP_ERR_TIMEOUT if timeout.
|
||||
*/
|
||||
esp_err_t sdio_slave_wait_int(int pos, TickType_t wait);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_DRIVER_SDIO_SLAVE_H */
|
||||
|
||||
|
@ -54,6 +54,12 @@
|
||||
#define SD_APP_OP_COND 41 /* R3 */
|
||||
#define SD_APP_SEND_SCR 51 /* R1 */
|
||||
|
||||
/* SD IO commands */
|
||||
#define SD_IO_SEND_OP_COND 5 /* R4 */
|
||||
#define SD_IO_RW_DIRECT 52 /* R5 */
|
||||
#define SD_IO_RW_EXTENDED 53 /* R5 */
|
||||
|
||||
|
||||
/* OCR bits */
|
||||
#define MMC_OCR_MEM_READY (1<<31) /* memory power-up status bit */
|
||||
#define MMC_OCR_ACCESS_MODE_MASK 0x60000000 /* bits 30:29 */
|
||||
@ -97,6 +103,8 @@
|
||||
/* 48-bit response decoding (32 bits w/o CRC) */
|
||||
#define MMC_R1(resp) ((resp)[0])
|
||||
#define MMC_R3(resp) ((resp)[0])
|
||||
#define MMC_R4(resp) ((resp)[0])
|
||||
#define MMC_R5(resp) ((resp)[0])
|
||||
#define SD_R6(resp) ((resp)[0])
|
||||
#define MMC_R1_CURRENT_STATE(resp) (((resp)[0] >> 9) & 0xf)
|
||||
|
||||
@ -364,4 +372,78 @@ static inline uint32_t MMC_RSP_BITS(uint32_t *src, int start, int len)
|
||||
return (left | right) & mask;
|
||||
}
|
||||
|
||||
/* SD R4 response (IO OCR) */
|
||||
#define SD_IO_OCR_MEM_READY (1<<31)
|
||||
#define SD_IO_OCR_NUM_FUNCTIONS(ocr) (((ocr) >> 28) & 0x7)
|
||||
#define SD_IO_OCR_MEM_PRESENT (1<<27)
|
||||
#define SD_IO_OCR_MASK 0x00fffff0
|
||||
|
||||
/* CMD52 arguments */
|
||||
#define SD_ARG_CMD52_READ (0<<31)
|
||||
#define SD_ARG_CMD52_WRITE (1<<31)
|
||||
#define SD_ARG_CMD52_FUNC_SHIFT 28
|
||||
#define SD_ARG_CMD52_FUNC_MASK 0x7
|
||||
#define SD_ARG_CMD52_EXCHANGE (1<<27)
|
||||
#define SD_ARG_CMD52_REG_SHIFT 9
|
||||
#define SD_ARG_CMD52_REG_MASK 0x1ffff
|
||||
#define SD_ARG_CMD52_DATA_SHIFT 0
|
||||
#define SD_ARG_CMD52_DATA_MASK 0xff
|
||||
#define SD_R5_DATA(resp) ((resp)[0] & 0xff)
|
||||
|
||||
/* CMD53 arguments */
|
||||
#define SD_ARG_CMD53_READ (0<<31)
|
||||
#define SD_ARG_CMD53_WRITE (1<<31)
|
||||
#define SD_ARG_CMD53_FUNC_SHIFT 28
|
||||
#define SD_ARG_CMD53_FUNC_MASK 0x7
|
||||
#define SD_ARG_CMD53_BLOCK_MODE (1<<27)
|
||||
#define SD_ARG_CMD53_INCREMENT (1<<26)
|
||||
#define SD_ARG_CMD53_REG_SHIFT 9
|
||||
#define SD_ARG_CMD53_REG_MASK 0x1ffff
|
||||
#define SD_ARG_CMD53_LENGTH_SHIFT 0
|
||||
#define SD_ARG_CMD53_LENGTH_MASK 0x1ff
|
||||
#define SD_ARG_CMD53_LENGTH_MAX 512
|
||||
|
||||
/* Card Common Control Registers (CCCR) */
|
||||
#define SD_IO_CCCR_START 0x00000
|
||||
#define SD_IO_CCCR_SIZE 0x100
|
||||
#define SD_IO_CCCR_FN_ENABLE 0x02
|
||||
#define SD_IO_CCCR_FN_READY 0x03
|
||||
#define SD_IO_CCCR_INT_ENABLE 0x04
|
||||
#define SD_IO_CCCR_INT_PENDING 0x05
|
||||
#define SD_IO_CCCR_CTL 0x06
|
||||
#define CCCR_CTL_RES (1<<3)
|
||||
#define SD_IO_CCCR_BUS_WIDTH 0x07
|
||||
#define CCCR_BUS_WIDTH_1 (0<<0)
|
||||
#define CCCR_BUS_WIDTH_4 (2<<0)
|
||||
#define CCCR_BUS_WIDTH_8 (3<<0)
|
||||
#define SD_IO_CCCR_CARD_CAP 0x08
|
||||
#define CCCR_CARD_CAP_LSC BIT(6)
|
||||
#define CCCR_CARD_CAP_4BLS BIT(7)
|
||||
#define SD_IO_CCCR_CISPTR 0x09
|
||||
#define SD_IO_CCCR_BLKSIZEL 0x10
|
||||
#define SD_IO_CCCR_BLKSIZEH 0x11
|
||||
#define SD_IO_CCCR_HIGHSPEED 0x13
|
||||
#define CCCR_HIGHSPEED_SUPPORT BIT(0)
|
||||
#define CCCR_HIGHSPEED_ENABLE BIT(1)
|
||||
|
||||
/* Function Basic Registers (FBR) */
|
||||
#define SD_IO_FBR_START 0x00100
|
||||
#define SD_IO_FBR_SIZE 0x00700
|
||||
|
||||
/* Card Information Structure (CIS) */
|
||||
#define SD_IO_CIS_START 0x01000
|
||||
#define SD_IO_CIS_SIZE 0x17000
|
||||
|
||||
/* CIS tuple codes (based on PC Card 16) */
|
||||
#define SD_IO_CISTPL_NULL 0x00
|
||||
#define SD_IO_CISTPL_VERS_1 0x15
|
||||
#define SD_IO_CISTPL_MANFID 0x20
|
||||
#define SD_IO_CISTPL_FUNCID 0x21
|
||||
#define SD_IO_CISTPL_FUNCE 0x22
|
||||
#define SD_IO_CISTPL_END 0xff
|
||||
|
||||
/* CISTPL_FUNCID codes */
|
||||
#define TPLFID_FUNCTION_SDIO 0x0c
|
||||
|
||||
|
||||
#endif //_SDMMC_DEFS_H_
|
||||
|
@ -43,6 +43,8 @@ extern "C" {
|
||||
.set_card_clk = &sdmmc_host_set_card_clk, \
|
||||
.do_transaction = &sdmmc_host_do_transaction, \
|
||||
.deinit = &sdmmc_host_deinit, \
|
||||
.io_int_enable = sdmmc_host_io_int_enable, \
|
||||
.io_int_wait = sdmmc_host_io_int_wait, \
|
||||
.command_timeout_ms = 0, \
|
||||
}
|
||||
|
||||
@ -53,6 +55,12 @@ typedef struct {
|
||||
gpio_num_t gpio_cd; ///< GPIO number of card detect signal
|
||||
gpio_num_t gpio_wp; ///< GPIO number of write protect signal
|
||||
uint8_t width; ///< Bus width used by the slot (might be less than the max width supported)
|
||||
uint32_t flags; ///< Features used by this slot
|
||||
#define SDMMC_SLOT_FLAG_INTERNAL_PULLUP BIT(0)
|
||||
/**< Enable internal pullups on enabled pins. The internal pullups
|
||||
are insufficient however, please make sure external pullups are
|
||||
connected on the bus. This is for debug / example purpose only.
|
||||
*/
|
||||
} sdmmc_slot_config_t;
|
||||
|
||||
#define SDMMC_SLOT_NO_CD ((gpio_num_t) -1) ///< indicates that card detect line is not used
|
||||
@ -66,6 +74,7 @@ typedef struct {
|
||||
.gpio_cd = SDMMC_SLOT_NO_CD, \
|
||||
.gpio_wp = SDMMC_SLOT_NO_WP, \
|
||||
.width = SDMMC_SLOT_WIDTH_DEFAULT, \
|
||||
.flags = 0, \
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,6 +175,26 @@ esp_err_t sdmmc_host_set_card_clk(int slot, uint32_t freq_khz);
|
||||
*/
|
||||
esp_err_t sdmmc_host_do_transaction(int slot, sdmmc_command_t* cmdinfo);
|
||||
|
||||
/**
|
||||
* @brief Enable IO interrupts
|
||||
*
|
||||
* This function configures the host to accept SDIO interrupts.
|
||||
*
|
||||
* @param slot slot number (SDMMC_HOST_SLOT_0 or SDMMC_HOST_SLOT_1)
|
||||
* @return returns ESP_OK, other errors possible in the future
|
||||
*/
|
||||
esp_err_t sdmmc_host_io_int_enable(int slot);
|
||||
|
||||
/**
|
||||
* @brief Block until an SDIO interrupt is received, or timeout occurs
|
||||
* @param slot slot number (SDMMC_HOST_SLOT_0 or SDMMC_HOST_SLOT_1)
|
||||
* @param timeout_ticks number of RTOS ticks to wait for the interrupt
|
||||
* @return
|
||||
* - ESP_OK on success (interrupt received)
|
||||
* - ESP_ERR_TIMEOUT if the interrupt did not occur within timeout_ticks
|
||||
*/
|
||||
esp_err_t sdmmc_host_io_int_wait(int slot, TickType_t timeout_ticks);
|
||||
|
||||
/**
|
||||
* @brief Disable SDMMC host and release allocated resources
|
||||
*
|
||||
@ -177,6 +206,23 @@ esp_err_t sdmmc_host_do_transaction(int slot, sdmmc_command_t* cmdinfo);
|
||||
*/
|
||||
esp_err_t sdmmc_host_deinit();
|
||||
|
||||
/**
|
||||
* @brief Enable the pull-ups of sd pins.
|
||||
*
|
||||
* @note You should always place actual pullups on the lines instead of using
|
||||
* this function. Internal pullup resistance are high and not sufficient, may
|
||||
* cause instability in products. This is for debug or examples only.
|
||||
*
|
||||
* @param slot Slot to use, normally set it to 1.
|
||||
* @param width Bit width of your configuration, 1 or 4.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if success
|
||||
* - ESP_ERR_INVALID_ARG: if configured width larger than maximum the slot can
|
||||
* support
|
||||
*/
|
||||
esp_err_t sdmmc_host_pullup_en(int slot, int width);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
/**
|
||||
* Decoded values from SD card Card Specific Data register
|
||||
@ -78,6 +79,7 @@ typedef struct {
|
||||
size_t datalen; /*!< length of data buffer */
|
||||
size_t blklen; /*!< block length */
|
||||
int flags; /*!< see below */
|
||||
/** @cond */
|
||||
#define SCF_ITSDONE 0x0001 /*!< command is complete */
|
||||
#define SCF_CMD(flags) ((flags) & 0x00f0)
|
||||
#define SCF_CMD_AC 0x0000
|
||||
@ -101,6 +103,7 @@ typedef struct {
|
||||
#define SCF_RSP_R5B (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX|SCF_RSP_BSY)
|
||||
#define SCF_RSP_R6 (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX)
|
||||
#define SCF_RSP_R7 (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX)
|
||||
/** @endcond */
|
||||
esp_err_t error; /*!< error returned from transfer */
|
||||
int timeout_ms; /*!< response timeout, in milliseconds */
|
||||
} sdmmc_command_t;
|
||||
@ -129,6 +132,8 @@ typedef struct {
|
||||
esp_err_t (*set_card_clk)(int slot, uint32_t freq_khz); /*!< host function to set card clock frequency */
|
||||
esp_err_t (*do_transaction)(int slot, sdmmc_command_t* cmdinfo); /*!< host function to do a transaction */
|
||||
esp_err_t (*deinit)(void); /*!< host function to deinitialize the driver */
|
||||
esp_err_t (*io_int_enable)(int slot); /*!< Host function to enable SDIO interrupt line */
|
||||
esp_err_t (*io_int_wait)(int slot, TickType_t timeout_ticks); /*!< Host function to wait for SDIO interrupt line to be active */
|
||||
int command_timeout_ms; /*!< timeout, in milliseconds, of a single command. Set to 0 to use the default value. */
|
||||
} sdmmc_host_t;
|
||||
|
||||
@ -142,9 +147,11 @@ typedef struct {
|
||||
sdmmc_csd_t csd; /*!< decoded CSD (Card-Specific Data) register value */
|
||||
sdmmc_scr_t scr; /*!< decoded SCR (SD card Configuration Register) value */
|
||||
uint16_t rca; /*!< RCA (Relative Card Address) */
|
||||
uint32_t is_mem : 1; /*!< Bit indicates if the card is a memory card */
|
||||
uint32_t is_sdio : 1; /*!< Bit indicates if the card is an IO card */
|
||||
uint32_t num_io_functions : 3; /*!< If is_sdio is 1, contains the number of IO functions on the card */
|
||||
uint32_t reserved : 27; /*!< Reserved for future expansion */
|
||||
} sdmmc_card_t;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _SDMMC_TYPES_H_
|
||||
|
@ -40,9 +40,12 @@ extern "C" {
|
||||
.io_voltage = 3.3f, \
|
||||
.init = &sdspi_host_init, \
|
||||
.set_bus_width = NULL, \
|
||||
.get_bus_width = NULL, \
|
||||
.set_card_clk = &sdspi_host_set_card_clk, \
|
||||
.do_transaction = &sdspi_host_do_transaction, \
|
||||
.deinit = &sdspi_host_deinit, \
|
||||
.io_int_enable = NULL, \
|
||||
.io_int_wait = NULL, \
|
||||
.command_timeout_ms = 0, \
|
||||
}
|
||||
|
||||
@ -70,8 +73,8 @@ typedef struct {
|
||||
.gpio_mosi = GPIO_NUM_15, \
|
||||
.gpio_sck = GPIO_NUM_14, \
|
||||
.gpio_cs = GPIO_NUM_13, \
|
||||
.gpio_cd = SDMMC_SLOT_NO_CD, \
|
||||
.gpio_wp = SDMMC_SLOT_NO_WP, \
|
||||
.gpio_cd = SDSPI_SLOT_NO_CD, \
|
||||
.gpio_wp = SDSPI_SLOT_NO_WP, \
|
||||
.dma_channel = 1 \
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
// 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.
|
||||
@ -19,9 +19,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include "rom/lldesc.h"
|
||||
|
||||
#include "soc/spi_periph.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -58,6 +57,7 @@ typedef struct {
|
||||
int quadwp_io_num; ///< GPIO pin for WP (Write Protect) signal which is used as D2 in 4-bit communication modes, or -1 if not used.
|
||||
int quadhd_io_num; ///< GPIO pin for HD (HolD) signal which is used as D3 in 4-bit communication modes, or -1 if not used.
|
||||
int max_transfer_sz; ///< Maximum transfer size, in bytes. Defaults to 4094 if 0.
|
||||
uint32_t flags; ///< Abilities of bus to be checked by the driver. Or-ed value of ``SPICOMMON_BUSFLAG_*`` flags.
|
||||
} spi_bus_config_t;
|
||||
|
||||
|
||||
@ -99,9 +99,15 @@ bool spicommon_dma_chan_claim(int dma_chan);
|
||||
*/
|
||||
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
|
||||
#define SPICOMMON_BUSFLAG_QUAD (1<<1) ///< Also initialize WP/HD pins, if specified
|
||||
#define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode
|
||||
#define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode
|
||||
#define SPICOMMON_BUSFLAG_NATIVE_PINS (1<<1) ///< Check using iomux pins. Or indicates the pins are configured through the IO mux rather than GPIO matrix.
|
||||
#define SPICOMMON_BUSFLAG_SCLK (1<<2) ///< Check existing of SCLK pin. Or indicates CLK line initialized.
|
||||
#define SPICOMMON_BUSFLAG_MISO (1<<3) ///< Check existing of MISO pin. Or indicates MISO line initialized.
|
||||
#define SPICOMMON_BUSFLAG_MOSI (1<<4) ///< Check existing of MOSI pin. Or indicates CLK line initialized.
|
||||
#define SPICOMMON_BUSFLAG_DUAL (1<<5) ///< Check MOSI and MISO pins can output. Or indicates bus able to work under DIO mode.
|
||||
#define SPICOMMON_BUSFLAG_WPHD (1<<6) ///< Check existing of WP and HD pins. Or indicates WP & HD pins initialized.
|
||||
#define SPICOMMON_BUSFLAG_QUAD (SPICOMMON_BUSFLAG_DUAL|SPICOMMON_BUSFLAG_WPHD) ///< Check existing of MOSI/MISO/WP/HD pins as output. Or indicates bus able to work under QIO mode.
|
||||
|
||||
/**
|
||||
* @brief Connect a SPI peripheral to GPIO pins
|
||||
@ -113,25 +119,51 @@ bool spicommon_dma_chan_free(int dma_chan);
|
||||
* @param host SPI peripheral to be routed
|
||||
* @param bus_config Pointer to a spi_bus_config struct detailing the GPIO pins
|
||||
* @param dma_chan DMA-channel (1 or 2) to use, or 0 for no DMA.
|
||||
* @param flags Combination of SPICOMMON_BUSFLAG_* flags
|
||||
* @param[out] is_native A value of 'true' will be written to this address if the GPIOs can be
|
||||
* routed using the IO_mux, 'false' if the GPIO matrix is used.
|
||||
* @param flags Combination of SPICOMMON_BUSFLAG_* flags, set to ensure the pins set are capable with some functions:
|
||||
* - ``SPICOMMON_BUSFLAG_MASTER``: Initialize I/O in master mode
|
||||
* - ``SPICOMMON_BUSFLAG_SLAVE``: Initialize I/O in slave mode
|
||||
* - ``SPICOMMON_BUSFLAG_NATIVE_PINS``: Pins set should match the iomux pins of the controller.
|
||||
* - ``SPICOMMON_BUSFLAG_SCLK``, ``SPICOMMON_BUSFLAG_MISO``, ``SPICOMMON_BUSFLAG_MOSI``:
|
||||
* Make sure SCLK/MISO/MOSI is/are set to a valid GPIO. Also check output capability according to the mode.
|
||||
* - ``SPICOMMON_BUSFLAG_DUAL``: Make sure both MISO and MOSI are output capable so that DIO mode is capable.
|
||||
* - ``SPICOMMON_BUSFLAG_WPHD`` Make sure WP and HD are set to valid output GPIOs.
|
||||
* - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``.
|
||||
* @param[out] flags_o A SPICOMMON_BUSFLAG_* flag combination of bus abilities will be written to this address.
|
||||
* Leave to NULL if not needed.
|
||||
* - ``SPICOMMON_BUSFLAG_NATIVE_PINS``: The bus is connected to iomux pins.
|
||||
* - ``SPICOMMON_BUSFLAG_SCLK``, ``SPICOMMON_BUSFLAG_MISO``, ``SPICOMMON_BUSFLAG_MOSI``: The bus has
|
||||
* CLK/MISO/MOSI connected.
|
||||
* - ``SPICOMMON_BUSFLAG_DUAL``: The bus is capable with DIO mode.
|
||||
* - ``SPICOMMON_BUSFLAG_WPHD`` The bus has WP and HD connected.
|
||||
* - ``SPICOMMON_BUSFLAG_QUAD``: Combination of ``SPICOMMON_BUSFLAG_DUAL`` and ``SPICOMMON_BUSFLAG_WPHD``.
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, int flags, bool *is_native);
|
||||
esp_err_t spicommon_bus_initialize_io(spi_host_device_t host, const spi_bus_config_t *bus_config, int dma_chan, uint32_t flags, uint32_t *flags_o);
|
||||
|
||||
/**
|
||||
* @brief Free the IO used by a SPI peripheral
|
||||
* @deprecated Use spicommon_bus_free_io_cfg instead.
|
||||
*
|
||||
* @param host SPI peripheral to be freed
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t spicommon_bus_free_io(spi_host_device_t host) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Free the IO used by a SPI peripheral
|
||||
*
|
||||
* @param host SPI peripheral to be freed
|
||||
* @param bus_cfg Bus config struct which defines which pins to be used.
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
|
||||
esp_err_t spicommon_bus_free_io(spi_host_device_t host);
|
||||
esp_err_t spicommon_bus_free_io_cfg(const spi_bus_config_t *bus_cfg);
|
||||
|
||||
/**
|
||||
* @brief Initialize a Chip Select pin for a specific SPI peripheral
|
||||
@ -148,12 +180,19 @@ void spicommon_cs_initialize(spi_host_device_t host, int cs_io_num, int cs_num,
|
||||
|
||||
/**
|
||||
* @brief Free a chip select line
|
||||
* @deprecated Use spicommon_cs_io, which inputs the gpio num rather than the cs id instead.
|
||||
*
|
||||
* @param host SPI peripheral
|
||||
* @param cs_num CS id to free
|
||||
*/
|
||||
void spicommon_cs_free(spi_host_device_t host, int cs_num);
|
||||
void spicommon_cs_free(spi_host_device_t host, int cs_num) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Free a chip select line
|
||||
*
|
||||
* @param cs_gpio_num CS gpio num to free
|
||||
*/
|
||||
void spicommon_cs_free_io(int cs_gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Setup a DMA link chain
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// 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.
|
||||
@ -22,6 +22,19 @@
|
||||
|
||||
#include "driver/spi_common.h"
|
||||
|
||||
/** SPI master clock is divided by 80MHz apb clock. Below defines are example frequencies, and are accurate. Be free to specify a random frequency, it will be rounded to closest frequency (to macros below if above 8MHz).
|
||||
* 8MHz
|
||||
*/
|
||||
#define SPI_MASTER_FREQ_8M (APB_CLK_FREQ/10)
|
||||
#define SPI_MASTER_FREQ_9M (APB_CLK_FREQ/9) ///< 8.89MHz
|
||||
#define SPI_MASTER_FREQ_10M (APB_CLK_FREQ/8) ///< 10MHz
|
||||
#define SPI_MASTER_FREQ_11M (APB_CLK_FREQ/7) ///< 11.43MHz
|
||||
#define SPI_MASTER_FREQ_13M (APB_CLK_FREQ/6) ///< 13.33MHz
|
||||
#define SPI_MASTER_FREQ_16M (APB_CLK_FREQ/5) ///< 16MHz
|
||||
#define SPI_MASTER_FREQ_20M (APB_CLK_FREQ/4) ///< 20MHz
|
||||
#define SPI_MASTER_FREQ_26M (APB_CLK_FREQ/3) ///< 26.67MHz
|
||||
#define SPI_MASTER_FREQ_40M (APB_CLK_FREQ/2) ///< 40MHz
|
||||
#define SPI_MASTER_FREQ_80M (APB_CLK_FREQ/1) ///< 80MHz
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -35,12 +48,12 @@ extern "C"
|
||||
#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
|
||||
#define SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active
|
||||
/** There are timing issue when reading at high frequency (the frequency is related to whether native pins are used, valid time after slave sees the clock).
|
||||
* In half-duplex mode, the driver automatically inserts dummy bits before reading phase to fix the timing issue. Set this flag to disable this feature.
|
||||
* However in full-duplex mode, dummy bits are not allowed to use and no way to prevent reading data from being corrupted.
|
||||
* Set this flag to confirm that you're going to work with output only, or read without dummy bits at your own risk.
|
||||
*/
|
||||
#define SPI_DEVICE_NO_DUMMY (1<<6)
|
||||
/** There are timing issue when reading at high frequency (the frequency is related to whether iomux pins are used, valid time after slave sees the clock).
|
||||
* - In half-duplex mode, the driver automatically inserts dummy bits before reading phase to fix the timing issue. Set this flag to disable this feature.
|
||||
* - In full-duplex mode, however, the hardware cannot use dummy bits, so there is no way to prevent data being read from getting corrupted.
|
||||
* Set this flag to confirm that you're going to work with output only, or read without dummy bits at your own risk.
|
||||
*/
|
||||
#define SPI_DEVICE_NO_DUMMY (1<<6)
|
||||
|
||||
|
||||
typedef struct spi_transaction_t spi_transaction_t;
|
||||
@ -57,7 +70,12 @@ typedef struct {
|
||||
uint8_t duty_cycle_pos; ///< Duty cycle of positive clock, in 1/256th increments (128 = 50%/50% duty). Setting this to 0 (=not setting it) is equivalent to setting this to 128.
|
||||
uint8_t cs_ena_pretrans; ///< Amount of SPI bit-cycles the cs should be activated before the transmission (0-16). This only works on half-duplex transactions.
|
||||
uint8_t cs_ena_posttrans; ///< Amount of SPI bit-cycles the cs should stay active after the transmission (0-16)
|
||||
int clock_speed_hz; ///< Clock speed, in Hz
|
||||
int clock_speed_hz; ///< Clock speed, divisors of 80MHz, in Hz. See ``SPI_MASTER_FREQ_*``.
|
||||
int input_delay_ns; /**< Maximum data valid time of slave. The time required between SCLK and MISO
|
||||
valid, including the possible clock delay from slave to master. The driver uses this value to give an extra
|
||||
delay before the MISO is ready on the line. Leave at 0 unless you know you need a delay. For better timing
|
||||
performance at high frequency (over 8MHz), it's suggest to have the right value.
|
||||
*/
|
||||
int spics_io_num; ///< CS GPIO pin for this device, or -1 if not used
|
||||
uint32_t flags; ///< Bitwise OR of SPI_DEVICE_* flags
|
||||
int queue_size; ///< Transaction queue size. This sets how many transactions can be 'in the air' (queued using spi_device_queue_trans but not yet finished using spi_device_get_trans_result) at the same time
|
||||
@ -79,12 +97,18 @@ typedef struct {
|
||||
*/
|
||||
struct spi_transaction_t {
|
||||
uint32_t flags; ///< Bitwise OR of SPI_TRANS_* flags
|
||||
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).
|
||||
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, 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.
|
||||
@ -119,14 +143,14 @@ typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a
|
||||
* @param host SPI peripheral that controls this bus
|
||||
* @param bus_config Pointer to a spi_bus_config_t struct specifying how the host should be initialized
|
||||
* @param dma_chan Either channel 1 or 2, or 0 in the case when no DMA is required. Selecting a DMA channel
|
||||
* for a SPI bus allows transfers on the bus to have sizes only limited by the amount of
|
||||
* for a SPI bus allows transfers on the bus to have sizes only limited by the amount of
|
||||
* internal memory. Selecting no DMA channel (by passing the value 0) limits the amount of
|
||||
* bytes transfered to a maximum of 32.
|
||||
*
|
||||
* @warning If a DMA channel is selected, any transmit and receive buffer used should be allocated in
|
||||
* @warning If a DMA channel is selected, any transmit and receive buffer used should be allocated in
|
||||
* DMA-capable memory.
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if configuration is invalid
|
||||
* - ESP_ERR_INVALID_STATE if host already is in use
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
@ -140,7 +164,7 @@ esp_err_t spi_bus_initialize(spi_host_device_t host, const spi_bus_config_t *bus
|
||||
* @warning In order for this to succeed, all devices have to be removed first.
|
||||
*
|
||||
* @param host SPI peripheral to free
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_INVALID_STATE if not all devices on the bus are freed
|
||||
* - ESP_OK on success
|
||||
@ -160,12 +184,12 @@ esp_err_t spi_bus_free(spi_host_device_t host);
|
||||
* @param host SPI peripheral to allocate device on
|
||||
* @param dev_config SPI interface protocol config for the device
|
||||
* @param handle Pointer to variable to hold the device handle
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NOT_FOUND if host doesn't have any free CS slots
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
*/
|
||||
esp_err_t spi_bus_add_device(spi_host_device_t host, const spi_device_interface_config_t *dev_config, spi_device_handle_t *handle);
|
||||
|
||||
|
||||
@ -173,7 +197,7 @@ esp_err_t spi_bus_add_device(spi_host_device_t host, const spi_device_interface_
|
||||
* @brief Remove a device from the SPI bus
|
||||
*
|
||||
* @param handle Device handle to free
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_INVALID_STATE if device already is freed
|
||||
* - ESP_OK on success
|
||||
@ -200,18 +224,18 @@ esp_err_t spi_device_queue_trans(spi_device_handle_t handle, spi_transaction_t *
|
||||
/**
|
||||
* @brief Get the result of a SPI transaction queued earlier
|
||||
*
|
||||
* This routine will wait until a transaction to the given device (queued earlier with
|
||||
* This routine will wait until a transaction to the given device (queued earlier with
|
||||
* spi_device_queue_trans) has succesfully completed. It will then return the description of the
|
||||
* completed transaction so software can inspect the result and e.g. free the memory or
|
||||
* completed transaction so software can inspect the result and e.g. free the memory or
|
||||
* 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. The descriptor should not be modified until the descriptor is returned by
|
||||
* @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
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_TIMEOUT if there was no completed transaction before ticks_to_wait expired
|
||||
* - ESP_OK on success
|
||||
@ -220,15 +244,17 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio
|
||||
|
||||
|
||||
/**
|
||||
* @brief Do a SPI transaction
|
||||
* @brief Send a SPI transaction, wait for it to complete, and return the result
|
||||
*
|
||||
* Essentially does the same as spi_device_queue_trans followed by spi_device_get_trans_result. Do
|
||||
* not use this when there is still a transaction queued that hasn't been finalized
|
||||
* using spi_device_get_trans_result.
|
||||
* This function is the equivalent of calling spi_device_queue_trans() followed by spi_device_get_trans_result().
|
||||
* Do not use this when there is still a transaction separately queued from spi_device_queue_trans() that hasn't been finalized
|
||||
* using spi_device_get_trans_result().
|
||||
*
|
||||
* @note This function is not thread safe when multiple tasks access the same SPI device.
|
||||
*
|
||||
* @param handle Device handle obtained using spi_host_add_dev
|
||||
* @param trans_desc Description of transaction to execute
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
@ -245,6 +271,30 @@ esp_err_t spi_device_transmit(spi_device_handle_t handle, spi_transaction_t *tra
|
||||
*/
|
||||
int spi_cal_clock(int fapb, int hz, int duty_cycle, uint32_t* reg_o);
|
||||
|
||||
/**
|
||||
* @brief Calculate the timing settings of specified frequency and settings.
|
||||
*
|
||||
* @param gpio_is_used True if using GPIO matrix, or False if iomux pins are used.
|
||||
* @param input_delay_ns Input delay from SCLK launch edge to MISO data valid.
|
||||
* @param eff_clk Effective clock frequency (in Hz) from spi_cal_clock.
|
||||
* @param dummy_o Address of dummy bits used output. Set to NULL if not needed.
|
||||
* @param cycles_remain_o Address of cycles remaining (after dummy bits are used) output.
|
||||
* - -1 If too many cycles remaining, suggest to compensate half a clock.
|
||||
* - 0 If no remaining cycles or dummy bits are not used.
|
||||
* - positive value: cycles suggest to compensate.
|
||||
* @note If **dummy_o* is not zero, it means dummy bits should be applied in half duplex mode, and full duplex mode may not work.
|
||||
*/
|
||||
void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int* dummy_o, int* cycles_remain_o);
|
||||
|
||||
/**
|
||||
* @brief Get the frequency limit of current configurations.
|
||||
* SPI master working at this limit is OK, while above the limit, full duplex mode and DMA will not work,
|
||||
* and dummy bits will be aplied in the half duplex mode.
|
||||
* @param gpio_is_used True if using GPIO matrix, or False if native pins are used.
|
||||
* @param input_delay_ns Input delay from SCLK launch edge to MISO data valid.
|
||||
* @return Frequency limit of current configurations.
|
||||
*/
|
||||
int spi_get_freq_limit(bool gpio_is_used, int input_delay_ns);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
// 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.
|
||||
|
@ -103,14 +103,17 @@ typedef enum {
|
||||
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_PAD_MEASURE_CYCLE_DEFAULT (0x7fff) /*!<The timer frequency is 8Mhz, the max value is 0x7fff */
|
||||
#define TOUCH_PAD_MEASURE_WAIT_DEFAULT (0xFF) /*!<The timer frequency is 8Mhz, the max value is 0xff */
|
||||
#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 */
|
||||
#define TOUCH_PAD_BIT_MASK_MAX (0x3ff)
|
||||
|
||||
/**
|
||||
* @brief Initialize touch module.
|
||||
* @note The default FSM mode is 'TOUCH_FSM_MODE_SW'. If you want to use interrupt trigger mode,
|
||||
* then set it using function 'touch_pad_set_fsm_mode' to 'TOUCH_FSM_MODE_TIMER' after calling 'touch_pad_init'.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Touch pad init error
|
||||
@ -127,8 +130,12 @@ esp_err_t touch_pad_deinit();
|
||||
|
||||
/**
|
||||
* @brief Configure touch pad interrupt threshold.
|
||||
*
|
||||
* @note If FSM mode is set to TOUCH_FSM_MODE_TIMER, this function will be blocked for one measurement cycle and wait for data to be valid.
|
||||
*
|
||||
* @param touch_num touch pad index
|
||||
* @param threshold interrupt threshold,
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG if argument wrong
|
||||
@ -138,34 +145,82 @@ esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold);
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* 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.
|
||||
*
|
||||
* @note This API requests hardware measurement once. If IIR filter mode is enabled,
|
||||
* please use 'touch_pad_read_raw_data' interface instead.
|
||||
*
|
||||
* @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_ERR_INVALID_ARG Touch pad parameter error
|
||||
* - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0.
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t * touch_value);
|
||||
|
||||
/**
|
||||
* @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_ERR_INVALID_ARG Touch pad parameter error
|
||||
* - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0.
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value);
|
||||
|
||||
/**
|
||||
* @brief get raw data (touch sensor counter value) from IIR filter process.
|
||||
* Need not request hardware measurements.
|
||||
*
|
||||
* @note touch_pad_filter_start has to be called before calling touch_pad_read_raw_data.
|
||||
* 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 parameter error
|
||||
* - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0.
|
||||
* - ESP_FAIL Touch pad not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint16_t *touch_value);
|
||||
|
||||
/**
|
||||
* @brief Callback function that is called after each IIR filter calculation.
|
||||
* @note This callback is called in timer task in each filtering cycle.
|
||||
* @note This callback should not be blocked.
|
||||
* @param raw_value The latest raw data(touch sensor counter value) that
|
||||
* points to all channels(raw_value[0..TOUCH_PAD_MAX-1]).
|
||||
* @param filtered_value The latest IIR filtered data(calculated from raw data) that
|
||||
* points to all channels(filtered_value[0..TOUCH_PAD_MAX-1]).
|
||||
*
|
||||
*/
|
||||
typedef void (* filter_cb_t)(uint16_t *raw_value, uint16_t *filtered_value);
|
||||
|
||||
/**
|
||||
* @brief Register the callback function that is called after each IIR filter calculation.
|
||||
* @note The 'read_cb' callback is called in timer task in each filtering cycle.
|
||||
* @param read_cb Pointer to filtered callback function.
|
||||
* If the argument passed in is NULL, the callback will stop.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG set error
|
||||
*/
|
||||
esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb);
|
||||
|
||||
/**
|
||||
* @brief Register touch-pad ISR,
|
||||
* @note Deprecated function, users should replace this with touch_pad_isr_register,
|
||||
@ -177,6 +232,7 @@ esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value);
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
* - ESP_ERR_NO_MEM No memory
|
||||
*/
|
||||
esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int unused, intr_handle_t *handle_unused) __attribute__ ((deprecated));
|
||||
|
||||
@ -188,6 +244,7 @@ esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int unuse
|
||||
* @return
|
||||
* - ESP_OK Success ;
|
||||
* - ESP_ERR_INVALID_ARG GPIO error
|
||||
* - ESP_ERR_NO_MEM No memory
|
||||
*/
|
||||
esp_err_t touch_pad_isr_register(intr_handler_t fn, void* arg);
|
||||
|
||||
@ -462,8 +519,6 @@ esp_err_t touch_pad_get_filter_period(uint32_t* p_period_ms);
|
||||
* 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.
|
||||
|
@ -594,8 +594,7 @@ int uart_write_bytes(uart_port_t uart_num, const char* src, size_t size);
|
||||
* @param uart_num UART_NUM_0, UART_NUM_1 or UART_NUM_2
|
||||
* @param src data buffer address
|
||||
* @param size data length to send
|
||||
* @param brk_len break signal length (unit: the time it takes to send a complete byte
|
||||
including start, stop and parity bits at current_baudrate)
|
||||
* @param brk_len break signal duration(unit: the time it takes to send one bit at current baudrate)
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
@ -674,8 +673,11 @@ esp_err_t uart_disable_pattern_det_intr(uart_port_t uart_num);
|
||||
* @param pattern_chr character of the pattern
|
||||
* @param chr_num number of the character, 8bit value.
|
||||
* @param chr_tout timeout of the interval between each pattern characters, 24bit value, unit is APB (80Mhz) clock cycle.
|
||||
* When the duration is less than this value, it will not take this data as at_cmd char
|
||||
* @param post_idle idle time after the last pattern character, 24bit value, unit is APB (80Mhz) clock cycle.
|
||||
* When the duration is less than this value, it will not take the previous data as the last at_cmd char
|
||||
* @param pre_idle idle time before the first pattern character, 24bit value, unit is APB (80Mhz) clock cycle.
|
||||
* When the duration is less than this value, it will not take this data as the first at_cmd char
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -702,6 +704,25 @@ esp_err_t uart_enable_pattern_det_intr(uart_port_t uart_num, char pattern_chr, u
|
||||
*/
|
||||
int uart_pattern_pop_pos(uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Return the nearest detected pattern position in buffer.
|
||||
* The positions of the detected pattern are saved in a queue,
|
||||
* This function do nothing to the queue.
|
||||
* @note If the RX buffer is full and flow control is not enabled,
|
||||
* the detected pattern may not be found in the rx buffer due to overflow.
|
||||
*
|
||||
* The following APIs will modify the pattern position info:
|
||||
* uart_flush_input, uart_read_bytes, uart_driver_delete, uart_pop_pattern_pos
|
||||
* It is the application's responsibility to ensure atomic access to the pattern queue and the rx data buffer
|
||||
* when using pattern detect feature.
|
||||
*
|
||||
* @param uart_num UART port number
|
||||
* @return
|
||||
* - (-1) No pattern found for current index or parameter error
|
||||
* - others the pattern position in rx buffer.
|
||||
*/
|
||||
int uart_pattern_get_pos(uart_port_t uart_num);
|
||||
|
||||
/**
|
||||
* @brief Allocate a new memory with the given length to save record the detected pattern position in rx buffer.
|
||||
* @param uart_num UART port number
|
||||
|
49
tools/sdk/include/driver/driver/uart_select.h
Normal file
49
tools/sdk/include/driver/driver/uart_select.h
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef _UART_SELECT_H_
|
||||
#define _UART_SELECT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver/uart.h"
|
||||
|
||||
typedef enum {
|
||||
UART_SELECT_READ_NOTIF,
|
||||
UART_SELECT_WRITE_NOTIF,
|
||||
UART_SELECT_ERROR_NOTIF,
|
||||
} uart_select_notif_t;
|
||||
|
||||
typedef void (*uart_select_notif_callback_t)(uart_port_t uart_num, uart_select_notif_t uart_select_notif, BaseType_t *task_woken);
|
||||
|
||||
/**
|
||||
* @brief Set notification callback function for select() events
|
||||
* @param uart_num UART port number
|
||||
* @param uart_select_notif_callback callback function
|
||||
*/
|
||||
void uart_set_select_notif_callback(uart_port_t uart_num, uart_select_notif_callback_t uart_select_notif_callback);
|
||||
|
||||
/**
|
||||
* @brief Get mutex guarding select() notifications
|
||||
*/
|
||||
portMUX_TYPE *uart_get_selectlock();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_UART_SELECT_H_
|
Reference in New Issue
Block a user