mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-29 20:10:59 +02:00
IDF master d93887f9f (#5336)
* Update toolchain * Update package_esp32_index.template.json * add optional component dependencies after Kconfig options are known (#5404) Until this commit, Kconfig options (e.g. CONFIG_TINYUSB_ENABLED) were used in conditions preceding idf_component_register to determine which components need to be added to `arduino` component requirements. However the Kconfig options aren't known at the early expansion stage, when the component CMakeLists.txt files are expanded the first time and requirements are evaluated. So all the conditions evaluated as if the options were not set. This commit changes the logic to only add these components as dependencies when the Kconfig options are known. Dependencies become "weak", which means that if one of the components isn't included into the build for some reason, it is not added as a dependency. This may happen, for example, if the component is not present in the `components` directory or is excluded by setting `COMPONENTS` variable in the project CMakeLists.txt file. This also ensures that if the component is not present, it will not be added as a dependency, and this will allow the build to proceed. Follow-up to https://github.com/espressif/arduino-esp32/pull/5391. Closes https://github.com/espressif/arduino-esp32/issues/5319. * IDF master d93887f9f * PlatformIO updates for CI (#5387) * Update PlatformIO CI build script - Switch to the latest toolchains 8.4.0 for ESP32, ESP32S2, ESP32C3 - Use PlatformIO from master branch for better robustness * Update package.json for PlatformIO Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com>
This commit is contained in:
@ -35,7 +35,7 @@ esp_err_t adc2_wifi_acquire(void);
|
||||
*/
|
||||
esp_err_t adc2_wifi_release(void);
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* @brief This API help ADC2 calibration constructor be linked.
|
||||
*
|
||||
|
@ -45,7 +45,7 @@ typedef enum {
|
||||
ADC1_CHANNEL_9, /*!< ADC1 channel 9 is GPIO10 */
|
||||
ADC1_CHANNEL_MAX,
|
||||
} adc1_channel_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/**** `adc1_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC1_CHANNEL_0 = 0, /*!< ADC1 channel 0 is GPIO0 */
|
||||
@ -72,7 +72,7 @@ typedef enum {
|
||||
ADC2_CHANNEL_9, /*!< ADC2 channel 9 is GPIO26 (ESP32), GPIO20 (ESP32-S2) */
|
||||
ADC2_CHANNEL_MAX,
|
||||
} adc2_channel_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/**** `adc2_channel_t` will be deprecated functions, combine into `adc_channel_t` ********/
|
||||
typedef enum {
|
||||
ADC2_CHANNEL_0 = 0, /*!< ADC2 channel 0 is GPIO5 */
|
||||
@ -103,7 +103,7 @@ typedef enum {
|
||||
#define ADC_WIDTH_11Bit ADC_WIDTH_BIT_11
|
||||
#define ADC_WIDTH_12Bit ADC_WIDTH_BIT_12
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* @brief Digital ADC DMA read max timeout value, it may make the ``adc_digi_read_bytes`` block forever if the OS supports
|
||||
*/
|
||||
@ -121,7 +121,7 @@ typedef enum {
|
||||
ADC_ENCODE_MAX,
|
||||
} adc_i2s_encode_t;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
//This feature is currently supported on ESP32C3, will be supported on other chips soon
|
||||
/**
|
||||
* @brief Digital ADC DMA configuration
|
||||
@ -167,7 +167,7 @@ void adc_power_acquire(void);
|
||||
*/
|
||||
void adc_power_release(void);
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* @brief Initialize ADC pad
|
||||
* @param adc_unit ADC unit index
|
||||
@ -177,7 +177,7 @@ void adc_power_release(void);
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t adc_gpio_init(adc_unit_t adc_unit, adc_channel_t channel);
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Single Read Setting
|
||||
@ -276,7 +276,7 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit);
|
||||
*/
|
||||
int adc1_get_raw(adc1_channel_t channel);
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* @brief Set ADC data invert
|
||||
* @param adc_unit ADC unit index
|
||||
@ -317,7 +317,7 @@ esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t width_bit);
|
||||
* to be called to configure ADC1 channels, before ADC1 is used by the ULP.
|
||||
*/
|
||||
void adc1_ulp_enable(void);
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
|
||||
/**
|
||||
* @brief Get the GPIO number of a specific ADC2 channel.
|
||||
@ -477,7 +477,7 @@ esp_err_t adc_digi_deinit(void);
|
||||
*/
|
||||
esp_err_t adc_digi_controller_config(const adc_digi_config_t *config);
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
//This feature is currently supported on ESP32C3, will be supported on other chips soon
|
||||
/*---------------------------------------------------------------
|
||||
DMA setting
|
||||
@ -537,7 +537,7 @@ esp_err_t adc_digi_read_bytes(uint8_t *buf, uint32_t length_max, uint32_t *out_l
|
||||
*/
|
||||
esp_err_t adc_digi_deinitialize(void);
|
||||
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ typedef struct {
|
||||
const int *gpio_array; /*!< Array of GPIO numbers, gpio_array[0] ~ gpio_array[size-1] <=> low_dedic_channel_num ~ high_dedic_channel_num */
|
||||
size_t array_size; /*!< Number of GPIOs in gpio_array */
|
||||
struct {
|
||||
int in_en: 1; /*!< Enable input */
|
||||
int in_invert: 1; /*!< Invert input signal */
|
||||
int out_en: 1; /*!< Enable output */
|
||||
int out_invert: 1; /*!< Invert output signal */
|
||||
unsigned int in_en: 1; /*!< Enable input */
|
||||
unsigned int in_invert: 1; /*!< Invert input signal */
|
||||
unsigned int out_en: 1; /*!< Enable output */
|
||||
unsigned int out_invert: 1; /*!< Invert output signal */
|
||||
} flags; /*!< Flags to control specific behaviour of GPIO bundle */
|
||||
} dedic_gpio_bundle_config_t;
|
||||
|
||||
|
@ -5,14 +5,18 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include <stdbool.h>
|
||||
#include "esp_intr_alloc.h"
|
||||
#if !CONFIG_IDF_TARGET_LINUX
|
||||
#include <esp_types.h>
|
||||
#include <esp_bit_defs.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#endif // !CONFIG_IDF_TARGET_LINUX
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
// |================================= WARNING ====================================================== |
|
||||
@ -29,6 +33,8 @@
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "esp32h2/rom/gpio.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS
|
||||
|
@ -36,6 +36,32 @@ extern "C" {
|
||||
#define I2C_SCLK_SRC_FLAG_AWARE_DFS (1 << 0) /*!< For REF tick clock, it won't change with APB.*/
|
||||
#define I2C_SCLK_SRC_FLAG_LIGHT_SLEEP (1 << 1) /*!< For light sleep mode.*/
|
||||
|
||||
/**
|
||||
* @brief Minimum size, in bytes, of the internal private structure used to describe
|
||||
* I2C commands link.
|
||||
*/
|
||||
#define I2C_INTERNAL_STRUCT_SIZE (24)
|
||||
|
||||
/**
|
||||
* @brief The following macro is used to determine the recommended size of the
|
||||
* buffer to pass to `i2c_cmd_link_create_static()` function.
|
||||
* It requires one parameter, `TRANSACTIONS`, describing the number of transactions
|
||||
* intended to be performed on the I2C port.
|
||||
* For example, if one wants to perform a read on an I2C device register, `TRANSACTIONS`
|
||||
* must be at least 2, because the commands required are the following:
|
||||
* - write device register
|
||||
* - read register content
|
||||
*
|
||||
* Signals such as "(repeated) start", "stop", "nack", "ack" shall not be counted.
|
||||
*/
|
||||
#define I2C_LINK_RECOMMENDED_SIZE(TRANSACTIONS) (2 * I2C_INTERNAL_STRUCT_SIZE + I2C_INTERNAL_STRUCT_SIZE * \
|
||||
(5 * TRANSACTIONS)) /* Make the assumption that each transaction
|
||||
* of the user is surrounded by a "start", device address
|
||||
* and a "nack/ack" signal. Allocate one more room for
|
||||
* "stop" signal at the end.
|
||||
* Allocate 2 more internal struct size for headers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief I2C initialization parameters
|
||||
*/
|
||||
@ -62,18 +88,14 @@ typedef struct{
|
||||
typedef void *i2c_cmd_handle_t; /*!< I2C command handle */
|
||||
|
||||
/**
|
||||
* @brief I2C driver install
|
||||
* @brief Install an I2C driver
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param mode I2C mode( master or slave )
|
||||
* @param slv_rx_buf_len receiving buffer size for slave mode
|
||||
* @note
|
||||
* Only slave mode will use this value, driver will ignore this value in master mode.
|
||||
* @param slv_tx_buf_len sending buffer size for slave mode
|
||||
* @note
|
||||
* Only slave mode will use this value, driver will ignore this value in master mode.
|
||||
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
|
||||
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
|
||||
* @param mode I2C mode (either master or slave)
|
||||
* @param slv_rx_buf_len Receiving buffer size. Only slave mode will use this value, it is ignored in master mode.
|
||||
* @param slv_tx_buf_len Sending buffer size. Only slave mode will use this value, it is ignored in master mode.
|
||||
* @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.
|
||||
* @note
|
||||
* In master mode, if the cache is likely to be disabled(such as write flash) and the slave is time-sensitive,
|
||||
* `ESP_INTR_FLAG_IRAM` is suggested to be used. In this case, please use the memory allocated from internal RAM in i2c read and write function,
|
||||
@ -82,17 +104,17 @@ typedef void *i2c_cmd_handle_t; /*!< I2C command handle */
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Driver install error
|
||||
* - ESP_FAIL Driver installation error
|
||||
*/
|
||||
esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_buf_len, size_t slv_tx_buf_len, int intr_alloc_flags);
|
||||
|
||||
/**
|
||||
* @brief I2C driver delete
|
||||
* @brief Delete I2C driver
|
||||
*
|
||||
* @note This function does not guarantee thread safety.
|
||||
* Please make sure that no thread will continuously hold semaphores before calling the delete function.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param i2c_num I2C port to delete
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -101,10 +123,10 @@ esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_
|
||||
esp_err_t i2c_driver_delete(i2c_port_t i2c_num);
|
||||
|
||||
/**
|
||||
* @brief I2C parameter initialization
|
||||
* @brief Configure an I2C bus with the given configuration.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param i2c_conf pointer to I2C parameter settings
|
||||
* @param i2c_num I2C port to configure
|
||||
* @param i2c_conf Pointer to the I2C configuration
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -135,14 +157,14 @@ esp_err_t i2c_reset_tx_fifo(i2c_port_t i2c_num);
|
||||
esp_err_t i2c_reset_rx_fifo(i2c_port_t i2c_num);
|
||||
|
||||
/**
|
||||
* @brief I2C isr handler register
|
||||
* @brief Register an I2C ISR handler.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param fn isr handler function
|
||||
* @param arg parameter for isr handler function
|
||||
* @param i2c_num I2C port number to attach handler to
|
||||
* @param fn ISR handler function
|
||||
* @param arg Parameter for the ISR handler
|
||||
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
|
||||
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
|
||||
* @param handle handle return from esp_intr_alloc.
|
||||
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
|
||||
* @param handle Handle return from esp_intr_alloc.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -151,9 +173,9 @@ esp_err_t i2c_reset_rx_fifo(i2c_port_t i2c_num);
|
||||
esp_err_t i2c_isr_register(i2c_port_t i2c_num, void (*fn)(void *), void *arg, int intr_alloc_flags, intr_handle_t *handle);
|
||||
|
||||
/**
|
||||
* @brief to delete and free I2C isr.
|
||||
* @brief Delete and free I2C ISR handle.
|
||||
*
|
||||
* @param handle handle of isr.
|
||||
* @param handle Handle of isr to delete.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -162,13 +184,13 @@ esp_err_t i2c_isr_register(i2c_port_t i2c_num, void (*fn)(void *), void *arg, in
|
||||
esp_err_t i2c_isr_free(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Configure GPIO signal for I2C sck and sda
|
||||
* @brief Configure GPIO pins for I2C SCK and SDA signals.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param sda_io_num GPIO number for I2C sda signal
|
||||
* @param scl_io_num GPIO number for I2C scl signal
|
||||
* @param sda_pullup_en Whether to enable the internal pullup for sda pin
|
||||
* @param scl_pullup_en Whether to enable the internal pullup for scl pin
|
||||
* @param sda_io_num GPIO number for I2C SDA signal
|
||||
* @param scl_io_num GPIO number for I2C SCL signal
|
||||
* @param sda_pullup_en Enable the internal pullup for SDA pin
|
||||
* @param scl_pullup_en Enable the internal pullup for SCL pin
|
||||
* @param mode I2C mode
|
||||
*
|
||||
* @return
|
||||
@ -179,191 +201,289 @@ esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num,
|
||||
bool sda_pullup_en, bool scl_pullup_en, i2c_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Create and init I2C command link
|
||||
* @note
|
||||
* Before we build I2C command link, we need to call i2c_cmd_link_create() to create
|
||||
* a command link.
|
||||
* After we finish sending the commands, we need to call i2c_cmd_link_delete() to
|
||||
* release and return the resources.
|
||||
* @brief Perform a write to a device connected to a particular I2C port.
|
||||
* This function is a wrapper to `i2c_master_start()`, `i2c_master_write()`, `i2c_master_read()`, etc...
|
||||
* It shall only be called in I2C master mode.
|
||||
*
|
||||
* @return i2c command link handler
|
||||
* @param i2c_num I2C port number to perform the transfer on
|
||||
* @param device_address I2C device's 7-bit address
|
||||
* @param write_buffer Bytes to send on the bus
|
||||
* @param write_size Size, in bytes, of the write buffer
|
||||
* @param ticks_to_wait Maximum ticks to wait before issuing a timeout.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave hasn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_master_write_to_device(i2c_port_t i2c_num, uint8_t device_address,
|
||||
const uint8_t* write_buffer, size_t write_size,
|
||||
TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Perform a read to a device connected to a particular I2C port.
|
||||
* This function is a wrapper to `i2c_master_start()`, `i2c_master_write()`, `i2c_master_read()`, etc...
|
||||
* It shall only be called in I2C master mode.
|
||||
*
|
||||
* @param i2c_num I2C port number to perform the transfer on
|
||||
* @param device_address I2C device's 7-bit address
|
||||
* @param read_buffer Buffer to store the bytes received on the bus
|
||||
* @param read_size Size, in bytes, of the read buffer
|
||||
* @param ticks_to_wait Maximum ticks to wait before issuing a timeout.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave hasn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_master_read_from_device(i2c_port_t i2c_num, uint8_t device_address,
|
||||
uint8_t* read_buffer, size_t read_size,
|
||||
TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Perform a write followed by a read to a device on the I2C bus.
|
||||
* A repeated start signal is used between the `write` and `read`, thus, the bus is
|
||||
* not released until the two transactions are finished.
|
||||
* This function is a wrapper to `i2c_master_start()`, `i2c_master_write()`, `i2c_master_read()`, etc...
|
||||
* It shall only be called in I2C master mode.
|
||||
*
|
||||
* @param i2c_num I2C port number to perform the transfer on
|
||||
* @param device_address I2C device's 7-bit address
|
||||
* @param write_buffer Bytes to send on the bus
|
||||
* @param write_size Size, in bytes, of the write buffer
|
||||
* @param read_buffer Buffer to store the bytes received on the bus
|
||||
* @param read_size Size, in bytes, of the read buffer
|
||||
* @param ticks_to_wait Maximum ticks to wait before issuing a timeout.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave hasn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_master_write_read_device(i2c_port_t i2c_num, uint8_t device_address,
|
||||
const uint8_t* write_buffer, size_t write_size,
|
||||
uint8_t* read_buffer, size_t read_size,
|
||||
TickType_t ticks_to_wait);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create and initialize an I2C commands list with a given buffer.
|
||||
* All the allocations for data or signals (START, STOP, ACK, ...) will be
|
||||
* performed within this buffer.
|
||||
* This buffer must be valid during the whole transaction.
|
||||
* After finishing the I2C transactions, it is required to call `i2c_cmd_link_delete_static()`.
|
||||
*
|
||||
* @note It is **highly** advised to not allocate this buffer on the stack. The size of the data
|
||||
* used underneath may increase in the future, resulting in a possible stack overflow as the macro
|
||||
* `I2C_LINK_RECOMMENDED_SIZE` would also return a bigger value.
|
||||
* A better option is to use a buffer allocated statically or dynamically (with `malloc`).
|
||||
*
|
||||
* @param buffer Buffer to use for commands allocations
|
||||
* @param size Size in bytes of the buffer
|
||||
*
|
||||
* @return Handle to the I2C command link or NULL if the buffer provided is too small, please
|
||||
* use `I2C_LINK_RECOMMENDED_SIZE` macro to get the recommended size for the buffer.
|
||||
*/
|
||||
i2c_cmd_handle_t i2c_cmd_link_create_static(uint8_t* buffer, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Create and initialize an I2C commands list with a given buffer.
|
||||
* After finishing the I2C transactions, it is required to call `i2c_cmd_link_delete()`
|
||||
* to release and return the resources.
|
||||
* The required bytes will be dynamically allocated.
|
||||
*
|
||||
* @return Handle to the I2C command link
|
||||
*/
|
||||
i2c_cmd_handle_t i2c_cmd_link_create(void);
|
||||
|
||||
/**
|
||||
* @brief Free I2C command link
|
||||
* @note
|
||||
* Before we build I2C command link, we need to call i2c_cmd_link_create() to create
|
||||
* a command link.
|
||||
* After we finish sending the commands, we need to call i2c_cmd_link_delete() to
|
||||
* release and return the resources.
|
||||
* @brief Free the I2C commands list allocated statically with `i2c_cmd_link_create_static`.
|
||||
*
|
||||
* @param cmd_handle I2C command handle
|
||||
* @param cmd_handle I2C commands list allocated statically. This handle should be created thanks to
|
||||
* `i2c_cmd_link_create_static()` function
|
||||
*/
|
||||
void i2c_cmd_link_delete_static(i2c_cmd_handle_t cmd_handle);
|
||||
|
||||
/**
|
||||
* @brief Free the I2C commands list
|
||||
*
|
||||
* @param cmd_handle I2C commands list. This handle should be created thanks to
|
||||
* `i2c_cmd_link_create()` function
|
||||
*/
|
||||
void i2c_cmd_link_delete(i2c_cmd_handle_t cmd_handle);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to generate a start signal
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* Call i2c_master_cmd_begin() to send all queued commands
|
||||
* @brief Queue a "START signal" to the given commands list.
|
||||
* This function shall only be called in I2C master mode.
|
||||
* Call `i2c_master_cmd_begin()` to send all the queued commands.
|
||||
*
|
||||
* @param cmd_handle I2C cmd link
|
||||
* @param cmd_handle I2C commands list
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM The static buffer used to create `cmd_handler` is too small
|
||||
* - ESP_FAIL No more memory left on the heap
|
||||
*/
|
||||
esp_err_t i2c_master_start(i2c_cmd_handle_t cmd_handle);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to write one byte to I2C bus
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* Call i2c_master_cmd_begin() to send all queued commands
|
||||
* @brief Queue a "write byte" command to the commands list.
|
||||
* A single byte will be sent on the I2C port. This function shall only be
|
||||
* called in I2C master mode.
|
||||
* Call `i2c_master_cmd_begin()` to send all queued commands
|
||||
*
|
||||
* @param cmd_handle I2C cmd link
|
||||
* @param data I2C one byte command to write to bus
|
||||
* @param ack_en enable ack check for master
|
||||
* @param cmd_handle I2C commands list
|
||||
* @param data Byte to send on the port
|
||||
* @param ack_en Enable ACK signal
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM The static buffer used to create `cmd_handler` is too small
|
||||
* - ESP_FAIL No more memory left on the heap
|
||||
*/
|
||||
esp_err_t i2c_master_write_byte(i2c_cmd_handle_t cmd_handle, uint8_t data, bool ack_en);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to write buffer to I2C bus
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* Call i2c_master_cmd_begin() to send all queued commands
|
||||
* @brief Queue a "write (multiple) bytes" command to the commands list.
|
||||
* This function shall only be called in I2C master mode.
|
||||
* Call `i2c_master_cmd_begin()` to send all queued commands
|
||||
*
|
||||
* @param cmd_handle I2C cmd link
|
||||
* @param data data to send
|
||||
* @note
|
||||
* If the psram is enabled and intr_flag is `ESP_INTR_FLAG_IRAM`, please use the memory allocated from internal RAM.
|
||||
* @param data_len data length
|
||||
* @param ack_en enable ack check for master
|
||||
* @param cmd_handle I2C commands list
|
||||
* @param data Bytes to send. This buffer shall remain **valid** until the transaction is finished.
|
||||
* If the PSRAM is enabled and `intr_flag` is set to `ESP_INTR_FLAG_IRAM`,
|
||||
* `data` should be allocated from internal RAM.
|
||||
* @param data_len Length, in bytes, of the data buffer
|
||||
* @param ack_en Enable ACK signal
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM The static buffer used to create `cmd_handler` is too small
|
||||
* - ESP_FAIL No more memory left on the heap
|
||||
*/
|
||||
esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, const uint8_t *data, size_t data_len, bool ack_en);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to read one byte from I2C bus
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* Call i2c_master_cmd_begin() to send all queued commands
|
||||
* @brief Queue a "read byte" command to the commands list.
|
||||
* A single byte will be read on the I2C bus. This function shall only be
|
||||
* called in I2C master mode.
|
||||
* Call `i2c_master_cmd_begin()` to send all queued commands
|
||||
*
|
||||
* @param cmd_handle I2C cmd link
|
||||
* @param data pointer accept the data byte
|
||||
* @note
|
||||
* If the psram is enabled and intr_flag is `ESP_INTR_FLAG_IRAM`, please use the memory allocated from internal RAM.
|
||||
* @param ack ack value for read command
|
||||
* @param cmd_handle I2C commands list
|
||||
* @param data Pointer where the received byte will the stored. This buffer shall remain **valid**
|
||||
* until the transaction is finished.
|
||||
* @param ack ACK signal
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM The static buffer used to create `cmd_handler` is too small
|
||||
* - ESP_FAIL No more memory left on the heap
|
||||
*/
|
||||
esp_err_t i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, uint8_t *data, i2c_ack_type_t ack);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to read data from I2C bus
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* Call i2c_master_cmd_begin() to send all queued commands
|
||||
* @brief Queue a "read (multiple) bytes" command to the commands list.
|
||||
* Multiple bytes will be read on the I2C bus. This function shall only be
|
||||
* called in I2C master mode.
|
||||
* Call `i2c_master_cmd_begin()` to send all queued commands
|
||||
*
|
||||
* @param cmd_handle I2C cmd link
|
||||
* @param data data buffer to accept the data from bus
|
||||
* @note
|
||||
* If the psram is enabled and intr_flag is `ESP_INTR_FLAG_IRAM`, please use the memory allocated from internal RAM.
|
||||
* @param data_len read data length
|
||||
* @param ack ack value for read command
|
||||
* @param cmd_handle I2C commands list
|
||||
* @param data Pointer where the received bytes will the stored. This buffer shall remain **valid**
|
||||
* until the transaction is finished.
|
||||
* @param data_len Size, in bytes, of the `data` buffer
|
||||
* @param ack ACK signal
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM The static buffer used to create `cmd_handler` is too small
|
||||
* - ESP_FAIL No more memory left on the heap
|
||||
*/
|
||||
esp_err_t i2c_master_read(i2c_cmd_handle_t cmd_handle, uint8_t *data, size_t data_len, i2c_ack_type_t ack);
|
||||
|
||||
/**
|
||||
* @brief Queue command for I2C master to generate a stop signal
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* Call i2c_master_cmd_begin() to send all queued commands
|
||||
* @brief Queue a "STOP signal" to the given commands list.
|
||||
* This function shall only be called in I2C master mode.
|
||||
* Call `i2c_master_cmd_begin()` to send all the queued commands.
|
||||
*
|
||||
* @param cmd_handle I2C cmd link
|
||||
* @param cmd_handle I2C commands list
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_ERR_NO_MEM The static buffer used to create `cmd_handler` is too small
|
||||
* - ESP_FAIL No more memory left on the heap
|
||||
*/
|
||||
esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle);
|
||||
|
||||
/**
|
||||
* @brief I2C master send queued commands.
|
||||
* This function will trigger sending all queued commands.
|
||||
* @brief Send all the queued commands on the I2C bus, in master mode.
|
||||
* The task will be blocked until all the commands have been sent out.
|
||||
* The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks,
|
||||
* you need to take care of the multi-thread issue.
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
* This function shall only be called in I2C master mode.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param cmd_handle I2C command handler
|
||||
* @param ticks_to_wait maximum wait ticks.
|
||||
* @param cmd_handle I2C commands list
|
||||
* @param ticks_to_wait Maximum ticks to wait before issuing a timeout.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_FAIL Sending command error, slave hasn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief I2C slave write data to internal ringbuffer, when tx fifo empty, isr will fill the hardware
|
||||
* fifo from the internal ringbuffer
|
||||
* @note
|
||||
* Only call this function in I2C slave mode
|
||||
* @brief Write bytes to internal ringbuffer of the I2C slave data. When the TX fifo empty, the ISR will
|
||||
* fill the hardware FIFO with the internal ringbuffer's data.
|
||||
* @note This function shall only be called in I2C slave mode.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param data data pointer to write into internal buffer
|
||||
* @param size data size
|
||||
* @param ticks_to_wait Maximum waiting ticks
|
||||
* @param data Bytes to write into internal buffer
|
||||
* @param size Size, in bytes, of `data` buffer
|
||||
* @param ticks_to_wait Maximum ticks to wait.
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL(-1) Parameter error
|
||||
* - Others(>=0) The number of data bytes that pushed to the I2C slave buffer.
|
||||
* - ESP_FAIL (-1) Parameter error
|
||||
* - Other (>=0) The number of data bytes pushed to the I2C slave buffer.
|
||||
*/
|
||||
int i2c_slave_write_buffer(i2c_port_t i2c_num, const uint8_t *data, int size, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief I2C slave read data from internal buffer. When I2C slave receive data, isr will copy received data
|
||||
* from hardware rx fifo to internal ringbuffer. Then users can read from internal ringbuffer.
|
||||
* @note
|
||||
* Only call this function in I2C slave mode
|
||||
* @brief Read bytes from I2C internal buffer. When the I2C bus receives data, the ISR will copy them
|
||||
* from the hardware RX FIFO to the internal ringbuffer.
|
||||
* Calling this function will then copy bytes from the internal ringbuffer to the `data` user buffer.
|
||||
* @note This function shall only be called in I2C slave mode.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param data data pointer to accept data from internal buffer
|
||||
* @param max_size Maximum data size to read
|
||||
* @param data Buffer to fill with ringbuffer's bytes
|
||||
* @param max_size Maximum bytes to read
|
||||
* @param ticks_to_wait Maximum waiting ticks
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL(-1) Parameter error
|
||||
* - Others(>=0) The number of data bytes that read from I2C slave buffer.
|
||||
* - Others(>=0) The number of data bytes read from I2C slave buffer.
|
||||
*/
|
||||
int i2c_slave_read_buffer(i2c_port_t i2c_num, uint8_t *data, size_t max_size, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief set I2C master clock period
|
||||
* @brief Set I2C master clock period
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param high_period clock cycle number during SCL is high level, high_period is a 14 bit value
|
||||
* @param low_period clock cycle number during SCL is low level, low_period is a 14 bit value
|
||||
* @param high_period Clock cycle number during SCL is high level, high_period is a 14 bit value
|
||||
* @param low_period Clock cycle number during SCL is low level, low_period is a 14 bit value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -372,7 +492,7 @@ int i2c_slave_read_buffer(i2c_port_t i2c_num, uint8_t *data, size_t max_size, Ti
|
||||
esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period);
|
||||
|
||||
/**
|
||||
* @brief get I2C master clock period
|
||||
* @brief Get I2C master clock period
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param high_period pointer to get clock cycle number during SCL is high level, will get a 14 bit value
|
||||
@ -385,15 +505,14 @@ esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period);
|
||||
esp_err_t i2c_get_period(i2c_port_t i2c_num, int *high_period, int *low_period);
|
||||
|
||||
/**
|
||||
* @brief enable hardware filter on I2C bus
|
||||
* @brief Enable hardware filter on I2C bus
|
||||
* Sometimes the I2C bus is disturbed by high frequency noise(about 20ns), or the rising edge of
|
||||
* the SCL clock is very slow, these may cause the master state machine broken. enable hardware
|
||||
* filter can filter out high frequency interference and make the master more stable.
|
||||
* @note
|
||||
* Enable filter will slow the SCL clock.
|
||||
* the SCL clock is very slow, these may cause the master state machine to break.
|
||||
* Enable hardware filter can filter out high frequency interference and make the master more stable.
|
||||
* @note Enable filter will slow down the SCL clock.
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param cyc_num the APB cycles need to be filtered(0<= cyc_num <=7).
|
||||
* @param i2c_num I2C port number to filter
|
||||
* @param cyc_num the APB cycles need to be filtered (0<= cyc_num <=7).
|
||||
* When the period of a pulse is less than cyc_num * APB_cycle, the I2C controller will ignore this pulse.
|
||||
*
|
||||
* @return
|
||||
@ -403,7 +522,7 @@ esp_err_t i2c_get_period(i2c_port_t i2c_num, int *high_period, int *low_period);
|
||||
esp_err_t i2c_filter_enable(i2c_port_t i2c_num, uint8_t cyc_num);
|
||||
|
||||
/**
|
||||
* @brief disable filter on I2C bus
|
||||
* @brief Disable filter on I2C bus
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
*
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#if SOC_MCPWM_SUPPORTED
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "soc/soc.h"
|
||||
#include "driver/gpio.h"
|
||||
@ -20,7 +19,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief IO signals for the MCPWM
|
||||
*
|
||||
@ -130,6 +128,15 @@ typedef enum {
|
||||
MCPWM_SELECT_F2, /*!<Select F2 as input*/
|
||||
} mcpwm_fault_signal_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select sync signal input
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_SELECT_SYNC0 = 4, /*!<Select SYNC0 as input*/
|
||||
MCPWM_SELECT_SYNC1, /*!<Select SYNC1 as input*/
|
||||
MCPWM_SELECT_SYNC2, /*!<Select SYNC2 as input*/
|
||||
} mcpwm_sync_signal_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select triggering level of fault signal
|
||||
*/
|
||||
@ -138,6 +145,62 @@ typedef enum {
|
||||
MCPWM_HIGH_LEVEL_TGR, /*!<Fault condition occurs when fault input signal goes low to high*/
|
||||
} mcpwm_fault_input_level_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select capture starts from which edge
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_NEG_EDGE = BIT(0), /*!<Capture the negative edge*/
|
||||
MCPWM_POS_EDGE = BIT(1), /*!<Capture the positive edge*/
|
||||
MCPWM_BOTH_EDGE = BIT(1) | BIT(0), /*!<Capture both edges*/
|
||||
} mcpwm_capture_on_edge_t;
|
||||
|
||||
/**
|
||||
* @brief Select type of MCPWM counter
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_FREEZE_COUNTER, /*!<Counter freeze */
|
||||
MCPWM_UP_COUNTER, /*!<For asymmetric MCPWM*/
|
||||
MCPWM_DOWN_COUNTER, /*!<For asymmetric MCPWM*/
|
||||
MCPWM_UP_DOWN_COUNTER, /*!<For symmetric MCPWM, frequency is half of MCPWM frequency set*/
|
||||
MCPWM_COUNTER_MAX, /*!<Maximum counter mode*/
|
||||
} mcpwm_counter_type_t;
|
||||
|
||||
/**
|
||||
* @brief Select type of MCPWM duty cycle mode
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_DUTY_MODE_0 = 0, /*!<Active high duty, i.e. duty cycle proportional to high time for asymmetric MCPWM*/
|
||||
MCPWM_DUTY_MODE_1, /*!<Active low duty, i.e. duty cycle proportional to low time for asymmetric MCPWM, out of phase(inverted) MCPWM*/
|
||||
MCPWM_HAL_GENERATOR_MODE_FORCE_LOW,
|
||||
MCPWM_HAL_GENERATOR_MODE_FORCE_HIGH,
|
||||
MCPWM_DUTY_MODE_MAX, /*!<Num of duty cycle modes*/
|
||||
} mcpwm_duty_type_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM deadtime types, used to generate deadtime, RED refers to rising edge delay and FED refers to falling edge delay
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_DEADTIME_BYPASS = 0, /*!<Bypass the deadtime*/
|
||||
MCPWM_BYPASS_RED, /*!<MCPWMXA = no change, MCPWMXB = falling edge delay*/
|
||||
MCPWM_BYPASS_FED, /*!<MCPWMXA = rising edge delay, MCPWMXB = no change*/
|
||||
MCPWM_ACTIVE_HIGH_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = falling edge delay*/
|
||||
MCPWM_ACTIVE_LOW_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = compliment of falling edge delay*/
|
||||
MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = compliment of falling edge delay*/
|
||||
MCPWM_ACTIVE_LOW_COMPLIMENT_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = falling edge delay*/
|
||||
MCPWM_ACTIVE_RED_FED_FROM_PWMXA, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXA*/
|
||||
MCPWM_ACTIVE_RED_FED_FROM_PWMXB, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXB*/
|
||||
MCPWM_DEADTIME_TYPE_MAX,
|
||||
} mcpwm_deadtime_type_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select action to be taken on the output when event happens
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_ACTION_NO_CHANGE = 0, /*!<No change in the output*/
|
||||
MCPWM_ACTION_FORCE_LOW, /*!<Make output low*/
|
||||
MCPWM_ACTION_FORCE_HIGH, /*!<Make output high*/
|
||||
MCPWM_ACTION_TOGGLE, /*!<Make output toggle*/
|
||||
} mcpwm_output_action_t;
|
||||
|
||||
/// @deprecated MCPWM select action to be taken on MCPWMXA when fault occurs
|
||||
typedef mcpwm_output_action_t mcpwm_action_on_pwmxa_t;
|
||||
@ -556,6 +619,9 @@ esp_err_t mcpwm_fault_deinit(mcpwm_unit_t mcpwm_num, mcpwm_fault_signal_t fault_
|
||||
/**
|
||||
* @brief Initialize capture submodule
|
||||
*
|
||||
* @note Enabling capture feature could also enable the capture interrupt,
|
||||
* users have to register an interrupt handler by `mcpwm_isr_register`, and in there, query the capture data.
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param cap_edge set capture edge, BIT(0) - negative edge, BIT(1) - positive edge
|
||||
* @param cap_sig capture pin, which needs to be enabled
|
||||
|
@ -4,8 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _DRIVER_SDIO_SLAVE_H_
|
||||
#define _DRIVER_SDIO_SLAVE_H_
|
||||
#pragma once
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_err.h"
|
||||
@ -132,6 +131,28 @@ esp_err_t sdio_slave_recv_unregister_buf(sdio_slave_buf_handle_t handle);
|
||||
*/
|
||||
esp_err_t sdio_slave_recv_load_buf(sdio_slave_buf_handle_t handle);
|
||||
|
||||
/** Get buffer of received data if exist with packet information. The driver returns the ownership of the buffer to the app.
|
||||
*
|
||||
* When you see return value is ``ESP_ERR_NOT_FINISHED``, you should call this API iteratively until the return value is ``ESP_OK``.
|
||||
* All the continuous buffers returned with ``ESP_ERR_NOT_FINISHED``, together with the last buffer returned with ``ESP_OK``, belong to one packet from the host.
|
||||
*
|
||||
* You can call simpler ``sdio_slave_recv`` instead, if the host never send data longer than the Receiving buffer size,
|
||||
* or you don't care about the packet boundary (e.g. the data is only a byte stream).
|
||||
*
|
||||
* @param handle_ret Handle of the buffer holding received data. Use this handle in ``sdio_slave_recv_load_buf()`` to receive in the same buffer again.
|
||||
* @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_ERR_NOT_FINISHED if returned buffer is not the end of a packet from the host, should call this API again until the end of a packet
|
||||
* - ESP_OK if success
|
||||
*/
|
||||
esp_err_t sdio_slave_recv_packet(sdio_slave_buf_handle_t* handle_ret, TickType_t wait);
|
||||
|
||||
/** 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.
|
||||
@ -265,5 +286,3 @@ esp_err_t sdio_slave_wait_int(int pos, TickType_t wait);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_DRIVER_SDIO_SLAVE_H */
|
||||
|
@ -9,8 +9,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#ifndef SPI_MOCK
|
||||
#include "soc/lldesc.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#endif
|
||||
#include "hal/spi_types.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
@ -0,0 +1,93 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configuration structure for the usb-serial-jtag-driver. Can be expanded in the future
|
||||
*
|
||||
* @note tx_buffer_size and rx_buffer_size must be > 0
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t tx_buffer_size; /* Size of the buffer (in bytes) for the TX direction */
|
||||
uint32_t rx_buffer_size; /* Size of the buffer (in bytes) for the RX direction */
|
||||
} usb_serial_jtag_driver_config_t;
|
||||
|
||||
#define USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT() (usb_serial_jtag_driver_config_t) {\
|
||||
.rx_buffer_size = 256,\
|
||||
.tx_buffer_size = 256,\
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Install USB-SERIAL-JTAG driver and set the USB-SERIAL-JTAG to the default configuration.
|
||||
*
|
||||
* USB-SERIAL-JTAG driver's ISR will be attached to the same CPU core that calls this function. Thus, users
|
||||
* should ensure that the same core is used when calling `usb_serial_jtag_driver_uninstall()`.
|
||||
*
|
||||
* @note Blocking mode will result in usb_serial_jtag_write_bytes() blocking until all bytes have been written to the TX FIFO.
|
||||
*
|
||||
* @param usb_serial_jtag_driver_config_t Configuration for usb_serial_jtag driver.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Failed for some reason.
|
||||
*/
|
||||
esp_err_t usb_serial_jtag_driver_install(usb_serial_jtag_driver_config_t *usb_serial_jtag_config);
|
||||
|
||||
/**
|
||||
* @brief USB_SERIAL_JTAG read bytes from USB_SERIAL_JTAG buffer
|
||||
*
|
||||
* @param buf pointer to the buffer.
|
||||
* @param length data length
|
||||
* @param ticks_to_wait Timeout in RTOS ticks
|
||||
*
|
||||
* @return
|
||||
* - The number of bytes read from USB_SERIAL FIFO
|
||||
*/
|
||||
int usb_serial_jtag_read_bytes(void* buf, uint32_t length, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Send data to the USB-UART port from a given buffer and length,
|
||||
*
|
||||
* Please ensure the `tx_buffer_size is larger than 0`, if the 'tx_buffer_size' > 0, this function will return after copying all the data to tx ring buffer,
|
||||
* USB_SERIAL_JTAG ISR will then move data from the ring buffer to TX FIFO gradually.
|
||||
*
|
||||
* @param src data buffer address
|
||||
* @param size data length to send
|
||||
* @param ticks_to_wait Timeout in RTOS ticks
|
||||
*
|
||||
* @return
|
||||
* - The number of bytes pushed to the TX FIFO
|
||||
*/
|
||||
int usb_serial_jtag_write_bytes(const void* src, size_t size, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Uninstall USB-SERIAL-JTAG driver.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t usb_serial_jtag_driver_uninstall(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user